babylon.module.d.ts 5.6 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551
  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/webRequest" {
  410. /**
  411. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  412. */
  413. export class WebRequest {
  414. private _xhr;
  415. /**
  416. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  417. * i.e. when loading files, where the server/service expects an Authorization header
  418. */
  419. static CustomRequestHeaders: {
  420. [key: string]: string;
  421. };
  422. /**
  423. * Add callback functions in this array to update all the requests before they get sent to the network
  424. */
  425. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  426. private _injectCustomRequestHeaders;
  427. /**
  428. * Gets or sets a function to be called when loading progress changes
  429. */
  430. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  431. /**
  432. * Returns client's state
  433. */
  434. readonly readyState: number;
  435. /**
  436. * Returns client's status
  437. */
  438. readonly status: number;
  439. /**
  440. * Returns client's status as a text
  441. */
  442. readonly statusText: string;
  443. /**
  444. * Returns client's response
  445. */
  446. readonly response: any;
  447. /**
  448. * Returns client's response url
  449. */
  450. readonly responseURL: string;
  451. /**
  452. * Returns client's response as text
  453. */
  454. readonly responseText: string;
  455. /**
  456. * Gets or sets the expected response type
  457. */
  458. responseType: XMLHttpRequestResponseType;
  459. /** @hidden */
  460. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  461. /** @hidden */
  462. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  463. /**
  464. * Cancels any network activity
  465. */
  466. abort(): void;
  467. /**
  468. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  469. * @param body defines an optional request body
  470. */
  471. send(body?: Document | BodyInit | null): void;
  472. /**
  473. * Sets the request method, request URL
  474. * @param method defines the method to use (GET, POST, etc..)
  475. * @param url defines the url to connect with
  476. */
  477. open(method: string, url: string): void;
  478. }
  479. }
  480. declare module "babylonjs/Misc/fileRequest" {
  481. import { Observable } from "babylonjs/Misc/observable";
  482. /**
  483. * File request interface
  484. */
  485. export interface IFileRequest {
  486. /**
  487. * Raised when the request is complete (success or error).
  488. */
  489. onCompleteObservable: Observable<IFileRequest>;
  490. /**
  491. * Aborts the request for a file.
  492. */
  493. abort: () => void;
  494. }
  495. }
  496. declare module "babylonjs/Maths/math.scalar" {
  497. /**
  498. * Scalar computation library
  499. */
  500. export class Scalar {
  501. /**
  502. * Two pi constants convenient for computation.
  503. */
  504. static TwoPi: number;
  505. /**
  506. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  507. * @param a number
  508. * @param b number
  509. * @param epsilon (default = 1.401298E-45)
  510. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  511. */
  512. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  513. /**
  514. * Returns a string : the upper case translation of the number i to hexadecimal.
  515. * @param i number
  516. * @returns the upper case translation of the number i to hexadecimal.
  517. */
  518. static ToHex(i: number): string;
  519. /**
  520. * Returns -1 if value is negative and +1 is value is positive.
  521. * @param value the value
  522. * @returns the value itself if it's equal to zero.
  523. */
  524. static Sign(value: number): number;
  525. /**
  526. * Returns the value itself if it's between min and max.
  527. * Returns min if the value is lower than min.
  528. * Returns max if the value is greater than max.
  529. * @param value the value to clmap
  530. * @param min the min value to clamp to (default: 0)
  531. * @param max the max value to clamp to (default: 1)
  532. * @returns the clamped value
  533. */
  534. static Clamp(value: number, min?: number, max?: number): number;
  535. /**
  536. * the log2 of value.
  537. * @param value the value to compute log2 of
  538. * @returns the log2 of value.
  539. */
  540. static Log2(value: number): number;
  541. /**
  542. * Loops the value, so that it is never larger than length and never smaller than 0.
  543. *
  544. * This is similar to the modulo operator but it works with floating point numbers.
  545. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  546. * With t = 5 and length = 2.5, the result would be 0.0.
  547. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  548. * @param value the value
  549. * @param length the length
  550. * @returns the looped value
  551. */
  552. static Repeat(value: number, length: number): number;
  553. /**
  554. * Normalize the value between 0.0 and 1.0 using min and max values
  555. * @param value value to normalize
  556. * @param min max to normalize between
  557. * @param max min to normalize between
  558. * @returns the normalized value
  559. */
  560. static Normalize(value: number, min: number, max: number): number;
  561. /**
  562. * Denormalize the value from 0.0 and 1.0 using min and max values
  563. * @param normalized value to denormalize
  564. * @param min max to denormalize between
  565. * @param max min to denormalize between
  566. * @returns the denormalized value
  567. */
  568. static Denormalize(normalized: number, min: number, max: number): number;
  569. /**
  570. * Calculates the shortest difference between two given angles given in degrees.
  571. * @param current current angle in degrees
  572. * @param target target angle in degrees
  573. * @returns the delta
  574. */
  575. static DeltaAngle(current: number, target: number): number;
  576. /**
  577. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  578. * @param tx value
  579. * @param length length
  580. * @returns The returned value will move back and forth between 0 and length
  581. */
  582. static PingPong(tx: number, length: number): number;
  583. /**
  584. * Interpolates between min and max with smoothing at the limits.
  585. *
  586. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  587. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  588. * @param from from
  589. * @param to to
  590. * @param tx value
  591. * @returns the smooth stepped value
  592. */
  593. static SmoothStep(from: number, to: number, tx: number): number;
  594. /**
  595. * Moves a value current towards target.
  596. *
  597. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  598. * Negative values of maxDelta pushes the value away from target.
  599. * @param current current value
  600. * @param target target value
  601. * @param maxDelta max distance to move
  602. * @returns resulting value
  603. */
  604. static MoveTowards(current: number, target: number, maxDelta: number): number;
  605. /**
  606. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  607. *
  608. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  609. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  610. * @param current current value
  611. * @param target target value
  612. * @param maxDelta max distance to move
  613. * @returns resulting angle
  614. */
  615. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  616. /**
  617. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  618. * @param start start value
  619. * @param end target value
  620. * @param amount amount to lerp between
  621. * @returns the lerped value
  622. */
  623. static Lerp(start: number, end: number, amount: number): number;
  624. /**
  625. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  626. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  627. * @param start start value
  628. * @param end target value
  629. * @param amount amount to lerp between
  630. * @returns the lerped value
  631. */
  632. static LerpAngle(start: number, end: number, amount: number): number;
  633. /**
  634. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  635. * @param a start value
  636. * @param b target value
  637. * @param value value between a and b
  638. * @returns the inverseLerp value
  639. */
  640. static InverseLerp(a: number, b: number, value: number): number;
  641. /**
  642. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  643. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  644. * @param value1 spline value
  645. * @param tangent1 spline value
  646. * @param value2 spline value
  647. * @param tangent2 spline value
  648. * @param amount input value
  649. * @returns hermite result
  650. */
  651. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  652. /**
  653. * Returns a random float number between and min and max values
  654. * @param min min value of random
  655. * @param max max value of random
  656. * @returns random value
  657. */
  658. static RandomRange(min: number, max: number): number;
  659. /**
  660. * This function returns percentage of a number in a given range.
  661. *
  662. * RangeToPercent(40,20,60) will return 0.5 (50%)
  663. * RangeToPercent(34,0,100) will return 0.34 (34%)
  664. * @param number to convert to percentage
  665. * @param min min range
  666. * @param max max range
  667. * @returns the percentage
  668. */
  669. static RangeToPercent(number: number, min: number, max: number): number;
  670. /**
  671. * This function returns number that corresponds to the percentage in a given range.
  672. *
  673. * PercentToRange(0.34,0,100) will return 34.
  674. * @param percent to convert to number
  675. * @param min min range
  676. * @param max max range
  677. * @returns the number
  678. */
  679. static PercentToRange(percent: number, min: number, max: number): number;
  680. /**
  681. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  682. * @param angle The angle to normalize in radian.
  683. * @return The converted angle.
  684. */
  685. static NormalizeRadians(angle: number): number;
  686. }
  687. }
  688. declare module "babylonjs/Maths/math.constants" {
  689. /**
  690. * Constant used to convert a value to gamma space
  691. * @ignorenaming
  692. */
  693. export const ToGammaSpace: number;
  694. /**
  695. * Constant used to convert a value to linear space
  696. * @ignorenaming
  697. */
  698. export const ToLinearSpace = 2.2;
  699. /**
  700. * Constant used to define the minimal number value in Babylon.js
  701. * @ignorenaming
  702. */
  703. let Epsilon: number;
  704. export { Epsilon };
  705. }
  706. declare module "babylonjs/Maths/math.viewport" {
  707. /**
  708. * Class used to represent a viewport on screen
  709. */
  710. export class Viewport {
  711. /** viewport left coordinate */
  712. x: number;
  713. /** viewport top coordinate */
  714. y: number;
  715. /**viewport width */
  716. width: number;
  717. /** viewport height */
  718. height: number;
  719. /**
  720. * Creates a Viewport object located at (x, y) and sized (width, height)
  721. * @param x defines viewport left coordinate
  722. * @param y defines viewport top coordinate
  723. * @param width defines the viewport width
  724. * @param height defines the viewport height
  725. */
  726. constructor(
  727. /** viewport left coordinate */
  728. x: number,
  729. /** viewport top coordinate */
  730. y: number,
  731. /**viewport width */
  732. width: number,
  733. /** viewport height */
  734. height: number);
  735. /**
  736. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  737. * @param renderWidth defines the rendering width
  738. * @param renderHeight defines the rendering height
  739. * @returns a new Viewport
  740. */
  741. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  742. /**
  743. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  744. * @param renderWidth defines the rendering width
  745. * @param renderHeight defines the rendering height
  746. * @param ref defines the target viewport
  747. * @returns the current viewport
  748. */
  749. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  750. /**
  751. * Returns a new Viewport copied from the current one
  752. * @returns a new Viewport
  753. */
  754. clone(): Viewport;
  755. }
  756. }
  757. declare module "babylonjs/Misc/arrayTools" {
  758. /**
  759. * Class containing a set of static utilities functions for arrays.
  760. */
  761. export class ArrayTools {
  762. /**
  763. * Returns an array of the given size filled with element built from the given constructor and the paramters
  764. * @param size the number of element to construct and put in the array
  765. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  766. * @returns a new array filled with new objects
  767. */
  768. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  769. }
  770. }
  771. declare module "babylonjs/Maths/math.like" {
  772. import { float, int, DeepImmutable } from "babylonjs/types";
  773. /**
  774. * @hidden
  775. */
  776. export interface IColor4Like {
  777. r: float;
  778. g: float;
  779. b: float;
  780. a: float;
  781. }
  782. /**
  783. * @hidden
  784. */
  785. export interface IColor3Like {
  786. r: float;
  787. g: float;
  788. b: float;
  789. }
  790. /**
  791. * @hidden
  792. */
  793. export interface IVector4Like {
  794. x: float;
  795. y: float;
  796. z: float;
  797. w: float;
  798. }
  799. /**
  800. * @hidden
  801. */
  802. export interface IVector3Like {
  803. x: float;
  804. y: float;
  805. z: float;
  806. }
  807. /**
  808. * @hidden
  809. */
  810. export interface IVector2Like {
  811. x: float;
  812. y: float;
  813. }
  814. /**
  815. * @hidden
  816. */
  817. export interface IMatrixLike {
  818. toArray(): DeepImmutable<Float32Array>;
  819. updateFlag: int;
  820. }
  821. /**
  822. * @hidden
  823. */
  824. export interface IViewportLike {
  825. x: float;
  826. y: float;
  827. width: float;
  828. height: float;
  829. }
  830. /**
  831. * @hidden
  832. */
  833. export interface IPlaneLike {
  834. normal: IVector3Like;
  835. d: float;
  836. normalize(): void;
  837. }
  838. }
  839. declare module "babylonjs/Maths/math.vector" {
  840. import { Viewport } from "babylonjs/Maths/math.viewport";
  841. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  842. import { IPlaneLike } from "babylonjs/Maths/math.like";
  843. /**
  844. * Class representing a vector containing 2 coordinates
  845. */
  846. export class Vector2 {
  847. /** defines the first coordinate */
  848. x: number;
  849. /** defines the second coordinate */
  850. y: number;
  851. /**
  852. * Creates a new Vector2 from the given x and y coordinates
  853. * @param x defines the first coordinate
  854. * @param y defines the second coordinate
  855. */
  856. constructor(
  857. /** defines the first coordinate */
  858. x?: number,
  859. /** defines the second coordinate */
  860. y?: number);
  861. /**
  862. * Gets a string with the Vector2 coordinates
  863. * @returns a string with the Vector2 coordinates
  864. */
  865. toString(): string;
  866. /**
  867. * Gets class name
  868. * @returns the string "Vector2"
  869. */
  870. getClassName(): string;
  871. /**
  872. * Gets current vector hash code
  873. * @returns the Vector2 hash code as a number
  874. */
  875. getHashCode(): number;
  876. /**
  877. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  878. * @param array defines the source array
  879. * @param index defines the offset in source array
  880. * @returns the current Vector2
  881. */
  882. toArray(array: FloatArray, index?: number): Vector2;
  883. /**
  884. * Copy the current vector to an array
  885. * @returns a new array with 2 elements: the Vector2 coordinates.
  886. */
  887. asArray(): number[];
  888. /**
  889. * Sets the Vector2 coordinates with the given Vector2 coordinates
  890. * @param source defines the source Vector2
  891. * @returns the current updated Vector2
  892. */
  893. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  894. /**
  895. * Sets the Vector2 coordinates with the given floats
  896. * @param x defines the first coordinate
  897. * @param y defines the second coordinate
  898. * @returns the current updated Vector2
  899. */
  900. copyFromFloats(x: number, y: number): Vector2;
  901. /**
  902. * Sets the Vector2 coordinates with the given floats
  903. * @param x defines the first coordinate
  904. * @param y defines the second coordinate
  905. * @returns the current updated Vector2
  906. */
  907. set(x: number, y: number): Vector2;
  908. /**
  909. * Add another vector with the current one
  910. * @param otherVector defines the other vector
  911. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  912. */
  913. add(otherVector: DeepImmutable<Vector2>): Vector2;
  914. /**
  915. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  916. * @param otherVector defines the other vector
  917. * @param result defines the target vector
  918. * @returns the unmodified current Vector2
  919. */
  920. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  921. /**
  922. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  923. * @param otherVector defines the other vector
  924. * @returns the current updated Vector2
  925. */
  926. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  927. /**
  928. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  929. * @param otherVector defines the other vector
  930. * @returns a new Vector2
  931. */
  932. addVector3(otherVector: Vector3): Vector2;
  933. /**
  934. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  935. * @param otherVector defines the other vector
  936. * @returns a new Vector2
  937. */
  938. subtract(otherVector: Vector2): Vector2;
  939. /**
  940. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  941. * @param otherVector defines the other vector
  942. * @param result defines the target vector
  943. * @returns the unmodified current Vector2
  944. */
  945. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  946. /**
  947. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  948. * @param otherVector defines the other vector
  949. * @returns the current updated Vector2
  950. */
  951. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  952. /**
  953. * Multiplies in place the current Vector2 coordinates by the given ones
  954. * @param otherVector defines the other vector
  955. * @returns the current updated Vector2
  956. */
  957. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  958. /**
  959. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  960. * @param otherVector defines the other vector
  961. * @returns a new Vector2
  962. */
  963. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  964. /**
  965. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  966. * @param otherVector defines the other vector
  967. * @param result defines the target vector
  968. * @returns the unmodified current Vector2
  969. */
  970. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  971. /**
  972. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  973. * @param x defines the first coordinate
  974. * @param y defines the second coordinate
  975. * @returns a new Vector2
  976. */
  977. multiplyByFloats(x: number, y: number): Vector2;
  978. /**
  979. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  980. * @param otherVector defines the other vector
  981. * @returns a new Vector2
  982. */
  983. divide(otherVector: Vector2): Vector2;
  984. /**
  985. * Sets the "result" coordinates with the Vector2 divided by 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. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  991. /**
  992. * Divides the current Vector2 coordinates by the given ones
  993. * @param otherVector defines the other vector
  994. * @returns the current updated Vector2
  995. */
  996. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  997. /**
  998. * Gets a new Vector2 with current Vector2 negated coordinates
  999. * @returns a new Vector2
  1000. */
  1001. negate(): Vector2;
  1002. /**
  1003. * Multiply the Vector2 coordinates by scale
  1004. * @param scale defines the scaling factor
  1005. * @returns the current updated Vector2
  1006. */
  1007. scaleInPlace(scale: number): Vector2;
  1008. /**
  1009. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1010. * @param scale defines the scaling factor
  1011. * @returns a new Vector2
  1012. */
  1013. scale(scale: number): Vector2;
  1014. /**
  1015. * Scale the current Vector2 values by a factor to a given Vector2
  1016. * @param scale defines the scale factor
  1017. * @param result defines the Vector2 object where to store the result
  1018. * @returns the unmodified current Vector2
  1019. */
  1020. scaleToRef(scale: number, result: Vector2): Vector2;
  1021. /**
  1022. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1023. * @param scale defines the scale factor
  1024. * @param result defines the Vector2 object where to store the result
  1025. * @returns the unmodified current Vector2
  1026. */
  1027. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1028. /**
  1029. * Gets a boolean if two vectors are equals
  1030. * @param otherVector defines the other vector
  1031. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1032. */
  1033. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1034. /**
  1035. * Gets a boolean if two vectors are equals (using an epsilon value)
  1036. * @param otherVector defines the other vector
  1037. * @param epsilon defines the minimal distance to consider equality
  1038. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1039. */
  1040. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1041. /**
  1042. * Gets a new Vector2 from current Vector2 floored values
  1043. * @returns a new Vector2
  1044. */
  1045. floor(): Vector2;
  1046. /**
  1047. * Gets a new Vector2 from current Vector2 floored values
  1048. * @returns a new Vector2
  1049. */
  1050. fract(): Vector2;
  1051. /**
  1052. * Gets the length of the vector
  1053. * @returns the vector length (float)
  1054. */
  1055. length(): number;
  1056. /**
  1057. * Gets the vector squared length
  1058. * @returns the vector squared length (float)
  1059. */
  1060. lengthSquared(): number;
  1061. /**
  1062. * Normalize the vector
  1063. * @returns the current updated Vector2
  1064. */
  1065. normalize(): Vector2;
  1066. /**
  1067. * Gets a new Vector2 copied from the Vector2
  1068. * @returns a new Vector2
  1069. */
  1070. clone(): Vector2;
  1071. /**
  1072. * Gets a new Vector2(0, 0)
  1073. * @returns a new Vector2
  1074. */
  1075. static Zero(): Vector2;
  1076. /**
  1077. * Gets a new Vector2(1, 1)
  1078. * @returns a new Vector2
  1079. */
  1080. static One(): Vector2;
  1081. /**
  1082. * Gets a new Vector2 set from the given index element of the given array
  1083. * @param array defines the data source
  1084. * @param offset defines the offset in the data source
  1085. * @returns a new Vector2
  1086. */
  1087. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1088. /**
  1089. * Sets "result" from the given index element of the given array
  1090. * @param array defines the data source
  1091. * @param offset defines the offset in the data source
  1092. * @param result defines the target vector
  1093. */
  1094. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1095. /**
  1096. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1097. * @param value1 defines 1st point of control
  1098. * @param value2 defines 2nd point of control
  1099. * @param value3 defines 3rd point of control
  1100. * @param value4 defines 4th point of control
  1101. * @param amount defines the interpolation factor
  1102. * @returns a new Vector2
  1103. */
  1104. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1105. /**
  1106. * 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".
  1107. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1108. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1109. * @param value defines the value to clamp
  1110. * @param min defines the lower limit
  1111. * @param max defines the upper limit
  1112. * @returns a new Vector2
  1113. */
  1114. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1115. /**
  1116. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1117. * @param value1 defines the 1st control point
  1118. * @param tangent1 defines the outgoing tangent
  1119. * @param value2 defines the 2nd control point
  1120. * @param tangent2 defines the incoming tangent
  1121. * @param amount defines the interpolation factor
  1122. * @returns a new Vector2
  1123. */
  1124. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1125. /**
  1126. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1127. * @param start defines the start vector
  1128. * @param end defines the end vector
  1129. * @param amount defines the interpolation factor
  1130. * @returns a new Vector2
  1131. */
  1132. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1133. /**
  1134. * Gets the dot product of the vector "left" and the vector "right"
  1135. * @param left defines first vector
  1136. * @param right defines second vector
  1137. * @returns the dot product (float)
  1138. */
  1139. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1140. /**
  1141. * Returns a new Vector2 equal to the normalized given vector
  1142. * @param vector defines the vector to normalize
  1143. * @returns a new Vector2
  1144. */
  1145. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1146. /**
  1147. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1148. * @param left defines 1st vector
  1149. * @param right defines 2nd vector
  1150. * @returns a new Vector2
  1151. */
  1152. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1153. /**
  1154. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1155. * @param left defines 1st vector
  1156. * @param right defines 2nd vector
  1157. * @returns a new Vector2
  1158. */
  1159. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1160. /**
  1161. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1162. * @param vector defines the vector to transform
  1163. * @param transformation defines the matrix to apply
  1164. * @returns a new Vector2
  1165. */
  1166. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1167. /**
  1168. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1169. * @param vector defines the vector to transform
  1170. * @param transformation defines the matrix to apply
  1171. * @param result defines the target vector
  1172. */
  1173. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1174. /**
  1175. * Determines if a given vector is included in a triangle
  1176. * @param p defines the vector to test
  1177. * @param p0 defines 1st triangle point
  1178. * @param p1 defines 2nd triangle point
  1179. * @param p2 defines 3rd triangle point
  1180. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1181. */
  1182. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1183. /**
  1184. * Gets the distance between the vectors "value1" and "value2"
  1185. * @param value1 defines first vector
  1186. * @param value2 defines second vector
  1187. * @returns the distance between vectors
  1188. */
  1189. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1190. /**
  1191. * Returns the squared distance between the vectors "value1" and "value2"
  1192. * @param value1 defines first vector
  1193. * @param value2 defines second vector
  1194. * @returns the squared distance between vectors
  1195. */
  1196. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1197. /**
  1198. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1199. * @param value1 defines first vector
  1200. * @param value2 defines second vector
  1201. * @returns a new Vector2
  1202. */
  1203. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1204. /**
  1205. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1206. * @param p defines the middle point
  1207. * @param segA defines one point of the segment
  1208. * @param segB defines the other point of the segment
  1209. * @returns the shortest distance
  1210. */
  1211. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1212. }
  1213. /**
  1214. * Classed used to store (x,y,z) vector representation
  1215. * A Vector3 is the main object used in 3D geometry
  1216. * It can represent etiher the coordinates of a point the space, either a direction
  1217. * Reminder: js uses a left handed forward facing system
  1218. */
  1219. export class Vector3 {
  1220. /**
  1221. * Defines the first coordinates (on X axis)
  1222. */
  1223. x: number;
  1224. /**
  1225. * Defines the second coordinates (on Y axis)
  1226. */
  1227. y: number;
  1228. /**
  1229. * Defines the third coordinates (on Z axis)
  1230. */
  1231. z: number;
  1232. private static _UpReadOnly;
  1233. private static _ZeroReadOnly;
  1234. /**
  1235. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1236. * @param x defines the first coordinates (on X axis)
  1237. * @param y defines the second coordinates (on Y axis)
  1238. * @param z defines the third coordinates (on Z axis)
  1239. */
  1240. constructor(
  1241. /**
  1242. * Defines the first coordinates (on X axis)
  1243. */
  1244. x?: number,
  1245. /**
  1246. * Defines the second coordinates (on Y axis)
  1247. */
  1248. y?: number,
  1249. /**
  1250. * Defines the third coordinates (on Z axis)
  1251. */
  1252. z?: number);
  1253. /**
  1254. * Creates a string representation of the Vector3
  1255. * @returns a string with the Vector3 coordinates.
  1256. */
  1257. toString(): string;
  1258. /**
  1259. * Gets the class name
  1260. * @returns the string "Vector3"
  1261. */
  1262. getClassName(): string;
  1263. /**
  1264. * Creates the Vector3 hash code
  1265. * @returns a number which tends to be unique between Vector3 instances
  1266. */
  1267. getHashCode(): number;
  1268. /**
  1269. * Creates an array containing three elements : the coordinates of the Vector3
  1270. * @returns a new array of numbers
  1271. */
  1272. asArray(): number[];
  1273. /**
  1274. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1275. * @param array defines the destination array
  1276. * @param index defines the offset in the destination array
  1277. * @returns the current Vector3
  1278. */
  1279. toArray(array: FloatArray, index?: number): Vector3;
  1280. /**
  1281. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1282. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1283. */
  1284. toQuaternion(): Quaternion;
  1285. /**
  1286. * Adds the given vector to the current Vector3
  1287. * @param otherVector defines the second operand
  1288. * @returns the current updated Vector3
  1289. */
  1290. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1291. /**
  1292. * Adds the given coordinates to the current Vector3
  1293. * @param x defines the x coordinate of the operand
  1294. * @param y defines the y coordinate of the operand
  1295. * @param z defines the z coordinate of the operand
  1296. * @returns the current updated Vector3
  1297. */
  1298. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1299. /**
  1300. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1301. * @param otherVector defines the second operand
  1302. * @returns the resulting Vector3
  1303. */
  1304. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1305. /**
  1306. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1307. * @param otherVector defines the second operand
  1308. * @param result defines the Vector3 object where to store the result
  1309. * @returns the current Vector3
  1310. */
  1311. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1312. /**
  1313. * Subtract the given vector from the current Vector3
  1314. * @param otherVector defines the second operand
  1315. * @returns the current updated Vector3
  1316. */
  1317. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1318. /**
  1319. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1320. * @param otherVector defines the second operand
  1321. * @returns the resulting Vector3
  1322. */
  1323. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1324. /**
  1325. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1326. * @param otherVector defines the second operand
  1327. * @param result defines the Vector3 object where to store the result
  1328. * @returns the current Vector3
  1329. */
  1330. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1331. /**
  1332. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1333. * @param x defines the x coordinate of the operand
  1334. * @param y defines the y coordinate of the operand
  1335. * @param z defines the z coordinate of the operand
  1336. * @returns the resulting Vector3
  1337. */
  1338. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1339. /**
  1340. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1341. * @param x defines the x coordinate of the operand
  1342. * @param y defines the y coordinate of the operand
  1343. * @param z defines the z coordinate of the operand
  1344. * @param result defines the Vector3 object where to store the result
  1345. * @returns the current Vector3
  1346. */
  1347. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1348. /**
  1349. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1350. * @returns a new Vector3
  1351. */
  1352. negate(): Vector3;
  1353. /**
  1354. * Multiplies the Vector3 coordinates by the float "scale"
  1355. * @param scale defines the multiplier factor
  1356. * @returns the current updated Vector3
  1357. */
  1358. scaleInPlace(scale: number): Vector3;
  1359. /**
  1360. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1361. * @param scale defines the multiplier factor
  1362. * @returns a new Vector3
  1363. */
  1364. scale(scale: number): Vector3;
  1365. /**
  1366. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1367. * @param scale defines the multiplier factor
  1368. * @param result defines the Vector3 object where to store the result
  1369. * @returns the current Vector3
  1370. */
  1371. scaleToRef(scale: number, result: Vector3): Vector3;
  1372. /**
  1373. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1374. * @param scale defines the scale factor
  1375. * @param result defines the Vector3 object where to store the result
  1376. * @returns the unmodified current Vector3
  1377. */
  1378. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1379. /**
  1380. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1381. * @param otherVector defines the second operand
  1382. * @returns true if both vectors are equals
  1383. */
  1384. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1385. /**
  1386. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1387. * @param otherVector defines the second operand
  1388. * @param epsilon defines the minimal distance to define values as equals
  1389. * @returns true if both vectors are distant less than epsilon
  1390. */
  1391. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1392. /**
  1393. * Returns true if the current Vector3 coordinates equals the given floats
  1394. * @param x defines the x coordinate of the operand
  1395. * @param y defines the y coordinate of the operand
  1396. * @param z defines the z coordinate of the operand
  1397. * @returns true if both vectors are equals
  1398. */
  1399. equalsToFloats(x: number, y: number, z: number): boolean;
  1400. /**
  1401. * Multiplies the current Vector3 coordinates by the given ones
  1402. * @param otherVector defines the second operand
  1403. * @returns the current updated Vector3
  1404. */
  1405. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1406. /**
  1407. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1408. * @param otherVector defines the second operand
  1409. * @returns the new Vector3
  1410. */
  1411. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1412. /**
  1413. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1414. * @param otherVector defines the second operand
  1415. * @param result defines the Vector3 object where to store the result
  1416. * @returns the current Vector3
  1417. */
  1418. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1419. /**
  1420. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1421. * @param x defines the x coordinate of the operand
  1422. * @param y defines the y coordinate of the operand
  1423. * @param z defines the z coordinate of the operand
  1424. * @returns the new Vector3
  1425. */
  1426. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1427. /**
  1428. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1429. * @param otherVector defines the second operand
  1430. * @returns the new Vector3
  1431. */
  1432. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1433. /**
  1434. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1435. * @param otherVector defines the second operand
  1436. * @param result defines the Vector3 object where to store the result
  1437. * @returns the current Vector3
  1438. */
  1439. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1440. /**
  1441. * Divides the current Vector3 coordinates by the given ones.
  1442. * @param otherVector defines the second operand
  1443. * @returns the current updated Vector3
  1444. */
  1445. divideInPlace(otherVector: Vector3): Vector3;
  1446. /**
  1447. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1448. * @param other defines the second operand
  1449. * @returns the current updated Vector3
  1450. */
  1451. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1452. /**
  1453. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1454. * @param other defines the second operand
  1455. * @returns the current updated Vector3
  1456. */
  1457. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1458. /**
  1459. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1460. * @param x defines the x coordinate of the operand
  1461. * @param y defines the y coordinate of the operand
  1462. * @param z defines the z coordinate of the operand
  1463. * @returns the current updated Vector3
  1464. */
  1465. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1466. /**
  1467. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1468. * @param x defines the x coordinate of the operand
  1469. * @param y defines the y coordinate of the operand
  1470. * @param z defines the z coordinate of the operand
  1471. * @returns the current updated Vector3
  1472. */
  1473. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1474. /**
  1475. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1476. * Check if is non uniform within a certain amount of decimal places to account for this
  1477. * @param epsilon the amount the values can differ
  1478. * @returns if the the vector is non uniform to a certain number of decimal places
  1479. */
  1480. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1481. /**
  1482. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1483. */
  1484. readonly isNonUniform: boolean;
  1485. /**
  1486. * Gets a new Vector3 from current Vector3 floored values
  1487. * @returns a new Vector3
  1488. */
  1489. floor(): Vector3;
  1490. /**
  1491. * Gets a new Vector3 from current Vector3 floored values
  1492. * @returns a new Vector3
  1493. */
  1494. fract(): Vector3;
  1495. /**
  1496. * Gets the length of the Vector3
  1497. * @returns the length of the Vector3
  1498. */
  1499. length(): number;
  1500. /**
  1501. * Gets the squared length of the Vector3
  1502. * @returns squared length of the Vector3
  1503. */
  1504. lengthSquared(): number;
  1505. /**
  1506. * Normalize the current Vector3.
  1507. * Please note that this is an in place operation.
  1508. * @returns the current updated Vector3
  1509. */
  1510. normalize(): Vector3;
  1511. /**
  1512. * Reorders the x y z properties of the vector in place
  1513. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1514. * @returns the current updated vector
  1515. */
  1516. reorderInPlace(order: string): this;
  1517. /**
  1518. * Rotates the vector around 0,0,0 by a quaternion
  1519. * @param quaternion the rotation quaternion
  1520. * @param result vector to store the result
  1521. * @returns the resulting vector
  1522. */
  1523. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1524. /**
  1525. * Rotates a vector around a given point
  1526. * @param quaternion the rotation quaternion
  1527. * @param point the point to rotate around
  1528. * @param result vector to store the result
  1529. * @returns the resulting vector
  1530. */
  1531. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1532. /**
  1533. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  1534. * The cross product is then orthogonal to both current and "other"
  1535. * @param other defines the right operand
  1536. * @returns the cross product
  1537. */
  1538. cross(other: Vector3): Vector3;
  1539. /**
  1540. * Normalize the current Vector3 with the given input length.
  1541. * Please note that this is an in place operation.
  1542. * @param len the length of the vector
  1543. * @returns the current updated Vector3
  1544. */
  1545. normalizeFromLength(len: number): Vector3;
  1546. /**
  1547. * Normalize the current Vector3 to a new vector
  1548. * @returns the new Vector3
  1549. */
  1550. normalizeToNew(): Vector3;
  1551. /**
  1552. * Normalize the current Vector3 to the reference
  1553. * @param reference define the Vector3 to update
  1554. * @returns the updated Vector3
  1555. */
  1556. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1557. /**
  1558. * Creates a new Vector3 copied from the current Vector3
  1559. * @returns the new Vector3
  1560. */
  1561. clone(): Vector3;
  1562. /**
  1563. * Copies the given vector coordinates to the current Vector3 ones
  1564. * @param source defines the source Vector3
  1565. * @returns the current updated Vector3
  1566. */
  1567. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1568. /**
  1569. * Copies the given floats to the current Vector3 coordinates
  1570. * @param x defines the x coordinate of the operand
  1571. * @param y defines the y coordinate of the operand
  1572. * @param z defines the z coordinate of the operand
  1573. * @returns the current updated Vector3
  1574. */
  1575. copyFromFloats(x: number, y: number, z: number): Vector3;
  1576. /**
  1577. * Copies the given floats to the current Vector3 coordinates
  1578. * @param x defines the x coordinate of the operand
  1579. * @param y defines the y coordinate of the operand
  1580. * @param z defines the z coordinate of the operand
  1581. * @returns the current updated Vector3
  1582. */
  1583. set(x: number, y: number, z: number): Vector3;
  1584. /**
  1585. * Copies the given float to the current Vector3 coordinates
  1586. * @param v defines the x, y and z coordinates of the operand
  1587. * @returns the current updated Vector3
  1588. */
  1589. setAll(v: number): Vector3;
  1590. /**
  1591. * Get the clip factor between two vectors
  1592. * @param vector0 defines the first operand
  1593. * @param vector1 defines the second operand
  1594. * @param axis defines the axis to use
  1595. * @param size defines the size along the axis
  1596. * @returns the clip factor
  1597. */
  1598. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1599. /**
  1600. * Get angle between two vectors
  1601. * @param vector0 angle between vector0 and vector1
  1602. * @param vector1 angle between vector0 and vector1
  1603. * @param normal direction of the normal
  1604. * @return the angle between vector0 and vector1
  1605. */
  1606. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1607. /**
  1608. * Returns a new Vector3 set from the index "offset" of the given array
  1609. * @param array defines the source array
  1610. * @param offset defines the offset in the source array
  1611. * @returns the new Vector3
  1612. */
  1613. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1614. /**
  1615. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1616. * This function is deprecated. Use FromArray instead
  1617. * @param array defines the source array
  1618. * @param offset defines the offset in the source array
  1619. * @returns the new Vector3
  1620. */
  1621. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1622. /**
  1623. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1624. * @param array defines the source array
  1625. * @param offset defines the offset in the source array
  1626. * @param result defines the Vector3 where to store the result
  1627. */
  1628. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1629. /**
  1630. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1631. * This function is deprecated. Use FromArrayToRef instead.
  1632. * @param array defines the source array
  1633. * @param offset defines the offset in the source array
  1634. * @param result defines the Vector3 where to store the result
  1635. */
  1636. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1637. /**
  1638. * Sets the given vector "result" with the given floats.
  1639. * @param x defines the x coordinate of the source
  1640. * @param y defines the y coordinate of the source
  1641. * @param z defines the z coordinate of the source
  1642. * @param result defines the Vector3 where to store the result
  1643. */
  1644. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1645. /**
  1646. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1647. * @returns a new empty Vector3
  1648. */
  1649. static Zero(): Vector3;
  1650. /**
  1651. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1652. * @returns a new unit Vector3
  1653. */
  1654. static One(): Vector3;
  1655. /**
  1656. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1657. * @returns a new up Vector3
  1658. */
  1659. static Up(): Vector3;
  1660. /**
  1661. * Gets a up Vector3 that must not be updated
  1662. */
  1663. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1664. /**
  1665. * Gets a zero Vector3 that must not be updated
  1666. */
  1667. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  1668. /**
  1669. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1670. * @returns a new down Vector3
  1671. */
  1672. static Down(): Vector3;
  1673. /**
  1674. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1675. * @returns a new forward Vector3
  1676. */
  1677. static Forward(): Vector3;
  1678. /**
  1679. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1680. * @returns a new forward Vector3
  1681. */
  1682. static Backward(): Vector3;
  1683. /**
  1684. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1685. * @returns a new right Vector3
  1686. */
  1687. static Right(): Vector3;
  1688. /**
  1689. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1690. * @returns a new left Vector3
  1691. */
  1692. static Left(): Vector3;
  1693. /**
  1694. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1695. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1696. * @param vector defines the Vector3 to transform
  1697. * @param transformation defines the transformation matrix
  1698. * @returns the transformed Vector3
  1699. */
  1700. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1701. /**
  1702. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1703. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1704. * @param vector defines the Vector3 to transform
  1705. * @param transformation defines the transformation matrix
  1706. * @param result defines the Vector3 where to store the result
  1707. */
  1708. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1709. /**
  1710. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1711. * This method computes tranformed coordinates only, not transformed direction vectors
  1712. * @param x define the x coordinate of the source vector
  1713. * @param y define the y coordinate of the source vector
  1714. * @param z define the z coordinate of the source vector
  1715. * @param transformation defines the transformation matrix
  1716. * @param result defines the Vector3 where to store the result
  1717. */
  1718. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1719. /**
  1720. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1721. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1722. * @param vector defines the Vector3 to transform
  1723. * @param transformation defines the transformation matrix
  1724. * @returns the new Vector3
  1725. */
  1726. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1727. /**
  1728. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1729. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1730. * @param vector defines the Vector3 to transform
  1731. * @param transformation defines the transformation matrix
  1732. * @param result defines the Vector3 where to store the result
  1733. */
  1734. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1735. /**
  1736. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1737. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1738. * @param x define the x coordinate of the source vector
  1739. * @param y define the y coordinate of the source vector
  1740. * @param z define the z coordinate of the source vector
  1741. * @param transformation defines the transformation matrix
  1742. * @param result defines the Vector3 where to store the result
  1743. */
  1744. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1745. /**
  1746. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1747. * @param value1 defines the first control point
  1748. * @param value2 defines the second control point
  1749. * @param value3 defines the third control point
  1750. * @param value4 defines the fourth control point
  1751. * @param amount defines the amount on the spline to use
  1752. * @returns the new Vector3
  1753. */
  1754. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1755. /**
  1756. * 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"
  1757. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1758. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1759. * @param value defines the current value
  1760. * @param min defines the lower range value
  1761. * @param max defines the upper range value
  1762. * @returns the new Vector3
  1763. */
  1764. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1765. /**
  1766. * 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"
  1767. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1768. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1769. * @param value defines the current value
  1770. * @param min defines the lower range value
  1771. * @param max defines the upper range value
  1772. * @param result defines the Vector3 where to store the result
  1773. */
  1774. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1775. /**
  1776. * Checks if a given vector is inside a specific range
  1777. * @param v defines the vector to test
  1778. * @param min defines the minimum range
  1779. * @param max defines the maximum range
  1780. */
  1781. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  1782. /**
  1783. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1784. * @param value1 defines the first control point
  1785. * @param tangent1 defines the first tangent vector
  1786. * @param value2 defines the second control point
  1787. * @param tangent2 defines the second tangent vector
  1788. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1789. * @returns the new Vector3
  1790. */
  1791. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1792. /**
  1793. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1794. * @param start defines the start value
  1795. * @param end defines the end value
  1796. * @param amount max defines amount between both (between 0 and 1)
  1797. * @returns the new Vector3
  1798. */
  1799. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1800. /**
  1801. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1802. * @param start defines the start value
  1803. * @param end defines the end value
  1804. * @param amount max defines amount between both (between 0 and 1)
  1805. * @param result defines the Vector3 where to store the result
  1806. */
  1807. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1808. /**
  1809. * Returns the dot product (float) between the vectors "left" and "right"
  1810. * @param left defines the left operand
  1811. * @param right defines the right operand
  1812. * @returns the dot product
  1813. */
  1814. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1815. /**
  1816. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1817. * The cross product is then orthogonal to both "left" and "right"
  1818. * @param left defines the left operand
  1819. * @param right defines the right operand
  1820. * @returns the cross product
  1821. */
  1822. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1823. /**
  1824. * Sets the given vector "result" with the cross product of "left" and "right"
  1825. * The cross product is then orthogonal to both "left" and "right"
  1826. * @param left defines the left operand
  1827. * @param right defines the right operand
  1828. * @param result defines the Vector3 where to store the result
  1829. */
  1830. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1831. /**
  1832. * Returns a new Vector3 as the normalization of the given vector
  1833. * @param vector defines the Vector3 to normalize
  1834. * @returns the new Vector3
  1835. */
  1836. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1837. /**
  1838. * Sets the given vector "result" with the normalization of the given first vector
  1839. * @param vector defines the Vector3 to normalize
  1840. * @param result defines the Vector3 where to store the result
  1841. */
  1842. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1843. /**
  1844. * Project a Vector3 onto screen space
  1845. * @param vector defines the Vector3 to project
  1846. * @param world defines the world matrix to use
  1847. * @param transform defines the transform (view x projection) matrix to use
  1848. * @param viewport defines the screen viewport to use
  1849. * @returns the new Vector3
  1850. */
  1851. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1852. /** @hidden */
  1853. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1854. /**
  1855. * Unproject from screen space to object space
  1856. * @param source defines the screen space Vector3 to use
  1857. * @param viewportWidth defines the current width of the viewport
  1858. * @param viewportHeight defines the current height of the viewport
  1859. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1860. * @param transform defines the transform (view x projection) matrix to use
  1861. * @returns the new Vector3
  1862. */
  1863. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1864. /**
  1865. * Unproject from screen space to object space
  1866. * @param source defines the screen space Vector3 to use
  1867. * @param viewportWidth defines the current width of the viewport
  1868. * @param viewportHeight defines the current height of the viewport
  1869. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1870. * @param view defines the view matrix to use
  1871. * @param projection defines the projection matrix to use
  1872. * @returns the new Vector3
  1873. */
  1874. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1875. /**
  1876. * Unproject from screen space to object space
  1877. * @param source defines the screen space Vector3 to use
  1878. * @param viewportWidth defines the current width of the viewport
  1879. * @param viewportHeight defines the current height of the viewport
  1880. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1881. * @param view defines the view matrix to use
  1882. * @param projection defines the projection matrix to use
  1883. * @param result defines the Vector3 where to store the result
  1884. */
  1885. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1886. /**
  1887. * Unproject from screen space to object space
  1888. * @param sourceX defines the screen space x coordinate to use
  1889. * @param sourceY defines the screen space y coordinate to use
  1890. * @param sourceZ defines the screen space z coordinate to use
  1891. * @param viewportWidth defines the current width of the viewport
  1892. * @param viewportHeight defines the current height of the viewport
  1893. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1894. * @param view defines the view matrix to use
  1895. * @param projection defines the projection matrix to use
  1896. * @param result defines the Vector3 where to store the result
  1897. */
  1898. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1899. /**
  1900. * Gets the minimal coordinate values between two Vector3
  1901. * @param left defines the first operand
  1902. * @param right defines the second operand
  1903. * @returns the new Vector3
  1904. */
  1905. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1906. /**
  1907. * Gets the maximal coordinate values between two Vector3
  1908. * @param left defines the first operand
  1909. * @param right defines the second operand
  1910. * @returns the new Vector3
  1911. */
  1912. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1913. /**
  1914. * Returns the distance between the vectors "value1" and "value2"
  1915. * @param value1 defines the first operand
  1916. * @param value2 defines the second operand
  1917. * @returns the distance
  1918. */
  1919. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1920. /**
  1921. * Returns the squared distance between the vectors "value1" and "value2"
  1922. * @param value1 defines the first operand
  1923. * @param value2 defines the second operand
  1924. * @returns the squared distance
  1925. */
  1926. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1927. /**
  1928. * Returns a new Vector3 located at the center between "value1" and "value2"
  1929. * @param value1 defines the first operand
  1930. * @param value2 defines the second operand
  1931. * @returns the new Vector3
  1932. */
  1933. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1934. /**
  1935. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1936. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1937. * to something in order to rotate it from its local system to the given target system
  1938. * Note: axis1, axis2 and axis3 are normalized during this operation
  1939. * @param axis1 defines the first axis
  1940. * @param axis2 defines the second axis
  1941. * @param axis3 defines the third axis
  1942. * @returns a new Vector3
  1943. */
  1944. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1945. /**
  1946. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1947. * @param axis1 defines the first axis
  1948. * @param axis2 defines the second axis
  1949. * @param axis3 defines the third axis
  1950. * @param ref defines the Vector3 where to store the result
  1951. */
  1952. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1953. }
  1954. /**
  1955. * Vector4 class created for EulerAngle class conversion to Quaternion
  1956. */
  1957. export class Vector4 {
  1958. /** x value of the vector */
  1959. x: number;
  1960. /** y value of the vector */
  1961. y: number;
  1962. /** z value of the vector */
  1963. z: number;
  1964. /** w value of the vector */
  1965. w: number;
  1966. /**
  1967. * Creates a Vector4 object from the given floats.
  1968. * @param x x value of the vector
  1969. * @param y y value of the vector
  1970. * @param z z value of the vector
  1971. * @param w w value of the vector
  1972. */
  1973. constructor(
  1974. /** x value of the vector */
  1975. x: number,
  1976. /** y value of the vector */
  1977. y: number,
  1978. /** z value of the vector */
  1979. z: number,
  1980. /** w value of the vector */
  1981. w: number);
  1982. /**
  1983. * Returns the string with the Vector4 coordinates.
  1984. * @returns a string containing all the vector values
  1985. */
  1986. toString(): string;
  1987. /**
  1988. * Returns the string "Vector4".
  1989. * @returns "Vector4"
  1990. */
  1991. getClassName(): string;
  1992. /**
  1993. * Returns the Vector4 hash code.
  1994. * @returns a unique hash code
  1995. */
  1996. getHashCode(): number;
  1997. /**
  1998. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1999. * @returns the resulting array
  2000. */
  2001. asArray(): number[];
  2002. /**
  2003. * Populates the given array from the given index with the Vector4 coordinates.
  2004. * @param array array to populate
  2005. * @param index index of the array to start at (default: 0)
  2006. * @returns the Vector4.
  2007. */
  2008. toArray(array: FloatArray, index?: number): Vector4;
  2009. /**
  2010. * Adds the given vector to the current Vector4.
  2011. * @param otherVector the vector to add
  2012. * @returns the updated Vector4.
  2013. */
  2014. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2015. /**
  2016. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2017. * @param otherVector the vector to add
  2018. * @returns the resulting vector
  2019. */
  2020. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2021. /**
  2022. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2023. * @param otherVector the vector to add
  2024. * @param result the vector to store the result
  2025. * @returns the current Vector4.
  2026. */
  2027. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2028. /**
  2029. * Subtract in place the given vector from the current Vector4.
  2030. * @param otherVector the vector to subtract
  2031. * @returns the updated Vector4.
  2032. */
  2033. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2034. /**
  2035. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2036. * @param otherVector the vector to add
  2037. * @returns the new vector with the result
  2038. */
  2039. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2040. /**
  2041. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2042. * @param otherVector the vector to subtract
  2043. * @param result the vector to store the result
  2044. * @returns the current Vector4.
  2045. */
  2046. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2047. /**
  2048. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2049. */
  2050. /**
  2051. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2052. * @param x value to subtract
  2053. * @param y value to subtract
  2054. * @param z value to subtract
  2055. * @param w value to subtract
  2056. * @returns new vector containing the result
  2057. */
  2058. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2059. /**
  2060. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2061. * @param x value to subtract
  2062. * @param y value to subtract
  2063. * @param z value to subtract
  2064. * @param w value to subtract
  2065. * @param result the vector to store the result in
  2066. * @returns the current Vector4.
  2067. */
  2068. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2069. /**
  2070. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2071. * @returns a new vector with the negated values
  2072. */
  2073. negate(): Vector4;
  2074. /**
  2075. * Multiplies the current Vector4 coordinates by scale (float).
  2076. * @param scale the number to scale with
  2077. * @returns the updated Vector4.
  2078. */
  2079. scaleInPlace(scale: number): Vector4;
  2080. /**
  2081. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2082. * @param scale the number to scale with
  2083. * @returns a new vector with the result
  2084. */
  2085. scale(scale: number): Vector4;
  2086. /**
  2087. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2088. * @param scale the number to scale with
  2089. * @param result a vector to store the result in
  2090. * @returns the current Vector4.
  2091. */
  2092. scaleToRef(scale: number, result: Vector4): Vector4;
  2093. /**
  2094. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2095. * @param scale defines the scale factor
  2096. * @param result defines the Vector4 object where to store the result
  2097. * @returns the unmodified current Vector4
  2098. */
  2099. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2100. /**
  2101. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2102. * @param otherVector the vector to compare against
  2103. * @returns true if they are equal
  2104. */
  2105. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2106. /**
  2107. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2108. * @param otherVector vector to compare against
  2109. * @param epsilon (Default: very small number)
  2110. * @returns true if they are equal
  2111. */
  2112. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2113. /**
  2114. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2115. * @param x x value to compare against
  2116. * @param y y value to compare against
  2117. * @param z z value to compare against
  2118. * @param w w value to compare against
  2119. * @returns true if equal
  2120. */
  2121. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2122. /**
  2123. * Multiplies in place the current Vector4 by the given one.
  2124. * @param otherVector vector to multiple with
  2125. * @returns the updated Vector4.
  2126. */
  2127. multiplyInPlace(otherVector: Vector4): Vector4;
  2128. /**
  2129. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2130. * @param otherVector vector to multiple with
  2131. * @returns resulting new vector
  2132. */
  2133. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2134. /**
  2135. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2136. * @param otherVector vector to multiple with
  2137. * @param result vector to store the result
  2138. * @returns the current Vector4.
  2139. */
  2140. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2141. /**
  2142. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2143. * @param x x value multiply with
  2144. * @param y y value multiply with
  2145. * @param z z value multiply with
  2146. * @param w w value multiply with
  2147. * @returns resulting new vector
  2148. */
  2149. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2150. /**
  2151. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2152. * @param otherVector vector to devide with
  2153. * @returns resulting new vector
  2154. */
  2155. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2156. /**
  2157. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2158. * @param otherVector vector to devide with
  2159. * @param result vector to store the result
  2160. * @returns the current Vector4.
  2161. */
  2162. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2163. /**
  2164. * Divides the current Vector3 coordinates by the given ones.
  2165. * @param otherVector vector to devide with
  2166. * @returns the updated Vector3.
  2167. */
  2168. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2169. /**
  2170. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2171. * @param other defines the second operand
  2172. * @returns the current updated Vector4
  2173. */
  2174. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2175. /**
  2176. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2177. * @param other defines the second operand
  2178. * @returns the current updated Vector4
  2179. */
  2180. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2181. /**
  2182. * Gets a new Vector4 from current Vector4 floored values
  2183. * @returns a new Vector4
  2184. */
  2185. floor(): Vector4;
  2186. /**
  2187. * Gets a new Vector4 from current Vector3 floored values
  2188. * @returns a new Vector4
  2189. */
  2190. fract(): Vector4;
  2191. /**
  2192. * Returns the Vector4 length (float).
  2193. * @returns the length
  2194. */
  2195. length(): number;
  2196. /**
  2197. * Returns the Vector4 squared length (float).
  2198. * @returns the length squared
  2199. */
  2200. lengthSquared(): number;
  2201. /**
  2202. * Normalizes in place the Vector4.
  2203. * @returns the updated Vector4.
  2204. */
  2205. normalize(): Vector4;
  2206. /**
  2207. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2208. * @returns this converted to a new vector3
  2209. */
  2210. toVector3(): Vector3;
  2211. /**
  2212. * Returns a new Vector4 copied from the current one.
  2213. * @returns the new cloned vector
  2214. */
  2215. clone(): Vector4;
  2216. /**
  2217. * Updates the current Vector4 with the given one coordinates.
  2218. * @param source the source vector to copy from
  2219. * @returns the updated Vector4.
  2220. */
  2221. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2222. /**
  2223. * Updates the current Vector4 coordinates with the given floats.
  2224. * @param x float to copy from
  2225. * @param y float to copy from
  2226. * @param z float to copy from
  2227. * @param w float to copy from
  2228. * @returns the updated Vector4.
  2229. */
  2230. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2231. /**
  2232. * Updates the current Vector4 coordinates with the given floats.
  2233. * @param x float to set from
  2234. * @param y float to set from
  2235. * @param z float to set from
  2236. * @param w float to set from
  2237. * @returns the updated Vector4.
  2238. */
  2239. set(x: number, y: number, z: number, w: number): Vector4;
  2240. /**
  2241. * Copies the given float to the current Vector3 coordinates
  2242. * @param v defines the x, y, z and w coordinates of the operand
  2243. * @returns the current updated Vector3
  2244. */
  2245. setAll(v: number): Vector4;
  2246. /**
  2247. * Returns a new Vector4 set from the starting index of the given array.
  2248. * @param array the array to pull values from
  2249. * @param offset the offset into the array to start at
  2250. * @returns the new vector
  2251. */
  2252. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2253. /**
  2254. * Updates the given vector "result" from the starting index of the given array.
  2255. * @param array the array to pull values from
  2256. * @param offset the offset into the array to start at
  2257. * @param result the vector to store the result in
  2258. */
  2259. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2260. /**
  2261. * Updates the given vector "result" from the starting index of the given Float32Array.
  2262. * @param array the array to pull values from
  2263. * @param offset the offset into the array to start at
  2264. * @param result the vector to store the result in
  2265. */
  2266. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2267. /**
  2268. * Updates the given vector "result" coordinates from the given floats.
  2269. * @param x float to set from
  2270. * @param y float to set from
  2271. * @param z float to set from
  2272. * @param w float to set from
  2273. * @param result the vector to the floats in
  2274. */
  2275. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2276. /**
  2277. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2278. * @returns the new vector
  2279. */
  2280. static Zero(): Vector4;
  2281. /**
  2282. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2283. * @returns the new vector
  2284. */
  2285. static One(): Vector4;
  2286. /**
  2287. * Returns a new normalized Vector4 from the given one.
  2288. * @param vector the vector to normalize
  2289. * @returns the vector
  2290. */
  2291. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2292. /**
  2293. * Updates the given vector "result" from the normalization of the given one.
  2294. * @param vector the vector to normalize
  2295. * @param result the vector to store the result in
  2296. */
  2297. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2298. /**
  2299. * Returns a vector with the minimum values from the left and right vectors
  2300. * @param left left vector to minimize
  2301. * @param right right vector to minimize
  2302. * @returns a new vector with the minimum of the left and right vector values
  2303. */
  2304. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2305. /**
  2306. * Returns a vector with the maximum values from the left and right vectors
  2307. * @param left left vector to maximize
  2308. * @param right right vector to maximize
  2309. * @returns a new vector with the maximum of the left and right vector values
  2310. */
  2311. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2312. /**
  2313. * Returns the distance (float) between the vectors "value1" and "value2".
  2314. * @param value1 value to calulate the distance between
  2315. * @param value2 value to calulate the distance between
  2316. * @return the distance between the two vectors
  2317. */
  2318. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2319. /**
  2320. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2321. * @param value1 value to calulate the distance between
  2322. * @param value2 value to calulate the distance between
  2323. * @return the distance between the two vectors squared
  2324. */
  2325. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2326. /**
  2327. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2328. * @param value1 value to calulate the center between
  2329. * @param value2 value to calulate the center between
  2330. * @return the center between the two vectors
  2331. */
  2332. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2333. /**
  2334. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2335. * This methods computes transformed normalized direction vectors only.
  2336. * @param vector the vector to transform
  2337. * @param transformation the transformation matrix to apply
  2338. * @returns the new vector
  2339. */
  2340. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2341. /**
  2342. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2343. * This methods computes transformed normalized direction vectors only.
  2344. * @param vector the vector to transform
  2345. * @param transformation the transformation matrix to apply
  2346. * @param result the vector to store the result in
  2347. */
  2348. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2349. /**
  2350. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2351. * This methods computes transformed normalized direction vectors only.
  2352. * @param x value to transform
  2353. * @param y value to transform
  2354. * @param z value to transform
  2355. * @param w value to transform
  2356. * @param transformation the transformation matrix to apply
  2357. * @param result the vector to store the results in
  2358. */
  2359. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2360. /**
  2361. * Creates a new Vector4 from a Vector3
  2362. * @param source defines the source data
  2363. * @param w defines the 4th component (default is 0)
  2364. * @returns a new Vector4
  2365. */
  2366. static FromVector3(source: Vector3, w?: number): Vector4;
  2367. }
  2368. /**
  2369. * Class used to store quaternion data
  2370. * @see https://en.wikipedia.org/wiki/Quaternion
  2371. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2372. */
  2373. export class Quaternion {
  2374. /** defines the first component (0 by default) */
  2375. x: number;
  2376. /** defines the second component (0 by default) */
  2377. y: number;
  2378. /** defines the third component (0 by default) */
  2379. z: number;
  2380. /** defines the fourth component (1.0 by default) */
  2381. w: number;
  2382. /**
  2383. * Creates a new Quaternion from the given floats
  2384. * @param x defines the first component (0 by default)
  2385. * @param y defines the second component (0 by default)
  2386. * @param z defines the third component (0 by default)
  2387. * @param w defines the fourth component (1.0 by default)
  2388. */
  2389. constructor(
  2390. /** defines the first component (0 by default) */
  2391. x?: number,
  2392. /** defines the second component (0 by default) */
  2393. y?: number,
  2394. /** defines the third component (0 by default) */
  2395. z?: number,
  2396. /** defines the fourth component (1.0 by default) */
  2397. w?: number);
  2398. /**
  2399. * Gets a string representation for the current quaternion
  2400. * @returns a string with the Quaternion coordinates
  2401. */
  2402. toString(): string;
  2403. /**
  2404. * Gets the class name of the quaternion
  2405. * @returns the string "Quaternion"
  2406. */
  2407. getClassName(): string;
  2408. /**
  2409. * Gets a hash code for this quaternion
  2410. * @returns the quaternion hash code
  2411. */
  2412. getHashCode(): number;
  2413. /**
  2414. * Copy the quaternion to an array
  2415. * @returns a new array populated with 4 elements from the quaternion coordinates
  2416. */
  2417. asArray(): number[];
  2418. /**
  2419. * Check if two quaternions are equals
  2420. * @param otherQuaternion defines the second operand
  2421. * @return true if the current quaternion and the given one coordinates are strictly equals
  2422. */
  2423. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2424. /**
  2425. * Clone the current quaternion
  2426. * @returns a new quaternion copied from the current one
  2427. */
  2428. clone(): Quaternion;
  2429. /**
  2430. * Copy a quaternion to the current one
  2431. * @param other defines the other quaternion
  2432. * @returns the updated current quaternion
  2433. */
  2434. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2435. /**
  2436. * Updates the current quaternion with the given float coordinates
  2437. * @param x defines the x coordinate
  2438. * @param y defines the y coordinate
  2439. * @param z defines the z coordinate
  2440. * @param w defines the w coordinate
  2441. * @returns the updated current quaternion
  2442. */
  2443. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2444. /**
  2445. * Updates the current quaternion from the given float coordinates
  2446. * @param x defines the x coordinate
  2447. * @param y defines the y coordinate
  2448. * @param z defines the z coordinate
  2449. * @param w defines the w coordinate
  2450. * @returns the updated current quaternion
  2451. */
  2452. set(x: number, y: number, z: number, w: number): Quaternion;
  2453. /**
  2454. * Adds two quaternions
  2455. * @param other defines the second operand
  2456. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2457. */
  2458. add(other: DeepImmutable<Quaternion>): Quaternion;
  2459. /**
  2460. * Add a quaternion to the current one
  2461. * @param other defines the quaternion to add
  2462. * @returns the current quaternion
  2463. */
  2464. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2465. /**
  2466. * Subtract two quaternions
  2467. * @param other defines the second operand
  2468. * @returns a new quaternion as the subtraction result of the given one from the current one
  2469. */
  2470. subtract(other: Quaternion): Quaternion;
  2471. /**
  2472. * Multiplies the current quaternion by a scale factor
  2473. * @param value defines the scale factor
  2474. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2475. */
  2476. scale(value: number): Quaternion;
  2477. /**
  2478. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2479. * @param scale defines the scale factor
  2480. * @param result defines the Quaternion object where to store the result
  2481. * @returns the unmodified current quaternion
  2482. */
  2483. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2484. /**
  2485. * Multiplies in place the current quaternion by a scale factor
  2486. * @param value defines the scale factor
  2487. * @returns the current modified quaternion
  2488. */
  2489. scaleInPlace(value: number): Quaternion;
  2490. /**
  2491. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2492. * @param scale defines the scale factor
  2493. * @param result defines the Quaternion object where to store the result
  2494. * @returns the unmodified current quaternion
  2495. */
  2496. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2497. /**
  2498. * Multiplies two quaternions
  2499. * @param q1 defines the second operand
  2500. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2501. */
  2502. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2503. /**
  2504. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2505. * @param q1 defines the second operand
  2506. * @param result defines the target quaternion
  2507. * @returns the current quaternion
  2508. */
  2509. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2510. /**
  2511. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2512. * @param q1 defines the second operand
  2513. * @returns the currentupdated quaternion
  2514. */
  2515. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2516. /**
  2517. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2518. * @param ref defines the target quaternion
  2519. * @returns the current quaternion
  2520. */
  2521. conjugateToRef(ref: Quaternion): Quaternion;
  2522. /**
  2523. * Conjugates in place (1-q) the current quaternion
  2524. * @returns the current updated quaternion
  2525. */
  2526. conjugateInPlace(): Quaternion;
  2527. /**
  2528. * Conjugates in place (1-q) the current quaternion
  2529. * @returns a new quaternion
  2530. */
  2531. conjugate(): Quaternion;
  2532. /**
  2533. * Gets length of current quaternion
  2534. * @returns the quaternion length (float)
  2535. */
  2536. length(): number;
  2537. /**
  2538. * Normalize in place the current quaternion
  2539. * @returns the current updated quaternion
  2540. */
  2541. normalize(): Quaternion;
  2542. /**
  2543. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2544. * @param order is a reserved parameter and is ignore for now
  2545. * @returns a new Vector3 containing the Euler angles
  2546. */
  2547. toEulerAngles(order?: string): Vector3;
  2548. /**
  2549. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2550. * @param result defines the vector which will be filled with the Euler angles
  2551. * @param order is a reserved parameter and is ignore for now
  2552. * @returns the current unchanged quaternion
  2553. */
  2554. toEulerAnglesToRef(result: Vector3): Quaternion;
  2555. /**
  2556. * Updates the given rotation matrix with the current quaternion values
  2557. * @param result defines the target matrix
  2558. * @returns the current unchanged quaternion
  2559. */
  2560. toRotationMatrix(result: Matrix): Quaternion;
  2561. /**
  2562. * Updates the current quaternion from the given rotation matrix values
  2563. * @param matrix defines the source matrix
  2564. * @returns the current updated quaternion
  2565. */
  2566. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2567. /**
  2568. * Creates a new quaternion from a rotation matrix
  2569. * @param matrix defines the source matrix
  2570. * @returns a new quaternion created from the given rotation matrix values
  2571. */
  2572. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2573. /**
  2574. * Updates the given quaternion with the given rotation matrix values
  2575. * @param matrix defines the source matrix
  2576. * @param result defines the target quaternion
  2577. */
  2578. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2579. /**
  2580. * Returns the dot product (float) between the quaternions "left" and "right"
  2581. * @param left defines the left operand
  2582. * @param right defines the right operand
  2583. * @returns the dot product
  2584. */
  2585. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2586. /**
  2587. * Checks if the two quaternions are close to each other
  2588. * @param quat0 defines the first quaternion to check
  2589. * @param quat1 defines the second quaternion to check
  2590. * @returns true if the two quaternions are close to each other
  2591. */
  2592. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2593. /**
  2594. * Creates an empty quaternion
  2595. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2596. */
  2597. static Zero(): Quaternion;
  2598. /**
  2599. * Inverse a given quaternion
  2600. * @param q defines the source quaternion
  2601. * @returns a new quaternion as the inverted current quaternion
  2602. */
  2603. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2604. /**
  2605. * Inverse a given quaternion
  2606. * @param q defines the source quaternion
  2607. * @param result the quaternion the result will be stored in
  2608. * @returns the result quaternion
  2609. */
  2610. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2611. /**
  2612. * Creates an identity quaternion
  2613. * @returns the identity quaternion
  2614. */
  2615. static Identity(): Quaternion;
  2616. /**
  2617. * Gets a boolean indicating if the given quaternion is identity
  2618. * @param quaternion defines the quaternion to check
  2619. * @returns true if the quaternion is identity
  2620. */
  2621. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2622. /**
  2623. * Creates a quaternion from a rotation around an axis
  2624. * @param axis defines the axis to use
  2625. * @param angle defines the angle to use
  2626. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2627. */
  2628. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2629. /**
  2630. * Creates a rotation around an axis and stores it into the given quaternion
  2631. * @param axis defines the axis to use
  2632. * @param angle defines the angle to use
  2633. * @param result defines the target quaternion
  2634. * @returns the target quaternion
  2635. */
  2636. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2637. /**
  2638. * Creates a new quaternion from data stored into an array
  2639. * @param array defines the data source
  2640. * @param offset defines the offset in the source array where the data starts
  2641. * @returns a new quaternion
  2642. */
  2643. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2644. /**
  2645. * Create a quaternion from Euler rotation angles
  2646. * @param x Pitch
  2647. * @param y Yaw
  2648. * @param z Roll
  2649. * @returns the new Quaternion
  2650. */
  2651. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2652. /**
  2653. * Updates a quaternion from Euler rotation angles
  2654. * @param x Pitch
  2655. * @param y Yaw
  2656. * @param z Roll
  2657. * @param result the quaternion to store the result
  2658. * @returns the updated quaternion
  2659. */
  2660. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2661. /**
  2662. * Create a quaternion from Euler rotation vector
  2663. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2664. * @returns the new Quaternion
  2665. */
  2666. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2667. /**
  2668. * Updates a quaternion from Euler rotation vector
  2669. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2670. * @param result the quaternion to store the result
  2671. * @returns the updated quaternion
  2672. */
  2673. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2674. /**
  2675. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2676. * @param yaw defines the rotation around Y axis
  2677. * @param pitch defines the rotation around X axis
  2678. * @param roll defines the rotation around Z axis
  2679. * @returns the new quaternion
  2680. */
  2681. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2682. /**
  2683. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2684. * @param yaw defines the rotation around Y axis
  2685. * @param pitch defines the rotation around X axis
  2686. * @param roll defines the rotation around Z axis
  2687. * @param result defines the target quaternion
  2688. */
  2689. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2690. /**
  2691. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2692. * @param alpha defines the rotation around first axis
  2693. * @param beta defines the rotation around second axis
  2694. * @param gamma defines the rotation around third axis
  2695. * @returns the new quaternion
  2696. */
  2697. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2698. /**
  2699. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2700. * @param alpha defines the rotation around first axis
  2701. * @param beta defines the rotation around second axis
  2702. * @param gamma defines the rotation around third axis
  2703. * @param result defines the target quaternion
  2704. */
  2705. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2706. /**
  2707. * 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)
  2708. * @param axis1 defines the first axis
  2709. * @param axis2 defines the second axis
  2710. * @param axis3 defines the third axis
  2711. * @returns the new quaternion
  2712. */
  2713. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2714. /**
  2715. * 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
  2716. * @param axis1 defines the first axis
  2717. * @param axis2 defines the second axis
  2718. * @param axis3 defines the third axis
  2719. * @param ref defines the target quaternion
  2720. */
  2721. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2722. /**
  2723. * Interpolates between two quaternions
  2724. * @param left defines first quaternion
  2725. * @param right defines second quaternion
  2726. * @param amount defines the gradient to use
  2727. * @returns the new interpolated quaternion
  2728. */
  2729. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2730. /**
  2731. * Interpolates between two quaternions and stores it into a target quaternion
  2732. * @param left defines first quaternion
  2733. * @param right defines second quaternion
  2734. * @param amount defines the gradient to use
  2735. * @param result defines the target quaternion
  2736. */
  2737. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2738. /**
  2739. * Interpolate between two quaternions using Hermite interpolation
  2740. * @param value1 defines first quaternion
  2741. * @param tangent1 defines the incoming tangent
  2742. * @param value2 defines second quaternion
  2743. * @param tangent2 defines the outgoing tangent
  2744. * @param amount defines the target quaternion
  2745. * @returns the new interpolated quaternion
  2746. */
  2747. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2748. }
  2749. /**
  2750. * Class used to store matrix data (4x4)
  2751. */
  2752. export class Matrix {
  2753. private static _updateFlagSeed;
  2754. private static _identityReadOnly;
  2755. private _isIdentity;
  2756. private _isIdentityDirty;
  2757. private _isIdentity3x2;
  2758. private _isIdentity3x2Dirty;
  2759. /**
  2760. * Gets the update flag of the matrix which is an unique number for the matrix.
  2761. * It will be incremented every time the matrix data change.
  2762. * You can use it to speed the comparison between two versions of the same matrix.
  2763. */
  2764. updateFlag: number;
  2765. private readonly _m;
  2766. /**
  2767. * Gets the internal data of the matrix
  2768. */
  2769. readonly m: DeepImmutable<Float32Array>;
  2770. /** @hidden */
  2771. _markAsUpdated(): void;
  2772. /** @hidden */
  2773. private _updateIdentityStatus;
  2774. /**
  2775. * Creates an empty matrix (filled with zeros)
  2776. */
  2777. constructor();
  2778. /**
  2779. * Check if the current matrix is identity
  2780. * @returns true is the matrix is the identity matrix
  2781. */
  2782. isIdentity(): boolean;
  2783. /**
  2784. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2785. * @returns true is the matrix is the identity matrix
  2786. */
  2787. isIdentityAs3x2(): boolean;
  2788. /**
  2789. * Gets the determinant of the matrix
  2790. * @returns the matrix determinant
  2791. */
  2792. determinant(): number;
  2793. /**
  2794. * Returns the matrix as a Float32Array
  2795. * @returns the matrix underlying array
  2796. */
  2797. toArray(): DeepImmutable<Float32Array>;
  2798. /**
  2799. * Returns the matrix as a Float32Array
  2800. * @returns the matrix underlying array.
  2801. */
  2802. asArray(): DeepImmutable<Float32Array>;
  2803. /**
  2804. * Inverts the current matrix in place
  2805. * @returns the current inverted matrix
  2806. */
  2807. invert(): Matrix;
  2808. /**
  2809. * Sets all the matrix elements to zero
  2810. * @returns the current matrix
  2811. */
  2812. reset(): Matrix;
  2813. /**
  2814. * Adds the current matrix with a second one
  2815. * @param other defines the matrix to add
  2816. * @returns a new matrix as the addition of the current matrix and the given one
  2817. */
  2818. add(other: DeepImmutable<Matrix>): Matrix;
  2819. /**
  2820. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2821. * @param other defines the matrix to add
  2822. * @param result defines the target matrix
  2823. * @returns the current matrix
  2824. */
  2825. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2826. /**
  2827. * Adds in place the given matrix to the current matrix
  2828. * @param other defines the second operand
  2829. * @returns the current updated matrix
  2830. */
  2831. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2832. /**
  2833. * Sets the given matrix to the current inverted Matrix
  2834. * @param other defines the target matrix
  2835. * @returns the unmodified current matrix
  2836. */
  2837. invertToRef(other: Matrix): Matrix;
  2838. /**
  2839. * add a value at the specified position in the current Matrix
  2840. * @param index the index of the value within the matrix. between 0 and 15.
  2841. * @param value the value to be added
  2842. * @returns the current updated matrix
  2843. */
  2844. addAtIndex(index: number, value: number): Matrix;
  2845. /**
  2846. * mutiply the specified position in the current Matrix by a value
  2847. * @param index the index of the value within the matrix. between 0 and 15.
  2848. * @param value the value to be added
  2849. * @returns the current updated matrix
  2850. */
  2851. multiplyAtIndex(index: number, value: number): Matrix;
  2852. /**
  2853. * Inserts the translation vector (using 3 floats) in the current matrix
  2854. * @param x defines the 1st component of the translation
  2855. * @param y defines the 2nd component of the translation
  2856. * @param z defines the 3rd component of the translation
  2857. * @returns the current updated matrix
  2858. */
  2859. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2860. /**
  2861. * Adds the translation vector (using 3 floats) in the current matrix
  2862. * @param x defines the 1st component of the translation
  2863. * @param y defines the 2nd component of the translation
  2864. * @param z defines the 3rd component of the translation
  2865. * @returns the current updated matrix
  2866. */
  2867. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2868. /**
  2869. * Inserts the translation vector in the current matrix
  2870. * @param vector3 defines the translation to insert
  2871. * @returns the current updated matrix
  2872. */
  2873. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2874. /**
  2875. * Gets the translation value of the current matrix
  2876. * @returns a new Vector3 as the extracted translation from the matrix
  2877. */
  2878. getTranslation(): Vector3;
  2879. /**
  2880. * Fill a Vector3 with the extracted translation from the matrix
  2881. * @param result defines the Vector3 where to store the translation
  2882. * @returns the current matrix
  2883. */
  2884. getTranslationToRef(result: Vector3): Matrix;
  2885. /**
  2886. * Remove rotation and scaling part from the matrix
  2887. * @returns the updated matrix
  2888. */
  2889. removeRotationAndScaling(): Matrix;
  2890. /**
  2891. * Multiply two matrices
  2892. * @param other defines the second operand
  2893. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2894. */
  2895. multiply(other: DeepImmutable<Matrix>): Matrix;
  2896. /**
  2897. * Copy the current matrix from the given one
  2898. * @param other defines the source matrix
  2899. * @returns the current updated matrix
  2900. */
  2901. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  2902. /**
  2903. * Populates the given array from the starting index with the current matrix values
  2904. * @param array defines the target array
  2905. * @param offset defines the offset in the target array where to start storing values
  2906. * @returns the current matrix
  2907. */
  2908. copyToArray(array: Float32Array, offset?: number): Matrix;
  2909. /**
  2910. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  2911. * @param other defines the second operand
  2912. * @param result defines the matrix where to store the multiplication
  2913. * @returns the current matrix
  2914. */
  2915. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2916. /**
  2917. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  2918. * @param other defines the second operand
  2919. * @param result defines the array where to store the multiplication
  2920. * @param offset defines the offset in the target array where to start storing values
  2921. * @returns the current matrix
  2922. */
  2923. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  2924. /**
  2925. * Check equality between this matrix and a second one
  2926. * @param value defines the second matrix to compare
  2927. * @returns true is the current matrix and the given one values are strictly equal
  2928. */
  2929. equals(value: DeepImmutable<Matrix>): boolean;
  2930. /**
  2931. * Clone the current matrix
  2932. * @returns a new matrix from the current matrix
  2933. */
  2934. clone(): Matrix;
  2935. /**
  2936. * Returns the name of the current matrix class
  2937. * @returns the string "Matrix"
  2938. */
  2939. getClassName(): string;
  2940. /**
  2941. * Gets the hash code of the current matrix
  2942. * @returns the hash code
  2943. */
  2944. getHashCode(): number;
  2945. /**
  2946. * Decomposes the current Matrix into a translation, rotation and scaling components
  2947. * @param scale defines the scale vector3 given as a reference to update
  2948. * @param rotation defines the rotation quaternion given as a reference to update
  2949. * @param translation defines the translation vector3 given as a reference to update
  2950. * @returns true if operation was successful
  2951. */
  2952. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  2953. /**
  2954. * Gets specific row of the matrix
  2955. * @param index defines the number of the row to get
  2956. * @returns the index-th row of the current matrix as a new Vector4
  2957. */
  2958. getRow(index: number): Nullable<Vector4>;
  2959. /**
  2960. * Sets the index-th row of the current matrix to the vector4 values
  2961. * @param index defines the number of the row to set
  2962. * @param row defines the target vector4
  2963. * @returns the updated current matrix
  2964. */
  2965. setRow(index: number, row: Vector4): Matrix;
  2966. /**
  2967. * Compute the transpose of the matrix
  2968. * @returns the new transposed matrix
  2969. */
  2970. transpose(): Matrix;
  2971. /**
  2972. * Compute the transpose of the matrix and store it in a given matrix
  2973. * @param result defines the target matrix
  2974. * @returns the current matrix
  2975. */
  2976. transposeToRef(result: Matrix): Matrix;
  2977. /**
  2978. * Sets the index-th row of the current matrix with the given 4 x float values
  2979. * @param index defines the row index
  2980. * @param x defines the x component to set
  2981. * @param y defines the y component to set
  2982. * @param z defines the z component to set
  2983. * @param w defines the w component to set
  2984. * @returns the updated current matrix
  2985. */
  2986. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  2987. /**
  2988. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  2989. * @param scale defines the scale factor
  2990. * @returns a new matrix
  2991. */
  2992. scale(scale: number): Matrix;
  2993. /**
  2994. * Scale the current matrix values by a factor to a given result matrix
  2995. * @param scale defines the scale factor
  2996. * @param result defines the matrix to store the result
  2997. * @returns the current matrix
  2998. */
  2999. scaleToRef(scale: number, result: Matrix): Matrix;
  3000. /**
  3001. * Scale the current matrix values by a factor and add the result to a given matrix
  3002. * @param scale defines the scale factor
  3003. * @param result defines the Matrix to store the result
  3004. * @returns the current matrix
  3005. */
  3006. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3007. /**
  3008. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3009. * @param ref matrix to store the result
  3010. */
  3011. toNormalMatrix(ref: Matrix): void;
  3012. /**
  3013. * Gets only rotation part of the current matrix
  3014. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3015. */
  3016. getRotationMatrix(): Matrix;
  3017. /**
  3018. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3019. * @param result defines the target matrix to store data to
  3020. * @returns the current matrix
  3021. */
  3022. getRotationMatrixToRef(result: Matrix): Matrix;
  3023. /**
  3024. * Toggles model matrix from being right handed to left handed in place and vice versa
  3025. */
  3026. toggleModelMatrixHandInPlace(): void;
  3027. /**
  3028. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3029. */
  3030. toggleProjectionMatrixHandInPlace(): void;
  3031. /**
  3032. * Creates a matrix from an array
  3033. * @param array defines the source array
  3034. * @param offset defines an offset in the source array
  3035. * @returns a new Matrix set from the starting index of the given array
  3036. */
  3037. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3038. /**
  3039. * Copy the content of an array into a given matrix
  3040. * @param array defines the source array
  3041. * @param offset defines an offset in the source array
  3042. * @param result defines the target matrix
  3043. */
  3044. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3045. /**
  3046. * Stores an array into a matrix after having multiplied each component by a given factor
  3047. * @param array defines the source array
  3048. * @param offset defines the offset in the source array
  3049. * @param scale defines the scaling factor
  3050. * @param result defines the target matrix
  3051. */
  3052. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3053. /**
  3054. * Gets an identity matrix that must not be updated
  3055. */
  3056. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3057. /**
  3058. * Stores a list of values (16) inside a given matrix
  3059. * @param initialM11 defines 1st value of 1st row
  3060. * @param initialM12 defines 2nd value of 1st row
  3061. * @param initialM13 defines 3rd value of 1st row
  3062. * @param initialM14 defines 4th value of 1st row
  3063. * @param initialM21 defines 1st value of 2nd row
  3064. * @param initialM22 defines 2nd value of 2nd row
  3065. * @param initialM23 defines 3rd value of 2nd row
  3066. * @param initialM24 defines 4th value of 2nd row
  3067. * @param initialM31 defines 1st value of 3rd row
  3068. * @param initialM32 defines 2nd value of 3rd row
  3069. * @param initialM33 defines 3rd value of 3rd row
  3070. * @param initialM34 defines 4th value of 3rd row
  3071. * @param initialM41 defines 1st value of 4th row
  3072. * @param initialM42 defines 2nd value of 4th row
  3073. * @param initialM43 defines 3rd value of 4th row
  3074. * @param initialM44 defines 4th value of 4th row
  3075. * @param result defines the target matrix
  3076. */
  3077. 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;
  3078. /**
  3079. * Creates new matrix from a list of values (16)
  3080. * @param initialM11 defines 1st value of 1st row
  3081. * @param initialM12 defines 2nd value of 1st row
  3082. * @param initialM13 defines 3rd value of 1st row
  3083. * @param initialM14 defines 4th value of 1st row
  3084. * @param initialM21 defines 1st value of 2nd row
  3085. * @param initialM22 defines 2nd value of 2nd row
  3086. * @param initialM23 defines 3rd value of 2nd row
  3087. * @param initialM24 defines 4th value of 2nd row
  3088. * @param initialM31 defines 1st value of 3rd row
  3089. * @param initialM32 defines 2nd value of 3rd row
  3090. * @param initialM33 defines 3rd value of 3rd row
  3091. * @param initialM34 defines 4th value of 3rd row
  3092. * @param initialM41 defines 1st value of 4th row
  3093. * @param initialM42 defines 2nd value of 4th row
  3094. * @param initialM43 defines 3rd value of 4th row
  3095. * @param initialM44 defines 4th value of 4th row
  3096. * @returns the new matrix
  3097. */
  3098. 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;
  3099. /**
  3100. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3101. * @param scale defines the scale vector3
  3102. * @param rotation defines the rotation quaternion
  3103. * @param translation defines the translation vector3
  3104. * @returns a new matrix
  3105. */
  3106. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3107. /**
  3108. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3109. * @param scale defines the scale vector3
  3110. * @param rotation defines the rotation quaternion
  3111. * @param translation defines the translation vector3
  3112. * @param result defines the target matrix
  3113. */
  3114. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3115. /**
  3116. * Creates a new identity matrix
  3117. * @returns a new identity matrix
  3118. */
  3119. static Identity(): Matrix;
  3120. /**
  3121. * Creates a new identity matrix and stores the result in a given matrix
  3122. * @param result defines the target matrix
  3123. */
  3124. static IdentityToRef(result: Matrix): void;
  3125. /**
  3126. * Creates a new zero matrix
  3127. * @returns a new zero matrix
  3128. */
  3129. static Zero(): Matrix;
  3130. /**
  3131. * Creates a new rotation matrix for "angle" radians around the X axis
  3132. * @param angle defines the angle (in radians) to use
  3133. * @return the new matrix
  3134. */
  3135. static RotationX(angle: number): Matrix;
  3136. /**
  3137. * Creates a new matrix as the invert of a given matrix
  3138. * @param source defines the source matrix
  3139. * @returns the new matrix
  3140. */
  3141. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3142. /**
  3143. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3144. * @param angle defines the angle (in radians) to use
  3145. * @param result defines the target matrix
  3146. */
  3147. static RotationXToRef(angle: number, result: Matrix): void;
  3148. /**
  3149. * Creates a new rotation matrix for "angle" radians around the Y axis
  3150. * @param angle defines the angle (in radians) to use
  3151. * @return the new matrix
  3152. */
  3153. static RotationY(angle: number): Matrix;
  3154. /**
  3155. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3156. * @param angle defines the angle (in radians) to use
  3157. * @param result defines the target matrix
  3158. */
  3159. static RotationYToRef(angle: number, result: Matrix): void;
  3160. /**
  3161. * Creates a new rotation matrix for "angle" radians around the Z axis
  3162. * @param angle defines the angle (in radians) to use
  3163. * @return the new matrix
  3164. */
  3165. static RotationZ(angle: number): Matrix;
  3166. /**
  3167. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3168. * @param angle defines the angle (in radians) to use
  3169. * @param result defines the target matrix
  3170. */
  3171. static RotationZToRef(angle: number, result: Matrix): void;
  3172. /**
  3173. * Creates a new rotation matrix for "angle" radians around the given axis
  3174. * @param axis defines the axis to use
  3175. * @param angle defines the angle (in radians) to use
  3176. * @return the new matrix
  3177. */
  3178. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3179. /**
  3180. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3181. * @param axis defines the axis to use
  3182. * @param angle defines the angle (in radians) to use
  3183. * @param result defines the target matrix
  3184. */
  3185. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3186. /**
  3187. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3188. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3189. * @param from defines the vector to align
  3190. * @param to defines the vector to align to
  3191. * @param result defines the target matrix
  3192. */
  3193. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3194. /**
  3195. * Creates a rotation matrix
  3196. * @param yaw defines the yaw angle in radians (Y axis)
  3197. * @param pitch defines the pitch angle in radians (X axis)
  3198. * @param roll defines the roll angle in radians (X axis)
  3199. * @returns the new rotation matrix
  3200. */
  3201. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3202. /**
  3203. * Creates a rotation matrix and stores it in a given matrix
  3204. * @param yaw defines the yaw angle in radians (Y axis)
  3205. * @param pitch defines the pitch angle in radians (X axis)
  3206. * @param roll defines the roll angle in radians (X axis)
  3207. * @param result defines the target matrix
  3208. */
  3209. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3210. /**
  3211. * Creates a scaling matrix
  3212. * @param x defines the scale factor on X axis
  3213. * @param y defines the scale factor on Y axis
  3214. * @param z defines the scale factor on Z axis
  3215. * @returns the new matrix
  3216. */
  3217. static Scaling(x: number, y: number, z: number): Matrix;
  3218. /**
  3219. * Creates a scaling matrix and stores it in a given matrix
  3220. * @param x defines the scale factor on X axis
  3221. * @param y defines the scale factor on Y axis
  3222. * @param z defines the scale factor on Z axis
  3223. * @param result defines the target matrix
  3224. */
  3225. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3226. /**
  3227. * Creates a translation matrix
  3228. * @param x defines the translation on X axis
  3229. * @param y defines the translation on Y axis
  3230. * @param z defines the translationon Z axis
  3231. * @returns the new matrix
  3232. */
  3233. static Translation(x: number, y: number, z: number): Matrix;
  3234. /**
  3235. * Creates a translation matrix and stores it in a given matrix
  3236. * @param x defines the translation on X axis
  3237. * @param y defines the translation on Y axis
  3238. * @param z defines the translationon Z axis
  3239. * @param result defines the target matrix
  3240. */
  3241. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3242. /**
  3243. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3244. * @param startValue defines the start value
  3245. * @param endValue defines the end value
  3246. * @param gradient defines the gradient factor
  3247. * @returns the new matrix
  3248. */
  3249. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3250. /**
  3251. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3252. * @param startValue defines the start value
  3253. * @param endValue defines the end value
  3254. * @param gradient defines the gradient factor
  3255. * @param result defines the Matrix object where to store data
  3256. */
  3257. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3258. /**
  3259. * Builds a new matrix whose values are computed by:
  3260. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3261. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3262. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3263. * @param startValue defines the first matrix
  3264. * @param endValue defines the second matrix
  3265. * @param gradient defines the gradient between the two matrices
  3266. * @returns the new matrix
  3267. */
  3268. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3269. /**
  3270. * Update a matrix to values which are computed by:
  3271. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3272. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3273. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3274. * @param startValue defines the first matrix
  3275. * @param endValue defines the second matrix
  3276. * @param gradient defines the gradient between the two matrices
  3277. * @param result defines the target matrix
  3278. */
  3279. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3280. /**
  3281. * 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"
  3282. * This function works in left handed mode
  3283. * @param eye defines the final position of the entity
  3284. * @param target defines where the entity should look at
  3285. * @param up defines the up vector for the entity
  3286. * @returns the new matrix
  3287. */
  3288. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3289. /**
  3290. * 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".
  3291. * This function works in left handed mode
  3292. * @param eye defines the final position of the entity
  3293. * @param target defines where the entity should look at
  3294. * @param up defines the up vector for the entity
  3295. * @param result defines the target matrix
  3296. */
  3297. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3298. /**
  3299. * 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"
  3300. * This function works in right handed mode
  3301. * @param eye defines the final position of the entity
  3302. * @param target defines where the entity should look at
  3303. * @param up defines the up vector for the entity
  3304. * @returns the new matrix
  3305. */
  3306. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3307. /**
  3308. * 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".
  3309. * This function works in right handed mode
  3310. * @param eye defines the final position of the entity
  3311. * @param target defines where the entity should look at
  3312. * @param up defines the up vector for the entity
  3313. * @param result defines the target matrix
  3314. */
  3315. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3316. /**
  3317. * Create a left-handed orthographic projection matrix
  3318. * @param width defines the viewport width
  3319. * @param height defines the viewport height
  3320. * @param znear defines the near clip plane
  3321. * @param zfar defines the far clip plane
  3322. * @returns a new matrix as a left-handed orthographic projection matrix
  3323. */
  3324. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3325. /**
  3326. * Store a left-handed orthographic projection to a given matrix
  3327. * @param width defines the viewport width
  3328. * @param height defines the viewport height
  3329. * @param znear defines the near clip plane
  3330. * @param zfar defines the far clip plane
  3331. * @param result defines the target matrix
  3332. */
  3333. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3334. /**
  3335. * Create a left-handed orthographic projection matrix
  3336. * @param left defines the viewport left coordinate
  3337. * @param right defines the viewport right coordinate
  3338. * @param bottom defines the viewport bottom coordinate
  3339. * @param top defines the viewport top coordinate
  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 OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3345. /**
  3346. * Stores a left-handed orthographic projection into a given matrix
  3347. * @param left defines the viewport left coordinate
  3348. * @param right defines the viewport right coordinate
  3349. * @param bottom defines the viewport bottom coordinate
  3350. * @param top defines the viewport top coordinate
  3351. * @param znear defines the near clip plane
  3352. * @param zfar defines the far clip plane
  3353. * @param result defines the target matrix
  3354. */
  3355. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3356. /**
  3357. * Creates a right-handed orthographic projection matrix
  3358. * @param left defines the viewport left coordinate
  3359. * @param right defines the viewport right coordinate
  3360. * @param bottom defines the viewport bottom coordinate
  3361. * @param top defines the viewport top coordinate
  3362. * @param znear defines the near clip plane
  3363. * @param zfar defines the far clip plane
  3364. * @returns a new matrix as a right-handed orthographic projection matrix
  3365. */
  3366. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3367. /**
  3368. * Stores a right-handed orthographic projection into a given matrix
  3369. * @param left defines the viewport left coordinate
  3370. * @param right defines the viewport right coordinate
  3371. * @param bottom defines the viewport bottom coordinate
  3372. * @param top defines the viewport top coordinate
  3373. * @param znear defines the near clip plane
  3374. * @param zfar defines the far clip plane
  3375. * @param result defines the target matrix
  3376. */
  3377. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3378. /**
  3379. * Creates a left-handed perspective projection matrix
  3380. * @param width defines the viewport width
  3381. * @param height defines the viewport height
  3382. * @param znear defines the near clip plane
  3383. * @param zfar defines the far clip plane
  3384. * @returns a new matrix as a left-handed perspective projection matrix
  3385. */
  3386. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3387. /**
  3388. * Creates a left-handed perspective projection matrix
  3389. * @param fov defines the horizontal field of view
  3390. * @param aspect defines the aspect ratio
  3391. * @param znear defines the near clip plane
  3392. * @param zfar defines the far clip plane
  3393. * @returns a new matrix as a left-handed perspective projection matrix
  3394. */
  3395. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3396. /**
  3397. * Stores a left-handed perspective projection into a given matrix
  3398. * @param fov defines the horizontal field of view
  3399. * @param aspect defines the aspect ratio
  3400. * @param znear defines the near clip plane
  3401. * @param zfar defines the far clip plane
  3402. * @param result defines the target matrix
  3403. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3404. */
  3405. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3406. /**
  3407. * Creates a right-handed perspective projection matrix
  3408. * @param fov defines the horizontal field of view
  3409. * @param aspect defines the aspect ratio
  3410. * @param znear defines the near clip plane
  3411. * @param zfar defines the far clip plane
  3412. * @returns a new matrix as a right-handed perspective projection matrix
  3413. */
  3414. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3415. /**
  3416. * Stores a right-handed perspective projection into a given matrix
  3417. * @param fov defines the horizontal field of view
  3418. * @param aspect defines the aspect ratio
  3419. * @param znear defines the near clip plane
  3420. * @param zfar defines the far clip plane
  3421. * @param result defines the target matrix
  3422. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3423. */
  3424. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3425. /**
  3426. * Stores a perspective projection for WebVR info a given matrix
  3427. * @param fov defines the field of view
  3428. * @param znear defines the near clip plane
  3429. * @param zfar defines the far clip plane
  3430. * @param result defines the target matrix
  3431. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3432. */
  3433. static PerspectiveFovWebVRToRef(fov: {
  3434. upDegrees: number;
  3435. downDegrees: number;
  3436. leftDegrees: number;
  3437. rightDegrees: number;
  3438. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3439. /**
  3440. * Computes a complete transformation matrix
  3441. * @param viewport defines the viewport to use
  3442. * @param world defines the world matrix
  3443. * @param view defines the view matrix
  3444. * @param projection defines the projection matrix
  3445. * @param zmin defines the near clip plane
  3446. * @param zmax defines the far clip plane
  3447. * @returns the transformation matrix
  3448. */
  3449. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3450. /**
  3451. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3452. * @param matrix defines the matrix to use
  3453. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3454. */
  3455. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3456. /**
  3457. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3458. * @param matrix defines the matrix to use
  3459. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3460. */
  3461. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3462. /**
  3463. * Compute the transpose of a given matrix
  3464. * @param matrix defines the matrix to transpose
  3465. * @returns the new matrix
  3466. */
  3467. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3468. /**
  3469. * Compute the transpose of a matrix and store it in a target matrix
  3470. * @param matrix defines the matrix to transpose
  3471. * @param result defines the target matrix
  3472. */
  3473. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3474. /**
  3475. * Computes a reflection matrix from a plane
  3476. * @param plane defines the reflection plane
  3477. * @returns a new matrix
  3478. */
  3479. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  3480. /**
  3481. * Computes a reflection matrix from a plane
  3482. * @param plane defines the reflection plane
  3483. * @param result defines the target matrix
  3484. */
  3485. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  3486. /**
  3487. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3488. * @param xaxis defines the value of the 1st axis
  3489. * @param yaxis defines the value of the 2nd axis
  3490. * @param zaxis defines the value of the 3rd axis
  3491. * @param result defines the target matrix
  3492. */
  3493. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3494. /**
  3495. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3496. * @param quat defines the quaternion to use
  3497. * @param result defines the target matrix
  3498. */
  3499. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3500. }
  3501. /**
  3502. * @hidden
  3503. */
  3504. export class TmpVectors {
  3505. static Vector2: Vector2[];
  3506. static Vector3: Vector3[];
  3507. static Vector4: Vector4[];
  3508. static Quaternion: Quaternion[];
  3509. static Matrix: Matrix[];
  3510. }
  3511. }
  3512. declare module "babylonjs/Maths/math.color" {
  3513. import { DeepImmutable, FloatArray } from "babylonjs/types";
  3514. /**
  3515. * Class used to hold a RBG color
  3516. */
  3517. export class Color3 {
  3518. /**
  3519. * Defines the red component (between 0 and 1, default is 0)
  3520. */
  3521. r: number;
  3522. /**
  3523. * Defines the green component (between 0 and 1, default is 0)
  3524. */
  3525. g: number;
  3526. /**
  3527. * Defines the blue component (between 0 and 1, default is 0)
  3528. */
  3529. b: number;
  3530. /**
  3531. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  3532. * @param r defines the red component (between 0 and 1, default is 0)
  3533. * @param g defines the green component (between 0 and 1, default is 0)
  3534. * @param b defines the blue component (between 0 and 1, default is 0)
  3535. */
  3536. constructor(
  3537. /**
  3538. * Defines the red component (between 0 and 1, default is 0)
  3539. */
  3540. r?: number,
  3541. /**
  3542. * Defines the green component (between 0 and 1, default is 0)
  3543. */
  3544. g?: number,
  3545. /**
  3546. * Defines the blue component (between 0 and 1, default is 0)
  3547. */
  3548. b?: number);
  3549. /**
  3550. * Creates a string with the Color3 current values
  3551. * @returns the string representation of the Color3 object
  3552. */
  3553. toString(): string;
  3554. /**
  3555. * Returns the string "Color3"
  3556. * @returns "Color3"
  3557. */
  3558. getClassName(): string;
  3559. /**
  3560. * Compute the Color3 hash code
  3561. * @returns an unique number that can be used to hash Color3 objects
  3562. */
  3563. getHashCode(): number;
  3564. /**
  3565. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  3566. * @param array defines the array where to store the r,g,b components
  3567. * @param index defines an optional index in the target array to define where to start storing values
  3568. * @returns the current Color3 object
  3569. */
  3570. toArray(array: FloatArray, index?: number): Color3;
  3571. /**
  3572. * Returns a new Color4 object from the current Color3 and the given alpha
  3573. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  3574. * @returns a new Color4 object
  3575. */
  3576. toColor4(alpha?: number): Color4;
  3577. /**
  3578. * Returns a new array populated with 3 numeric elements : red, green and blue values
  3579. * @returns the new array
  3580. */
  3581. asArray(): number[];
  3582. /**
  3583. * Returns the luminance value
  3584. * @returns a float value
  3585. */
  3586. toLuminance(): number;
  3587. /**
  3588. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  3589. * @param otherColor defines the second operand
  3590. * @returns the new Color3 object
  3591. */
  3592. multiply(otherColor: DeepImmutable<Color3>): Color3;
  3593. /**
  3594. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  3595. * @param otherColor defines the second operand
  3596. * @param result defines the Color3 object where to store the result
  3597. * @returns the current Color3
  3598. */
  3599. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  3600. /**
  3601. * Determines equality between Color3 objects
  3602. * @param otherColor defines the second operand
  3603. * @returns true if the rgb values are equal to the given ones
  3604. */
  3605. equals(otherColor: DeepImmutable<Color3>): boolean;
  3606. /**
  3607. * Determines equality between the current Color3 object and a set of r,b,g values
  3608. * @param r defines the red component to check
  3609. * @param g defines the green component to check
  3610. * @param b defines the blue component to check
  3611. * @returns true if the rgb values are equal to the given ones
  3612. */
  3613. equalsFloats(r: number, g: number, b: number): boolean;
  3614. /**
  3615. * Multiplies in place each rgb value by scale
  3616. * @param scale defines the scaling factor
  3617. * @returns the updated Color3
  3618. */
  3619. scale(scale: number): Color3;
  3620. /**
  3621. * Multiplies the rgb values by scale and stores the result into "result"
  3622. * @param scale defines the scaling factor
  3623. * @param result defines the Color3 object where to store the result
  3624. * @returns the unmodified current Color3
  3625. */
  3626. scaleToRef(scale: number, result: Color3): Color3;
  3627. /**
  3628. * Scale the current Color3 values by a factor and add the result to a given Color3
  3629. * @param scale defines the scale factor
  3630. * @param result defines color to store the result into
  3631. * @returns the unmodified current Color3
  3632. */
  3633. scaleAndAddToRef(scale: number, result: Color3): Color3;
  3634. /**
  3635. * Clamps the rgb values by the min and max values and stores the result into "result"
  3636. * @param min defines minimum clamping value (default is 0)
  3637. * @param max defines maximum clamping value (default is 1)
  3638. * @param result defines color to store the result into
  3639. * @returns the original Color3
  3640. */
  3641. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  3642. /**
  3643. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  3644. * @param otherColor defines the second operand
  3645. * @returns the new Color3
  3646. */
  3647. add(otherColor: DeepImmutable<Color3>): Color3;
  3648. /**
  3649. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  3650. * @param otherColor defines the second operand
  3651. * @param result defines Color3 object to store the result into
  3652. * @returns the unmodified current Color3
  3653. */
  3654. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  3655. /**
  3656. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  3657. * @param otherColor defines the second operand
  3658. * @returns the new Color3
  3659. */
  3660. subtract(otherColor: DeepImmutable<Color3>): Color3;
  3661. /**
  3662. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  3663. * @param otherColor defines the second operand
  3664. * @param result defines Color3 object to store the result into
  3665. * @returns the unmodified current Color3
  3666. */
  3667. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  3668. /**
  3669. * Copy the current object
  3670. * @returns a new Color3 copied the current one
  3671. */
  3672. clone(): Color3;
  3673. /**
  3674. * Copies the rgb values from the source in the current Color3
  3675. * @param source defines the source Color3 object
  3676. * @returns the updated Color3 object
  3677. */
  3678. copyFrom(source: DeepImmutable<Color3>): Color3;
  3679. /**
  3680. * Updates the Color3 rgb values from the given floats
  3681. * @param r defines the red component to read from
  3682. * @param g defines the green component to read from
  3683. * @param b defines the blue component to read from
  3684. * @returns the current Color3 object
  3685. */
  3686. copyFromFloats(r: number, g: number, b: number): Color3;
  3687. /**
  3688. * Updates the Color3 rgb values from the given floats
  3689. * @param r defines the red component to read from
  3690. * @param g defines the green component to read from
  3691. * @param b defines the blue component to read from
  3692. * @returns the current Color3 object
  3693. */
  3694. set(r: number, g: number, b: number): Color3;
  3695. /**
  3696. * Compute the Color3 hexadecimal code as a string
  3697. * @returns a string containing the hexadecimal representation of the Color3 object
  3698. */
  3699. toHexString(): string;
  3700. /**
  3701. * Computes a new Color3 converted from the current one to linear space
  3702. * @returns a new Color3 object
  3703. */
  3704. toLinearSpace(): Color3;
  3705. /**
  3706. * Converts current color in rgb space to HSV values
  3707. * @returns a new color3 representing the HSV values
  3708. */
  3709. toHSV(): Color3;
  3710. /**
  3711. * Converts current color in rgb space to HSV values
  3712. * @param result defines the Color3 where to store the HSV values
  3713. */
  3714. toHSVToRef(result: Color3): void;
  3715. /**
  3716. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  3717. * @param convertedColor defines the Color3 object where to store the linear space version
  3718. * @returns the unmodified Color3
  3719. */
  3720. toLinearSpaceToRef(convertedColor: Color3): Color3;
  3721. /**
  3722. * Computes a new Color3 converted from the current one to gamma space
  3723. * @returns a new Color3 object
  3724. */
  3725. toGammaSpace(): Color3;
  3726. /**
  3727. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  3728. * @param convertedColor defines the Color3 object where to store the gamma space version
  3729. * @returns the unmodified Color3
  3730. */
  3731. toGammaSpaceToRef(convertedColor: Color3): Color3;
  3732. private static _BlackReadOnly;
  3733. /**
  3734. * Convert Hue, saturation and value to a Color3 (RGB)
  3735. * @param hue defines the hue
  3736. * @param saturation defines the saturation
  3737. * @param value defines the value
  3738. * @param result defines the Color3 where to store the RGB values
  3739. */
  3740. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  3741. /**
  3742. * Creates a new Color3 from the string containing valid hexadecimal values
  3743. * @param hex defines a string containing valid hexadecimal values
  3744. * @returns a new Color3 object
  3745. */
  3746. static FromHexString(hex: string): Color3;
  3747. /**
  3748. * Creates a new Color3 from the starting index of the given array
  3749. * @param array defines the source array
  3750. * @param offset defines an offset in the source array
  3751. * @returns a new Color3 object
  3752. */
  3753. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  3754. /**
  3755. * Creates a new Color3 from integer values (< 256)
  3756. * @param r defines the red component to read from (value between 0 and 255)
  3757. * @param g defines the green component to read from (value between 0 and 255)
  3758. * @param b defines the blue component to read from (value between 0 and 255)
  3759. * @returns a new Color3 object
  3760. */
  3761. static FromInts(r: number, g: number, b: number): Color3;
  3762. /**
  3763. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  3764. * @param start defines the start Color3 value
  3765. * @param end defines the end Color3 value
  3766. * @param amount defines the gradient value between start and end
  3767. * @returns a new Color3 object
  3768. */
  3769. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  3770. /**
  3771. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  3772. * @param left defines the start value
  3773. * @param right defines the end value
  3774. * @param amount defines the gradient factor
  3775. * @param result defines the Color3 object where to store the result
  3776. */
  3777. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  3778. /**
  3779. * Returns a Color3 value containing a red color
  3780. * @returns a new Color3 object
  3781. */
  3782. static Red(): Color3;
  3783. /**
  3784. * Returns a Color3 value containing a green color
  3785. * @returns a new Color3 object
  3786. */
  3787. static Green(): Color3;
  3788. /**
  3789. * Returns a Color3 value containing a blue color
  3790. * @returns a new Color3 object
  3791. */
  3792. static Blue(): Color3;
  3793. /**
  3794. * Returns a Color3 value containing a black color
  3795. * @returns a new Color3 object
  3796. */
  3797. static Black(): Color3;
  3798. /**
  3799. * Gets a Color3 value containing a black color that must not be updated
  3800. */
  3801. static readonly BlackReadOnly: DeepImmutable<Color3>;
  3802. /**
  3803. * Returns a Color3 value containing a white color
  3804. * @returns a new Color3 object
  3805. */
  3806. static White(): Color3;
  3807. /**
  3808. * Returns a Color3 value containing a purple color
  3809. * @returns a new Color3 object
  3810. */
  3811. static Purple(): Color3;
  3812. /**
  3813. * Returns a Color3 value containing a magenta color
  3814. * @returns a new Color3 object
  3815. */
  3816. static Magenta(): Color3;
  3817. /**
  3818. * Returns a Color3 value containing a yellow color
  3819. * @returns a new Color3 object
  3820. */
  3821. static Yellow(): Color3;
  3822. /**
  3823. * Returns a Color3 value containing a gray color
  3824. * @returns a new Color3 object
  3825. */
  3826. static Gray(): Color3;
  3827. /**
  3828. * Returns a Color3 value containing a teal color
  3829. * @returns a new Color3 object
  3830. */
  3831. static Teal(): Color3;
  3832. /**
  3833. * Returns a Color3 value containing a random color
  3834. * @returns a new Color3 object
  3835. */
  3836. static Random(): Color3;
  3837. }
  3838. /**
  3839. * Class used to hold a RBGA color
  3840. */
  3841. export class Color4 {
  3842. /**
  3843. * Defines the red component (between 0 and 1, default is 0)
  3844. */
  3845. r: number;
  3846. /**
  3847. * Defines the green component (between 0 and 1, default is 0)
  3848. */
  3849. g: number;
  3850. /**
  3851. * Defines the blue component (between 0 and 1, default is 0)
  3852. */
  3853. b: number;
  3854. /**
  3855. * Defines the alpha component (between 0 and 1, default is 1)
  3856. */
  3857. a: number;
  3858. /**
  3859. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  3860. * @param r defines the red component (between 0 and 1, default is 0)
  3861. * @param g defines the green component (between 0 and 1, default is 0)
  3862. * @param b defines the blue component (between 0 and 1, default is 0)
  3863. * @param a defines the alpha component (between 0 and 1, default is 1)
  3864. */
  3865. constructor(
  3866. /**
  3867. * Defines the red component (between 0 and 1, default is 0)
  3868. */
  3869. r?: number,
  3870. /**
  3871. * Defines the green component (between 0 and 1, default is 0)
  3872. */
  3873. g?: number,
  3874. /**
  3875. * Defines the blue component (between 0 and 1, default is 0)
  3876. */
  3877. b?: number,
  3878. /**
  3879. * Defines the alpha component (between 0 and 1, default is 1)
  3880. */
  3881. a?: number);
  3882. /**
  3883. * Adds in place the given Color4 values to the current Color4 object
  3884. * @param right defines the second operand
  3885. * @returns the current updated Color4 object
  3886. */
  3887. addInPlace(right: DeepImmutable<Color4>): Color4;
  3888. /**
  3889. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  3890. * @returns the new array
  3891. */
  3892. asArray(): number[];
  3893. /**
  3894. * Stores from the starting index in the given array the Color4 successive values
  3895. * @param array defines the array where to store the r,g,b components
  3896. * @param index defines an optional index in the target array to define where to start storing values
  3897. * @returns the current Color4 object
  3898. */
  3899. toArray(array: number[], index?: number): Color4;
  3900. /**
  3901. * Determines equality between Color4 objects
  3902. * @param otherColor defines the second operand
  3903. * @returns true if the rgba values are equal to the given ones
  3904. */
  3905. equals(otherColor: DeepImmutable<Color4>): boolean;
  3906. /**
  3907. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  3908. * @param right defines the second operand
  3909. * @returns a new Color4 object
  3910. */
  3911. add(right: DeepImmutable<Color4>): Color4;
  3912. /**
  3913. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  3914. * @param right defines the second operand
  3915. * @returns a new Color4 object
  3916. */
  3917. subtract(right: DeepImmutable<Color4>): Color4;
  3918. /**
  3919. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  3920. * @param right defines the second operand
  3921. * @param result defines the Color4 object where to store the result
  3922. * @returns the current Color4 object
  3923. */
  3924. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  3925. /**
  3926. * Creates a new Color4 with the current Color4 values multiplied by scale
  3927. * @param scale defines the scaling factor to apply
  3928. * @returns a new Color4 object
  3929. */
  3930. scale(scale: number): Color4;
  3931. /**
  3932. * Multiplies the current Color4 values by scale and stores the result in "result"
  3933. * @param scale defines the scaling factor to apply
  3934. * @param result defines the Color4 object where to store the result
  3935. * @returns the current unmodified Color4
  3936. */
  3937. scaleToRef(scale: number, result: Color4): Color4;
  3938. /**
  3939. * Scale the current Color4 values by a factor and add the result to a given Color4
  3940. * @param scale defines the scale factor
  3941. * @param result defines the Color4 object where to store the result
  3942. * @returns the unmodified current Color4
  3943. */
  3944. scaleAndAddToRef(scale: number, result: Color4): Color4;
  3945. /**
  3946. * Clamps the rgb values by the min and max values and stores the result into "result"
  3947. * @param min defines minimum clamping value (default is 0)
  3948. * @param max defines maximum clamping value (default is 1)
  3949. * @param result defines color to store the result into.
  3950. * @returns the cuurent Color4
  3951. */
  3952. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  3953. /**
  3954. * Multipy an Color4 value by another and return a new Color4 object
  3955. * @param color defines the Color4 value to multiply by
  3956. * @returns a new Color4 object
  3957. */
  3958. multiply(color: Color4): Color4;
  3959. /**
  3960. * Multipy a Color4 value by another and push the result in a reference value
  3961. * @param color defines the Color4 value to multiply by
  3962. * @param result defines the Color4 to fill the result in
  3963. * @returns the result Color4
  3964. */
  3965. multiplyToRef(color: Color4, result: Color4): Color4;
  3966. /**
  3967. * Creates a string with the Color4 current values
  3968. * @returns the string representation of the Color4 object
  3969. */
  3970. toString(): string;
  3971. /**
  3972. * Returns the string "Color4"
  3973. * @returns "Color4"
  3974. */
  3975. getClassName(): string;
  3976. /**
  3977. * Compute the Color4 hash code
  3978. * @returns an unique number that can be used to hash Color4 objects
  3979. */
  3980. getHashCode(): number;
  3981. /**
  3982. * Creates a new Color4 copied from the current one
  3983. * @returns a new Color4 object
  3984. */
  3985. clone(): Color4;
  3986. /**
  3987. * Copies the given Color4 values into the current one
  3988. * @param source defines the source Color4 object
  3989. * @returns the current updated Color4 object
  3990. */
  3991. copyFrom(source: Color4): Color4;
  3992. /**
  3993. * Copies the given float values into the current one
  3994. * @param r defines the red component to read from
  3995. * @param g defines the green component to read from
  3996. * @param b defines the blue component to read from
  3997. * @param a defines the alpha component to read from
  3998. * @returns the current updated Color4 object
  3999. */
  4000. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  4001. /**
  4002. * Copies the given float values into the current one
  4003. * @param r defines the red component to read from
  4004. * @param g defines the green component to read from
  4005. * @param b defines the blue component to read from
  4006. * @param a defines the alpha component to read from
  4007. * @returns the current updated Color4 object
  4008. */
  4009. set(r: number, g: number, b: number, a: number): Color4;
  4010. /**
  4011. * Compute the Color4 hexadecimal code as a string
  4012. * @returns a string containing the hexadecimal representation of the Color4 object
  4013. */
  4014. toHexString(): string;
  4015. /**
  4016. * Computes a new Color4 converted from the current one to linear space
  4017. * @returns a new Color4 object
  4018. */
  4019. toLinearSpace(): Color4;
  4020. /**
  4021. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  4022. * @param convertedColor defines the Color4 object where to store the linear space version
  4023. * @returns the unmodified Color4
  4024. */
  4025. toLinearSpaceToRef(convertedColor: Color4): Color4;
  4026. /**
  4027. * Computes a new Color4 converted from the current one to gamma space
  4028. * @returns a new Color4 object
  4029. */
  4030. toGammaSpace(): Color4;
  4031. /**
  4032. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  4033. * @param convertedColor defines the Color4 object where to store the gamma space version
  4034. * @returns the unmodified Color4
  4035. */
  4036. toGammaSpaceToRef(convertedColor: Color4): Color4;
  4037. /**
  4038. * Creates a new Color4 from the string containing valid hexadecimal values
  4039. * @param hex defines a string containing valid hexadecimal values
  4040. * @returns a new Color4 object
  4041. */
  4042. static FromHexString(hex: string): Color4;
  4043. /**
  4044. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  4045. * @param left defines the start value
  4046. * @param right defines the end value
  4047. * @param amount defines the gradient factor
  4048. * @returns a new Color4 object
  4049. */
  4050. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  4051. /**
  4052. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  4053. * @param left defines the start value
  4054. * @param right defines the end value
  4055. * @param amount defines the gradient factor
  4056. * @param result defines the Color4 object where to store data
  4057. */
  4058. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  4059. /**
  4060. * Creates a new Color4 from a Color3 and an alpha value
  4061. * @param color3 defines the source Color3 to read from
  4062. * @param alpha defines the alpha component (1.0 by default)
  4063. * @returns a new Color4 object
  4064. */
  4065. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  4066. /**
  4067. * Creates a new Color4 from the starting index element of the given array
  4068. * @param array defines the source array to read from
  4069. * @param offset defines the offset in the source array
  4070. * @returns a new Color4 object
  4071. */
  4072. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  4073. /**
  4074. * Creates a new Color3 from integer values (< 256)
  4075. * @param r defines the red component to read from (value between 0 and 255)
  4076. * @param g defines the green component to read from (value between 0 and 255)
  4077. * @param b defines the blue component to read from (value between 0 and 255)
  4078. * @param a defines the alpha component to read from (value between 0 and 255)
  4079. * @returns a new Color3 object
  4080. */
  4081. static FromInts(r: number, g: number, b: number, a: number): Color4;
  4082. /**
  4083. * Check the content of a given array and convert it to an array containing RGBA data
  4084. * If the original array was already containing count * 4 values then it is returned directly
  4085. * @param colors defines the array to check
  4086. * @param count defines the number of RGBA data to expect
  4087. * @returns an array containing count * 4 values (RGBA)
  4088. */
  4089. static CheckColors4(colors: number[], count: number): number[];
  4090. }
  4091. /**
  4092. * @hidden
  4093. */
  4094. export class TmpColors {
  4095. static Color3: Color3[];
  4096. static Color4: Color4[];
  4097. }
  4098. }
  4099. declare module "babylonjs/Maths/sphericalPolynomial" {
  4100. import { Vector3 } from "babylonjs/Maths/math.vector";
  4101. import { Color3 } from "babylonjs/Maths/math.color";
  4102. /**
  4103. * Class representing spherical harmonics coefficients to the 3rd degree
  4104. */
  4105. export class SphericalHarmonics {
  4106. /**
  4107. * Defines whether or not the harmonics have been prescaled for rendering.
  4108. */
  4109. preScaled: boolean;
  4110. /**
  4111. * The l0,0 coefficients of the spherical harmonics
  4112. */
  4113. l00: Vector3;
  4114. /**
  4115. * The l1,-1 coefficients of the spherical harmonics
  4116. */
  4117. l1_1: Vector3;
  4118. /**
  4119. * The l1,0 coefficients of the spherical harmonics
  4120. */
  4121. l10: Vector3;
  4122. /**
  4123. * The l1,1 coefficients of the spherical harmonics
  4124. */
  4125. l11: Vector3;
  4126. /**
  4127. * The l2,-2 coefficients of the spherical harmonics
  4128. */
  4129. l2_2: Vector3;
  4130. /**
  4131. * The l2,-1 coefficients of the spherical harmonics
  4132. */
  4133. l2_1: Vector3;
  4134. /**
  4135. * The l2,0 coefficients of the spherical harmonics
  4136. */
  4137. l20: Vector3;
  4138. /**
  4139. * The l2,1 coefficients of the spherical harmonics
  4140. */
  4141. l21: Vector3;
  4142. /**
  4143. * The l2,2 coefficients of the spherical harmonics
  4144. */
  4145. l22: Vector3;
  4146. /**
  4147. * Adds a light to the spherical harmonics
  4148. * @param direction the direction of the light
  4149. * @param color the color of the light
  4150. * @param deltaSolidAngle the delta solid angle of the light
  4151. */
  4152. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  4153. /**
  4154. * Scales the spherical harmonics by the given amount
  4155. * @param scale the amount to scale
  4156. */
  4157. scaleInPlace(scale: number): void;
  4158. /**
  4159. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  4160. *
  4161. * ```
  4162. * E_lm = A_l * L_lm
  4163. * ```
  4164. *
  4165. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  4166. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  4167. * the scaling factors are given in equation 9.
  4168. */
  4169. convertIncidentRadianceToIrradiance(): void;
  4170. /**
  4171. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  4172. *
  4173. * ```
  4174. * L = (1/pi) * E * rho
  4175. * ```
  4176. *
  4177. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  4178. */
  4179. convertIrradianceToLambertianRadiance(): void;
  4180. /**
  4181. * Integrates the reconstruction coefficients directly in to the SH preventing further
  4182. * required operations at run time.
  4183. *
  4184. * This is simply done by scaling back the SH with Ylm constants parameter.
  4185. * The trigonometric part being applied by the shader at run time.
  4186. */
  4187. preScaleForRendering(): void;
  4188. /**
  4189. * Constructs a spherical harmonics from an array.
  4190. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  4191. * @returns the spherical harmonics
  4192. */
  4193. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  4194. /**
  4195. * Gets the spherical harmonics from polynomial
  4196. * @param polynomial the spherical polynomial
  4197. * @returns the spherical harmonics
  4198. */
  4199. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  4200. }
  4201. /**
  4202. * Class representing spherical polynomial coefficients to the 3rd degree
  4203. */
  4204. export class SphericalPolynomial {
  4205. private _harmonics;
  4206. /**
  4207. * The spherical harmonics used to create the polynomials.
  4208. */
  4209. readonly preScaledHarmonics: SphericalHarmonics;
  4210. /**
  4211. * The x coefficients of the spherical polynomial
  4212. */
  4213. x: Vector3;
  4214. /**
  4215. * The y coefficients of the spherical polynomial
  4216. */
  4217. y: Vector3;
  4218. /**
  4219. * The z coefficients of the spherical polynomial
  4220. */
  4221. z: Vector3;
  4222. /**
  4223. * The xx coefficients of the spherical polynomial
  4224. */
  4225. xx: Vector3;
  4226. /**
  4227. * The yy coefficients of the spherical polynomial
  4228. */
  4229. yy: Vector3;
  4230. /**
  4231. * The zz coefficients of the spherical polynomial
  4232. */
  4233. zz: Vector3;
  4234. /**
  4235. * The xy coefficients of the spherical polynomial
  4236. */
  4237. xy: Vector3;
  4238. /**
  4239. * The yz coefficients of the spherical polynomial
  4240. */
  4241. yz: Vector3;
  4242. /**
  4243. * The zx coefficients of the spherical polynomial
  4244. */
  4245. zx: Vector3;
  4246. /**
  4247. * Adds an ambient color to the spherical polynomial
  4248. * @param color the color to add
  4249. */
  4250. addAmbient(color: Color3): void;
  4251. /**
  4252. * Scales the spherical polynomial by the given amount
  4253. * @param scale the amount to scale
  4254. */
  4255. scaleInPlace(scale: number): void;
  4256. /**
  4257. * Gets the spherical polynomial from harmonics
  4258. * @param harmonics the spherical harmonics
  4259. * @returns the spherical polynomial
  4260. */
  4261. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  4262. /**
  4263. * Constructs a spherical polynomial from an array.
  4264. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  4265. * @returns the spherical polynomial
  4266. */
  4267. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  4268. }
  4269. }
  4270. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  4271. /**
  4272. * Define options used to create a render target texture
  4273. */
  4274. export class RenderTargetCreationOptions {
  4275. /**
  4276. * Specifies is mipmaps must be generated
  4277. */
  4278. generateMipMaps?: boolean;
  4279. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  4280. generateDepthBuffer?: boolean;
  4281. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  4282. generateStencilBuffer?: boolean;
  4283. /** Defines texture type (int by default) */
  4284. type?: number;
  4285. /** Defines sampling mode (trilinear by default) */
  4286. samplingMode?: number;
  4287. /** Defines format (RGBA by default) */
  4288. format?: number;
  4289. }
  4290. }
  4291. declare module "babylonjs/Instrumentation/timeToken" {
  4292. import { Nullable } from "babylonjs/types";
  4293. /**
  4294. * @hidden
  4295. **/
  4296. export class _TimeToken {
  4297. _startTimeQuery: Nullable<WebGLQuery>;
  4298. _endTimeQuery: Nullable<WebGLQuery>;
  4299. _timeElapsedQuery: Nullable<WebGLQuery>;
  4300. _timeElapsedQueryEnded: boolean;
  4301. }
  4302. }
  4303. declare module "babylonjs/Engines/constants" {
  4304. /** Defines the cross module used constants to avoid circular dependncies */
  4305. export class Constants {
  4306. /** Defines that alpha blending is disabled */
  4307. static readonly ALPHA_DISABLE: number;
  4308. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4309. static readonly ALPHA_ADD: number;
  4310. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4311. static readonly ALPHA_COMBINE: number;
  4312. /** Defines that alpha blending to DEST - SRC * DEST */
  4313. static readonly ALPHA_SUBTRACT: number;
  4314. /** Defines that alpha blending to SRC * DEST */
  4315. static readonly ALPHA_MULTIPLY: number;
  4316. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4317. static readonly ALPHA_MAXIMIZED: number;
  4318. /** Defines that alpha blending to SRC + DEST */
  4319. static readonly ALPHA_ONEONE: number;
  4320. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4321. static readonly ALPHA_PREMULTIPLIED: number;
  4322. /**
  4323. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4324. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4325. */
  4326. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4327. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4328. static readonly ALPHA_INTERPOLATE: number;
  4329. /**
  4330. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4331. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4332. */
  4333. static readonly ALPHA_SCREENMODE: number;
  4334. /**
  4335. * Defines that alpha blending to SRC + DST
  4336. * Alpha will be set to SRC ALPHA + DST ALPHA
  4337. */
  4338. static readonly ALPHA_ONEONE_ONEONE: number;
  4339. /**
  4340. * Defines that alpha blending to SRC * DST ALPHA + DST
  4341. * Alpha will be set to 0
  4342. */
  4343. static readonly ALPHA_ALPHATOCOLOR: number;
  4344. /**
  4345. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  4346. */
  4347. static readonly ALPHA_REVERSEONEMINUS: number;
  4348. /**
  4349. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  4350. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  4351. */
  4352. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  4353. /**
  4354. * Defines that alpha blending to SRC + DST
  4355. * Alpha will be set to SRC ALPHA
  4356. */
  4357. static readonly ALPHA_ONEONE_ONEZERO: number;
  4358. /** Defines that alpha blending equation a SUM */
  4359. static readonly ALPHA_EQUATION_ADD: number;
  4360. /** Defines that alpha blending equation a SUBSTRACTION */
  4361. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  4362. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  4363. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  4364. /** Defines that alpha blending equation a MAX operation */
  4365. static readonly ALPHA_EQUATION_MAX: number;
  4366. /** Defines that alpha blending equation a MIN operation */
  4367. static readonly ALPHA_EQUATION_MIN: number;
  4368. /**
  4369. * Defines that alpha blending equation a DARKEN operation:
  4370. * It takes the min of the src and sums the alpha channels.
  4371. */
  4372. static readonly ALPHA_EQUATION_DARKEN: number;
  4373. /** Defines that the ressource is not delayed*/
  4374. static readonly DELAYLOADSTATE_NONE: number;
  4375. /** Defines that the ressource was successfully delay loaded */
  4376. static readonly DELAYLOADSTATE_LOADED: number;
  4377. /** Defines that the ressource is currently delay loading */
  4378. static readonly DELAYLOADSTATE_LOADING: number;
  4379. /** Defines that the ressource is delayed and has not started loading */
  4380. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4381. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4382. static readonly NEVER: number;
  4383. /** 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 */
  4384. static readonly ALWAYS: number;
  4385. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4386. static readonly LESS: number;
  4387. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4388. static readonly EQUAL: number;
  4389. /** 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 */
  4390. static readonly LEQUAL: number;
  4391. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4392. static readonly GREATER: number;
  4393. /** 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 */
  4394. static readonly GEQUAL: number;
  4395. /** 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 */
  4396. static readonly NOTEQUAL: number;
  4397. /** Passed to stencilOperation to specify that stencil value must be kept */
  4398. static readonly KEEP: number;
  4399. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4400. static readonly REPLACE: number;
  4401. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4402. static readonly INCR: number;
  4403. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4404. static readonly DECR: number;
  4405. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4406. static readonly INVERT: number;
  4407. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4408. static readonly INCR_WRAP: number;
  4409. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4410. static readonly DECR_WRAP: number;
  4411. /** Texture is not repeating outside of 0..1 UVs */
  4412. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4413. /** Texture is repeating outside of 0..1 UVs */
  4414. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4415. /** Texture is repeating and mirrored */
  4416. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4417. /** ALPHA */
  4418. static readonly TEXTUREFORMAT_ALPHA: number;
  4419. /** LUMINANCE */
  4420. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4421. /** LUMINANCE_ALPHA */
  4422. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4423. /** RGB */
  4424. static readonly TEXTUREFORMAT_RGB: number;
  4425. /** RGBA */
  4426. static readonly TEXTUREFORMAT_RGBA: number;
  4427. /** RED */
  4428. static readonly TEXTUREFORMAT_RED: number;
  4429. /** RED (2nd reference) */
  4430. static readonly TEXTUREFORMAT_R: number;
  4431. /** RG */
  4432. static readonly TEXTUREFORMAT_RG: number;
  4433. /** RED_INTEGER */
  4434. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4435. /** RED_INTEGER (2nd reference) */
  4436. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4437. /** RG_INTEGER */
  4438. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4439. /** RGB_INTEGER */
  4440. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4441. /** RGBA_INTEGER */
  4442. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4443. /** UNSIGNED_BYTE */
  4444. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4445. /** UNSIGNED_BYTE (2nd reference) */
  4446. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4447. /** FLOAT */
  4448. static readonly TEXTURETYPE_FLOAT: number;
  4449. /** HALF_FLOAT */
  4450. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4451. /** BYTE */
  4452. static readonly TEXTURETYPE_BYTE: number;
  4453. /** SHORT */
  4454. static readonly TEXTURETYPE_SHORT: number;
  4455. /** UNSIGNED_SHORT */
  4456. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4457. /** INT */
  4458. static readonly TEXTURETYPE_INT: number;
  4459. /** UNSIGNED_INT */
  4460. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4461. /** UNSIGNED_SHORT_4_4_4_4 */
  4462. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4463. /** UNSIGNED_SHORT_5_5_5_1 */
  4464. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4465. /** UNSIGNED_SHORT_5_6_5 */
  4466. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4467. /** UNSIGNED_INT_2_10_10_10_REV */
  4468. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4469. /** UNSIGNED_INT_24_8 */
  4470. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4471. /** UNSIGNED_INT_10F_11F_11F_REV */
  4472. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4473. /** UNSIGNED_INT_5_9_9_9_REV */
  4474. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4475. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4476. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4477. /** nearest is mag = nearest and min = nearest and mip = linear */
  4478. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4479. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4480. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4481. /** Trilinear is mag = linear and min = linear and mip = linear */
  4482. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4483. /** nearest is mag = nearest and min = nearest and mip = linear */
  4484. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4485. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4486. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4487. /** Trilinear is mag = linear and min = linear and mip = linear */
  4488. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4489. /** mag = nearest and min = nearest and mip = nearest */
  4490. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4491. /** mag = nearest and min = linear and mip = nearest */
  4492. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4493. /** mag = nearest and min = linear and mip = linear */
  4494. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4495. /** mag = nearest and min = linear and mip = none */
  4496. static readonly TEXTURE_NEAREST_LINEAR: number;
  4497. /** mag = nearest and min = nearest and mip = none */
  4498. static readonly TEXTURE_NEAREST_NEAREST: number;
  4499. /** mag = linear and min = nearest and mip = nearest */
  4500. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4501. /** mag = linear and min = nearest and mip = linear */
  4502. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4503. /** mag = linear and min = linear and mip = none */
  4504. static readonly TEXTURE_LINEAR_LINEAR: number;
  4505. /** mag = linear and min = nearest and mip = none */
  4506. static readonly TEXTURE_LINEAR_NEAREST: number;
  4507. /** Explicit coordinates mode */
  4508. static readonly TEXTURE_EXPLICIT_MODE: number;
  4509. /** Spherical coordinates mode */
  4510. static readonly TEXTURE_SPHERICAL_MODE: number;
  4511. /** Planar coordinates mode */
  4512. static readonly TEXTURE_PLANAR_MODE: number;
  4513. /** Cubic coordinates mode */
  4514. static readonly TEXTURE_CUBIC_MODE: number;
  4515. /** Projection coordinates mode */
  4516. static readonly TEXTURE_PROJECTION_MODE: number;
  4517. /** Skybox coordinates mode */
  4518. static readonly TEXTURE_SKYBOX_MODE: number;
  4519. /** Inverse Cubic coordinates mode */
  4520. static readonly TEXTURE_INVCUBIC_MODE: number;
  4521. /** Equirectangular coordinates mode */
  4522. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4523. /** Equirectangular Fixed coordinates mode */
  4524. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4525. /** Equirectangular Fixed Mirrored coordinates mode */
  4526. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4527. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4528. static readonly SCALEMODE_FLOOR: number;
  4529. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4530. static readonly SCALEMODE_NEAREST: number;
  4531. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4532. static readonly SCALEMODE_CEILING: number;
  4533. /**
  4534. * The dirty texture flag value
  4535. */
  4536. static readonly MATERIAL_TextureDirtyFlag: number;
  4537. /**
  4538. * The dirty light flag value
  4539. */
  4540. static readonly MATERIAL_LightDirtyFlag: number;
  4541. /**
  4542. * The dirty fresnel flag value
  4543. */
  4544. static readonly MATERIAL_FresnelDirtyFlag: number;
  4545. /**
  4546. * The dirty attribute flag value
  4547. */
  4548. static readonly MATERIAL_AttributesDirtyFlag: number;
  4549. /**
  4550. * The dirty misc flag value
  4551. */
  4552. static readonly MATERIAL_MiscDirtyFlag: number;
  4553. /**
  4554. * The all dirty flag value
  4555. */
  4556. static readonly MATERIAL_AllDirtyFlag: number;
  4557. /**
  4558. * Returns the triangle fill mode
  4559. */
  4560. static readonly MATERIAL_TriangleFillMode: number;
  4561. /**
  4562. * Returns the wireframe mode
  4563. */
  4564. static readonly MATERIAL_WireFrameFillMode: number;
  4565. /**
  4566. * Returns the point fill mode
  4567. */
  4568. static readonly MATERIAL_PointFillMode: number;
  4569. /**
  4570. * Returns the point list draw mode
  4571. */
  4572. static readonly MATERIAL_PointListDrawMode: number;
  4573. /**
  4574. * Returns the line list draw mode
  4575. */
  4576. static readonly MATERIAL_LineListDrawMode: number;
  4577. /**
  4578. * Returns the line loop draw mode
  4579. */
  4580. static readonly MATERIAL_LineLoopDrawMode: number;
  4581. /**
  4582. * Returns the line strip draw mode
  4583. */
  4584. static readonly MATERIAL_LineStripDrawMode: number;
  4585. /**
  4586. * Returns the triangle strip draw mode
  4587. */
  4588. static readonly MATERIAL_TriangleStripDrawMode: number;
  4589. /**
  4590. * Returns the triangle fan draw mode
  4591. */
  4592. static readonly MATERIAL_TriangleFanDrawMode: number;
  4593. /**
  4594. * Stores the clock-wise side orientation
  4595. */
  4596. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4597. /**
  4598. * Stores the counter clock-wise side orientation
  4599. */
  4600. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4601. /**
  4602. * Nothing
  4603. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4604. */
  4605. static readonly ACTION_NothingTrigger: number;
  4606. /**
  4607. * On pick
  4608. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4609. */
  4610. static readonly ACTION_OnPickTrigger: number;
  4611. /**
  4612. * On left pick
  4613. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4614. */
  4615. static readonly ACTION_OnLeftPickTrigger: number;
  4616. /**
  4617. * On right pick
  4618. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4619. */
  4620. static readonly ACTION_OnRightPickTrigger: number;
  4621. /**
  4622. * On center pick
  4623. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4624. */
  4625. static readonly ACTION_OnCenterPickTrigger: number;
  4626. /**
  4627. * On pick down
  4628. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4629. */
  4630. static readonly ACTION_OnPickDownTrigger: number;
  4631. /**
  4632. * On double pick
  4633. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4634. */
  4635. static readonly ACTION_OnDoublePickTrigger: number;
  4636. /**
  4637. * On pick up
  4638. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4639. */
  4640. static readonly ACTION_OnPickUpTrigger: number;
  4641. /**
  4642. * On pick out.
  4643. * This trigger will only be raised if you also declared a OnPickDown
  4644. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4645. */
  4646. static readonly ACTION_OnPickOutTrigger: number;
  4647. /**
  4648. * On long press
  4649. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4650. */
  4651. static readonly ACTION_OnLongPressTrigger: number;
  4652. /**
  4653. * On pointer over
  4654. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4655. */
  4656. static readonly ACTION_OnPointerOverTrigger: number;
  4657. /**
  4658. * On pointer out
  4659. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4660. */
  4661. static readonly ACTION_OnPointerOutTrigger: number;
  4662. /**
  4663. * On every frame
  4664. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4665. */
  4666. static readonly ACTION_OnEveryFrameTrigger: number;
  4667. /**
  4668. * On intersection enter
  4669. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4670. */
  4671. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4672. /**
  4673. * On intersection exit
  4674. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4675. */
  4676. static readonly ACTION_OnIntersectionExitTrigger: number;
  4677. /**
  4678. * On key down
  4679. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4680. */
  4681. static readonly ACTION_OnKeyDownTrigger: number;
  4682. /**
  4683. * On key up
  4684. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4685. */
  4686. static readonly ACTION_OnKeyUpTrigger: number;
  4687. /**
  4688. * Billboard mode will only apply to Y axis
  4689. */
  4690. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4691. /**
  4692. * Billboard mode will apply to all axes
  4693. */
  4694. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4695. /**
  4696. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4697. */
  4698. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4699. /**
  4700. * Gets or sets base Assets URL
  4701. */
  4702. static PARTICLES_BaseAssetsUrl: string;
  4703. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4704. * Test order :
  4705. * Is the bounding sphere outside the frustum ?
  4706. * If not, are the bounding box vertices outside the frustum ?
  4707. * It not, then the cullable object is in the frustum.
  4708. */
  4709. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4710. /** Culling strategy : Bounding Sphere Only.
  4711. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4712. * It's also less accurate than the standard because some not visible objects can still be selected.
  4713. * Test : is the bounding sphere outside the frustum ?
  4714. * If not, then the cullable object is in the frustum.
  4715. */
  4716. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4717. /** Culling strategy : Optimistic Inclusion.
  4718. * This in an inclusion test first, then the standard exclusion test.
  4719. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4720. * 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.
  4721. * Anyway, it's as accurate as the standard strategy.
  4722. * Test :
  4723. * Is the cullable object bounding sphere center in the frustum ?
  4724. * If not, apply the default culling strategy.
  4725. */
  4726. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4727. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4728. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4729. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4730. * 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.
  4731. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4732. * Test :
  4733. * Is the cullable object bounding sphere center in the frustum ?
  4734. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4735. */
  4736. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4737. /**
  4738. * No logging while loading
  4739. */
  4740. static readonly SCENELOADER_NO_LOGGING: number;
  4741. /**
  4742. * Minimal logging while loading
  4743. */
  4744. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4745. /**
  4746. * Summary logging while loading
  4747. */
  4748. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4749. /**
  4750. * Detailled logging while loading
  4751. */
  4752. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4753. }
  4754. }
  4755. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  4756. import { Nullable } from "babylonjs/types";
  4757. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  4758. /**
  4759. * This represents the required contract to create a new type of texture loader.
  4760. */
  4761. export interface IInternalTextureLoader {
  4762. /**
  4763. * Defines wether the loader supports cascade loading the different faces.
  4764. */
  4765. supportCascades: boolean;
  4766. /**
  4767. * This returns if the loader support the current file information.
  4768. * @param extension defines the file extension of the file being loaded
  4769. * @param textureFormatInUse defines the current compressed format in use iun the engine
  4770. * @param fallback defines the fallback internal texture if any
  4771. * @param isBase64 defines whether the texture is encoded as a base64
  4772. * @param isBuffer defines whether the texture data are stored as a buffer
  4773. * @returns true if the loader can load the specified file
  4774. */
  4775. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  4776. /**
  4777. * Transform the url before loading if required.
  4778. * @param rootUrl the url of the texture
  4779. * @param textureFormatInUse defines the current compressed format in use iun the engine
  4780. * @returns the transformed texture
  4781. */
  4782. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  4783. /**
  4784. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  4785. * @param rootUrl the url of the texture
  4786. * @param textureFormatInUse defines the current compressed format in use iun the engine
  4787. * @returns the fallback texture
  4788. */
  4789. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  4790. /**
  4791. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  4792. * @param data contains the texture data
  4793. * @param texture defines the BabylonJS internal texture
  4794. * @param createPolynomials will be true if polynomials have been requested
  4795. * @param onLoad defines the callback to trigger once the texture is ready
  4796. * @param onError defines the callback to trigger in case of error
  4797. */
  4798. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  4799. /**
  4800. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  4801. * @param data contains the texture data
  4802. * @param texture defines the BabylonJS internal texture
  4803. * @param callback defines the method to call once ready to upload
  4804. */
  4805. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  4806. }
  4807. }
  4808. declare module "babylonjs/Engines/IPipelineContext" {
  4809. /**
  4810. * Class used to store and describe the pipeline context associated with an effect
  4811. */
  4812. export interface IPipelineContext {
  4813. /**
  4814. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  4815. */
  4816. isAsync: boolean;
  4817. /**
  4818. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  4819. */
  4820. isReady: boolean;
  4821. /** @hidden */
  4822. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  4823. }
  4824. }
  4825. declare module "babylonjs/Meshes/dataBuffer" {
  4826. /**
  4827. * Class used to store gfx data (like WebGLBuffer)
  4828. */
  4829. export class DataBuffer {
  4830. /**
  4831. * Gets or sets the number of objects referencing this buffer
  4832. */
  4833. references: number;
  4834. /** Gets or sets the size of the underlying buffer */
  4835. capacity: number;
  4836. /**
  4837. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  4838. */
  4839. is32Bits: boolean;
  4840. /**
  4841. * Gets the underlying buffer
  4842. */
  4843. readonly underlyingResource: any;
  4844. }
  4845. }
  4846. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  4847. /** @hidden */
  4848. export interface IShaderProcessor {
  4849. attributeProcessor?: (attribute: string) => string;
  4850. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  4851. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  4852. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  4853. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  4854. lineProcessor?: (line: string, isFragment: boolean) => string;
  4855. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4856. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4857. }
  4858. }
  4859. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  4860. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  4861. /** @hidden */
  4862. export interface ProcessingOptions {
  4863. defines: string[];
  4864. indexParameters: any;
  4865. isFragment: boolean;
  4866. shouldUseHighPrecisionShader: boolean;
  4867. supportsUniformBuffers: boolean;
  4868. shadersRepository: string;
  4869. includesShadersStore: {
  4870. [key: string]: string;
  4871. };
  4872. processor?: IShaderProcessor;
  4873. version: string;
  4874. platformName: string;
  4875. lookForClosingBracketForUniformBuffer?: boolean;
  4876. }
  4877. }
  4878. declare module "babylonjs/Misc/stringTools" {
  4879. /**
  4880. * Helper to manipulate strings
  4881. */
  4882. export class StringTools {
  4883. /**
  4884. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  4885. * @param str Source string
  4886. * @param suffix Suffix to search for in the source string
  4887. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4888. */
  4889. static EndsWith(str: string, suffix: string): boolean;
  4890. /**
  4891. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  4892. * @param str Source string
  4893. * @param suffix Suffix to search for in the source string
  4894. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4895. */
  4896. static StartsWith(str: string, suffix: string): boolean;
  4897. }
  4898. }
  4899. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  4900. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4901. /** @hidden */
  4902. export class ShaderCodeNode {
  4903. line: string;
  4904. children: ShaderCodeNode[];
  4905. additionalDefineKey?: string;
  4906. additionalDefineValue?: string;
  4907. isValid(preprocessors: {
  4908. [key: string]: string;
  4909. }): boolean;
  4910. process(preprocessors: {
  4911. [key: string]: string;
  4912. }, options: ProcessingOptions): string;
  4913. }
  4914. }
  4915. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  4916. /** @hidden */
  4917. export class ShaderCodeCursor {
  4918. private _lines;
  4919. lineIndex: number;
  4920. readonly currentLine: string;
  4921. readonly canRead: boolean;
  4922. lines: string[];
  4923. }
  4924. }
  4925. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  4926. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  4927. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4928. /** @hidden */
  4929. export class ShaderCodeConditionNode extends ShaderCodeNode {
  4930. process(preprocessors: {
  4931. [key: string]: string;
  4932. }, options: ProcessingOptions): string;
  4933. }
  4934. }
  4935. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  4936. /** @hidden */
  4937. export class ShaderDefineExpression {
  4938. isTrue(preprocessors: {
  4939. [key: string]: string;
  4940. }): boolean;
  4941. }
  4942. }
  4943. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  4944. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  4945. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4946. /** @hidden */
  4947. export class ShaderCodeTestNode extends ShaderCodeNode {
  4948. testExpression: ShaderDefineExpression;
  4949. isValid(preprocessors: {
  4950. [key: string]: string;
  4951. }): boolean;
  4952. }
  4953. }
  4954. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  4955. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4956. /** @hidden */
  4957. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  4958. define: string;
  4959. not: boolean;
  4960. constructor(define: string, not?: boolean);
  4961. isTrue(preprocessors: {
  4962. [key: string]: string;
  4963. }): boolean;
  4964. }
  4965. }
  4966. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  4967. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4968. /** @hidden */
  4969. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  4970. leftOperand: ShaderDefineExpression;
  4971. rightOperand: ShaderDefineExpression;
  4972. isTrue(preprocessors: {
  4973. [key: string]: string;
  4974. }): boolean;
  4975. }
  4976. }
  4977. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  4978. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4979. /** @hidden */
  4980. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  4981. leftOperand: ShaderDefineExpression;
  4982. rightOperand: ShaderDefineExpression;
  4983. isTrue(preprocessors: {
  4984. [key: string]: string;
  4985. }): boolean;
  4986. }
  4987. }
  4988. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  4989. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4990. /** @hidden */
  4991. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  4992. define: string;
  4993. operand: string;
  4994. testValue: string;
  4995. constructor(define: string, operand: string, testValue: string);
  4996. isTrue(preprocessors: {
  4997. [key: string]: string;
  4998. }): boolean;
  4999. }
  5000. }
  5001. declare module "babylonjs/Misc/loadFileError" {
  5002. import { WebRequest } from "babylonjs/Misc/webRequest";
  5003. /**
  5004. * @ignore
  5005. * Application error to support additional information when loading a file
  5006. */
  5007. export class LoadFileError extends Error {
  5008. /** defines the optional web request */
  5009. request?: WebRequest | undefined;
  5010. private static _setPrototypeOf;
  5011. /**
  5012. * Creates a new LoadFileError
  5013. * @param message defines the message of the error
  5014. * @param request defines the optional web request
  5015. */
  5016. constructor(message: string,
  5017. /** defines the optional web request */
  5018. request?: WebRequest | undefined);
  5019. }
  5020. }
  5021. declare module "babylonjs/Offline/IOfflineProvider" {
  5022. /**
  5023. * Class used to enable access to offline support
  5024. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  5025. */
  5026. export interface IOfflineProvider {
  5027. /**
  5028. * Gets a boolean indicating if scene must be saved in the database
  5029. */
  5030. enableSceneOffline: boolean;
  5031. /**
  5032. * Gets a boolean indicating if textures must be saved in the database
  5033. */
  5034. enableTexturesOffline: boolean;
  5035. /**
  5036. * Open the offline support and make it available
  5037. * @param successCallback defines the callback to call on success
  5038. * @param errorCallback defines the callback to call on error
  5039. */
  5040. open(successCallback: () => void, errorCallback: () => void): void;
  5041. /**
  5042. * Loads an image from the offline support
  5043. * @param url defines the url to load from
  5044. * @param image defines the target DOM image
  5045. */
  5046. loadImage(url: string, image: HTMLImageElement): void;
  5047. /**
  5048. * Loads a file from offline support
  5049. * @param url defines the URL to load from
  5050. * @param sceneLoaded defines a callback to call on success
  5051. * @param progressCallBack defines a callback to call when progress changed
  5052. * @param errorCallback defines a callback to call on error
  5053. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  5054. */
  5055. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  5056. }
  5057. }
  5058. declare module "babylonjs/Misc/filesInputStore" {
  5059. /**
  5060. * Class used to help managing file picking and drag'n'drop
  5061. * File Storage
  5062. */
  5063. export class FilesInputStore {
  5064. /**
  5065. * List of files ready to be loaded
  5066. */
  5067. static FilesToLoad: {
  5068. [key: string]: File;
  5069. };
  5070. }
  5071. }
  5072. declare module "babylonjs/Misc/retryStrategy" {
  5073. import { WebRequest } from "babylonjs/Misc/webRequest";
  5074. /**
  5075. * Class used to define a retry strategy when error happens while loading assets
  5076. */
  5077. export class RetryStrategy {
  5078. /**
  5079. * Function used to defines an exponential back off strategy
  5080. * @param maxRetries defines the maximum number of retries (3 by default)
  5081. * @param baseInterval defines the interval between retries
  5082. * @returns the strategy function to use
  5083. */
  5084. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  5085. }
  5086. }
  5087. declare module "babylonjs/Misc/fileTools" {
  5088. import { WebRequest } from "babylonjs/Misc/webRequest";
  5089. import { Nullable } from "babylonjs/types";
  5090. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  5091. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  5092. /**
  5093. * @hidden
  5094. */
  5095. export class FileTools {
  5096. /**
  5097. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  5098. */
  5099. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  5100. /**
  5101. * Gets or sets the base URL to use to load assets
  5102. */
  5103. static BaseUrl: string;
  5104. /**
  5105. * Default behaviour for cors in the application.
  5106. * It can be a string if the expected behavior is identical in the entire app.
  5107. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  5108. */
  5109. static CorsBehavior: string | ((url: string | string[]) => string);
  5110. /**
  5111. * Gets or sets a function used to pre-process url before using them to load assets
  5112. */
  5113. static PreprocessUrl: (url: string) => string;
  5114. /**
  5115. * Removes unwanted characters from an url
  5116. * @param url defines the url to clean
  5117. * @returns the cleaned url
  5118. */
  5119. private static _CleanUrl;
  5120. /**
  5121. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  5122. * @param url define the url we are trying
  5123. * @param element define the dom element where to configure the cors policy
  5124. */
  5125. static SetCorsBehavior(url: string | string[], element: {
  5126. crossOrigin: string | null;
  5127. }): void;
  5128. /**
  5129. * Loads an image as an HTMLImageElement.
  5130. * @param input url string, ArrayBuffer, or Blob to load
  5131. * @param onLoad callback called when the image successfully loads
  5132. * @param onError callback called when the image fails to load
  5133. * @param offlineProvider offline provider for caching
  5134. * @returns the HTMLImageElement of the loaded image
  5135. */
  5136. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  5137. /**
  5138. * Loads a file
  5139. * @param fileToLoad defines the file to load
  5140. * @param callback defines the callback to call when data is loaded
  5141. * @param progressCallBack defines the callback to call during loading process
  5142. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  5143. * @returns a file request object
  5144. */
  5145. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  5146. /**
  5147. * Loads a file
  5148. * @param url url string, ArrayBuffer, or Blob to load
  5149. * @param onSuccess callback called when the file successfully loads
  5150. * @param onProgress callback called while file is loading (if the server supports this mode)
  5151. * @param offlineProvider defines the offline provider for caching
  5152. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  5153. * @param onError callback called when the file fails to load
  5154. * @returns a file request object
  5155. */
  5156. 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;
  5157. /**
  5158. * Checks if the loaded document was accessed via `file:`-Protocol.
  5159. * @returns boolean
  5160. */
  5161. static IsFileURL(): boolean;
  5162. }
  5163. }
  5164. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  5165. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  5166. /** @hidden */
  5167. export class ShaderProcessor {
  5168. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  5169. private static _ProcessPrecision;
  5170. private static _ExtractOperation;
  5171. private static _BuildSubExpression;
  5172. private static _BuildExpression;
  5173. private static _MoveCursorWithinIf;
  5174. private static _MoveCursor;
  5175. private static _EvaluatePreProcessors;
  5176. private static _PreparePreProcessors;
  5177. private static _ProcessShaderConversion;
  5178. private static _ProcessIncludes;
  5179. }
  5180. }
  5181. declare module "babylonjs/Materials/iEffectFallbacks" {
  5182. import { Effect } from "babylonjs/Materials/effect";
  5183. /**
  5184. * Interface used to define common properties for effect fallbacks
  5185. */
  5186. export interface IEffectFallbacks {
  5187. /**
  5188. * Removes the defines that should be removed when falling back.
  5189. * @param currentDefines defines the current define statements for the shader.
  5190. * @param effect defines the current effect we try to compile
  5191. * @returns The resulting defines with defines of the current rank removed.
  5192. */
  5193. reduce(currentDefines: string, effect: Effect): string;
  5194. /**
  5195. * Removes the fallback from the bound mesh.
  5196. */
  5197. unBindMesh(): void;
  5198. /**
  5199. * Checks to see if more fallbacks are still availible.
  5200. */
  5201. hasMoreFallbacks: boolean;
  5202. }
  5203. }
  5204. declare module "babylonjs/Misc/andOrNotEvaluator" {
  5205. /**
  5206. * Class used to evalaute queries containing `and` and `or` operators
  5207. */
  5208. export class AndOrNotEvaluator {
  5209. /**
  5210. * Evaluate a query
  5211. * @param query defines the query to evaluate
  5212. * @param evaluateCallback defines the callback used to filter result
  5213. * @returns true if the query matches
  5214. */
  5215. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5216. private static _HandleParenthesisContent;
  5217. private static _SimplifyNegation;
  5218. }
  5219. }
  5220. declare module "babylonjs/Misc/tags" {
  5221. /**
  5222. * Class used to store custom tags
  5223. */
  5224. export class Tags {
  5225. /**
  5226. * Adds support for tags on the given object
  5227. * @param obj defines the object to use
  5228. */
  5229. static EnableFor(obj: any): void;
  5230. /**
  5231. * Removes tags support
  5232. * @param obj defines the object to use
  5233. */
  5234. static DisableFor(obj: any): void;
  5235. /**
  5236. * Gets a boolean indicating if the given object has tags
  5237. * @param obj defines the object to use
  5238. * @returns a boolean
  5239. */
  5240. static HasTags(obj: any): boolean;
  5241. /**
  5242. * Gets the tags available on a given object
  5243. * @param obj defines the object to use
  5244. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5245. * @returns the tags
  5246. */
  5247. static GetTags(obj: any, asString?: boolean): any;
  5248. /**
  5249. * Adds tags to an object
  5250. * @param obj defines the object to use
  5251. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5252. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5253. */
  5254. static AddTagsTo(obj: any, tagsString: string): void;
  5255. /**
  5256. * @hidden
  5257. */
  5258. static _AddTagTo(obj: any, tag: string): void;
  5259. /**
  5260. * Removes specific tags from a specific object
  5261. * @param obj defines the object to use
  5262. * @param tagsString defines the tags to remove
  5263. */
  5264. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5265. /**
  5266. * @hidden
  5267. */
  5268. static _RemoveTagFrom(obj: any, tag: string): void;
  5269. /**
  5270. * Defines if tags hosted on an object match a given query
  5271. * @param obj defines the object to use
  5272. * @param tagsQuery defines the tag query
  5273. * @returns a boolean
  5274. */
  5275. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5276. }
  5277. }
  5278. declare module "babylonjs/Maths/math.path" {
  5279. import { DeepImmutable, Nullable } from "babylonjs/types";
  5280. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  5281. /**
  5282. * Defines potential orientation for back face culling
  5283. */
  5284. export enum Orientation {
  5285. /**
  5286. * Clockwise
  5287. */
  5288. CW = 0,
  5289. /** Counter clockwise */
  5290. CCW = 1
  5291. }
  5292. /** Class used to represent a Bezier curve */
  5293. export class BezierCurve {
  5294. /**
  5295. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5296. * @param t defines the time
  5297. * @param x1 defines the left coordinate on X axis
  5298. * @param y1 defines the left coordinate on Y axis
  5299. * @param x2 defines the right coordinate on X axis
  5300. * @param y2 defines the right coordinate on Y axis
  5301. * @returns the interpolated value
  5302. */
  5303. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5304. }
  5305. /**
  5306. * Defines angle representation
  5307. */
  5308. export class Angle {
  5309. private _radians;
  5310. /**
  5311. * Creates an Angle object of "radians" radians (float).
  5312. * @param radians the angle in radians
  5313. */
  5314. constructor(radians: number);
  5315. /**
  5316. * Get value in degrees
  5317. * @returns the Angle value in degrees (float)
  5318. */
  5319. degrees(): number;
  5320. /**
  5321. * Get value in radians
  5322. * @returns the Angle value in radians (float)
  5323. */
  5324. radians(): number;
  5325. /**
  5326. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  5327. * @param a defines first vector
  5328. * @param b defines second vector
  5329. * @returns a new Angle
  5330. */
  5331. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5332. /**
  5333. * Gets a new Angle object from the given float in radians
  5334. * @param radians defines the angle value in radians
  5335. * @returns a new Angle
  5336. */
  5337. static FromRadians(radians: number): Angle;
  5338. /**
  5339. * Gets a new Angle object from the given float in degrees
  5340. * @param degrees defines the angle value in degrees
  5341. * @returns a new Angle
  5342. */
  5343. static FromDegrees(degrees: number): Angle;
  5344. }
  5345. /**
  5346. * This represents an arc in a 2d space.
  5347. */
  5348. export class Arc2 {
  5349. /** Defines the start point of the arc */
  5350. startPoint: Vector2;
  5351. /** Defines the mid point of the arc */
  5352. midPoint: Vector2;
  5353. /** Defines the end point of the arc */
  5354. endPoint: Vector2;
  5355. /**
  5356. * Defines the center point of the arc.
  5357. */
  5358. centerPoint: Vector2;
  5359. /**
  5360. * Defines the radius of the arc.
  5361. */
  5362. radius: number;
  5363. /**
  5364. * Defines the angle of the arc (from mid point to end point).
  5365. */
  5366. angle: Angle;
  5367. /**
  5368. * Defines the start angle of the arc (from start point to middle point).
  5369. */
  5370. startAngle: Angle;
  5371. /**
  5372. * Defines the orientation of the arc (clock wise/counter clock wise).
  5373. */
  5374. orientation: Orientation;
  5375. /**
  5376. * Creates an Arc object from the three given points : start, middle and end.
  5377. * @param startPoint Defines the start point of the arc
  5378. * @param midPoint Defines the midlle point of the arc
  5379. * @param endPoint Defines the end point of the arc
  5380. */
  5381. constructor(
  5382. /** Defines the start point of the arc */
  5383. startPoint: Vector2,
  5384. /** Defines the mid point of the arc */
  5385. midPoint: Vector2,
  5386. /** Defines the end point of the arc */
  5387. endPoint: Vector2);
  5388. }
  5389. /**
  5390. * Represents a 2D path made up of multiple 2D points
  5391. */
  5392. export class Path2 {
  5393. private _points;
  5394. private _length;
  5395. /**
  5396. * If the path start and end point are the same
  5397. */
  5398. closed: boolean;
  5399. /**
  5400. * Creates a Path2 object from the starting 2D coordinates x and y.
  5401. * @param x the starting points x value
  5402. * @param y the starting points y value
  5403. */
  5404. constructor(x: number, y: number);
  5405. /**
  5406. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5407. * @param x the added points x value
  5408. * @param y the added points y value
  5409. * @returns the updated Path2.
  5410. */
  5411. addLineTo(x: number, y: number): Path2;
  5412. /**
  5413. * 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.
  5414. * @param midX middle point x value
  5415. * @param midY middle point y value
  5416. * @param endX end point x value
  5417. * @param endY end point y value
  5418. * @param numberOfSegments (default: 36)
  5419. * @returns the updated Path2.
  5420. */
  5421. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5422. /**
  5423. * Closes the Path2.
  5424. * @returns the Path2.
  5425. */
  5426. close(): Path2;
  5427. /**
  5428. * Gets the sum of the distance between each sequential point in the path
  5429. * @returns the Path2 total length (float).
  5430. */
  5431. length(): number;
  5432. /**
  5433. * Gets the points which construct the path
  5434. * @returns the Path2 internal array of points.
  5435. */
  5436. getPoints(): Vector2[];
  5437. /**
  5438. * Retreives the point at the distance aways from the starting point
  5439. * @param normalizedLengthPosition the length along the path to retreive the point from
  5440. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5441. */
  5442. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5443. /**
  5444. * Creates a new path starting from an x and y position
  5445. * @param x starting x value
  5446. * @param y starting y value
  5447. * @returns a new Path2 starting at the coordinates (x, y).
  5448. */
  5449. static StartingAt(x: number, y: number): Path2;
  5450. }
  5451. /**
  5452. * Represents a 3D path made up of multiple 3D points
  5453. */
  5454. export class Path3D {
  5455. /**
  5456. * an array of Vector3, the curve axis of the Path3D
  5457. */
  5458. path: Vector3[];
  5459. private _curve;
  5460. private _distances;
  5461. private _tangents;
  5462. private _normals;
  5463. private _binormals;
  5464. private _raw;
  5465. /**
  5466. * new Path3D(path, normal, raw)
  5467. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5468. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5469. * @param path an array of Vector3, the curve axis of the Path3D
  5470. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5471. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5472. */
  5473. constructor(
  5474. /**
  5475. * an array of Vector3, the curve axis of the Path3D
  5476. */
  5477. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  5478. /**
  5479. * Returns the Path3D array of successive Vector3 designing its curve.
  5480. * @returns the Path3D array of successive Vector3 designing its curve.
  5481. */
  5482. getCurve(): Vector3[];
  5483. /**
  5484. * Returns an array populated with tangent vectors on each Path3D curve point.
  5485. * @returns an array populated with tangent vectors on each Path3D curve point.
  5486. */
  5487. getTangents(): Vector3[];
  5488. /**
  5489. * Returns an array populated with normal vectors on each Path3D curve point.
  5490. * @returns an array populated with normal vectors on each Path3D curve point.
  5491. */
  5492. getNormals(): Vector3[];
  5493. /**
  5494. * Returns an array populated with binormal vectors on each Path3D curve point.
  5495. * @returns an array populated with binormal vectors on each Path3D curve point.
  5496. */
  5497. getBinormals(): Vector3[];
  5498. /**
  5499. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5500. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5501. */
  5502. getDistances(): number[];
  5503. /**
  5504. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5505. * @param path path which all values are copied into the curves points
  5506. * @param firstNormal which should be projected onto the curve
  5507. * @returns the same object updated.
  5508. */
  5509. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  5510. private _compute;
  5511. private _getFirstNonNullVector;
  5512. private _getLastNonNullVector;
  5513. private _normalVector;
  5514. }
  5515. /**
  5516. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5517. * A Curve3 is designed from a series of successive Vector3.
  5518. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5519. */
  5520. export class Curve3 {
  5521. private _points;
  5522. private _length;
  5523. /**
  5524. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5525. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5526. * @param v1 (Vector3) the control point
  5527. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5528. * @param nbPoints (integer) the wanted number of points in the curve
  5529. * @returns the created Curve3
  5530. */
  5531. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5532. /**
  5533. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5534. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5535. * @param v1 (Vector3) the first control point
  5536. * @param v2 (Vector3) the second control point
  5537. * @param v3 (Vector3) the end point of the Cubic Bezier
  5538. * @param nbPoints (integer) the wanted number of points in the curve
  5539. * @returns the created Curve3
  5540. */
  5541. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5542. /**
  5543. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5544. * @param p1 (Vector3) the origin point of the Hermite Spline
  5545. * @param t1 (Vector3) the tangent vector at the origin point
  5546. * @param p2 (Vector3) the end point of the Hermite Spline
  5547. * @param t2 (Vector3) the tangent vector at the end point
  5548. * @param nbPoints (integer) the wanted number of points in the curve
  5549. * @returns the created Curve3
  5550. */
  5551. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5552. /**
  5553. * Returns a Curve3 object along a CatmullRom Spline curve :
  5554. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5555. * @param nbPoints (integer) the wanted number of points between each curve control points
  5556. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5557. * @returns the created Curve3
  5558. */
  5559. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5560. /**
  5561. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5562. * A Curve3 is designed from a series of successive Vector3.
  5563. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5564. * @param points points which make up the curve
  5565. */
  5566. constructor(points: Vector3[]);
  5567. /**
  5568. * @returns the Curve3 stored array of successive Vector3
  5569. */
  5570. getPoints(): Vector3[];
  5571. /**
  5572. * @returns the computed length (float) of the curve.
  5573. */
  5574. length(): number;
  5575. /**
  5576. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5577. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5578. * curveA and curveB keep unchanged.
  5579. * @param curve the curve to continue from this curve
  5580. * @returns the newly constructed curve
  5581. */
  5582. continue(curve: DeepImmutable<Curve3>): Curve3;
  5583. private _computeLength;
  5584. }
  5585. }
  5586. declare module "babylonjs/Animations/easing" {
  5587. /**
  5588. * This represents the main contract an easing function should follow.
  5589. * Easing functions are used throughout the animation system.
  5590. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5591. */
  5592. export interface IEasingFunction {
  5593. /**
  5594. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5595. * of the easing function.
  5596. * The link below provides some of the most common examples of easing functions.
  5597. * @see https://easings.net/
  5598. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5599. * @returns the corresponding value on the curve defined by the easing function
  5600. */
  5601. ease(gradient: number): number;
  5602. }
  5603. /**
  5604. * Base class used for every default easing function.
  5605. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5606. */
  5607. export class EasingFunction implements IEasingFunction {
  5608. /**
  5609. * Interpolation follows the mathematical formula associated with the easing function.
  5610. */
  5611. static readonly EASINGMODE_EASEIN: number;
  5612. /**
  5613. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5614. */
  5615. static readonly EASINGMODE_EASEOUT: number;
  5616. /**
  5617. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5618. */
  5619. static readonly EASINGMODE_EASEINOUT: number;
  5620. private _easingMode;
  5621. /**
  5622. * Sets the easing mode of the current function.
  5623. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5624. */
  5625. setEasingMode(easingMode: number): void;
  5626. /**
  5627. * Gets the current easing mode.
  5628. * @returns the easing mode
  5629. */
  5630. getEasingMode(): number;
  5631. /**
  5632. * @hidden
  5633. */
  5634. easeInCore(gradient: number): number;
  5635. /**
  5636. * Given an input gradient between 0 and 1, this returns the corresponding value
  5637. * of the easing function.
  5638. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5639. * @returns the corresponding value on the curve defined by the easing function
  5640. */
  5641. ease(gradient: number): number;
  5642. }
  5643. /**
  5644. * Easing function with a circle shape (see link below).
  5645. * @see https://easings.net/#easeInCirc
  5646. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5647. */
  5648. export class CircleEase extends EasingFunction implements IEasingFunction {
  5649. /** @hidden */
  5650. easeInCore(gradient: number): number;
  5651. }
  5652. /**
  5653. * Easing function with a ease back shape (see link below).
  5654. * @see https://easings.net/#easeInBack
  5655. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5656. */
  5657. export class BackEase extends EasingFunction implements IEasingFunction {
  5658. /** Defines the amplitude of the function */
  5659. amplitude: number;
  5660. /**
  5661. * Instantiates a back ease easing
  5662. * @see https://easings.net/#easeInBack
  5663. * @param amplitude Defines the amplitude of the function
  5664. */
  5665. constructor(
  5666. /** Defines the amplitude of the function */
  5667. amplitude?: number);
  5668. /** @hidden */
  5669. easeInCore(gradient: number): number;
  5670. }
  5671. /**
  5672. * Easing function with a bouncing shape (see link below).
  5673. * @see https://easings.net/#easeInBounce
  5674. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5675. */
  5676. export class BounceEase extends EasingFunction implements IEasingFunction {
  5677. /** Defines the number of bounces */
  5678. bounces: number;
  5679. /** Defines the amplitude of the bounce */
  5680. bounciness: number;
  5681. /**
  5682. * Instantiates a bounce easing
  5683. * @see https://easings.net/#easeInBounce
  5684. * @param bounces Defines the number of bounces
  5685. * @param bounciness Defines the amplitude of the bounce
  5686. */
  5687. constructor(
  5688. /** Defines the number of bounces */
  5689. bounces?: number,
  5690. /** Defines the amplitude of the bounce */
  5691. bounciness?: number);
  5692. /** @hidden */
  5693. easeInCore(gradient: number): number;
  5694. }
  5695. /**
  5696. * Easing function with a power of 3 shape (see link below).
  5697. * @see https://easings.net/#easeInCubic
  5698. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5699. */
  5700. export class CubicEase extends EasingFunction implements IEasingFunction {
  5701. /** @hidden */
  5702. easeInCore(gradient: number): number;
  5703. }
  5704. /**
  5705. * Easing function with an elastic shape (see link below).
  5706. * @see https://easings.net/#easeInElastic
  5707. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5708. */
  5709. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5710. /** Defines the number of oscillations*/
  5711. oscillations: number;
  5712. /** Defines the amplitude of the oscillations*/
  5713. springiness: number;
  5714. /**
  5715. * Instantiates an elastic easing function
  5716. * @see https://easings.net/#easeInElastic
  5717. * @param oscillations Defines the number of oscillations
  5718. * @param springiness Defines the amplitude of the oscillations
  5719. */
  5720. constructor(
  5721. /** Defines the number of oscillations*/
  5722. oscillations?: number,
  5723. /** Defines the amplitude of the oscillations*/
  5724. springiness?: number);
  5725. /** @hidden */
  5726. easeInCore(gradient: number): number;
  5727. }
  5728. /**
  5729. * Easing function with an exponential shape (see link below).
  5730. * @see https://easings.net/#easeInExpo
  5731. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5732. */
  5733. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5734. /** Defines the exponent of the function */
  5735. exponent: number;
  5736. /**
  5737. * Instantiates an exponential easing function
  5738. * @see https://easings.net/#easeInExpo
  5739. * @param exponent Defines the exponent of the function
  5740. */
  5741. constructor(
  5742. /** Defines the exponent of the function */
  5743. exponent?: number);
  5744. /** @hidden */
  5745. easeInCore(gradient: number): number;
  5746. }
  5747. /**
  5748. * Easing function with a power shape (see link below).
  5749. * @see https://easings.net/#easeInQuad
  5750. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5751. */
  5752. export class PowerEase extends EasingFunction implements IEasingFunction {
  5753. /** Defines the power of the function */
  5754. power: number;
  5755. /**
  5756. * Instantiates an power base easing function
  5757. * @see https://easings.net/#easeInQuad
  5758. * @param power Defines the power of the function
  5759. */
  5760. constructor(
  5761. /** Defines the power of the function */
  5762. power?: number);
  5763. /** @hidden */
  5764. easeInCore(gradient: number): number;
  5765. }
  5766. /**
  5767. * Easing function with a power of 2 shape (see link below).
  5768. * @see https://easings.net/#easeInQuad
  5769. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5770. */
  5771. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5772. /** @hidden */
  5773. easeInCore(gradient: number): number;
  5774. }
  5775. /**
  5776. * Easing function with a power of 4 shape (see link below).
  5777. * @see https://easings.net/#easeInQuart
  5778. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5779. */
  5780. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5781. /** @hidden */
  5782. easeInCore(gradient: number): number;
  5783. }
  5784. /**
  5785. * Easing function with a power of 5 shape (see link below).
  5786. * @see https://easings.net/#easeInQuint
  5787. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5788. */
  5789. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5790. /** @hidden */
  5791. easeInCore(gradient: number): number;
  5792. }
  5793. /**
  5794. * Easing function with a sin shape (see link below).
  5795. * @see https://easings.net/#easeInSine
  5796. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5797. */
  5798. export class SineEase extends EasingFunction implements IEasingFunction {
  5799. /** @hidden */
  5800. easeInCore(gradient: number): number;
  5801. }
  5802. /**
  5803. * Easing function with a bezier shape (see link below).
  5804. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5805. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5806. */
  5807. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5808. /** Defines the x component of the start tangent in the bezier curve */
  5809. x1: number;
  5810. /** Defines the y component of the start tangent in the bezier curve */
  5811. y1: number;
  5812. /** Defines the x component of the end tangent in the bezier curve */
  5813. x2: number;
  5814. /** Defines the y component of the end tangent in the bezier curve */
  5815. y2: number;
  5816. /**
  5817. * Instantiates a bezier function
  5818. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5819. * @param x1 Defines the x component of the start tangent in the bezier curve
  5820. * @param y1 Defines the y component of the start tangent in the bezier curve
  5821. * @param x2 Defines the x component of the end tangent in the bezier curve
  5822. * @param y2 Defines the y component of the end tangent in the bezier curve
  5823. */
  5824. constructor(
  5825. /** Defines the x component of the start tangent in the bezier curve */
  5826. x1?: number,
  5827. /** Defines the y component of the start tangent in the bezier curve */
  5828. y1?: number,
  5829. /** Defines the x component of the end tangent in the bezier curve */
  5830. x2?: number,
  5831. /** Defines the y component of the end tangent in the bezier curve */
  5832. y2?: number);
  5833. /** @hidden */
  5834. easeInCore(gradient: number): number;
  5835. }
  5836. }
  5837. declare module "babylonjs/Animations/animationKey" {
  5838. /**
  5839. * Defines an interface which represents an animation key frame
  5840. */
  5841. export interface IAnimationKey {
  5842. /**
  5843. * Frame of the key frame
  5844. */
  5845. frame: number;
  5846. /**
  5847. * Value at the specifies key frame
  5848. */
  5849. value: any;
  5850. /**
  5851. * The input tangent for the cubic hermite spline
  5852. */
  5853. inTangent?: any;
  5854. /**
  5855. * The output tangent for the cubic hermite spline
  5856. */
  5857. outTangent?: any;
  5858. /**
  5859. * The animation interpolation type
  5860. */
  5861. interpolation?: AnimationKeyInterpolation;
  5862. }
  5863. /**
  5864. * Enum for the animation key frame interpolation type
  5865. */
  5866. export enum AnimationKeyInterpolation {
  5867. /**
  5868. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5869. */
  5870. STEP = 1
  5871. }
  5872. }
  5873. declare module "babylonjs/Animations/animationRange" {
  5874. /**
  5875. * Represents the range of an animation
  5876. */
  5877. export class AnimationRange {
  5878. /**The name of the animation range**/
  5879. name: string;
  5880. /**The starting frame of the animation */
  5881. from: number;
  5882. /**The ending frame of the animation*/
  5883. to: number;
  5884. /**
  5885. * Initializes the range of an animation
  5886. * @param name The name of the animation range
  5887. * @param from The starting frame of the animation
  5888. * @param to The ending frame of the animation
  5889. */
  5890. constructor(
  5891. /**The name of the animation range**/
  5892. name: string,
  5893. /**The starting frame of the animation */
  5894. from: number,
  5895. /**The ending frame of the animation*/
  5896. to: number);
  5897. /**
  5898. * Makes a copy of the animation range
  5899. * @returns A copy of the animation range
  5900. */
  5901. clone(): AnimationRange;
  5902. }
  5903. }
  5904. declare module "babylonjs/Animations/animationEvent" {
  5905. /**
  5906. * Composed of a frame, and an action function
  5907. */
  5908. export class AnimationEvent {
  5909. /** The frame for which the event is triggered **/
  5910. frame: number;
  5911. /** The event to perform when triggered **/
  5912. action: (currentFrame: number) => void;
  5913. /** Specifies if the event should be triggered only once**/
  5914. onlyOnce?: boolean | undefined;
  5915. /**
  5916. * Specifies if the animation event is done
  5917. */
  5918. isDone: boolean;
  5919. /**
  5920. * Initializes the animation event
  5921. * @param frame The frame for which the event is triggered
  5922. * @param action The event to perform when triggered
  5923. * @param onlyOnce Specifies if the event should be triggered only once
  5924. */
  5925. constructor(
  5926. /** The frame for which the event is triggered **/
  5927. frame: number,
  5928. /** The event to perform when triggered **/
  5929. action: (currentFrame: number) => void,
  5930. /** Specifies if the event should be triggered only once**/
  5931. onlyOnce?: boolean | undefined);
  5932. /** @hidden */
  5933. _clone(): AnimationEvent;
  5934. }
  5935. }
  5936. declare module "babylonjs/Behaviors/behavior" {
  5937. import { Nullable } from "babylonjs/types";
  5938. /**
  5939. * Interface used to define a behavior
  5940. */
  5941. export interface Behavior<T> {
  5942. /** gets or sets behavior's name */
  5943. name: string;
  5944. /**
  5945. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5946. */
  5947. init(): void;
  5948. /**
  5949. * Called when the behavior is attached to a target
  5950. * @param target defines the target where the behavior is attached to
  5951. */
  5952. attach(target: T): void;
  5953. /**
  5954. * Called when the behavior is detached from its target
  5955. */
  5956. detach(): void;
  5957. }
  5958. /**
  5959. * Interface implemented by classes supporting behaviors
  5960. */
  5961. export interface IBehaviorAware<T> {
  5962. /**
  5963. * Attach a behavior
  5964. * @param behavior defines the behavior to attach
  5965. * @returns the current host
  5966. */
  5967. addBehavior(behavior: Behavior<T>): T;
  5968. /**
  5969. * Remove a behavior from the current object
  5970. * @param behavior defines the behavior to detach
  5971. * @returns the current host
  5972. */
  5973. removeBehavior(behavior: Behavior<T>): T;
  5974. /**
  5975. * Gets a behavior using its name to search
  5976. * @param name defines the name to search
  5977. * @returns the behavior or null if not found
  5978. */
  5979. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5980. }
  5981. }
  5982. declare module "babylonjs/Misc/smartArray" {
  5983. /**
  5984. * Defines an array and its length.
  5985. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  5986. */
  5987. export interface ISmartArrayLike<T> {
  5988. /**
  5989. * The data of the array.
  5990. */
  5991. data: Array<T>;
  5992. /**
  5993. * The active length of the array.
  5994. */
  5995. length: number;
  5996. }
  5997. /**
  5998. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  5999. */
  6000. export class SmartArray<T> implements ISmartArrayLike<T> {
  6001. /**
  6002. * The full set of data from the array.
  6003. */
  6004. data: Array<T>;
  6005. /**
  6006. * The active length of the array.
  6007. */
  6008. length: number;
  6009. protected _id: number;
  6010. /**
  6011. * Instantiates a Smart Array.
  6012. * @param capacity defines the default capacity of the array.
  6013. */
  6014. constructor(capacity: number);
  6015. /**
  6016. * Pushes a value at the end of the active data.
  6017. * @param value defines the object to push in the array.
  6018. */
  6019. push(value: T): void;
  6020. /**
  6021. * Iterates over the active data and apply the lambda to them.
  6022. * @param func defines the action to apply on each value.
  6023. */
  6024. forEach(func: (content: T) => void): void;
  6025. /**
  6026. * Sorts the full sets of data.
  6027. * @param compareFn defines the comparison function to apply.
  6028. */
  6029. sort(compareFn: (a: T, b: T) => number): void;
  6030. /**
  6031. * Resets the active data to an empty array.
  6032. */
  6033. reset(): void;
  6034. /**
  6035. * Releases all the data from the array as well as the array.
  6036. */
  6037. dispose(): void;
  6038. /**
  6039. * Concats the active data with a given array.
  6040. * @param array defines the data to concatenate with.
  6041. */
  6042. concat(array: any): void;
  6043. /**
  6044. * Returns the position of a value in the active data.
  6045. * @param value defines the value to find the index for
  6046. * @returns the index if found in the active data otherwise -1
  6047. */
  6048. indexOf(value: T): number;
  6049. /**
  6050. * Returns whether an element is part of the active data.
  6051. * @param value defines the value to look for
  6052. * @returns true if found in the active data otherwise false
  6053. */
  6054. contains(value: T): boolean;
  6055. private static _GlobalId;
  6056. }
  6057. /**
  6058. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6059. * The data in this array can only be present once
  6060. */
  6061. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6062. private _duplicateId;
  6063. /**
  6064. * Pushes a value at the end of the active data.
  6065. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6066. * @param value defines the object to push in the array.
  6067. */
  6068. push(value: T): void;
  6069. /**
  6070. * Pushes a value at the end of the active data.
  6071. * If the data is already present, it won t be added again
  6072. * @param value defines the object to push in the array.
  6073. * @returns true if added false if it was already present
  6074. */
  6075. pushNoDuplicate(value: T): boolean;
  6076. /**
  6077. * Resets the active data to an empty array.
  6078. */
  6079. reset(): void;
  6080. /**
  6081. * Concats the active data with a given array.
  6082. * This ensures no dupplicate will be present in the result.
  6083. * @param array defines the data to concatenate with.
  6084. */
  6085. concatWithNoDuplicate(array: any): void;
  6086. }
  6087. }
  6088. declare module "babylonjs/Cameras/cameraInputsManager" {
  6089. import { Nullable } from "babylonjs/types";
  6090. import { Camera } from "babylonjs/Cameras/camera";
  6091. /**
  6092. * @ignore
  6093. * This is a list of all the different input types that are available in the application.
  6094. * Fo instance: ArcRotateCameraGamepadInput...
  6095. */
  6096. export var CameraInputTypes: {};
  6097. /**
  6098. * This is the contract to implement in order to create a new input class.
  6099. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6100. */
  6101. export interface ICameraInput<TCamera extends Camera> {
  6102. /**
  6103. * Defines the camera the input is attached to.
  6104. */
  6105. camera: Nullable<TCamera>;
  6106. /**
  6107. * Gets the class name of the current intput.
  6108. * @returns the class name
  6109. */
  6110. getClassName(): string;
  6111. /**
  6112. * Get the friendly name associated with the input class.
  6113. * @returns the input friendly name
  6114. */
  6115. getSimpleName(): string;
  6116. /**
  6117. * Attach the input controls to a specific dom element to get the input from.
  6118. * @param element Defines the element the controls should be listened from
  6119. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6120. */
  6121. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6122. /**
  6123. * Detach the current controls from the specified dom element.
  6124. * @param element Defines the element to stop listening the inputs from
  6125. */
  6126. detachControl(element: Nullable<HTMLElement>): void;
  6127. /**
  6128. * Update the current camera state depending on the inputs that have been used this frame.
  6129. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6130. */
  6131. checkInputs?: () => void;
  6132. }
  6133. /**
  6134. * Represents a map of input types to input instance or input index to input instance.
  6135. */
  6136. export interface CameraInputsMap<TCamera extends Camera> {
  6137. /**
  6138. * Accessor to the input by input type.
  6139. */
  6140. [name: string]: ICameraInput<TCamera>;
  6141. /**
  6142. * Accessor to the input by input index.
  6143. */
  6144. [idx: number]: ICameraInput<TCamera>;
  6145. }
  6146. /**
  6147. * This represents the input manager used within a camera.
  6148. * It helps dealing with all the different kind of input attached to a camera.
  6149. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6150. */
  6151. export class CameraInputsManager<TCamera extends Camera> {
  6152. /**
  6153. * Defines the list of inputs attahed to the camera.
  6154. */
  6155. attached: CameraInputsMap<TCamera>;
  6156. /**
  6157. * Defines the dom element the camera is collecting inputs from.
  6158. * This is null if the controls have not been attached.
  6159. */
  6160. attachedElement: Nullable<HTMLElement>;
  6161. /**
  6162. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6163. */
  6164. noPreventDefault: boolean;
  6165. /**
  6166. * Defined the camera the input manager belongs to.
  6167. */
  6168. camera: TCamera;
  6169. /**
  6170. * Update the current camera state depending on the inputs that have been used this frame.
  6171. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6172. */
  6173. checkInputs: () => void;
  6174. /**
  6175. * Instantiate a new Camera Input Manager.
  6176. * @param camera Defines the camera the input manager blongs to
  6177. */
  6178. constructor(camera: TCamera);
  6179. /**
  6180. * Add an input method to a camera
  6181. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6182. * @param input camera input method
  6183. */
  6184. add(input: ICameraInput<TCamera>): void;
  6185. /**
  6186. * Remove a specific input method from a camera
  6187. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6188. * @param inputToRemove camera input method
  6189. */
  6190. remove(inputToRemove: ICameraInput<TCamera>): void;
  6191. /**
  6192. * Remove a specific input type from a camera
  6193. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6194. * @param inputType the type of the input to remove
  6195. */
  6196. removeByType(inputType: string): void;
  6197. private _addCheckInputs;
  6198. /**
  6199. * Attach the input controls to the currently attached dom element to listen the events from.
  6200. * @param input Defines the input to attach
  6201. */
  6202. attachInput(input: ICameraInput<TCamera>): void;
  6203. /**
  6204. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6205. * @param element Defines the dom element to collect the events from
  6206. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6207. */
  6208. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6209. /**
  6210. * Detach the current manager inputs controls from a specific dom element.
  6211. * @param element Defines the dom element to collect the events from
  6212. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6213. */
  6214. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6215. /**
  6216. * Rebuild the dynamic inputCheck function from the current list of
  6217. * defined inputs in the manager.
  6218. */
  6219. rebuildInputCheck(): void;
  6220. /**
  6221. * Remove all attached input methods from a camera
  6222. */
  6223. clear(): void;
  6224. /**
  6225. * Serialize the current input manager attached to a camera.
  6226. * This ensures than once parsed,
  6227. * the input associated to the camera will be identical to the current ones
  6228. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6229. */
  6230. serialize(serializedCamera: any): void;
  6231. /**
  6232. * Parses an input manager serialized JSON to restore the previous list of inputs
  6233. * and states associated to a camera.
  6234. * @param parsedCamera Defines the JSON to parse
  6235. */
  6236. parse(parsedCamera: any): void;
  6237. }
  6238. }
  6239. declare module "babylonjs/Meshes/buffer" {
  6240. import { Nullable, DataArray } from "babylonjs/types";
  6241. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6242. /**
  6243. * Class used to store data that will be store in GPU memory
  6244. */
  6245. export class Buffer {
  6246. private _engine;
  6247. private _buffer;
  6248. /** @hidden */
  6249. _data: Nullable<DataArray>;
  6250. private _updatable;
  6251. private _instanced;
  6252. /**
  6253. * Gets the byte stride.
  6254. */
  6255. readonly byteStride: number;
  6256. /**
  6257. * Constructor
  6258. * @param engine the engine
  6259. * @param data the data to use for this buffer
  6260. * @param updatable whether the data is updatable
  6261. * @param stride the stride (optional)
  6262. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6263. * @param instanced whether the buffer is instanced (optional)
  6264. * @param useBytes set to true if the stride in in bytes (optional)
  6265. */
  6266. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  6267. /**
  6268. * Create a new VertexBuffer based on the current buffer
  6269. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6270. * @param offset defines offset in the buffer (0 by default)
  6271. * @param size defines the size in floats of attributes (position is 3 for instance)
  6272. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6273. * @param instanced defines if the vertex buffer contains indexed data
  6274. * @param useBytes defines if the offset and stride are in bytes
  6275. * @returns the new vertex buffer
  6276. */
  6277. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  6278. /**
  6279. * Gets a boolean indicating if the Buffer is updatable?
  6280. * @returns true if the buffer is updatable
  6281. */
  6282. isUpdatable(): boolean;
  6283. /**
  6284. * Gets current buffer's data
  6285. * @returns a DataArray or null
  6286. */
  6287. getData(): Nullable<DataArray>;
  6288. /**
  6289. * Gets underlying native buffer
  6290. * @returns underlying native buffer
  6291. */
  6292. getBuffer(): Nullable<DataBuffer>;
  6293. /**
  6294. * Gets the stride in float32 units (i.e. byte stride / 4).
  6295. * May not be an integer if the byte stride is not divisible by 4.
  6296. * DEPRECATED. Use byteStride instead.
  6297. * @returns the stride in float32 units
  6298. */
  6299. getStrideSize(): number;
  6300. /**
  6301. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6302. * @param data defines the data to store
  6303. */
  6304. create(data?: Nullable<DataArray>): void;
  6305. /** @hidden */
  6306. _rebuild(): void;
  6307. /**
  6308. * Update current buffer data
  6309. * @param data defines the data to store
  6310. */
  6311. update(data: DataArray): void;
  6312. /**
  6313. * Updates the data directly.
  6314. * @param data the new data
  6315. * @param offset the new offset
  6316. * @param vertexCount the vertex count (optional)
  6317. * @param useBytes set to true if the offset is in bytes
  6318. */
  6319. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6320. /**
  6321. * Release all resources
  6322. */
  6323. dispose(): void;
  6324. }
  6325. /**
  6326. * Specialized buffer used to store vertex data
  6327. */
  6328. export class VertexBuffer {
  6329. /** @hidden */
  6330. _buffer: Buffer;
  6331. private _kind;
  6332. private _size;
  6333. private _ownsBuffer;
  6334. private _instanced;
  6335. private _instanceDivisor;
  6336. /**
  6337. * The byte type.
  6338. */
  6339. static readonly BYTE: number;
  6340. /**
  6341. * The unsigned byte type.
  6342. */
  6343. static readonly UNSIGNED_BYTE: number;
  6344. /**
  6345. * The short type.
  6346. */
  6347. static readonly SHORT: number;
  6348. /**
  6349. * The unsigned short type.
  6350. */
  6351. static readonly UNSIGNED_SHORT: number;
  6352. /**
  6353. * The integer type.
  6354. */
  6355. static readonly INT: number;
  6356. /**
  6357. * The unsigned integer type.
  6358. */
  6359. static readonly UNSIGNED_INT: number;
  6360. /**
  6361. * The float type.
  6362. */
  6363. static readonly FLOAT: number;
  6364. /**
  6365. * Gets or sets the instance divisor when in instanced mode
  6366. */
  6367. instanceDivisor: number;
  6368. /**
  6369. * Gets the byte stride.
  6370. */
  6371. readonly byteStride: number;
  6372. /**
  6373. * Gets the byte offset.
  6374. */
  6375. readonly byteOffset: number;
  6376. /**
  6377. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6378. */
  6379. readonly normalized: boolean;
  6380. /**
  6381. * Gets the data type of each component in the array.
  6382. */
  6383. readonly type: number;
  6384. /**
  6385. * Constructor
  6386. * @param engine the engine
  6387. * @param data the data to use for this vertex buffer
  6388. * @param kind the vertex buffer kind
  6389. * @param updatable whether the data is updatable
  6390. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6391. * @param stride the stride (optional)
  6392. * @param instanced whether the buffer is instanced (optional)
  6393. * @param offset the offset of the data (optional)
  6394. * @param size the number of components (optional)
  6395. * @param type the type of the component (optional)
  6396. * @param normalized whether the data contains normalized data (optional)
  6397. * @param useBytes set to true if stride and offset are in bytes (optional)
  6398. */
  6399. 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);
  6400. /** @hidden */
  6401. _rebuild(): void;
  6402. /**
  6403. * Returns the kind of the VertexBuffer (string)
  6404. * @returns a string
  6405. */
  6406. getKind(): string;
  6407. /**
  6408. * Gets a boolean indicating if the VertexBuffer is updatable?
  6409. * @returns true if the buffer is updatable
  6410. */
  6411. isUpdatable(): boolean;
  6412. /**
  6413. * Gets current buffer's data
  6414. * @returns a DataArray or null
  6415. */
  6416. getData(): Nullable<DataArray>;
  6417. /**
  6418. * Gets underlying native buffer
  6419. * @returns underlying native buffer
  6420. */
  6421. getBuffer(): Nullable<DataBuffer>;
  6422. /**
  6423. * Gets the stride in float32 units (i.e. byte stride / 4).
  6424. * May not be an integer if the byte stride is not divisible by 4.
  6425. * DEPRECATED. Use byteStride instead.
  6426. * @returns the stride in float32 units
  6427. */
  6428. getStrideSize(): number;
  6429. /**
  6430. * Returns the offset as a multiple of the type byte length.
  6431. * DEPRECATED. Use byteOffset instead.
  6432. * @returns the offset in bytes
  6433. */
  6434. getOffset(): number;
  6435. /**
  6436. * Returns the number of components per vertex attribute (integer)
  6437. * @returns the size in float
  6438. */
  6439. getSize(): number;
  6440. /**
  6441. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6442. * @returns true if this buffer is instanced
  6443. */
  6444. getIsInstanced(): boolean;
  6445. /**
  6446. * Returns the instancing divisor, zero for non-instanced (integer).
  6447. * @returns a number
  6448. */
  6449. getInstanceDivisor(): number;
  6450. /**
  6451. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6452. * @param data defines the data to store
  6453. */
  6454. create(data?: DataArray): void;
  6455. /**
  6456. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6457. * This function will create a new buffer if the current one is not updatable
  6458. * @param data defines the data to store
  6459. */
  6460. update(data: DataArray): void;
  6461. /**
  6462. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6463. * Returns the directly updated WebGLBuffer.
  6464. * @param data the new data
  6465. * @param offset the new offset
  6466. * @param useBytes set to true if the offset is in bytes
  6467. */
  6468. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6469. /**
  6470. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6471. */
  6472. dispose(): void;
  6473. /**
  6474. * Enumerates each value of this vertex buffer as numbers.
  6475. * @param count the number of values to enumerate
  6476. * @param callback the callback function called for each value
  6477. */
  6478. forEach(count: number, callback: (value: number, index: number) => void): void;
  6479. /**
  6480. * Positions
  6481. */
  6482. static readonly PositionKind: string;
  6483. /**
  6484. * Normals
  6485. */
  6486. static readonly NormalKind: string;
  6487. /**
  6488. * Tangents
  6489. */
  6490. static readonly TangentKind: string;
  6491. /**
  6492. * Texture coordinates
  6493. */
  6494. static readonly UVKind: string;
  6495. /**
  6496. * Texture coordinates 2
  6497. */
  6498. static readonly UV2Kind: string;
  6499. /**
  6500. * Texture coordinates 3
  6501. */
  6502. static readonly UV3Kind: string;
  6503. /**
  6504. * Texture coordinates 4
  6505. */
  6506. static readonly UV4Kind: string;
  6507. /**
  6508. * Texture coordinates 5
  6509. */
  6510. static readonly UV5Kind: string;
  6511. /**
  6512. * Texture coordinates 6
  6513. */
  6514. static readonly UV6Kind: string;
  6515. /**
  6516. * Colors
  6517. */
  6518. static readonly ColorKind: string;
  6519. /**
  6520. * Matrix indices (for bones)
  6521. */
  6522. static readonly MatricesIndicesKind: string;
  6523. /**
  6524. * Matrix weights (for bones)
  6525. */
  6526. static readonly MatricesWeightsKind: string;
  6527. /**
  6528. * Additional matrix indices (for bones)
  6529. */
  6530. static readonly MatricesIndicesExtraKind: string;
  6531. /**
  6532. * Additional matrix weights (for bones)
  6533. */
  6534. static readonly MatricesWeightsExtraKind: string;
  6535. /**
  6536. * Deduces the stride given a kind.
  6537. * @param kind The kind string to deduce
  6538. * @returns The deduced stride
  6539. */
  6540. static DeduceStride(kind: string): number;
  6541. /**
  6542. * Gets the byte length of the given type.
  6543. * @param type the type
  6544. * @returns the number of bytes
  6545. */
  6546. static GetTypeByteLength(type: number): number;
  6547. /**
  6548. * Enumerates each value of the given parameters as numbers.
  6549. * @param data the data to enumerate
  6550. * @param byteOffset the byte offset of the data
  6551. * @param byteStride the byte stride of the data
  6552. * @param componentCount the number of components per element
  6553. * @param componentType the type of the component
  6554. * @param count the number of values to enumerate
  6555. * @param normalized whether the data is normalized
  6556. * @param callback the callback function called for each value
  6557. */
  6558. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6559. private static _GetFloatValue;
  6560. }
  6561. }
  6562. declare module "babylonjs/Collisions/intersectionInfo" {
  6563. import { Nullable } from "babylonjs/types";
  6564. /**
  6565. * @hidden
  6566. */
  6567. export class IntersectionInfo {
  6568. bu: Nullable<number>;
  6569. bv: Nullable<number>;
  6570. distance: number;
  6571. faceId: number;
  6572. subMeshId: number;
  6573. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6574. }
  6575. }
  6576. declare module "babylonjs/Maths/math.plane" {
  6577. import { DeepImmutable } from "babylonjs/types";
  6578. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6579. /**
  6580. * Represens a plane by the equation ax + by + cz + d = 0
  6581. */
  6582. export class Plane {
  6583. private static _TmpMatrix;
  6584. /**
  6585. * Normal of the plane (a,b,c)
  6586. */
  6587. normal: Vector3;
  6588. /**
  6589. * d component of the plane
  6590. */
  6591. d: number;
  6592. /**
  6593. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6594. * @param a a component of the plane
  6595. * @param b b component of the plane
  6596. * @param c c component of the plane
  6597. * @param d d component of the plane
  6598. */
  6599. constructor(a: number, b: number, c: number, d: number);
  6600. /**
  6601. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6602. */
  6603. asArray(): number[];
  6604. /**
  6605. * @returns a new plane copied from the current Plane.
  6606. */
  6607. clone(): Plane;
  6608. /**
  6609. * @returns the string "Plane".
  6610. */
  6611. getClassName(): string;
  6612. /**
  6613. * @returns the Plane hash code.
  6614. */
  6615. getHashCode(): number;
  6616. /**
  6617. * Normalize the current Plane in place.
  6618. * @returns the updated Plane.
  6619. */
  6620. normalize(): Plane;
  6621. /**
  6622. * Applies a transformation the plane and returns the result
  6623. * @param transformation the transformation matrix to be applied to the plane
  6624. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6625. */
  6626. transform(transformation: DeepImmutable<Matrix>): Plane;
  6627. /**
  6628. * Calcualtte the dot product between the point and the plane normal
  6629. * @param point point to calculate the dot product with
  6630. * @returns the dot product (float) of the point coordinates and the plane normal.
  6631. */
  6632. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6633. /**
  6634. * Updates the current Plane from the plane defined by the three given points.
  6635. * @param point1 one of the points used to contruct the plane
  6636. * @param point2 one of the points used to contruct the plane
  6637. * @param point3 one of the points used to contruct the plane
  6638. * @returns the updated Plane.
  6639. */
  6640. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6641. /**
  6642. * Checks if the plane is facing a given direction
  6643. * @param direction the direction to check if the plane is facing
  6644. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6645. * @returns True is the vector "direction" is the same side than the plane normal.
  6646. */
  6647. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6648. /**
  6649. * Calculates the distance to a point
  6650. * @param point point to calculate distance to
  6651. * @returns the signed distance (float) from the given point to the Plane.
  6652. */
  6653. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6654. /**
  6655. * Creates a plane from an array
  6656. * @param array the array to create a plane from
  6657. * @returns a new Plane from the given array.
  6658. */
  6659. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6660. /**
  6661. * Creates a plane from three points
  6662. * @param point1 point used to create the plane
  6663. * @param point2 point used to create the plane
  6664. * @param point3 point used to create the plane
  6665. * @returns a new Plane defined by the three given points.
  6666. */
  6667. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6668. /**
  6669. * Creates a plane from an origin point and a normal
  6670. * @param origin origin of the plane to be constructed
  6671. * @param normal normal of the plane to be constructed
  6672. * @returns a new Plane the normal vector to this plane at the given origin point.
  6673. * Note : the vector "normal" is updated because normalized.
  6674. */
  6675. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6676. /**
  6677. * Calculates the distance from a plane and a point
  6678. * @param origin origin of the plane to be constructed
  6679. * @param normal normal of the plane to be constructed
  6680. * @param point point to calculate distance to
  6681. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6682. */
  6683. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6684. }
  6685. }
  6686. declare module "babylonjs/Culling/boundingSphere" {
  6687. import { DeepImmutable } from "babylonjs/types";
  6688. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6689. import { Plane } from "babylonjs/Maths/math.plane";
  6690. /**
  6691. * Class used to store bounding sphere information
  6692. */
  6693. export class BoundingSphere {
  6694. /**
  6695. * Gets the center of the bounding sphere in local space
  6696. */
  6697. readonly center: Vector3;
  6698. /**
  6699. * Radius of the bounding sphere in local space
  6700. */
  6701. radius: number;
  6702. /**
  6703. * Gets the center of the bounding sphere in world space
  6704. */
  6705. readonly centerWorld: Vector3;
  6706. /**
  6707. * Radius of the bounding sphere in world space
  6708. */
  6709. radiusWorld: number;
  6710. /**
  6711. * Gets the minimum vector in local space
  6712. */
  6713. readonly minimum: Vector3;
  6714. /**
  6715. * Gets the maximum vector in local space
  6716. */
  6717. readonly maximum: Vector3;
  6718. private _worldMatrix;
  6719. private static readonly TmpVector3;
  6720. /**
  6721. * Creates a new bounding sphere
  6722. * @param min defines the minimum vector (in local space)
  6723. * @param max defines the maximum vector (in local space)
  6724. * @param worldMatrix defines the new world matrix
  6725. */
  6726. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6727. /**
  6728. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6729. * @param min defines the new minimum vector (in local space)
  6730. * @param max defines the new maximum vector (in local space)
  6731. * @param worldMatrix defines the new world matrix
  6732. */
  6733. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6734. /**
  6735. * Scale the current bounding sphere by applying a scale factor
  6736. * @param factor defines the scale factor to apply
  6737. * @returns the current bounding box
  6738. */
  6739. scale(factor: number): BoundingSphere;
  6740. /**
  6741. * Gets the world matrix of the bounding box
  6742. * @returns a matrix
  6743. */
  6744. getWorldMatrix(): DeepImmutable<Matrix>;
  6745. /** @hidden */
  6746. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6747. /**
  6748. * Tests if the bounding sphere is intersecting the frustum planes
  6749. * @param frustumPlanes defines the frustum planes to test
  6750. * @returns true if there is an intersection
  6751. */
  6752. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6753. /**
  6754. * Tests if the bounding sphere center is in between the frustum planes.
  6755. * Used for optimistic fast inclusion.
  6756. * @param frustumPlanes defines the frustum planes to test
  6757. * @returns true if the sphere center is in between the frustum planes
  6758. */
  6759. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6760. /**
  6761. * Tests if a point is inside the bounding sphere
  6762. * @param point defines the point to test
  6763. * @returns true if the point is inside the bounding sphere
  6764. */
  6765. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6766. /**
  6767. * Checks if two sphere intersct
  6768. * @param sphere0 sphere 0
  6769. * @param sphere1 sphere 1
  6770. * @returns true if the speres intersect
  6771. */
  6772. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6773. }
  6774. }
  6775. declare module "babylonjs/Culling/boundingBox" {
  6776. import { DeepImmutable } from "babylonjs/types";
  6777. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6778. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6779. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6780. import { Plane } from "babylonjs/Maths/math.plane";
  6781. /**
  6782. * Class used to store bounding box information
  6783. */
  6784. export class BoundingBox implements ICullable {
  6785. /**
  6786. * Gets the 8 vectors representing the bounding box in local space
  6787. */
  6788. readonly vectors: Vector3[];
  6789. /**
  6790. * Gets the center of the bounding box in local space
  6791. */
  6792. readonly center: Vector3;
  6793. /**
  6794. * Gets the center of the bounding box in world space
  6795. */
  6796. readonly centerWorld: Vector3;
  6797. /**
  6798. * Gets the extend size in local space
  6799. */
  6800. readonly extendSize: Vector3;
  6801. /**
  6802. * Gets the extend size in world space
  6803. */
  6804. readonly extendSizeWorld: Vector3;
  6805. /**
  6806. * Gets the OBB (object bounding box) directions
  6807. */
  6808. readonly directions: Vector3[];
  6809. /**
  6810. * Gets the 8 vectors representing the bounding box in world space
  6811. */
  6812. readonly vectorsWorld: Vector3[];
  6813. /**
  6814. * Gets the minimum vector in world space
  6815. */
  6816. readonly minimumWorld: Vector3;
  6817. /**
  6818. * Gets the maximum vector in world space
  6819. */
  6820. readonly maximumWorld: Vector3;
  6821. /**
  6822. * Gets the minimum vector in local space
  6823. */
  6824. readonly minimum: Vector3;
  6825. /**
  6826. * Gets the maximum vector in local space
  6827. */
  6828. readonly maximum: Vector3;
  6829. private _worldMatrix;
  6830. private static readonly TmpVector3;
  6831. /**
  6832. * @hidden
  6833. */
  6834. _tag: number;
  6835. /**
  6836. * Creates a new bounding box
  6837. * @param min defines the minimum vector (in local space)
  6838. * @param max defines the maximum vector (in local space)
  6839. * @param worldMatrix defines the new world matrix
  6840. */
  6841. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6842. /**
  6843. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6844. * @param min defines the new minimum vector (in local space)
  6845. * @param max defines the new maximum vector (in local space)
  6846. * @param worldMatrix defines the new world matrix
  6847. */
  6848. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6849. /**
  6850. * Scale the current bounding box by applying a scale factor
  6851. * @param factor defines the scale factor to apply
  6852. * @returns the current bounding box
  6853. */
  6854. scale(factor: number): BoundingBox;
  6855. /**
  6856. * Gets the world matrix of the bounding box
  6857. * @returns a matrix
  6858. */
  6859. getWorldMatrix(): DeepImmutable<Matrix>;
  6860. /** @hidden */
  6861. _update(world: DeepImmutable<Matrix>): void;
  6862. /**
  6863. * Tests if the bounding box is intersecting the frustum planes
  6864. * @param frustumPlanes defines the frustum planes to test
  6865. * @returns true if there is an intersection
  6866. */
  6867. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6868. /**
  6869. * Tests if the bounding box is entirely inside the frustum planes
  6870. * @param frustumPlanes defines the frustum planes to test
  6871. * @returns true if there is an inclusion
  6872. */
  6873. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6874. /**
  6875. * Tests if a point is inside the bounding box
  6876. * @param point defines the point to test
  6877. * @returns true if the point is inside the bounding box
  6878. */
  6879. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6880. /**
  6881. * Tests if the bounding box intersects with a bounding sphere
  6882. * @param sphere defines the sphere to test
  6883. * @returns true if there is an intersection
  6884. */
  6885. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6886. /**
  6887. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6888. * @param min defines the min vector to use
  6889. * @param max defines the max vector to use
  6890. * @returns true if there is an intersection
  6891. */
  6892. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6893. /**
  6894. * Tests if two bounding boxes are intersections
  6895. * @param box0 defines the first box to test
  6896. * @param box1 defines the second box to test
  6897. * @returns true if there is an intersection
  6898. */
  6899. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6900. /**
  6901. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6902. * @param minPoint defines the minimum vector of the bounding box
  6903. * @param maxPoint defines the maximum vector of the bounding box
  6904. * @param sphereCenter defines the sphere center
  6905. * @param sphereRadius defines the sphere radius
  6906. * @returns true if there is an intersection
  6907. */
  6908. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6909. /**
  6910. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6911. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6912. * @param frustumPlanes defines the frustum planes to test
  6913. * @return true if there is an inclusion
  6914. */
  6915. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6916. /**
  6917. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6918. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6919. * @param frustumPlanes defines the frustum planes to test
  6920. * @return true if there is an intersection
  6921. */
  6922. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6923. }
  6924. }
  6925. declare module "babylonjs/Collisions/collider" {
  6926. import { Nullable, IndicesArray } from "babylonjs/types";
  6927. import { Vector3 } from "babylonjs/Maths/math.vector";
  6928. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  6929. import { Plane } from "babylonjs/Maths/math.plane";
  6930. /** @hidden */
  6931. export class Collider {
  6932. /** Define if a collision was found */
  6933. collisionFound: boolean;
  6934. /**
  6935. * Define last intersection point in local space
  6936. */
  6937. intersectionPoint: Vector3;
  6938. /**
  6939. * Define last collided mesh
  6940. */
  6941. collidedMesh: Nullable<AbstractMesh>;
  6942. private _collisionPoint;
  6943. private _planeIntersectionPoint;
  6944. private _tempVector;
  6945. private _tempVector2;
  6946. private _tempVector3;
  6947. private _tempVector4;
  6948. private _edge;
  6949. private _baseToVertex;
  6950. private _destinationPoint;
  6951. private _slidePlaneNormal;
  6952. private _displacementVector;
  6953. /** @hidden */
  6954. _radius: Vector3;
  6955. /** @hidden */
  6956. _retry: number;
  6957. private _velocity;
  6958. private _basePoint;
  6959. private _epsilon;
  6960. /** @hidden */
  6961. _velocityWorldLength: number;
  6962. /** @hidden */
  6963. _basePointWorld: Vector3;
  6964. private _velocityWorld;
  6965. private _normalizedVelocity;
  6966. /** @hidden */
  6967. _initialVelocity: Vector3;
  6968. /** @hidden */
  6969. _initialPosition: Vector3;
  6970. private _nearestDistance;
  6971. private _collisionMask;
  6972. collisionMask: number;
  6973. /**
  6974. * Gets the plane normal used to compute the sliding response (in local space)
  6975. */
  6976. readonly slidePlaneNormal: Vector3;
  6977. /** @hidden */
  6978. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6979. /** @hidden */
  6980. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6981. /** @hidden */
  6982. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6983. /** @hidden */
  6984. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6985. /** @hidden */
  6986. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6987. /** @hidden */
  6988. _getResponse(pos: Vector3, vel: Vector3): void;
  6989. }
  6990. }
  6991. declare module "babylonjs/Culling/boundingInfo" {
  6992. import { DeepImmutable } from "babylonjs/types";
  6993. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6994. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  6995. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6996. import { Plane } from "babylonjs/Maths/math.plane";
  6997. import { Collider } from "babylonjs/Collisions/collider";
  6998. /**
  6999. * Interface for cullable objects
  7000. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7001. */
  7002. export interface ICullable {
  7003. /**
  7004. * Checks if the object or part of the object is in the frustum
  7005. * @param frustumPlanes Camera near/planes
  7006. * @returns true if the object is in frustum otherwise false
  7007. */
  7008. isInFrustum(frustumPlanes: Plane[]): boolean;
  7009. /**
  7010. * Checks if a cullable object (mesh...) is in the camera frustum
  7011. * Unlike isInFrustum this cheks the full bounding box
  7012. * @param frustumPlanes Camera near/planes
  7013. * @returns true if the object is in frustum otherwise false
  7014. */
  7015. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7016. }
  7017. /**
  7018. * Info for a bounding data of a mesh
  7019. */
  7020. export class BoundingInfo implements ICullable {
  7021. /**
  7022. * Bounding box for the mesh
  7023. */
  7024. readonly boundingBox: BoundingBox;
  7025. /**
  7026. * Bounding sphere for the mesh
  7027. */
  7028. readonly boundingSphere: BoundingSphere;
  7029. private _isLocked;
  7030. private static readonly TmpVector3;
  7031. /**
  7032. * Constructs bounding info
  7033. * @param minimum min vector of the bounding box/sphere
  7034. * @param maximum max vector of the bounding box/sphere
  7035. * @param worldMatrix defines the new world matrix
  7036. */
  7037. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7038. /**
  7039. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7040. * @param min defines the new minimum vector (in local space)
  7041. * @param max defines the new maximum vector (in local space)
  7042. * @param worldMatrix defines the new world matrix
  7043. */
  7044. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7045. /**
  7046. * min vector of the bounding box/sphere
  7047. */
  7048. readonly minimum: Vector3;
  7049. /**
  7050. * max vector of the bounding box/sphere
  7051. */
  7052. readonly maximum: Vector3;
  7053. /**
  7054. * If the info is locked and won't be updated to avoid perf overhead
  7055. */
  7056. isLocked: boolean;
  7057. /**
  7058. * Updates the bounding sphere and box
  7059. * @param world world matrix to be used to update
  7060. */
  7061. update(world: DeepImmutable<Matrix>): void;
  7062. /**
  7063. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7064. * @param center New center of the bounding info
  7065. * @param extend New extend of the bounding info
  7066. * @returns the current bounding info
  7067. */
  7068. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7069. /**
  7070. * Scale the current bounding info by applying a scale factor
  7071. * @param factor defines the scale factor to apply
  7072. * @returns the current bounding info
  7073. */
  7074. scale(factor: number): BoundingInfo;
  7075. /**
  7076. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7077. * @param frustumPlanes defines the frustum to test
  7078. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7079. * @returns true if the bounding info is in the frustum planes
  7080. */
  7081. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7082. /**
  7083. * Gets the world distance between the min and max points of the bounding box
  7084. */
  7085. readonly diagonalLength: number;
  7086. /**
  7087. * Checks if a cullable object (mesh...) is in the camera frustum
  7088. * Unlike isInFrustum this cheks the full bounding box
  7089. * @param frustumPlanes Camera near/planes
  7090. * @returns true if the object is in frustum otherwise false
  7091. */
  7092. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7093. /** @hidden */
  7094. _checkCollision(collider: Collider): boolean;
  7095. /**
  7096. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7097. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7098. * @param point the point to check intersection with
  7099. * @returns if the point intersects
  7100. */
  7101. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7102. /**
  7103. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7104. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7105. * @param boundingInfo the bounding info to check intersection with
  7106. * @param precise if the intersection should be done using OBB
  7107. * @returns if the bounding info intersects
  7108. */
  7109. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7110. }
  7111. }
  7112. declare module "babylonjs/Maths/math.functions" {
  7113. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7114. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7115. /**
  7116. * Extracts minimum and maximum values from a list of indexed positions
  7117. * @param positions defines the positions to use
  7118. * @param indices defines the indices to the positions
  7119. * @param indexStart defines the start index
  7120. * @param indexCount defines the end index
  7121. * @param bias defines bias value to add to the result
  7122. * @return minimum and maximum values
  7123. */
  7124. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7125. minimum: Vector3;
  7126. maximum: Vector3;
  7127. };
  7128. /**
  7129. * Extracts minimum and maximum values from a list of positions
  7130. * @param positions defines the positions to use
  7131. * @param start defines the start index in the positions array
  7132. * @param count defines the number of positions to handle
  7133. * @param bias defines bias value to add to the result
  7134. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7135. * @return minimum and maximum values
  7136. */
  7137. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7138. minimum: Vector3;
  7139. maximum: Vector3;
  7140. };
  7141. }
  7142. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7143. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7144. /** @hidden */
  7145. export class WebGLDataBuffer extends DataBuffer {
  7146. private _buffer;
  7147. constructor(resource: WebGLBuffer);
  7148. readonly underlyingResource: any;
  7149. }
  7150. }
  7151. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7152. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7153. import { Nullable } from "babylonjs/types";
  7154. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7155. /** @hidden */
  7156. export class WebGLPipelineContext implements IPipelineContext {
  7157. engine: ThinEngine;
  7158. program: Nullable<WebGLProgram>;
  7159. context?: WebGLRenderingContext;
  7160. vertexShader?: WebGLShader;
  7161. fragmentShader?: WebGLShader;
  7162. isParallelCompiled: boolean;
  7163. onCompiled?: () => void;
  7164. transformFeedback?: WebGLTransformFeedback | null;
  7165. readonly isAsync: boolean;
  7166. readonly isReady: boolean;
  7167. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7168. }
  7169. }
  7170. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7171. import { FloatArray, Nullable } from "babylonjs/types";
  7172. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7173. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7174. module "babylonjs/Engines/thinEngine" {
  7175. interface ThinEngine {
  7176. /**
  7177. * Create an uniform buffer
  7178. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7179. * @param elements defines the content of the uniform buffer
  7180. * @returns the webGL uniform buffer
  7181. */
  7182. createUniformBuffer(elements: FloatArray): DataBuffer;
  7183. /**
  7184. * Create a dynamic uniform buffer
  7185. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7186. * @param elements defines the content of the uniform buffer
  7187. * @returns the webGL uniform buffer
  7188. */
  7189. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7190. /**
  7191. * Update an existing uniform buffer
  7192. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7193. * @param uniformBuffer defines the target uniform buffer
  7194. * @param elements defines the content to update
  7195. * @param offset defines the offset in the uniform buffer where update should start
  7196. * @param count defines the size of the data to update
  7197. */
  7198. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7199. /**
  7200. * Bind an uniform buffer to the current webGL context
  7201. * @param buffer defines the buffer to bind
  7202. */
  7203. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7204. /**
  7205. * Bind a buffer to the current webGL context at a given location
  7206. * @param buffer defines the buffer to bind
  7207. * @param location defines the index where to bind the buffer
  7208. */
  7209. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7210. /**
  7211. * Bind a specific block at a given index in a specific shader program
  7212. * @param pipelineContext defines the pipeline context to use
  7213. * @param blockName defines the block name
  7214. * @param index defines the index where to bind the block
  7215. */
  7216. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7217. }
  7218. }
  7219. }
  7220. declare module "babylonjs/Materials/uniformBuffer" {
  7221. import { Nullable, FloatArray } from "babylonjs/types";
  7222. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7223. import { Engine } from "babylonjs/Engines/engine";
  7224. import { Effect } from "babylonjs/Materials/effect";
  7225. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7226. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7227. import { Color3 } from "babylonjs/Maths/math.color";
  7228. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7229. /**
  7230. * Uniform buffer objects.
  7231. *
  7232. * Handles blocks of uniform on the GPU.
  7233. *
  7234. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7235. *
  7236. * For more information, please refer to :
  7237. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7238. */
  7239. export class UniformBuffer {
  7240. private _engine;
  7241. private _buffer;
  7242. private _data;
  7243. private _bufferData;
  7244. private _dynamic?;
  7245. private _uniformLocations;
  7246. private _uniformSizes;
  7247. private _uniformLocationPointer;
  7248. private _needSync;
  7249. private _noUBO;
  7250. private _currentEffect;
  7251. private static _MAX_UNIFORM_SIZE;
  7252. private static _tempBuffer;
  7253. /**
  7254. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7255. * This is dynamic to allow compat with webgl 1 and 2.
  7256. * You will need to pass the name of the uniform as well as the value.
  7257. */
  7258. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7259. /**
  7260. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7261. * This is dynamic to allow compat with webgl 1 and 2.
  7262. * You will need to pass the name of the uniform as well as the value.
  7263. */
  7264. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7265. /**
  7266. * Lambda to Update a single float in a uniform buffer.
  7267. * This is dynamic to allow compat with webgl 1 and 2.
  7268. * You will need to pass the name of the uniform as well as the value.
  7269. */
  7270. updateFloat: (name: string, x: number) => void;
  7271. /**
  7272. * Lambda to Update a vec2 of float in a uniform buffer.
  7273. * This is dynamic to allow compat with webgl 1 and 2.
  7274. * You will need to pass the name of the uniform as well as the value.
  7275. */
  7276. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7277. /**
  7278. * Lambda to Update a vec3 of float in a uniform buffer.
  7279. * This is dynamic to allow compat with webgl 1 and 2.
  7280. * You will need to pass the name of the uniform as well as the value.
  7281. */
  7282. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7283. /**
  7284. * Lambda to Update a vec4 of float in a uniform buffer.
  7285. * This is dynamic to allow compat with webgl 1 and 2.
  7286. * You will need to pass the name of the uniform as well as the value.
  7287. */
  7288. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7289. /**
  7290. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7291. * This is dynamic to allow compat with webgl 1 and 2.
  7292. * You will need to pass the name of the uniform as well as the value.
  7293. */
  7294. updateMatrix: (name: string, mat: Matrix) => void;
  7295. /**
  7296. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7297. * This is dynamic to allow compat with webgl 1 and 2.
  7298. * You will need to pass the name of the uniform as well as the value.
  7299. */
  7300. updateVector3: (name: string, vector: Vector3) => void;
  7301. /**
  7302. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7303. * This is dynamic to allow compat with webgl 1 and 2.
  7304. * You will need to pass the name of the uniform as well as the value.
  7305. */
  7306. updateVector4: (name: string, vector: Vector4) => void;
  7307. /**
  7308. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7309. * This is dynamic to allow compat with webgl 1 and 2.
  7310. * You will need to pass the name of the uniform as well as the value.
  7311. */
  7312. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7313. /**
  7314. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7315. * This is dynamic to allow compat with webgl 1 and 2.
  7316. * You will need to pass the name of the uniform as well as the value.
  7317. */
  7318. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7319. /**
  7320. * Instantiates a new Uniform buffer objects.
  7321. *
  7322. * Handles blocks of uniform on the GPU.
  7323. *
  7324. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7325. *
  7326. * For more information, please refer to :
  7327. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7328. * @param engine Define the engine the buffer is associated with
  7329. * @param data Define the data contained in the buffer
  7330. * @param dynamic Define if the buffer is updatable
  7331. */
  7332. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7333. /**
  7334. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7335. * or just falling back on setUniformXXX calls.
  7336. */
  7337. readonly useUbo: boolean;
  7338. /**
  7339. * Indicates if the WebGL underlying uniform buffer is in sync
  7340. * with the javascript cache data.
  7341. */
  7342. readonly isSync: boolean;
  7343. /**
  7344. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7345. * Also, a dynamic UniformBuffer will disable cache verification and always
  7346. * update the underlying WebGL uniform buffer to the GPU.
  7347. * @returns if Dynamic, otherwise false
  7348. */
  7349. isDynamic(): boolean;
  7350. /**
  7351. * The data cache on JS side.
  7352. * @returns the underlying data as a float array
  7353. */
  7354. getData(): Float32Array;
  7355. /**
  7356. * The underlying WebGL Uniform buffer.
  7357. * @returns the webgl buffer
  7358. */
  7359. getBuffer(): Nullable<DataBuffer>;
  7360. /**
  7361. * std140 layout specifies how to align data within an UBO structure.
  7362. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7363. * for specs.
  7364. */
  7365. private _fillAlignment;
  7366. /**
  7367. * Adds an uniform in the buffer.
  7368. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7369. * for the layout to be correct !
  7370. * @param name Name of the uniform, as used in the uniform block in the shader.
  7371. * @param size Data size, or data directly.
  7372. */
  7373. addUniform(name: string, size: number | number[]): void;
  7374. /**
  7375. * Adds a Matrix 4x4 to the uniform buffer.
  7376. * @param name Name of the uniform, as used in the uniform block in the shader.
  7377. * @param mat A 4x4 matrix.
  7378. */
  7379. addMatrix(name: string, mat: Matrix): void;
  7380. /**
  7381. * Adds a vec2 to the uniform buffer.
  7382. * @param name Name of the uniform, as used in the uniform block in the shader.
  7383. * @param x Define the x component value of the vec2
  7384. * @param y Define the y component value of the vec2
  7385. */
  7386. addFloat2(name: string, x: number, y: number): void;
  7387. /**
  7388. * Adds a vec3 to the uniform buffer.
  7389. * @param name Name of the uniform, as used in the uniform block in the shader.
  7390. * @param x Define the x component value of the vec3
  7391. * @param y Define the y component value of the vec3
  7392. * @param z Define the z component value of the vec3
  7393. */
  7394. addFloat3(name: string, x: number, y: number, z: number): void;
  7395. /**
  7396. * Adds a vec3 to the uniform buffer.
  7397. * @param name Name of the uniform, as used in the uniform block in the shader.
  7398. * @param color Define the vec3 from a Color
  7399. */
  7400. addColor3(name: string, color: Color3): void;
  7401. /**
  7402. * Adds a vec4 to the uniform buffer.
  7403. * @param name Name of the uniform, as used in the uniform block in the shader.
  7404. * @param color Define the rgb components from a Color
  7405. * @param alpha Define the a component of the vec4
  7406. */
  7407. addColor4(name: string, color: Color3, alpha: number): void;
  7408. /**
  7409. * Adds a vec3 to the uniform buffer.
  7410. * @param name Name of the uniform, as used in the uniform block in the shader.
  7411. * @param vector Define the vec3 components from a Vector
  7412. */
  7413. addVector3(name: string, vector: Vector3): void;
  7414. /**
  7415. * Adds a Matrix 3x3 to the uniform buffer.
  7416. * @param name Name of the uniform, as used in the uniform block in the shader.
  7417. */
  7418. addMatrix3x3(name: string): void;
  7419. /**
  7420. * Adds a Matrix 2x2 to the uniform buffer.
  7421. * @param name Name of the uniform, as used in the uniform block in the shader.
  7422. */
  7423. addMatrix2x2(name: string): void;
  7424. /**
  7425. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7426. */
  7427. create(): void;
  7428. /** @hidden */
  7429. _rebuild(): void;
  7430. /**
  7431. * Updates the WebGL Uniform Buffer on the GPU.
  7432. * If the `dynamic` flag is set to true, no cache comparison is done.
  7433. * Otherwise, the buffer will be updated only if the cache differs.
  7434. */
  7435. update(): void;
  7436. /**
  7437. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7438. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7439. * @param data Define the flattened data
  7440. * @param size Define the size of the data.
  7441. */
  7442. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7443. private _valueCache;
  7444. private _cacheMatrix;
  7445. private _updateMatrix3x3ForUniform;
  7446. private _updateMatrix3x3ForEffect;
  7447. private _updateMatrix2x2ForEffect;
  7448. private _updateMatrix2x2ForUniform;
  7449. private _updateFloatForEffect;
  7450. private _updateFloatForUniform;
  7451. private _updateFloat2ForEffect;
  7452. private _updateFloat2ForUniform;
  7453. private _updateFloat3ForEffect;
  7454. private _updateFloat3ForUniform;
  7455. private _updateFloat4ForEffect;
  7456. private _updateFloat4ForUniform;
  7457. private _updateMatrixForEffect;
  7458. private _updateMatrixForUniform;
  7459. private _updateVector3ForEffect;
  7460. private _updateVector3ForUniform;
  7461. private _updateVector4ForEffect;
  7462. private _updateVector4ForUniform;
  7463. private _updateColor3ForEffect;
  7464. private _updateColor3ForUniform;
  7465. private _updateColor4ForEffect;
  7466. private _updateColor4ForUniform;
  7467. /**
  7468. * Sets a sampler uniform on the effect.
  7469. * @param name Define the name of the sampler.
  7470. * @param texture Define the texture to set in the sampler
  7471. */
  7472. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7473. /**
  7474. * Directly updates the value of the uniform in the cache AND on the GPU.
  7475. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7476. * @param data Define the flattened data
  7477. */
  7478. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7479. /**
  7480. * Binds this uniform buffer to an effect.
  7481. * @param effect Define the effect to bind the buffer to
  7482. * @param name Name of the uniform block in the shader.
  7483. */
  7484. bindToEffect(effect: Effect, name: string): void;
  7485. /**
  7486. * Disposes the uniform buffer.
  7487. */
  7488. dispose(): void;
  7489. }
  7490. }
  7491. declare module "babylonjs/Misc/iInspectable" {
  7492. /**
  7493. * Enum that determines the text-wrapping mode to use.
  7494. */
  7495. export enum InspectableType {
  7496. /**
  7497. * Checkbox for booleans
  7498. */
  7499. Checkbox = 0,
  7500. /**
  7501. * Sliders for numbers
  7502. */
  7503. Slider = 1,
  7504. /**
  7505. * Vector3
  7506. */
  7507. Vector3 = 2,
  7508. /**
  7509. * Quaternions
  7510. */
  7511. Quaternion = 3,
  7512. /**
  7513. * Color3
  7514. */
  7515. Color3 = 4,
  7516. /**
  7517. * String
  7518. */
  7519. String = 5
  7520. }
  7521. /**
  7522. * Interface used to define custom inspectable properties.
  7523. * This interface is used by the inspector to display custom property grids
  7524. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7525. */
  7526. export interface IInspectable {
  7527. /**
  7528. * Gets the label to display
  7529. */
  7530. label: string;
  7531. /**
  7532. * Gets the name of the property to edit
  7533. */
  7534. propertyName: string;
  7535. /**
  7536. * Gets the type of the editor to use
  7537. */
  7538. type: InspectableType;
  7539. /**
  7540. * Gets the minimum value of the property when using in "slider" mode
  7541. */
  7542. min?: number;
  7543. /**
  7544. * Gets the maximum value of the property when using in "slider" mode
  7545. */
  7546. max?: number;
  7547. /**
  7548. * Gets the setp to use when using in "slider" mode
  7549. */
  7550. step?: number;
  7551. }
  7552. }
  7553. declare module "babylonjs/Misc/timingTools" {
  7554. /**
  7555. * Class used to provide helper for timing
  7556. */
  7557. export class TimingTools {
  7558. /**
  7559. * Polyfill for setImmediate
  7560. * @param action defines the action to execute after the current execution block
  7561. */
  7562. static SetImmediate(action: () => void): void;
  7563. }
  7564. }
  7565. declare module "babylonjs/Misc/instantiationTools" {
  7566. /**
  7567. * Class used to enable instatition of objects by class name
  7568. */
  7569. export class InstantiationTools {
  7570. /**
  7571. * Use this object to register external classes like custom textures or material
  7572. * to allow the laoders to instantiate them
  7573. */
  7574. static RegisteredExternalClasses: {
  7575. [key: string]: Object;
  7576. };
  7577. /**
  7578. * Tries to instantiate a new object from a given class name
  7579. * @param className defines the class name to instantiate
  7580. * @returns the new object or null if the system was not able to do the instantiation
  7581. */
  7582. static Instantiate(className: string): any;
  7583. }
  7584. }
  7585. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7586. /**
  7587. * Define options used to create a depth texture
  7588. */
  7589. export class DepthTextureCreationOptions {
  7590. /** Specifies whether or not a stencil should be allocated in the texture */
  7591. generateStencil?: boolean;
  7592. /** Specifies whether or not bilinear filtering is enable on the texture */
  7593. bilinearFiltering?: boolean;
  7594. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7595. comparisonFunction?: number;
  7596. /** Specifies if the created texture is a cube texture */
  7597. isCube?: boolean;
  7598. }
  7599. }
  7600. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7601. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7602. import { Nullable } from "babylonjs/types";
  7603. import { Scene } from "babylonjs/scene";
  7604. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7605. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7606. module "babylonjs/Engines/thinEngine" {
  7607. interface ThinEngine {
  7608. /**
  7609. * Creates a depth stencil cube texture.
  7610. * This is only available in WebGL 2.
  7611. * @param size The size of face edge in the cube texture.
  7612. * @param options The options defining the cube texture.
  7613. * @returns The cube texture
  7614. */
  7615. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7616. /**
  7617. * Creates a cube texture
  7618. * @param rootUrl defines the url where the files to load is located
  7619. * @param scene defines the current scene
  7620. * @param files defines the list of files to load (1 per face)
  7621. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7622. * @param onLoad defines an optional callback raised when the texture is loaded
  7623. * @param onError defines an optional callback raised if there is an issue to load the texture
  7624. * @param format defines the format of the data
  7625. * @param forcedExtension defines the extension to use to pick the right loader
  7626. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7627. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7628. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7629. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7630. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7631. * @returns the cube texture as an InternalTexture
  7632. */
  7633. 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;
  7634. /**
  7635. * Creates a cube texture
  7636. * @param rootUrl defines the url where the files to load is located
  7637. * @param scene defines the current scene
  7638. * @param files defines the list of files to load (1 per face)
  7639. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7640. * @param onLoad defines an optional callback raised when the texture is loaded
  7641. * @param onError defines an optional callback raised if there is an issue to load the texture
  7642. * @param format defines the format of the data
  7643. * @param forcedExtension defines the extension to use to pick the right loader
  7644. * @returns the cube texture as an InternalTexture
  7645. */
  7646. 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;
  7647. /**
  7648. * Creates a cube texture
  7649. * @param rootUrl defines the url where the files to load is located
  7650. * @param scene defines the current scene
  7651. * @param files defines the list of files to load (1 per face)
  7652. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7653. * @param onLoad defines an optional callback raised when the texture is loaded
  7654. * @param onError defines an optional callback raised if there is an issue to load the texture
  7655. * @param format defines the format of the data
  7656. * @param forcedExtension defines the extension to use to pick the right loader
  7657. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7658. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7659. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7660. * @returns the cube texture as an InternalTexture
  7661. */
  7662. 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;
  7663. /** @hidden */
  7664. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7665. /** @hidden */
  7666. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7667. /** @hidden */
  7668. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7669. /** @hidden */
  7670. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7671. }
  7672. }
  7673. }
  7674. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7675. import { Nullable } from "babylonjs/types";
  7676. import { Scene } from "babylonjs/scene";
  7677. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7678. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7679. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7680. /**
  7681. * Class for creating a cube texture
  7682. */
  7683. export class CubeTexture extends BaseTexture {
  7684. private _delayedOnLoad;
  7685. /**
  7686. * The url of the texture
  7687. */
  7688. url: string;
  7689. /**
  7690. * Gets or sets the center of the bounding box associated with the cube texture.
  7691. * It must define where the camera used to render the texture was set
  7692. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7693. */
  7694. boundingBoxPosition: Vector3;
  7695. private _boundingBoxSize;
  7696. /**
  7697. * Gets or sets the size of the bounding box associated with the cube texture
  7698. * When defined, the cubemap will switch to local mode
  7699. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7700. * @example https://www.babylonjs-playground.com/#RNASML
  7701. */
  7702. /**
  7703. * Returns the bounding box size
  7704. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7705. */
  7706. boundingBoxSize: Vector3;
  7707. protected _rotationY: number;
  7708. /**
  7709. * Sets texture matrix rotation angle around Y axis in radians.
  7710. */
  7711. /**
  7712. * Gets texture matrix rotation angle around Y axis radians.
  7713. */
  7714. rotationY: number;
  7715. /**
  7716. * Are mip maps generated for this texture or not.
  7717. */
  7718. readonly noMipmap: boolean;
  7719. private _noMipmap;
  7720. private _files;
  7721. protected _forcedExtension: Nullable<string>;
  7722. private _extensions;
  7723. private _textureMatrix;
  7724. private _format;
  7725. private _createPolynomials;
  7726. /** @hidden */
  7727. _prefiltered: boolean;
  7728. /**
  7729. * Creates a cube texture from an array of image urls
  7730. * @param files defines an array of image urls
  7731. * @param scene defines the hosting scene
  7732. * @param noMipmap specifies if mip maps are not used
  7733. * @returns a cube texture
  7734. */
  7735. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7736. /**
  7737. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7738. * @param url defines the url of the prefiltered texture
  7739. * @param scene defines the scene the texture is attached to
  7740. * @param forcedExtension defines the extension of the file if different from the url
  7741. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7742. * @return the prefiltered texture
  7743. */
  7744. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7745. /**
  7746. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7747. * as prefiltered data.
  7748. * @param rootUrl defines the url of the texture or the root name of the six images
  7749. * @param scene defines the scene the texture is attached to
  7750. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7751. * @param noMipmap defines if mipmaps should be created or not
  7752. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7753. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7754. * @param onError defines a callback triggered in case of error during load
  7755. * @param format defines the internal format to use for the texture once loaded
  7756. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7757. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7758. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7759. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7760. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7761. * @return the cube texture
  7762. */
  7763. 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);
  7764. /**
  7765. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7766. */
  7767. readonly isPrefiltered: boolean;
  7768. /**
  7769. * Get the current class name of the texture useful for serialization or dynamic coding.
  7770. * @returns "CubeTexture"
  7771. */
  7772. getClassName(): string;
  7773. /**
  7774. * Update the url (and optional buffer) of this texture if url was null during construction.
  7775. * @param url the url of the texture
  7776. * @param forcedExtension defines the extension to use
  7777. * @param onLoad callback called when the texture is loaded (defaults to null)
  7778. */
  7779. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7780. /**
  7781. * Delays loading of the cube texture
  7782. * @param forcedExtension defines the extension to use
  7783. */
  7784. delayLoad(forcedExtension?: string): void;
  7785. /**
  7786. * Returns the reflection texture matrix
  7787. * @returns the reflection texture matrix
  7788. */
  7789. getReflectionTextureMatrix(): Matrix;
  7790. /**
  7791. * Sets the reflection texture matrix
  7792. * @param value Reflection texture matrix
  7793. */
  7794. setReflectionTextureMatrix(value: Matrix): void;
  7795. /**
  7796. * Parses text to create a cube texture
  7797. * @param parsedTexture define the serialized text to read from
  7798. * @param scene defines the hosting scene
  7799. * @param rootUrl defines the root url of the cube texture
  7800. * @returns a cube texture
  7801. */
  7802. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7803. /**
  7804. * Makes a clone, or deep copy, of the cube texture
  7805. * @returns a new cube texture
  7806. */
  7807. clone(): CubeTexture;
  7808. }
  7809. }
  7810. declare module "babylonjs/Materials/materialDefines" {
  7811. /**
  7812. * Manages the defines for the Material
  7813. */
  7814. export class MaterialDefines {
  7815. /** @hidden */
  7816. protected _keys: string[];
  7817. private _isDirty;
  7818. /** @hidden */
  7819. _renderId: number;
  7820. /** @hidden */
  7821. _areLightsDirty: boolean;
  7822. /** @hidden */
  7823. _areLightsDisposed: boolean;
  7824. /** @hidden */
  7825. _areAttributesDirty: boolean;
  7826. /** @hidden */
  7827. _areTexturesDirty: boolean;
  7828. /** @hidden */
  7829. _areFresnelDirty: boolean;
  7830. /** @hidden */
  7831. _areMiscDirty: boolean;
  7832. /** @hidden */
  7833. _areImageProcessingDirty: boolean;
  7834. /** @hidden */
  7835. _normals: boolean;
  7836. /** @hidden */
  7837. _uvs: boolean;
  7838. /** @hidden */
  7839. _needNormals: boolean;
  7840. /** @hidden */
  7841. _needUVs: boolean;
  7842. [id: string]: any;
  7843. /**
  7844. * Specifies if the material needs to be re-calculated
  7845. */
  7846. readonly isDirty: boolean;
  7847. /**
  7848. * Marks the material to indicate that it has been re-calculated
  7849. */
  7850. markAsProcessed(): void;
  7851. /**
  7852. * Marks the material to indicate that it needs to be re-calculated
  7853. */
  7854. markAsUnprocessed(): void;
  7855. /**
  7856. * Marks the material to indicate all of its defines need to be re-calculated
  7857. */
  7858. markAllAsDirty(): void;
  7859. /**
  7860. * Marks the material to indicate that image processing needs to be re-calculated
  7861. */
  7862. markAsImageProcessingDirty(): void;
  7863. /**
  7864. * Marks the material to indicate the lights need to be re-calculated
  7865. * @param disposed Defines whether the light is dirty due to dispose or not
  7866. */
  7867. markAsLightDirty(disposed?: boolean): void;
  7868. /**
  7869. * Marks the attribute state as changed
  7870. */
  7871. markAsAttributesDirty(): void;
  7872. /**
  7873. * Marks the texture state as changed
  7874. */
  7875. markAsTexturesDirty(): void;
  7876. /**
  7877. * Marks the fresnel state as changed
  7878. */
  7879. markAsFresnelDirty(): void;
  7880. /**
  7881. * Marks the misc state as changed
  7882. */
  7883. markAsMiscDirty(): void;
  7884. /**
  7885. * Rebuilds the material defines
  7886. */
  7887. rebuild(): void;
  7888. /**
  7889. * Specifies if two material defines are equal
  7890. * @param other - A material define instance to compare to
  7891. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7892. */
  7893. isEqual(other: MaterialDefines): boolean;
  7894. /**
  7895. * Clones this instance's defines to another instance
  7896. * @param other - material defines to clone values to
  7897. */
  7898. cloneTo(other: MaterialDefines): void;
  7899. /**
  7900. * Resets the material define values
  7901. */
  7902. reset(): void;
  7903. /**
  7904. * Converts the material define values to a string
  7905. * @returns - String of material define information
  7906. */
  7907. toString(): string;
  7908. }
  7909. }
  7910. declare module "babylonjs/Materials/colorCurves" {
  7911. import { Effect } from "babylonjs/Materials/effect";
  7912. /**
  7913. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7914. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7915. * 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;
  7916. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7917. */
  7918. export class ColorCurves {
  7919. private _dirty;
  7920. private _tempColor;
  7921. private _globalCurve;
  7922. private _highlightsCurve;
  7923. private _midtonesCurve;
  7924. private _shadowsCurve;
  7925. private _positiveCurve;
  7926. private _negativeCurve;
  7927. private _globalHue;
  7928. private _globalDensity;
  7929. private _globalSaturation;
  7930. private _globalExposure;
  7931. /**
  7932. * Gets the global Hue value.
  7933. * 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).
  7934. */
  7935. /**
  7936. * Sets the global Hue value.
  7937. * 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).
  7938. */
  7939. globalHue: number;
  7940. /**
  7941. * Gets the global Density value.
  7942. * 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.
  7943. * Values less than zero provide a filter of opposite hue.
  7944. */
  7945. /**
  7946. * Sets the global Density value.
  7947. * 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.
  7948. * Values less than zero provide a filter of opposite hue.
  7949. */
  7950. globalDensity: number;
  7951. /**
  7952. * Gets the global Saturation value.
  7953. * 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.
  7954. */
  7955. /**
  7956. * Sets the global Saturation value.
  7957. * 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.
  7958. */
  7959. globalSaturation: number;
  7960. /**
  7961. * Gets the global Exposure value.
  7962. * 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.
  7963. */
  7964. /**
  7965. * Sets the global Exposure value.
  7966. * 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.
  7967. */
  7968. globalExposure: number;
  7969. private _highlightsHue;
  7970. private _highlightsDensity;
  7971. private _highlightsSaturation;
  7972. private _highlightsExposure;
  7973. /**
  7974. * Gets the highlights Hue value.
  7975. * 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).
  7976. */
  7977. /**
  7978. * Sets the highlights Hue value.
  7979. * 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).
  7980. */
  7981. highlightsHue: number;
  7982. /**
  7983. * Gets the highlights Density value.
  7984. * 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.
  7985. * Values less than zero provide a filter of opposite hue.
  7986. */
  7987. /**
  7988. * Sets the highlights Density value.
  7989. * 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.
  7990. * Values less than zero provide a filter of opposite hue.
  7991. */
  7992. highlightsDensity: number;
  7993. /**
  7994. * Gets the highlights Saturation value.
  7995. * 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.
  7996. */
  7997. /**
  7998. * Sets the highlights Saturation value.
  7999. * 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.
  8000. */
  8001. highlightsSaturation: number;
  8002. /**
  8003. * Gets the highlights Exposure value.
  8004. * 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.
  8005. */
  8006. /**
  8007. * Sets the highlights Exposure value.
  8008. * 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.
  8009. */
  8010. highlightsExposure: number;
  8011. private _midtonesHue;
  8012. private _midtonesDensity;
  8013. private _midtonesSaturation;
  8014. private _midtonesExposure;
  8015. /**
  8016. * Gets the midtones Hue value.
  8017. * 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).
  8018. */
  8019. /**
  8020. * Sets the midtones Hue value.
  8021. * 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).
  8022. */
  8023. midtonesHue: number;
  8024. /**
  8025. * Gets the midtones Density value.
  8026. * 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.
  8027. * Values less than zero provide a filter of opposite hue.
  8028. */
  8029. /**
  8030. * Sets the midtones Density value.
  8031. * 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.
  8032. * Values less than zero provide a filter of opposite hue.
  8033. */
  8034. midtonesDensity: number;
  8035. /**
  8036. * Gets the midtones Saturation value.
  8037. * 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.
  8038. */
  8039. /**
  8040. * Sets the midtones Saturation value.
  8041. * 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.
  8042. */
  8043. midtonesSaturation: number;
  8044. /**
  8045. * Gets the midtones Exposure value.
  8046. * 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.
  8047. */
  8048. /**
  8049. * Sets the midtones Exposure value.
  8050. * 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.
  8051. */
  8052. midtonesExposure: number;
  8053. private _shadowsHue;
  8054. private _shadowsDensity;
  8055. private _shadowsSaturation;
  8056. private _shadowsExposure;
  8057. /**
  8058. * Gets the shadows Hue value.
  8059. * 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).
  8060. */
  8061. /**
  8062. * Sets the shadows Hue value.
  8063. * 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).
  8064. */
  8065. shadowsHue: number;
  8066. /**
  8067. * Gets the shadows Density value.
  8068. * 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.
  8069. * Values less than zero provide a filter of opposite hue.
  8070. */
  8071. /**
  8072. * Sets the shadows Density value.
  8073. * 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.
  8074. * Values less than zero provide a filter of opposite hue.
  8075. */
  8076. shadowsDensity: number;
  8077. /**
  8078. * Gets the shadows Saturation value.
  8079. * 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.
  8080. */
  8081. /**
  8082. * Sets the shadows Saturation value.
  8083. * 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.
  8084. */
  8085. shadowsSaturation: number;
  8086. /**
  8087. * Gets the shadows Exposure value.
  8088. * 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.
  8089. */
  8090. /**
  8091. * Sets the shadows Exposure value.
  8092. * 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.
  8093. */
  8094. shadowsExposure: number;
  8095. /**
  8096. * Returns the class name
  8097. * @returns The class name
  8098. */
  8099. getClassName(): string;
  8100. /**
  8101. * Binds the color curves to the shader.
  8102. * @param colorCurves The color curve to bind
  8103. * @param effect The effect to bind to
  8104. * @param positiveUniform The positive uniform shader parameter
  8105. * @param neutralUniform The neutral uniform shader parameter
  8106. * @param negativeUniform The negative uniform shader parameter
  8107. */
  8108. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8109. /**
  8110. * Prepare the list of uniforms associated with the ColorCurves effects.
  8111. * @param uniformsList The list of uniforms used in the effect
  8112. */
  8113. static PrepareUniforms(uniformsList: string[]): void;
  8114. /**
  8115. * Returns color grading data based on a hue, density, saturation and exposure value.
  8116. * @param filterHue The hue of the color filter.
  8117. * @param filterDensity The density of the color filter.
  8118. * @param saturation The saturation.
  8119. * @param exposure The exposure.
  8120. * @param result The result data container.
  8121. */
  8122. private getColorGradingDataToRef;
  8123. /**
  8124. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8125. * @param value The input slider value in range [-100,100].
  8126. * @returns Adjusted value.
  8127. */
  8128. private static applyColorGradingSliderNonlinear;
  8129. /**
  8130. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8131. * @param hue The hue (H) input.
  8132. * @param saturation The saturation (S) input.
  8133. * @param brightness The brightness (B) input.
  8134. * @result An RGBA color represented as Vector4.
  8135. */
  8136. private static fromHSBToRef;
  8137. /**
  8138. * Returns a value clamped between min and max
  8139. * @param value The value to clamp
  8140. * @param min The minimum of value
  8141. * @param max The maximum of value
  8142. * @returns The clamped value.
  8143. */
  8144. private static clamp;
  8145. /**
  8146. * Clones the current color curve instance.
  8147. * @return The cloned curves
  8148. */
  8149. clone(): ColorCurves;
  8150. /**
  8151. * Serializes the current color curve instance to a json representation.
  8152. * @return a JSON representation
  8153. */
  8154. serialize(): any;
  8155. /**
  8156. * Parses the color curve from a json representation.
  8157. * @param source the JSON source to parse
  8158. * @return The parsed curves
  8159. */
  8160. static Parse(source: any): ColorCurves;
  8161. }
  8162. }
  8163. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8164. import { Observable } from "babylonjs/Misc/observable";
  8165. import { Nullable } from "babylonjs/types";
  8166. import { Color4 } from "babylonjs/Maths/math.color";
  8167. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8168. import { Effect } from "babylonjs/Materials/effect";
  8169. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8170. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8171. /**
  8172. * Interface to follow in your material defines to integrate easily the
  8173. * Image proccessing functions.
  8174. * @hidden
  8175. */
  8176. export interface IImageProcessingConfigurationDefines {
  8177. IMAGEPROCESSING: boolean;
  8178. VIGNETTE: boolean;
  8179. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8180. VIGNETTEBLENDMODEOPAQUE: boolean;
  8181. TONEMAPPING: boolean;
  8182. TONEMAPPING_ACES: boolean;
  8183. CONTRAST: boolean;
  8184. EXPOSURE: boolean;
  8185. COLORCURVES: boolean;
  8186. COLORGRADING: boolean;
  8187. COLORGRADING3D: boolean;
  8188. SAMPLER3DGREENDEPTH: boolean;
  8189. SAMPLER3DBGRMAP: boolean;
  8190. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8191. }
  8192. /**
  8193. * @hidden
  8194. */
  8195. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8196. IMAGEPROCESSING: boolean;
  8197. VIGNETTE: boolean;
  8198. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8199. VIGNETTEBLENDMODEOPAQUE: boolean;
  8200. TONEMAPPING: boolean;
  8201. TONEMAPPING_ACES: boolean;
  8202. CONTRAST: boolean;
  8203. COLORCURVES: boolean;
  8204. COLORGRADING: boolean;
  8205. COLORGRADING3D: boolean;
  8206. SAMPLER3DGREENDEPTH: boolean;
  8207. SAMPLER3DBGRMAP: boolean;
  8208. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8209. EXPOSURE: boolean;
  8210. constructor();
  8211. }
  8212. /**
  8213. * This groups together the common properties used for image processing either in direct forward pass
  8214. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8215. * or not.
  8216. */
  8217. export class ImageProcessingConfiguration {
  8218. /**
  8219. * Default tone mapping applied in BabylonJS.
  8220. */
  8221. static readonly TONEMAPPING_STANDARD: number;
  8222. /**
  8223. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8224. * to other engines rendering to increase portability.
  8225. */
  8226. static readonly TONEMAPPING_ACES: number;
  8227. /**
  8228. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8229. */
  8230. colorCurves: Nullable<ColorCurves>;
  8231. private _colorCurvesEnabled;
  8232. /**
  8233. * Gets wether the color curves effect is enabled.
  8234. */
  8235. /**
  8236. * Sets wether the color curves effect is enabled.
  8237. */
  8238. colorCurvesEnabled: boolean;
  8239. private _colorGradingTexture;
  8240. /**
  8241. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8242. */
  8243. /**
  8244. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8245. */
  8246. colorGradingTexture: Nullable<BaseTexture>;
  8247. private _colorGradingEnabled;
  8248. /**
  8249. * Gets wether the color grading effect is enabled.
  8250. */
  8251. /**
  8252. * Sets wether the color grading effect is enabled.
  8253. */
  8254. colorGradingEnabled: boolean;
  8255. private _colorGradingWithGreenDepth;
  8256. /**
  8257. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8258. */
  8259. /**
  8260. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8261. */
  8262. colorGradingWithGreenDepth: boolean;
  8263. private _colorGradingBGR;
  8264. /**
  8265. * Gets wether the color grading texture contains BGR values.
  8266. */
  8267. /**
  8268. * Sets wether the color grading texture contains BGR values.
  8269. */
  8270. colorGradingBGR: boolean;
  8271. /** @hidden */
  8272. _exposure: number;
  8273. /**
  8274. * Gets the Exposure used in the effect.
  8275. */
  8276. /**
  8277. * Sets the Exposure used in the effect.
  8278. */
  8279. exposure: number;
  8280. private _toneMappingEnabled;
  8281. /**
  8282. * Gets wether the tone mapping effect is enabled.
  8283. */
  8284. /**
  8285. * Sets wether the tone mapping effect is enabled.
  8286. */
  8287. toneMappingEnabled: boolean;
  8288. private _toneMappingType;
  8289. /**
  8290. * Gets the type of tone mapping effect.
  8291. */
  8292. /**
  8293. * Sets the type of tone mapping effect used in BabylonJS.
  8294. */
  8295. toneMappingType: number;
  8296. protected _contrast: number;
  8297. /**
  8298. * Gets the contrast used in the effect.
  8299. */
  8300. /**
  8301. * Sets the contrast used in the effect.
  8302. */
  8303. contrast: number;
  8304. /**
  8305. * Vignette stretch size.
  8306. */
  8307. vignetteStretch: number;
  8308. /**
  8309. * Vignette centre X Offset.
  8310. */
  8311. vignetteCentreX: number;
  8312. /**
  8313. * Vignette centre Y Offset.
  8314. */
  8315. vignetteCentreY: number;
  8316. /**
  8317. * Vignette weight or intensity of the vignette effect.
  8318. */
  8319. vignetteWeight: number;
  8320. /**
  8321. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8322. * if vignetteEnabled is set to true.
  8323. */
  8324. vignetteColor: Color4;
  8325. /**
  8326. * Camera field of view used by the Vignette effect.
  8327. */
  8328. vignetteCameraFov: number;
  8329. private _vignetteBlendMode;
  8330. /**
  8331. * Gets the vignette blend mode allowing different kind of effect.
  8332. */
  8333. /**
  8334. * Sets the vignette blend mode allowing different kind of effect.
  8335. */
  8336. vignetteBlendMode: number;
  8337. private _vignetteEnabled;
  8338. /**
  8339. * Gets wether the vignette effect is enabled.
  8340. */
  8341. /**
  8342. * Sets wether the vignette effect is enabled.
  8343. */
  8344. vignetteEnabled: boolean;
  8345. private _applyByPostProcess;
  8346. /**
  8347. * Gets wether the image processing is applied through a post process or not.
  8348. */
  8349. /**
  8350. * Sets wether the image processing is applied through a post process or not.
  8351. */
  8352. applyByPostProcess: boolean;
  8353. private _isEnabled;
  8354. /**
  8355. * Gets wether the image processing is enabled or not.
  8356. */
  8357. /**
  8358. * Sets wether the image processing is enabled or not.
  8359. */
  8360. isEnabled: boolean;
  8361. /**
  8362. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8363. */
  8364. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8365. /**
  8366. * Method called each time the image processing information changes requires to recompile the effect.
  8367. */
  8368. protected _updateParameters(): void;
  8369. /**
  8370. * Gets the current class name.
  8371. * @return "ImageProcessingConfiguration"
  8372. */
  8373. getClassName(): string;
  8374. /**
  8375. * Prepare the list of uniforms associated with the Image Processing effects.
  8376. * @param uniforms The list of uniforms used in the effect
  8377. * @param defines the list of defines currently in use
  8378. */
  8379. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8380. /**
  8381. * Prepare the list of samplers associated with the Image Processing effects.
  8382. * @param samplersList The list of uniforms used in the effect
  8383. * @param defines the list of defines currently in use
  8384. */
  8385. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8386. /**
  8387. * Prepare the list of defines associated to the shader.
  8388. * @param defines the list of defines to complete
  8389. * @param forPostProcess Define if we are currently in post process mode or not
  8390. */
  8391. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8392. /**
  8393. * Returns true if all the image processing information are ready.
  8394. * @returns True if ready, otherwise, false
  8395. */
  8396. isReady(): boolean;
  8397. /**
  8398. * Binds the image processing to the shader.
  8399. * @param effect The effect to bind to
  8400. * @param aspectRatio Define the current aspect ratio of the effect
  8401. */
  8402. bind(effect: Effect, aspectRatio?: number): void;
  8403. /**
  8404. * Clones the current image processing instance.
  8405. * @return The cloned image processing
  8406. */
  8407. clone(): ImageProcessingConfiguration;
  8408. /**
  8409. * Serializes the current image processing instance to a json representation.
  8410. * @return a JSON representation
  8411. */
  8412. serialize(): any;
  8413. /**
  8414. * Parses the image processing from a json representation.
  8415. * @param source the JSON source to parse
  8416. * @return The parsed image processing
  8417. */
  8418. static Parse(source: any): ImageProcessingConfiguration;
  8419. private static _VIGNETTEMODE_MULTIPLY;
  8420. private static _VIGNETTEMODE_OPAQUE;
  8421. /**
  8422. * Used to apply the vignette as a mix with the pixel color.
  8423. */
  8424. static readonly VIGNETTEMODE_MULTIPLY: number;
  8425. /**
  8426. * Used to apply the vignette as a replacement of the pixel color.
  8427. */
  8428. static readonly VIGNETTEMODE_OPAQUE: number;
  8429. }
  8430. }
  8431. declare module "babylonjs/Shaders/postprocess.vertex" {
  8432. /** @hidden */
  8433. export var postprocessVertexShader: {
  8434. name: string;
  8435. shader: string;
  8436. };
  8437. }
  8438. declare module "babylonjs/Maths/math.axis" {
  8439. import { Vector3 } from "babylonjs/Maths/math.vector";
  8440. /** Defines supported spaces */
  8441. export enum Space {
  8442. /** Local (object) space */
  8443. LOCAL = 0,
  8444. /** World space */
  8445. WORLD = 1,
  8446. /** Bone space */
  8447. BONE = 2
  8448. }
  8449. /** Defines the 3 main axes */
  8450. export class Axis {
  8451. /** X axis */
  8452. static X: Vector3;
  8453. /** Y axis */
  8454. static Y: Vector3;
  8455. /** Z axis */
  8456. static Z: Vector3;
  8457. }
  8458. }
  8459. declare module "babylonjs/Cameras/targetCamera" {
  8460. import { Nullable } from "babylonjs/types";
  8461. import { Camera } from "babylonjs/Cameras/camera";
  8462. import { Scene } from "babylonjs/scene";
  8463. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8464. /**
  8465. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8466. * This is the base of the follow, arc rotate cameras and Free camera
  8467. * @see http://doc.babylonjs.com/features/cameras
  8468. */
  8469. export class TargetCamera extends Camera {
  8470. private static _RigCamTransformMatrix;
  8471. private static _TargetTransformMatrix;
  8472. private static _TargetFocalPoint;
  8473. /**
  8474. * Define the current direction the camera is moving to
  8475. */
  8476. cameraDirection: Vector3;
  8477. /**
  8478. * Define the current rotation the camera is rotating to
  8479. */
  8480. cameraRotation: Vector2;
  8481. /**
  8482. * When set, the up vector of the camera will be updated by the rotation of the camera
  8483. */
  8484. updateUpVectorFromRotation: boolean;
  8485. private _tmpQuaternion;
  8486. /**
  8487. * Define the current rotation of the camera
  8488. */
  8489. rotation: Vector3;
  8490. /**
  8491. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8492. */
  8493. rotationQuaternion: Quaternion;
  8494. /**
  8495. * Define the current speed of the camera
  8496. */
  8497. speed: number;
  8498. /**
  8499. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8500. * around all axis.
  8501. */
  8502. noRotationConstraint: boolean;
  8503. /**
  8504. * Define the current target of the camera as an object or a position.
  8505. */
  8506. lockedTarget: any;
  8507. /** @hidden */
  8508. _currentTarget: Vector3;
  8509. /** @hidden */
  8510. _initialFocalDistance: number;
  8511. /** @hidden */
  8512. _viewMatrix: Matrix;
  8513. /** @hidden */
  8514. _camMatrix: Matrix;
  8515. /** @hidden */
  8516. _cameraTransformMatrix: Matrix;
  8517. /** @hidden */
  8518. _cameraRotationMatrix: Matrix;
  8519. /** @hidden */
  8520. _referencePoint: Vector3;
  8521. /** @hidden */
  8522. _transformedReferencePoint: Vector3;
  8523. protected _globalCurrentTarget: Vector3;
  8524. protected _globalCurrentUpVector: Vector3;
  8525. /** @hidden */
  8526. _reset: () => void;
  8527. private _defaultUp;
  8528. /**
  8529. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8530. * This is the base of the follow, arc rotate cameras and Free camera
  8531. * @see http://doc.babylonjs.com/features/cameras
  8532. * @param name Defines the name of the camera in the scene
  8533. * @param position Defines the start position of the camera in the scene
  8534. * @param scene Defines the scene the camera belongs to
  8535. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8536. */
  8537. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8538. /**
  8539. * Gets the position in front of the camera at a given distance.
  8540. * @param distance The distance from the camera we want the position to be
  8541. * @returns the position
  8542. */
  8543. getFrontPosition(distance: number): Vector3;
  8544. /** @hidden */
  8545. _getLockedTargetPosition(): Nullable<Vector3>;
  8546. private _storedPosition;
  8547. private _storedRotation;
  8548. private _storedRotationQuaternion;
  8549. /**
  8550. * Store current camera state of the camera (fov, position, rotation, etc..)
  8551. * @returns the camera
  8552. */
  8553. storeState(): Camera;
  8554. /**
  8555. * Restored camera state. You must call storeState() first
  8556. * @returns whether it was successful or not
  8557. * @hidden
  8558. */
  8559. _restoreStateValues(): boolean;
  8560. /** @hidden */
  8561. _initCache(): void;
  8562. /** @hidden */
  8563. _updateCache(ignoreParentClass?: boolean): void;
  8564. /** @hidden */
  8565. _isSynchronizedViewMatrix(): boolean;
  8566. /** @hidden */
  8567. _computeLocalCameraSpeed(): number;
  8568. /**
  8569. * Defines the target the camera should look at.
  8570. * @param target Defines the new target as a Vector or a mesh
  8571. */
  8572. setTarget(target: Vector3): void;
  8573. /**
  8574. * Return the current target position of the camera. This value is expressed in local space.
  8575. * @returns the target position
  8576. */
  8577. getTarget(): Vector3;
  8578. /** @hidden */
  8579. _decideIfNeedsToMove(): boolean;
  8580. /** @hidden */
  8581. _updatePosition(): void;
  8582. /** @hidden */
  8583. _checkInputs(): void;
  8584. protected _updateCameraRotationMatrix(): void;
  8585. /**
  8586. * 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)
  8587. * @returns the current camera
  8588. */
  8589. private _rotateUpVectorWithCameraRotationMatrix;
  8590. private _cachedRotationZ;
  8591. private _cachedQuaternionRotationZ;
  8592. /** @hidden */
  8593. _getViewMatrix(): Matrix;
  8594. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8595. /**
  8596. * @hidden
  8597. */
  8598. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8599. /**
  8600. * @hidden
  8601. */
  8602. _updateRigCameras(): void;
  8603. private _getRigCamPositionAndTarget;
  8604. /**
  8605. * Gets the current object class name.
  8606. * @return the class name
  8607. */
  8608. getClassName(): string;
  8609. }
  8610. }
  8611. declare module "babylonjs/Events/keyboardEvents" {
  8612. /**
  8613. * Gather the list of keyboard event types as constants.
  8614. */
  8615. export class KeyboardEventTypes {
  8616. /**
  8617. * The keydown event is fired when a key becomes active (pressed).
  8618. */
  8619. static readonly KEYDOWN: number;
  8620. /**
  8621. * The keyup event is fired when a key has been released.
  8622. */
  8623. static readonly KEYUP: number;
  8624. }
  8625. /**
  8626. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8627. */
  8628. export class KeyboardInfo {
  8629. /**
  8630. * Defines the type of event (KeyboardEventTypes)
  8631. */
  8632. type: number;
  8633. /**
  8634. * Defines the related dom event
  8635. */
  8636. event: KeyboardEvent;
  8637. /**
  8638. * Instantiates a new keyboard info.
  8639. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8640. * @param type Defines the type of event (KeyboardEventTypes)
  8641. * @param event Defines the related dom event
  8642. */
  8643. constructor(
  8644. /**
  8645. * Defines the type of event (KeyboardEventTypes)
  8646. */
  8647. type: number,
  8648. /**
  8649. * Defines the related dom event
  8650. */
  8651. event: KeyboardEvent);
  8652. }
  8653. /**
  8654. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8655. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8656. */
  8657. export class KeyboardInfoPre extends KeyboardInfo {
  8658. /**
  8659. * Defines the type of event (KeyboardEventTypes)
  8660. */
  8661. type: number;
  8662. /**
  8663. * Defines the related dom event
  8664. */
  8665. event: KeyboardEvent;
  8666. /**
  8667. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8668. */
  8669. skipOnPointerObservable: boolean;
  8670. /**
  8671. * Instantiates a new keyboard pre info.
  8672. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8673. * @param type Defines the type of event (KeyboardEventTypes)
  8674. * @param event Defines the related dom event
  8675. */
  8676. constructor(
  8677. /**
  8678. * Defines the type of event (KeyboardEventTypes)
  8679. */
  8680. type: number,
  8681. /**
  8682. * Defines the related dom event
  8683. */
  8684. event: KeyboardEvent);
  8685. }
  8686. }
  8687. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8688. import { Nullable } from "babylonjs/types";
  8689. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8690. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8691. /**
  8692. * Manage the keyboard inputs to control the movement of a free camera.
  8693. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8694. */
  8695. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8696. /**
  8697. * Defines the camera the input is attached to.
  8698. */
  8699. camera: FreeCamera;
  8700. /**
  8701. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8702. */
  8703. keysUp: number[];
  8704. /**
  8705. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8706. */
  8707. keysDown: number[];
  8708. /**
  8709. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8710. */
  8711. keysLeft: number[];
  8712. /**
  8713. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8714. */
  8715. keysRight: number[];
  8716. private _keys;
  8717. private _onCanvasBlurObserver;
  8718. private _onKeyboardObserver;
  8719. private _engine;
  8720. private _scene;
  8721. /**
  8722. * Attach the input controls to a specific dom element to get the input from.
  8723. * @param element Defines the element the controls should be listened from
  8724. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8725. */
  8726. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8727. /**
  8728. * Detach the current controls from the specified dom element.
  8729. * @param element Defines the element to stop listening the inputs from
  8730. */
  8731. detachControl(element: Nullable<HTMLElement>): void;
  8732. /**
  8733. * Update the current camera state depending on the inputs that have been used this frame.
  8734. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8735. */
  8736. checkInputs(): void;
  8737. /**
  8738. * Gets the class name of the current intput.
  8739. * @returns the class name
  8740. */
  8741. getClassName(): string;
  8742. /** @hidden */
  8743. _onLostFocus(): void;
  8744. /**
  8745. * Get the friendly name associated with the input class.
  8746. * @returns the input friendly name
  8747. */
  8748. getSimpleName(): string;
  8749. }
  8750. }
  8751. declare module "babylonjs/Lights/shadowLight" {
  8752. import { Camera } from "babylonjs/Cameras/camera";
  8753. import { Scene } from "babylonjs/scene";
  8754. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8755. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8756. import { Light } from "babylonjs/Lights/light";
  8757. /**
  8758. * Interface describing all the common properties and methods a shadow light needs to implement.
  8759. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8760. * as well as binding the different shadow properties to the effects.
  8761. */
  8762. export interface IShadowLight extends Light {
  8763. /**
  8764. * The light id in the scene (used in scene.findLighById for instance)
  8765. */
  8766. id: string;
  8767. /**
  8768. * The position the shdow will be casted from.
  8769. */
  8770. position: Vector3;
  8771. /**
  8772. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8773. */
  8774. direction: Vector3;
  8775. /**
  8776. * The transformed position. Position of the light in world space taking parenting in account.
  8777. */
  8778. transformedPosition: Vector3;
  8779. /**
  8780. * The transformed direction. Direction of the light in world space taking parenting in account.
  8781. */
  8782. transformedDirection: Vector3;
  8783. /**
  8784. * The friendly name of the light in the scene.
  8785. */
  8786. name: string;
  8787. /**
  8788. * Defines the shadow projection clipping minimum z value.
  8789. */
  8790. shadowMinZ: number;
  8791. /**
  8792. * Defines the shadow projection clipping maximum z value.
  8793. */
  8794. shadowMaxZ: number;
  8795. /**
  8796. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8797. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8798. */
  8799. computeTransformedInformation(): boolean;
  8800. /**
  8801. * Gets the scene the light belongs to.
  8802. * @returns The scene
  8803. */
  8804. getScene(): Scene;
  8805. /**
  8806. * Callback defining a custom Projection Matrix Builder.
  8807. * This can be used to override the default projection matrix computation.
  8808. */
  8809. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8810. /**
  8811. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8812. * @param matrix The materix to updated with the projection information
  8813. * @param viewMatrix The transform matrix of the light
  8814. * @param renderList The list of mesh to render in the map
  8815. * @returns The current light
  8816. */
  8817. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8818. /**
  8819. * Gets the current depth scale used in ESM.
  8820. * @returns The scale
  8821. */
  8822. getDepthScale(): number;
  8823. /**
  8824. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8825. * @returns true if a cube texture needs to be use
  8826. */
  8827. needCube(): boolean;
  8828. /**
  8829. * Detects if the projection matrix requires to be recomputed this frame.
  8830. * @returns true if it requires to be recomputed otherwise, false.
  8831. */
  8832. needProjectionMatrixCompute(): boolean;
  8833. /**
  8834. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8835. */
  8836. forceProjectionMatrixCompute(): void;
  8837. /**
  8838. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8839. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8840. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8841. */
  8842. getShadowDirection(faceIndex?: number): Vector3;
  8843. /**
  8844. * Gets the minZ used for shadow according to both the scene and the light.
  8845. * @param activeCamera The camera we are returning the min for
  8846. * @returns the depth min z
  8847. */
  8848. getDepthMinZ(activeCamera: Camera): number;
  8849. /**
  8850. * Gets the maxZ used for shadow according to both the scene and the light.
  8851. * @param activeCamera The camera we are returning the max for
  8852. * @returns the depth max z
  8853. */
  8854. getDepthMaxZ(activeCamera: Camera): number;
  8855. }
  8856. /**
  8857. * Base implementation IShadowLight
  8858. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8859. */
  8860. export abstract class ShadowLight extends Light implements IShadowLight {
  8861. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8862. protected _position: Vector3;
  8863. protected _setPosition(value: Vector3): void;
  8864. /**
  8865. * Sets the position the shadow will be casted from. Also use as the light position for both
  8866. * point and spot lights.
  8867. */
  8868. /**
  8869. * Sets the position the shadow will be casted from. Also use as the light position for both
  8870. * point and spot lights.
  8871. */
  8872. position: Vector3;
  8873. protected _direction: Vector3;
  8874. protected _setDirection(value: Vector3): void;
  8875. /**
  8876. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8877. * Also use as the light direction on spot and directional lights.
  8878. */
  8879. /**
  8880. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8881. * Also use as the light direction on spot and directional lights.
  8882. */
  8883. direction: Vector3;
  8884. private _shadowMinZ;
  8885. /**
  8886. * Gets the shadow projection clipping minimum z value.
  8887. */
  8888. /**
  8889. * Sets the shadow projection clipping minimum z value.
  8890. */
  8891. shadowMinZ: number;
  8892. private _shadowMaxZ;
  8893. /**
  8894. * Sets the shadow projection clipping maximum z value.
  8895. */
  8896. /**
  8897. * Gets the shadow projection clipping maximum z value.
  8898. */
  8899. shadowMaxZ: number;
  8900. /**
  8901. * Callback defining a custom Projection Matrix Builder.
  8902. * This can be used to override the default projection matrix computation.
  8903. */
  8904. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8905. /**
  8906. * The transformed position. Position of the light in world space taking parenting in account.
  8907. */
  8908. transformedPosition: Vector3;
  8909. /**
  8910. * The transformed direction. Direction of the light in world space taking parenting in account.
  8911. */
  8912. transformedDirection: Vector3;
  8913. private _needProjectionMatrixCompute;
  8914. /**
  8915. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8916. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8917. */
  8918. computeTransformedInformation(): boolean;
  8919. /**
  8920. * Return the depth scale used for the shadow map.
  8921. * @returns the depth scale.
  8922. */
  8923. getDepthScale(): number;
  8924. /**
  8925. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8926. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8927. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8928. */
  8929. getShadowDirection(faceIndex?: number): Vector3;
  8930. /**
  8931. * Returns the ShadowLight absolute position in the World.
  8932. * @returns the position vector in world space
  8933. */
  8934. getAbsolutePosition(): Vector3;
  8935. /**
  8936. * Sets the ShadowLight direction toward the passed target.
  8937. * @param target The point to target in local space
  8938. * @returns the updated ShadowLight direction
  8939. */
  8940. setDirectionToTarget(target: Vector3): Vector3;
  8941. /**
  8942. * Returns the light rotation in euler definition.
  8943. * @returns the x y z rotation in local space.
  8944. */
  8945. getRotation(): Vector3;
  8946. /**
  8947. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8948. * @returns true if a cube texture needs to be use
  8949. */
  8950. needCube(): boolean;
  8951. /**
  8952. * Detects if the projection matrix requires to be recomputed this frame.
  8953. * @returns true if it requires to be recomputed otherwise, false.
  8954. */
  8955. needProjectionMatrixCompute(): boolean;
  8956. /**
  8957. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8958. */
  8959. forceProjectionMatrixCompute(): void;
  8960. /** @hidden */
  8961. _initCache(): void;
  8962. /** @hidden */
  8963. _isSynchronized(): boolean;
  8964. /**
  8965. * Computes the world matrix of the node
  8966. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8967. * @returns the world matrix
  8968. */
  8969. computeWorldMatrix(force?: boolean): Matrix;
  8970. /**
  8971. * Gets the minZ used for shadow according to both the scene and the light.
  8972. * @param activeCamera The camera we are returning the min for
  8973. * @returns the depth min z
  8974. */
  8975. getDepthMinZ(activeCamera: Camera): number;
  8976. /**
  8977. * Gets the maxZ used for shadow according to both the scene and the light.
  8978. * @param activeCamera The camera we are returning the max for
  8979. * @returns the depth max z
  8980. */
  8981. getDepthMaxZ(activeCamera: Camera): number;
  8982. /**
  8983. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8984. * @param matrix The materix to updated with the projection information
  8985. * @param viewMatrix The transform matrix of the light
  8986. * @param renderList The list of mesh to render in the map
  8987. * @returns The current light
  8988. */
  8989. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8990. }
  8991. }
  8992. declare module "babylonjs/Materials/effectFallbacks" {
  8993. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  8994. import { Effect } from "babylonjs/Materials/effect";
  8995. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8996. /**
  8997. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  8998. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  8999. */
  9000. export class EffectFallbacks implements IEffectFallbacks {
  9001. private _defines;
  9002. private _currentRank;
  9003. private _maxRank;
  9004. private _mesh;
  9005. /**
  9006. * Removes the fallback from the bound mesh.
  9007. */
  9008. unBindMesh(): void;
  9009. /**
  9010. * Adds a fallback on the specified property.
  9011. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9012. * @param define The name of the define in the shader
  9013. */
  9014. addFallback(rank: number, define: string): void;
  9015. /**
  9016. * Sets the mesh to use CPU skinning when needing to fallback.
  9017. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9018. * @param mesh The mesh to use the fallbacks.
  9019. */
  9020. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9021. /**
  9022. * Checks to see if more fallbacks are still availible.
  9023. */
  9024. readonly hasMoreFallbacks: boolean;
  9025. /**
  9026. * Removes the defines that should be removed when falling back.
  9027. * @param currentDefines defines the current define statements for the shader.
  9028. * @param effect defines the current effect we try to compile
  9029. * @returns The resulting defines with defines of the current rank removed.
  9030. */
  9031. reduce(currentDefines: string, effect: Effect): string;
  9032. }
  9033. }
  9034. declare module "babylonjs/Materials/materialHelper" {
  9035. import { Nullable } from "babylonjs/types";
  9036. import { Scene } from "babylonjs/scene";
  9037. import { Engine } from "babylonjs/Engines/engine";
  9038. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9039. import { Light } from "babylonjs/Lights/light";
  9040. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9041. import { Effect, EffectCreationOptions } from "babylonjs/Materials/effect";
  9042. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9043. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9044. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  9045. /**
  9046. * "Static Class" containing the most commonly used helper while dealing with material for
  9047. * rendering purpose.
  9048. *
  9049. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9050. *
  9051. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9052. */
  9053. export class MaterialHelper {
  9054. /**
  9055. * Bind the current view position to an effect.
  9056. * @param effect The effect to be bound
  9057. * @param scene The scene the eyes position is used from
  9058. */
  9059. static BindEyePosition(effect: Effect, scene: Scene): void;
  9060. /**
  9061. * Helps preparing the defines values about the UVs in used in the effect.
  9062. * UVs are shared as much as we can accross channels in the shaders.
  9063. * @param texture The texture we are preparing the UVs for
  9064. * @param defines The defines to update
  9065. * @param key The channel key "diffuse", "specular"... used in the shader
  9066. */
  9067. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9068. /**
  9069. * Binds a texture matrix value to its corrsponding uniform
  9070. * @param texture The texture to bind the matrix for
  9071. * @param uniformBuffer The uniform buffer receivin the data
  9072. * @param key The channel key "diffuse", "specular"... used in the shader
  9073. */
  9074. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9075. /**
  9076. * Gets the current status of the fog (should it be enabled?)
  9077. * @param mesh defines the mesh to evaluate for fog support
  9078. * @param scene defines the hosting scene
  9079. * @returns true if fog must be enabled
  9080. */
  9081. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9082. /**
  9083. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9084. * @param mesh defines the current mesh
  9085. * @param scene defines the current scene
  9086. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9087. * @param pointsCloud defines if point cloud rendering has to be turned on
  9088. * @param fogEnabled defines if fog has to be turned on
  9089. * @param alphaTest defines if alpha testing has to be turned on
  9090. * @param defines defines the current list of defines
  9091. */
  9092. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9093. /**
  9094. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9095. * @param scene defines the current scene
  9096. * @param engine defines the current engine
  9097. * @param defines specifies the list of active defines
  9098. * @param useInstances defines if instances have to be turned on
  9099. * @param useClipPlane defines if clip plane have to be turned on
  9100. */
  9101. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9102. /**
  9103. * Prepares the defines for bones
  9104. * @param mesh The mesh containing the geometry data we will draw
  9105. * @param defines The defines to update
  9106. */
  9107. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9108. /**
  9109. * Prepares the defines for morph targets
  9110. * @param mesh The mesh containing the geometry data we will draw
  9111. * @param defines The defines to update
  9112. */
  9113. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9114. /**
  9115. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9116. * @param mesh The mesh containing the geometry data we will draw
  9117. * @param defines The defines to update
  9118. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9119. * @param useBones Precise whether bones should be used or not (override mesh info)
  9120. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9121. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9122. * @returns false if defines are considered not dirty and have not been checked
  9123. */
  9124. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9125. /**
  9126. * Prepares the defines related to multiview
  9127. * @param scene The scene we are intending to draw
  9128. * @param defines The defines to update
  9129. */
  9130. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9131. /**
  9132. * Prepares the defines related to the light information passed in parameter
  9133. * @param scene The scene we are intending to draw
  9134. * @param mesh The mesh the effect is compiling for
  9135. * @param light The light the effect is compiling for
  9136. * @param lightIndex The index of the light
  9137. * @param defines The defines to update
  9138. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9139. * @param state Defines the current state regarding what is needed (normals, etc...)
  9140. */
  9141. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9142. needNormals: boolean;
  9143. needRebuild: boolean;
  9144. shadowEnabled: boolean;
  9145. specularEnabled: boolean;
  9146. lightmapMode: boolean;
  9147. }): void;
  9148. /**
  9149. * Prepares the defines related to the light information passed in parameter
  9150. * @param scene The scene we are intending to draw
  9151. * @param mesh The mesh the effect is compiling for
  9152. * @param defines The defines to update
  9153. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9154. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9155. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9156. * @returns true if normals will be required for the rest of the effect
  9157. */
  9158. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9159. /**
  9160. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9161. * @param lightIndex defines the light index
  9162. * @param uniformsList The uniform list
  9163. * @param samplersList The sampler list
  9164. * @param projectedLightTexture defines if projected texture must be used
  9165. * @param uniformBuffersList defines an optional list of uniform buffers
  9166. */
  9167. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9168. /**
  9169. * Prepares the uniforms and samplers list to be used in the effect
  9170. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9171. * @param samplersList The sampler list
  9172. * @param defines The defines helping in the list generation
  9173. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9174. */
  9175. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9176. /**
  9177. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9178. * @param defines The defines to update while falling back
  9179. * @param fallbacks The authorized effect fallbacks
  9180. * @param maxSimultaneousLights The maximum number of lights allowed
  9181. * @param rank the current rank of the Effect
  9182. * @returns The newly affected rank
  9183. */
  9184. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9185. private static _TmpMorphInfluencers;
  9186. /**
  9187. * Prepares the list of attributes required for morph targets according to the effect defines.
  9188. * @param attribs The current list of supported attribs
  9189. * @param mesh The mesh to prepare the morph targets attributes for
  9190. * @param influencers The number of influencers
  9191. */
  9192. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9193. /**
  9194. * Prepares the list of attributes required for morph targets according to the effect defines.
  9195. * @param attribs The current list of supported attribs
  9196. * @param mesh The mesh to prepare the morph targets attributes for
  9197. * @param defines The current Defines of the effect
  9198. */
  9199. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9200. /**
  9201. * Prepares the list of attributes required for bones according to the effect defines.
  9202. * @param attribs The current list of supported attribs
  9203. * @param mesh The mesh to prepare the bones attributes for
  9204. * @param defines The current Defines of the effect
  9205. * @param fallbacks The current efffect fallback strategy
  9206. */
  9207. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9208. /**
  9209. * Check and prepare the list of attributes required for instances according to the effect defines.
  9210. * @param attribs The current list of supported attribs
  9211. * @param defines The current MaterialDefines of the effect
  9212. */
  9213. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9214. /**
  9215. * Add the list of attributes required for instances to the attribs array.
  9216. * @param attribs The current list of supported attribs
  9217. */
  9218. static PushAttributesForInstances(attribs: string[]): void;
  9219. /**
  9220. * Binds the light shadow information to the effect for the given mesh.
  9221. * @param light The light containing the generator
  9222. * @param scene The scene the lights belongs to
  9223. * @param mesh The mesh we are binding the information to render
  9224. * @param lightIndex The light index in the effect used to render the mesh
  9225. * @param effect The effect we are binding the data to
  9226. */
  9227. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9228. /**
  9229. * Binds the light information to the effect.
  9230. * @param light The light containing the generator
  9231. * @param effect The effect we are binding the data to
  9232. * @param lightIndex The light index in the effect used to render
  9233. */
  9234. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9235. /**
  9236. * Binds the lights information from the scene to the effect for the given mesh.
  9237. * @param light Light to bind
  9238. * @param lightIndex Light index
  9239. * @param scene The scene where the light belongs to
  9240. * @param mesh The mesh we are binding the information to render
  9241. * @param effect The effect we are binding the data to
  9242. * @param useSpecular Defines if specular is supported
  9243. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9244. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9245. */
  9246. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9247. /**
  9248. * Binds the lights information from the scene to the effect for the given mesh.
  9249. * @param scene The scene the lights belongs to
  9250. * @param mesh The mesh we are binding the information to render
  9251. * @param effect The effect we are binding the data to
  9252. * @param defines The generated defines for the effect
  9253. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9254. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9255. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9256. */
  9257. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9258. private static _tempFogColor;
  9259. /**
  9260. * Binds the fog information from the scene to the effect for the given mesh.
  9261. * @param scene The scene the lights belongs to
  9262. * @param mesh The mesh we are binding the information to render
  9263. * @param effect The effect we are binding the data to
  9264. * @param linearSpace Defines if the fog effect is applied in linear space
  9265. */
  9266. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9267. /**
  9268. * Binds the bones information from the mesh to the effect.
  9269. * @param mesh The mesh we are binding the information to render
  9270. * @param effect The effect we are binding the data to
  9271. */
  9272. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9273. /**
  9274. * Binds the morph targets information from the mesh to the effect.
  9275. * @param abstractMesh The mesh we are binding the information to render
  9276. * @param effect The effect we are binding the data to
  9277. */
  9278. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9279. /**
  9280. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9281. * @param defines The generated defines used in the effect
  9282. * @param effect The effect we are binding the data to
  9283. * @param scene The scene we are willing to render with logarithmic scale for
  9284. */
  9285. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9286. /**
  9287. * Binds the clip plane information from the scene to the effect.
  9288. * @param scene The scene the clip plane information are extracted from
  9289. * @param effect The effect we are binding the data to
  9290. */
  9291. static BindClipPlane(effect: Effect, scene: Scene): void;
  9292. }
  9293. }
  9294. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9295. /** @hidden */
  9296. export var packingFunctions: {
  9297. name: string;
  9298. shader: string;
  9299. };
  9300. }
  9301. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9302. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9303. /** @hidden */
  9304. export var shadowMapPixelShader: {
  9305. name: string;
  9306. shader: string;
  9307. };
  9308. }
  9309. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9310. /** @hidden */
  9311. export var bonesDeclaration: {
  9312. name: string;
  9313. shader: string;
  9314. };
  9315. }
  9316. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9317. /** @hidden */
  9318. export var morphTargetsVertexGlobalDeclaration: {
  9319. name: string;
  9320. shader: string;
  9321. };
  9322. }
  9323. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9324. /** @hidden */
  9325. export var morphTargetsVertexDeclaration: {
  9326. name: string;
  9327. shader: string;
  9328. };
  9329. }
  9330. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9331. /** @hidden */
  9332. export var instancesDeclaration: {
  9333. name: string;
  9334. shader: string;
  9335. };
  9336. }
  9337. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9338. /** @hidden */
  9339. export var helperFunctions: {
  9340. name: string;
  9341. shader: string;
  9342. };
  9343. }
  9344. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9345. /** @hidden */
  9346. export var morphTargetsVertex: {
  9347. name: string;
  9348. shader: string;
  9349. };
  9350. }
  9351. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9352. /** @hidden */
  9353. export var instancesVertex: {
  9354. name: string;
  9355. shader: string;
  9356. };
  9357. }
  9358. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9359. /** @hidden */
  9360. export var bonesVertex: {
  9361. name: string;
  9362. shader: string;
  9363. };
  9364. }
  9365. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9366. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9367. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9368. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9369. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9370. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9371. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9372. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9373. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9374. /** @hidden */
  9375. export var shadowMapVertexShader: {
  9376. name: string;
  9377. shader: string;
  9378. };
  9379. }
  9380. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9381. /** @hidden */
  9382. export var depthBoxBlurPixelShader: {
  9383. name: string;
  9384. shader: string;
  9385. };
  9386. }
  9387. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9388. import { Nullable } from "babylonjs/types";
  9389. import { Scene } from "babylonjs/scene";
  9390. import { Matrix } from "babylonjs/Maths/math.vector";
  9391. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9392. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9393. import { Mesh } from "babylonjs/Meshes/mesh";
  9394. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9395. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9396. import { Effect } from "babylonjs/Materials/effect";
  9397. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9398. import "babylonjs/Shaders/shadowMap.fragment";
  9399. import "babylonjs/Shaders/shadowMap.vertex";
  9400. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9401. import { Observable } from "babylonjs/Misc/observable";
  9402. /**
  9403. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9404. */
  9405. export interface ICustomShaderOptions {
  9406. /**
  9407. * Gets or sets the custom shader name to use
  9408. */
  9409. shaderName: string;
  9410. /**
  9411. * The list of attribute names used in the shader
  9412. */
  9413. attributes?: string[];
  9414. /**
  9415. * The list of unifrom names used in the shader
  9416. */
  9417. uniforms?: string[];
  9418. /**
  9419. * The list of sampler names used in the shader
  9420. */
  9421. samplers?: string[];
  9422. /**
  9423. * The list of defines used in the shader
  9424. */
  9425. defines?: string[];
  9426. }
  9427. /**
  9428. * Interface to implement to create a shadow generator compatible with BJS.
  9429. */
  9430. export interface IShadowGenerator {
  9431. /**
  9432. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9433. * @returns The render target texture if present otherwise, null
  9434. */
  9435. getShadowMap(): Nullable<RenderTargetTexture>;
  9436. /**
  9437. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9438. * @returns The render target texture if the shadow map is present otherwise, null
  9439. */
  9440. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9441. /**
  9442. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9443. * @param subMesh The submesh we want to render in the shadow map
  9444. * @param useInstances Defines wether will draw in the map using instances
  9445. * @returns true if ready otherwise, false
  9446. */
  9447. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9448. /**
  9449. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9450. * @param defines Defines of the material we want to update
  9451. * @param lightIndex Index of the light in the enabled light list of the material
  9452. */
  9453. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9454. /**
  9455. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9456. * defined in the generator but impacting the effect).
  9457. * It implies the unifroms available on the materials are the standard BJS ones.
  9458. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9459. * @param effect The effect we are binfing the information for
  9460. */
  9461. bindShadowLight(lightIndex: string, effect: Effect): void;
  9462. /**
  9463. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9464. * (eq to shadow prjection matrix * light transform matrix)
  9465. * @returns The transform matrix used to create the shadow map
  9466. */
  9467. getTransformMatrix(): Matrix;
  9468. /**
  9469. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9470. * Cube and 2D textures for instance.
  9471. */
  9472. recreateShadowMap(): void;
  9473. /**
  9474. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9475. * @param onCompiled Callback triggered at the and of the effects compilation
  9476. * @param options Sets of optional options forcing the compilation with different modes
  9477. */
  9478. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9479. useInstances: boolean;
  9480. }>): void;
  9481. /**
  9482. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9483. * @param options Sets of optional options forcing the compilation with different modes
  9484. * @returns A promise that resolves when the compilation completes
  9485. */
  9486. forceCompilationAsync(options?: Partial<{
  9487. useInstances: boolean;
  9488. }>): Promise<void>;
  9489. /**
  9490. * Serializes the shadow generator setup to a json object.
  9491. * @returns The serialized JSON object
  9492. */
  9493. serialize(): any;
  9494. /**
  9495. * Disposes the Shadow map and related Textures and effects.
  9496. */
  9497. dispose(): void;
  9498. }
  9499. /**
  9500. * Default implementation IShadowGenerator.
  9501. * This is the main object responsible of generating shadows in the framework.
  9502. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9503. */
  9504. export class ShadowGenerator implements IShadowGenerator {
  9505. /**
  9506. * Shadow generator mode None: no filtering applied.
  9507. */
  9508. static readonly FILTER_NONE: number;
  9509. /**
  9510. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9511. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9512. */
  9513. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9514. /**
  9515. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9516. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9517. */
  9518. static readonly FILTER_POISSONSAMPLING: number;
  9519. /**
  9520. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9521. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9522. */
  9523. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9524. /**
  9525. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9526. * edge artifacts on steep falloff.
  9527. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9528. */
  9529. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9530. /**
  9531. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9532. * edge artifacts on steep falloff.
  9533. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9534. */
  9535. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9536. /**
  9537. * Shadow generator mode PCF: Percentage Closer Filtering
  9538. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9539. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9540. */
  9541. static readonly FILTER_PCF: number;
  9542. /**
  9543. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9544. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9545. * Contact Hardening
  9546. */
  9547. static readonly FILTER_PCSS: number;
  9548. /**
  9549. * Reserved for PCF and PCSS
  9550. * Highest Quality.
  9551. *
  9552. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9553. *
  9554. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9555. */
  9556. static readonly QUALITY_HIGH: number;
  9557. /**
  9558. * Reserved for PCF and PCSS
  9559. * Good tradeoff for quality/perf cross devices
  9560. *
  9561. * Execute PCF on a 3*3 kernel.
  9562. *
  9563. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9564. */
  9565. static readonly QUALITY_MEDIUM: number;
  9566. /**
  9567. * Reserved for PCF and PCSS
  9568. * The lowest quality but the fastest.
  9569. *
  9570. * Execute PCF on a 1*1 kernel.
  9571. *
  9572. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9573. */
  9574. static readonly QUALITY_LOW: number;
  9575. /** Gets or sets the custom shader name to use */
  9576. customShaderOptions: ICustomShaderOptions;
  9577. /**
  9578. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9579. */
  9580. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9581. /**
  9582. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9583. */
  9584. onAfterShadowMapRenderObservable: Observable<Effect>;
  9585. /**
  9586. * Observable triggered before a mesh is rendered in the shadow map.
  9587. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9588. */
  9589. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9590. /**
  9591. * Observable triggered after a mesh is rendered in the shadow map.
  9592. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9593. */
  9594. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9595. private _bias;
  9596. /**
  9597. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9598. */
  9599. /**
  9600. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9601. */
  9602. bias: number;
  9603. private _normalBias;
  9604. /**
  9605. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9606. */
  9607. /**
  9608. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9609. */
  9610. normalBias: number;
  9611. private _blurBoxOffset;
  9612. /**
  9613. * Gets the blur box offset: offset applied during the blur pass.
  9614. * Only useful if useKernelBlur = false
  9615. */
  9616. /**
  9617. * Sets the blur box offset: offset applied during the blur pass.
  9618. * Only useful if useKernelBlur = false
  9619. */
  9620. blurBoxOffset: number;
  9621. private _blurScale;
  9622. /**
  9623. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9624. * 2 means half of the size.
  9625. */
  9626. /**
  9627. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9628. * 2 means half of the size.
  9629. */
  9630. blurScale: number;
  9631. private _blurKernel;
  9632. /**
  9633. * Gets the blur kernel: kernel size of the blur pass.
  9634. * Only useful if useKernelBlur = true
  9635. */
  9636. /**
  9637. * Sets the blur kernel: kernel size of the blur pass.
  9638. * Only useful if useKernelBlur = true
  9639. */
  9640. blurKernel: number;
  9641. private _useKernelBlur;
  9642. /**
  9643. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9644. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9645. */
  9646. /**
  9647. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9648. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9649. */
  9650. useKernelBlur: boolean;
  9651. private _depthScale;
  9652. /**
  9653. * Gets the depth scale used in ESM mode.
  9654. */
  9655. /**
  9656. * Sets the depth scale used in ESM mode.
  9657. * This can override the scale stored on the light.
  9658. */
  9659. depthScale: number;
  9660. private _filter;
  9661. /**
  9662. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9663. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9664. */
  9665. /**
  9666. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9667. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9668. */
  9669. filter: number;
  9670. /**
  9671. * Gets if the current filter is set to Poisson Sampling.
  9672. */
  9673. /**
  9674. * Sets the current filter to Poisson Sampling.
  9675. */
  9676. usePoissonSampling: boolean;
  9677. /**
  9678. * Gets if the current filter is set to ESM.
  9679. */
  9680. /**
  9681. * Sets the current filter is to ESM.
  9682. */
  9683. useExponentialShadowMap: boolean;
  9684. /**
  9685. * Gets if the current filter is set to filtered ESM.
  9686. */
  9687. /**
  9688. * Gets if the current filter is set to filtered ESM.
  9689. */
  9690. useBlurExponentialShadowMap: boolean;
  9691. /**
  9692. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9693. * exponential to prevent steep falloff artifacts).
  9694. */
  9695. /**
  9696. * Sets the current filter to "close ESM" (using the inverse of the
  9697. * exponential to prevent steep falloff artifacts).
  9698. */
  9699. useCloseExponentialShadowMap: boolean;
  9700. /**
  9701. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9702. * exponential to prevent steep falloff artifacts).
  9703. */
  9704. /**
  9705. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9706. * exponential to prevent steep falloff artifacts).
  9707. */
  9708. useBlurCloseExponentialShadowMap: boolean;
  9709. /**
  9710. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9711. */
  9712. /**
  9713. * Sets the current filter to "PCF" (percentage closer filtering).
  9714. */
  9715. usePercentageCloserFiltering: boolean;
  9716. private _filteringQuality;
  9717. /**
  9718. * Gets the PCF or PCSS Quality.
  9719. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9720. */
  9721. /**
  9722. * Sets the PCF or PCSS Quality.
  9723. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9724. */
  9725. filteringQuality: number;
  9726. /**
  9727. * Gets if the current filter is set to "PCSS" (contact hardening).
  9728. */
  9729. /**
  9730. * Sets the current filter to "PCSS" (contact hardening).
  9731. */
  9732. useContactHardeningShadow: boolean;
  9733. private _contactHardeningLightSizeUVRatio;
  9734. /**
  9735. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9736. * Using a ratio helps keeping shape stability independently of the map size.
  9737. *
  9738. * It does not account for the light projection as it was having too much
  9739. * instability during the light setup or during light position changes.
  9740. *
  9741. * Only valid if useContactHardeningShadow is true.
  9742. */
  9743. /**
  9744. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9745. * Using a ratio helps keeping shape stability independently of the map size.
  9746. *
  9747. * It does not account for the light projection as it was having too much
  9748. * instability during the light setup or during light position changes.
  9749. *
  9750. * Only valid if useContactHardeningShadow is true.
  9751. */
  9752. contactHardeningLightSizeUVRatio: number;
  9753. private _darkness;
  9754. /** Gets or sets the actual darkness of a shadow */
  9755. darkness: number;
  9756. /**
  9757. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9758. * 0 means strongest and 1 would means no shadow.
  9759. * @returns the darkness.
  9760. */
  9761. getDarkness(): number;
  9762. /**
  9763. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9764. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9765. * @returns the shadow generator allowing fluent coding.
  9766. */
  9767. setDarkness(darkness: number): ShadowGenerator;
  9768. private _transparencyShadow;
  9769. /** Gets or sets the ability to have transparent shadow */
  9770. transparencyShadow: boolean;
  9771. /**
  9772. * Sets the ability to have transparent shadow (boolean).
  9773. * @param transparent True if transparent else False
  9774. * @returns the shadow generator allowing fluent coding
  9775. */
  9776. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9777. private _shadowMap;
  9778. private _shadowMap2;
  9779. /**
  9780. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9781. * @returns The render target texture if present otherwise, null
  9782. */
  9783. getShadowMap(): Nullable<RenderTargetTexture>;
  9784. /**
  9785. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9786. * @returns The render target texture if the shadow map is present otherwise, null
  9787. */
  9788. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9789. /**
  9790. * Gets the class name of that object
  9791. * @returns "ShadowGenerator"
  9792. */
  9793. getClassName(): string;
  9794. /**
  9795. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9796. * @param mesh Mesh to add
  9797. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9798. * @returns the Shadow Generator itself
  9799. */
  9800. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9801. /**
  9802. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9803. * @param mesh Mesh to remove
  9804. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9805. * @returns the Shadow Generator itself
  9806. */
  9807. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9808. /**
  9809. * Controls the extent to which the shadows fade out at the edge of the frustum
  9810. * Used only by directionals and spots
  9811. */
  9812. frustumEdgeFalloff: number;
  9813. private _light;
  9814. /**
  9815. * Returns the associated light object.
  9816. * @returns the light generating the shadow
  9817. */
  9818. getLight(): IShadowLight;
  9819. /**
  9820. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9821. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9822. * It might on the other hand introduce peter panning.
  9823. */
  9824. forceBackFacesOnly: boolean;
  9825. private _scene;
  9826. private _lightDirection;
  9827. private _effect;
  9828. private _viewMatrix;
  9829. private _projectionMatrix;
  9830. private _transformMatrix;
  9831. private _cachedPosition;
  9832. private _cachedDirection;
  9833. private _cachedDefines;
  9834. private _currentRenderID;
  9835. private _boxBlurPostprocess;
  9836. private _kernelBlurXPostprocess;
  9837. private _kernelBlurYPostprocess;
  9838. private _blurPostProcesses;
  9839. private _mapSize;
  9840. private _currentFaceIndex;
  9841. private _currentFaceIndexCache;
  9842. private _textureType;
  9843. private _defaultTextureMatrix;
  9844. private _storedUniqueId;
  9845. /** @hidden */
  9846. static _SceneComponentInitialization: (scene: Scene) => void;
  9847. /**
  9848. * Creates a ShadowGenerator object.
  9849. * A ShadowGenerator is the required tool to use the shadows.
  9850. * Each light casting shadows needs to use its own ShadowGenerator.
  9851. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9852. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9853. * @param light The light object generating the shadows.
  9854. * @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.
  9855. */
  9856. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9857. private _initializeGenerator;
  9858. private _initializeShadowMap;
  9859. private _initializeBlurRTTAndPostProcesses;
  9860. private _renderForShadowMap;
  9861. private _renderSubMeshForShadowMap;
  9862. private _applyFilterValues;
  9863. /**
  9864. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9865. * @param onCompiled Callback triggered at the and of the effects compilation
  9866. * @param options Sets of optional options forcing the compilation with different modes
  9867. */
  9868. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9869. useInstances: boolean;
  9870. }>): void;
  9871. /**
  9872. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9873. * @param options Sets of optional options forcing the compilation with different modes
  9874. * @returns A promise that resolves when the compilation completes
  9875. */
  9876. forceCompilationAsync(options?: Partial<{
  9877. useInstances: boolean;
  9878. }>): Promise<void>;
  9879. /**
  9880. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9881. * @param subMesh The submesh we want to render in the shadow map
  9882. * @param useInstances Defines wether will draw in the map using instances
  9883. * @returns true if ready otherwise, false
  9884. */
  9885. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9886. /**
  9887. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9888. * @param defines Defines of the material we want to update
  9889. * @param lightIndex Index of the light in the enabled light list of the material
  9890. */
  9891. prepareDefines(defines: any, lightIndex: number): void;
  9892. /**
  9893. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9894. * defined in the generator but impacting the effect).
  9895. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9896. * @param effect The effect we are binfing the information for
  9897. */
  9898. bindShadowLight(lightIndex: string, effect: Effect): void;
  9899. /**
  9900. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9901. * (eq to shadow prjection matrix * light transform matrix)
  9902. * @returns The transform matrix used to create the shadow map
  9903. */
  9904. getTransformMatrix(): Matrix;
  9905. /**
  9906. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9907. * Cube and 2D textures for instance.
  9908. */
  9909. recreateShadowMap(): void;
  9910. private _disposeBlurPostProcesses;
  9911. private _disposeRTTandPostProcesses;
  9912. /**
  9913. * Disposes the ShadowGenerator.
  9914. * Returns nothing.
  9915. */
  9916. dispose(): void;
  9917. /**
  9918. * Serializes the shadow generator setup to a json object.
  9919. * @returns The serialized JSON object
  9920. */
  9921. serialize(): any;
  9922. /**
  9923. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9924. * @param parsedShadowGenerator The JSON object to parse
  9925. * @param scene The scene to create the shadow map for
  9926. * @returns The parsed shadow generator
  9927. */
  9928. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9929. }
  9930. }
  9931. declare module "babylonjs/Lights/light" {
  9932. import { Nullable } from "babylonjs/types";
  9933. import { Scene } from "babylonjs/scene";
  9934. import { Vector3 } from "babylonjs/Maths/math.vector";
  9935. import { Color3 } from "babylonjs/Maths/math.color";
  9936. import { Node } from "babylonjs/node";
  9937. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9938. import { Effect } from "babylonjs/Materials/effect";
  9939. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9940. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  9941. /**
  9942. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9943. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9944. * 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.
  9945. */
  9946. export abstract class Light extends Node {
  9947. /**
  9948. * Falloff Default: light is falling off following the material specification:
  9949. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9950. */
  9951. static readonly FALLOFF_DEFAULT: number;
  9952. /**
  9953. * Falloff Physical: light is falling off following the inverse squared distance law.
  9954. */
  9955. static readonly FALLOFF_PHYSICAL: number;
  9956. /**
  9957. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9958. * to enhance interoperability with other engines.
  9959. */
  9960. static readonly FALLOFF_GLTF: number;
  9961. /**
  9962. * Falloff Standard: light is falling off like in the standard material
  9963. * to enhance interoperability with other materials.
  9964. */
  9965. static readonly FALLOFF_STANDARD: number;
  9966. /**
  9967. * If every light affecting the material is in this lightmapMode,
  9968. * material.lightmapTexture adds or multiplies
  9969. * (depends on material.useLightmapAsShadowmap)
  9970. * after every other light calculations.
  9971. */
  9972. static readonly LIGHTMAP_DEFAULT: number;
  9973. /**
  9974. * material.lightmapTexture as only diffuse lighting from this light
  9975. * adds only specular lighting from this light
  9976. * adds dynamic shadows
  9977. */
  9978. static readonly LIGHTMAP_SPECULAR: number;
  9979. /**
  9980. * material.lightmapTexture as only lighting
  9981. * no light calculation from this light
  9982. * only adds dynamic shadows from this light
  9983. */
  9984. static readonly LIGHTMAP_SHADOWSONLY: number;
  9985. /**
  9986. * Each light type uses the default quantity according to its type:
  9987. * point/spot lights use luminous intensity
  9988. * directional lights use illuminance
  9989. */
  9990. static readonly INTENSITYMODE_AUTOMATIC: number;
  9991. /**
  9992. * lumen (lm)
  9993. */
  9994. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9995. /**
  9996. * candela (lm/sr)
  9997. */
  9998. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9999. /**
  10000. * lux (lm/m^2)
  10001. */
  10002. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10003. /**
  10004. * nit (cd/m^2)
  10005. */
  10006. static readonly INTENSITYMODE_LUMINANCE: number;
  10007. /**
  10008. * Light type const id of the point light.
  10009. */
  10010. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10011. /**
  10012. * Light type const id of the directional light.
  10013. */
  10014. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10015. /**
  10016. * Light type const id of the spot light.
  10017. */
  10018. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10019. /**
  10020. * Light type const id of the hemispheric light.
  10021. */
  10022. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10023. /**
  10024. * Diffuse gives the basic color to an object.
  10025. */
  10026. diffuse: Color3;
  10027. /**
  10028. * Specular produces a highlight color on an object.
  10029. * Note: This is note affecting PBR materials.
  10030. */
  10031. specular: Color3;
  10032. /**
  10033. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10034. * falling off base on range or angle.
  10035. * This can be set to any values in Light.FALLOFF_x.
  10036. *
  10037. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10038. * other types of materials.
  10039. */
  10040. falloffType: number;
  10041. /**
  10042. * Strength of the light.
  10043. * Note: By default it is define in the framework own unit.
  10044. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10045. */
  10046. intensity: number;
  10047. private _range;
  10048. protected _inverseSquaredRange: number;
  10049. /**
  10050. * Defines how far from the source the light is impacting in scene units.
  10051. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10052. */
  10053. /**
  10054. * Defines how far from the source the light is impacting in scene units.
  10055. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10056. */
  10057. range: number;
  10058. /**
  10059. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10060. * of light.
  10061. */
  10062. private _photometricScale;
  10063. private _intensityMode;
  10064. /**
  10065. * Gets the photometric scale used to interpret the intensity.
  10066. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10067. */
  10068. /**
  10069. * Sets the photometric scale used to interpret the intensity.
  10070. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10071. */
  10072. intensityMode: number;
  10073. private _radius;
  10074. /**
  10075. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10076. */
  10077. /**
  10078. * sets the light radius used by PBR Materials to simulate soft area lights.
  10079. */
  10080. radius: number;
  10081. private _renderPriority;
  10082. /**
  10083. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10084. * exceeding the number allowed of the materials.
  10085. */
  10086. renderPriority: number;
  10087. private _shadowEnabled;
  10088. /**
  10089. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10090. * the current shadow generator.
  10091. */
  10092. /**
  10093. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10094. * the current shadow generator.
  10095. */
  10096. shadowEnabled: boolean;
  10097. private _includedOnlyMeshes;
  10098. /**
  10099. * Gets the only meshes impacted by this light.
  10100. */
  10101. /**
  10102. * Sets the only meshes impacted by this light.
  10103. */
  10104. includedOnlyMeshes: AbstractMesh[];
  10105. private _excludedMeshes;
  10106. /**
  10107. * Gets the meshes not impacted by this light.
  10108. */
  10109. /**
  10110. * Sets the meshes not impacted by this light.
  10111. */
  10112. excludedMeshes: AbstractMesh[];
  10113. private _excludeWithLayerMask;
  10114. /**
  10115. * Gets the layer id use to find what meshes are not impacted by the light.
  10116. * Inactive if 0
  10117. */
  10118. /**
  10119. * Sets the layer id use to find what meshes are not impacted by the light.
  10120. * Inactive if 0
  10121. */
  10122. excludeWithLayerMask: number;
  10123. private _includeOnlyWithLayerMask;
  10124. /**
  10125. * Gets the layer id use to find what meshes are impacted by the light.
  10126. * Inactive if 0
  10127. */
  10128. /**
  10129. * Sets the layer id use to find what meshes are impacted by the light.
  10130. * Inactive if 0
  10131. */
  10132. includeOnlyWithLayerMask: number;
  10133. private _lightmapMode;
  10134. /**
  10135. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10136. */
  10137. /**
  10138. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10139. */
  10140. lightmapMode: number;
  10141. /**
  10142. * Shadow generator associted to the light.
  10143. * @hidden Internal use only.
  10144. */
  10145. _shadowGenerator: Nullable<IShadowGenerator>;
  10146. /**
  10147. * @hidden Internal use only.
  10148. */
  10149. _excludedMeshesIds: string[];
  10150. /**
  10151. * @hidden Internal use only.
  10152. */
  10153. _includedOnlyMeshesIds: string[];
  10154. /**
  10155. * The current light unifom buffer.
  10156. * @hidden Internal use only.
  10157. */
  10158. _uniformBuffer: UniformBuffer;
  10159. /**
  10160. * Creates a Light object in the scene.
  10161. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10162. * @param name The firendly name of the light
  10163. * @param scene The scene the light belongs too
  10164. */
  10165. constructor(name: string, scene: Scene);
  10166. protected abstract _buildUniformLayout(): void;
  10167. /**
  10168. * Sets the passed Effect "effect" with the Light information.
  10169. * @param effect The effect to update
  10170. * @param lightIndex The index of the light in the effect to update
  10171. * @returns The light
  10172. */
  10173. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10174. /**
  10175. * Sets the passed Effect "effect" with the Light information.
  10176. * @param effect The effect to update
  10177. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10178. * @returns The light
  10179. */
  10180. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10181. /**
  10182. * Returns the string "Light".
  10183. * @returns the class name
  10184. */
  10185. getClassName(): string;
  10186. /** @hidden */
  10187. readonly _isLight: boolean;
  10188. /**
  10189. * Converts the light information to a readable string for debug purpose.
  10190. * @param fullDetails Supports for multiple levels of logging within scene loading
  10191. * @returns the human readable light info
  10192. */
  10193. toString(fullDetails?: boolean): string;
  10194. /** @hidden */
  10195. protected _syncParentEnabledState(): void;
  10196. /**
  10197. * Set the enabled state of this node.
  10198. * @param value - the new enabled state
  10199. */
  10200. setEnabled(value: boolean): void;
  10201. /**
  10202. * Returns the Light associated shadow generator if any.
  10203. * @return the associated shadow generator.
  10204. */
  10205. getShadowGenerator(): Nullable<IShadowGenerator>;
  10206. /**
  10207. * Returns a Vector3, the absolute light position in the World.
  10208. * @returns the world space position of the light
  10209. */
  10210. getAbsolutePosition(): Vector3;
  10211. /**
  10212. * Specifies if the light will affect the passed mesh.
  10213. * @param mesh The mesh to test against the light
  10214. * @return true the mesh is affected otherwise, false.
  10215. */
  10216. canAffectMesh(mesh: AbstractMesh): boolean;
  10217. /**
  10218. * Sort function to order lights for rendering.
  10219. * @param a First Light object to compare to second.
  10220. * @param b Second Light object to compare first.
  10221. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10222. */
  10223. static CompareLightsPriority(a: Light, b: Light): number;
  10224. /**
  10225. * Releases resources associated with this node.
  10226. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10227. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10228. */
  10229. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10230. /**
  10231. * Returns the light type ID (integer).
  10232. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10233. */
  10234. getTypeID(): number;
  10235. /**
  10236. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10237. * @returns the scaled intensity in intensity mode unit
  10238. */
  10239. getScaledIntensity(): number;
  10240. /**
  10241. * Returns a new Light object, named "name", from the current one.
  10242. * @param name The name of the cloned light
  10243. * @returns the new created light
  10244. */
  10245. clone(name: string): Nullable<Light>;
  10246. /**
  10247. * Serializes the current light into a Serialization object.
  10248. * @returns the serialized object.
  10249. */
  10250. serialize(): any;
  10251. /**
  10252. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10253. * This new light is named "name" and added to the passed scene.
  10254. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10255. * @param name The friendly name of the light
  10256. * @param scene The scene the new light will belong to
  10257. * @returns the constructor function
  10258. */
  10259. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10260. /**
  10261. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10262. * @param parsedLight The JSON representation of the light
  10263. * @param scene The scene to create the parsed light in
  10264. * @returns the created light after parsing
  10265. */
  10266. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10267. private _hookArrayForExcluded;
  10268. private _hookArrayForIncludedOnly;
  10269. private _resyncMeshes;
  10270. /**
  10271. * Forces the meshes to update their light related information in their rendering used effects
  10272. * @hidden Internal Use Only
  10273. */
  10274. _markMeshesAsLightDirty(): void;
  10275. /**
  10276. * Recomputes the cached photometric scale if needed.
  10277. */
  10278. private _computePhotometricScale;
  10279. /**
  10280. * Returns the Photometric Scale according to the light type and intensity mode.
  10281. */
  10282. private _getPhotometricScale;
  10283. /**
  10284. * Reorder the light in the scene according to their defined priority.
  10285. * @hidden Internal Use Only
  10286. */
  10287. _reorderLightsInScene(): void;
  10288. /**
  10289. * Prepares the list of defines specific to the light type.
  10290. * @param defines the list of defines
  10291. * @param lightIndex defines the index of the light for the effect
  10292. */
  10293. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10294. }
  10295. }
  10296. declare module "babylonjs/Actions/action" {
  10297. import { Observable } from "babylonjs/Misc/observable";
  10298. import { Condition } from "babylonjs/Actions/condition";
  10299. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10300. import { ActionManager } from "babylonjs/Actions/actionManager";
  10301. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10302. /**
  10303. * Interface used to define Action
  10304. */
  10305. export interface IAction {
  10306. /**
  10307. * Trigger for the action
  10308. */
  10309. trigger: number;
  10310. /** Options of the trigger */
  10311. triggerOptions: any;
  10312. /**
  10313. * Gets the trigger parameters
  10314. * @returns the trigger parameters
  10315. */
  10316. getTriggerParameter(): any;
  10317. /**
  10318. * Internal only - executes current action event
  10319. * @hidden
  10320. */
  10321. _executeCurrent(evt?: ActionEvent): void;
  10322. /**
  10323. * Serialize placeholder for child classes
  10324. * @param parent of child
  10325. * @returns the serialized object
  10326. */
  10327. serialize(parent: any): any;
  10328. /**
  10329. * Internal only
  10330. * @hidden
  10331. */
  10332. _prepare(): void;
  10333. /**
  10334. * Internal only - manager for action
  10335. * @hidden
  10336. */
  10337. _actionManager: AbstractActionManager;
  10338. /**
  10339. * Adds action to chain of actions, may be a DoNothingAction
  10340. * @param action defines the next action to execute
  10341. * @returns The action passed in
  10342. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10343. */
  10344. then(action: IAction): IAction;
  10345. }
  10346. /**
  10347. * The action to be carried out following a trigger
  10348. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10349. */
  10350. export class Action implements IAction {
  10351. /** the trigger, with or without parameters, for the action */
  10352. triggerOptions: any;
  10353. /**
  10354. * Trigger for the action
  10355. */
  10356. trigger: number;
  10357. /**
  10358. * Internal only - manager for action
  10359. * @hidden
  10360. */
  10361. _actionManager: ActionManager;
  10362. private _nextActiveAction;
  10363. private _child;
  10364. private _condition?;
  10365. private _triggerParameter;
  10366. /**
  10367. * An event triggered prior to action being executed.
  10368. */
  10369. onBeforeExecuteObservable: Observable<Action>;
  10370. /**
  10371. * Creates a new Action
  10372. * @param triggerOptions the trigger, with or without parameters, for the action
  10373. * @param condition an optional determinant of action
  10374. */
  10375. constructor(
  10376. /** the trigger, with or without parameters, for the action */
  10377. triggerOptions: any, condition?: Condition);
  10378. /**
  10379. * Internal only
  10380. * @hidden
  10381. */
  10382. _prepare(): void;
  10383. /**
  10384. * Gets the trigger parameters
  10385. * @returns the trigger parameters
  10386. */
  10387. getTriggerParameter(): any;
  10388. /**
  10389. * Internal only - executes current action event
  10390. * @hidden
  10391. */
  10392. _executeCurrent(evt?: ActionEvent): void;
  10393. /**
  10394. * Execute placeholder for child classes
  10395. * @param evt optional action event
  10396. */
  10397. execute(evt?: ActionEvent): void;
  10398. /**
  10399. * Skips to next active action
  10400. */
  10401. skipToNextActiveAction(): void;
  10402. /**
  10403. * Adds action to chain of actions, may be a DoNothingAction
  10404. * @param action defines the next action to execute
  10405. * @returns The action passed in
  10406. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10407. */
  10408. then(action: Action): Action;
  10409. /**
  10410. * Internal only
  10411. * @hidden
  10412. */
  10413. _getProperty(propertyPath: string): string;
  10414. /**
  10415. * Internal only
  10416. * @hidden
  10417. */
  10418. _getEffectiveTarget(target: any, propertyPath: string): any;
  10419. /**
  10420. * Serialize placeholder for child classes
  10421. * @param parent of child
  10422. * @returns the serialized object
  10423. */
  10424. serialize(parent: any): any;
  10425. /**
  10426. * Internal only called by serialize
  10427. * @hidden
  10428. */
  10429. protected _serialize(serializedAction: any, parent?: any): any;
  10430. /**
  10431. * Internal only
  10432. * @hidden
  10433. */
  10434. static _SerializeValueAsString: (value: any) => string;
  10435. /**
  10436. * Internal only
  10437. * @hidden
  10438. */
  10439. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  10440. name: string;
  10441. targetType: string;
  10442. value: string;
  10443. };
  10444. }
  10445. }
  10446. declare module "babylonjs/Actions/condition" {
  10447. import { ActionManager } from "babylonjs/Actions/actionManager";
  10448. /**
  10449. * A Condition applied to an Action
  10450. */
  10451. export class Condition {
  10452. /**
  10453. * Internal only - manager for action
  10454. * @hidden
  10455. */
  10456. _actionManager: ActionManager;
  10457. /**
  10458. * Internal only
  10459. * @hidden
  10460. */
  10461. _evaluationId: number;
  10462. /**
  10463. * Internal only
  10464. * @hidden
  10465. */
  10466. _currentResult: boolean;
  10467. /**
  10468. * Creates a new Condition
  10469. * @param actionManager the manager of the action the condition is applied to
  10470. */
  10471. constructor(actionManager: ActionManager);
  10472. /**
  10473. * Check if the current condition is valid
  10474. * @returns a boolean
  10475. */
  10476. isValid(): boolean;
  10477. /**
  10478. * Internal only
  10479. * @hidden
  10480. */
  10481. _getProperty(propertyPath: string): string;
  10482. /**
  10483. * Internal only
  10484. * @hidden
  10485. */
  10486. _getEffectiveTarget(target: any, propertyPath: string): any;
  10487. /**
  10488. * Serialize placeholder for child classes
  10489. * @returns the serialized object
  10490. */
  10491. serialize(): any;
  10492. /**
  10493. * Internal only
  10494. * @hidden
  10495. */
  10496. protected _serialize(serializedCondition: any): any;
  10497. }
  10498. /**
  10499. * Defines specific conditional operators as extensions of Condition
  10500. */
  10501. export class ValueCondition extends Condition {
  10502. /** path to specify the property of the target the conditional operator uses */
  10503. propertyPath: string;
  10504. /** the value compared by the conditional operator against the current value of the property */
  10505. value: any;
  10506. /** the conditional operator, default ValueCondition.IsEqual */
  10507. operator: number;
  10508. /**
  10509. * Internal only
  10510. * @hidden
  10511. */
  10512. private static _IsEqual;
  10513. /**
  10514. * Internal only
  10515. * @hidden
  10516. */
  10517. private static _IsDifferent;
  10518. /**
  10519. * Internal only
  10520. * @hidden
  10521. */
  10522. private static _IsGreater;
  10523. /**
  10524. * Internal only
  10525. * @hidden
  10526. */
  10527. private static _IsLesser;
  10528. /**
  10529. * returns the number for IsEqual
  10530. */
  10531. static readonly IsEqual: number;
  10532. /**
  10533. * Returns the number for IsDifferent
  10534. */
  10535. static readonly IsDifferent: number;
  10536. /**
  10537. * Returns the number for IsGreater
  10538. */
  10539. static readonly IsGreater: number;
  10540. /**
  10541. * Returns the number for IsLesser
  10542. */
  10543. static readonly IsLesser: number;
  10544. /**
  10545. * Internal only The action manager for the condition
  10546. * @hidden
  10547. */
  10548. _actionManager: ActionManager;
  10549. /**
  10550. * Internal only
  10551. * @hidden
  10552. */
  10553. private _target;
  10554. /**
  10555. * Internal only
  10556. * @hidden
  10557. */
  10558. private _effectiveTarget;
  10559. /**
  10560. * Internal only
  10561. * @hidden
  10562. */
  10563. private _property;
  10564. /**
  10565. * Creates a new ValueCondition
  10566. * @param actionManager manager for the action the condition applies to
  10567. * @param target for the action
  10568. * @param propertyPath path to specify the property of the target the conditional operator uses
  10569. * @param value the value compared by the conditional operator against the current value of the property
  10570. * @param operator the conditional operator, default ValueCondition.IsEqual
  10571. */
  10572. constructor(actionManager: ActionManager, target: any,
  10573. /** path to specify the property of the target the conditional operator uses */
  10574. propertyPath: string,
  10575. /** the value compared by the conditional operator against the current value of the property */
  10576. value: any,
  10577. /** the conditional operator, default ValueCondition.IsEqual */
  10578. operator?: number);
  10579. /**
  10580. * Compares the given value with the property value for the specified conditional operator
  10581. * @returns the result of the comparison
  10582. */
  10583. isValid(): boolean;
  10584. /**
  10585. * Serialize the ValueCondition into a JSON compatible object
  10586. * @returns serialization object
  10587. */
  10588. serialize(): any;
  10589. /**
  10590. * Gets the name of the conditional operator for the ValueCondition
  10591. * @param operator the conditional operator
  10592. * @returns the name
  10593. */
  10594. static GetOperatorName(operator: number): string;
  10595. }
  10596. /**
  10597. * Defines a predicate condition as an extension of Condition
  10598. */
  10599. export class PredicateCondition extends Condition {
  10600. /** defines the predicate function used to validate the condition */
  10601. predicate: () => boolean;
  10602. /**
  10603. * Internal only - manager for action
  10604. * @hidden
  10605. */
  10606. _actionManager: ActionManager;
  10607. /**
  10608. * Creates a new PredicateCondition
  10609. * @param actionManager manager for the action the condition applies to
  10610. * @param predicate defines the predicate function used to validate the condition
  10611. */
  10612. constructor(actionManager: ActionManager,
  10613. /** defines the predicate function used to validate the condition */
  10614. predicate: () => boolean);
  10615. /**
  10616. * @returns the validity of the predicate condition
  10617. */
  10618. isValid(): boolean;
  10619. }
  10620. /**
  10621. * Defines a state condition as an extension of Condition
  10622. */
  10623. export class StateCondition extends Condition {
  10624. /** Value to compare with target state */
  10625. value: string;
  10626. /**
  10627. * Internal only - manager for action
  10628. * @hidden
  10629. */
  10630. _actionManager: ActionManager;
  10631. /**
  10632. * Internal only
  10633. * @hidden
  10634. */
  10635. private _target;
  10636. /**
  10637. * Creates a new StateCondition
  10638. * @param actionManager manager for the action the condition applies to
  10639. * @param target of the condition
  10640. * @param value to compare with target state
  10641. */
  10642. constructor(actionManager: ActionManager, target: any,
  10643. /** Value to compare with target state */
  10644. value: string);
  10645. /**
  10646. * Gets a boolean indicating if the current condition is met
  10647. * @returns the validity of the state
  10648. */
  10649. isValid(): boolean;
  10650. /**
  10651. * Serialize the StateCondition into a JSON compatible object
  10652. * @returns serialization object
  10653. */
  10654. serialize(): any;
  10655. }
  10656. }
  10657. declare module "babylonjs/Actions/directActions" {
  10658. import { Action } from "babylonjs/Actions/action";
  10659. import { Condition } from "babylonjs/Actions/condition";
  10660. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10661. /**
  10662. * This defines an action responsible to toggle a boolean once triggered.
  10663. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10664. */
  10665. export class SwitchBooleanAction extends Action {
  10666. /**
  10667. * The path to the boolean property in the target object
  10668. */
  10669. propertyPath: string;
  10670. private _target;
  10671. private _effectiveTarget;
  10672. private _property;
  10673. /**
  10674. * Instantiate the action
  10675. * @param triggerOptions defines the trigger options
  10676. * @param target defines the object containing the boolean
  10677. * @param propertyPath defines the path to the boolean property in the target object
  10678. * @param condition defines the trigger related conditions
  10679. */
  10680. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10681. /** @hidden */
  10682. _prepare(): void;
  10683. /**
  10684. * Execute the action toggle the boolean value.
  10685. */
  10686. execute(): void;
  10687. /**
  10688. * Serializes the actions and its related information.
  10689. * @param parent defines the object to serialize in
  10690. * @returns the serialized object
  10691. */
  10692. serialize(parent: any): any;
  10693. }
  10694. /**
  10695. * This defines an action responsible to set a the state field of the target
  10696. * to a desired value once triggered.
  10697. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10698. */
  10699. export class SetStateAction extends Action {
  10700. /**
  10701. * The value to store in the state field.
  10702. */
  10703. value: string;
  10704. private _target;
  10705. /**
  10706. * Instantiate the action
  10707. * @param triggerOptions defines the trigger options
  10708. * @param target defines the object containing the state property
  10709. * @param value defines the value to store in the state field
  10710. * @param condition defines the trigger related conditions
  10711. */
  10712. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10713. /**
  10714. * Execute the action and store the value on the target state property.
  10715. */
  10716. execute(): void;
  10717. /**
  10718. * Serializes the actions and its related information.
  10719. * @param parent defines the object to serialize in
  10720. * @returns the serialized object
  10721. */
  10722. serialize(parent: any): any;
  10723. }
  10724. /**
  10725. * This defines an action responsible to set a property of the target
  10726. * to a desired value once triggered.
  10727. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10728. */
  10729. export class SetValueAction extends Action {
  10730. /**
  10731. * The path of the property to set in the target.
  10732. */
  10733. propertyPath: string;
  10734. /**
  10735. * The value to set in the property
  10736. */
  10737. value: any;
  10738. private _target;
  10739. private _effectiveTarget;
  10740. private _property;
  10741. /**
  10742. * Instantiate the action
  10743. * @param triggerOptions defines the trigger options
  10744. * @param target defines the object containing the property
  10745. * @param propertyPath defines the path of the property to set in the target
  10746. * @param value defines the value to set in the property
  10747. * @param condition defines the trigger related conditions
  10748. */
  10749. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10750. /** @hidden */
  10751. _prepare(): void;
  10752. /**
  10753. * Execute the action and set the targetted property to the desired value.
  10754. */
  10755. execute(): void;
  10756. /**
  10757. * Serializes the actions and its related information.
  10758. * @param parent defines the object to serialize in
  10759. * @returns the serialized object
  10760. */
  10761. serialize(parent: any): any;
  10762. }
  10763. /**
  10764. * This defines an action responsible to increment the target value
  10765. * to a desired value once triggered.
  10766. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10767. */
  10768. export class IncrementValueAction extends Action {
  10769. /**
  10770. * The path of the property to increment in the target.
  10771. */
  10772. propertyPath: string;
  10773. /**
  10774. * The value we should increment the property by.
  10775. */
  10776. value: any;
  10777. private _target;
  10778. private _effectiveTarget;
  10779. private _property;
  10780. /**
  10781. * Instantiate the action
  10782. * @param triggerOptions defines the trigger options
  10783. * @param target defines the object containing the property
  10784. * @param propertyPath defines the path of the property to increment in the target
  10785. * @param value defines the value value we should increment the property by
  10786. * @param condition defines the trigger related conditions
  10787. */
  10788. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10789. /** @hidden */
  10790. _prepare(): void;
  10791. /**
  10792. * Execute the action and increment the target of the value amount.
  10793. */
  10794. execute(): void;
  10795. /**
  10796. * Serializes the actions and its related information.
  10797. * @param parent defines the object to serialize in
  10798. * @returns the serialized object
  10799. */
  10800. serialize(parent: any): any;
  10801. }
  10802. /**
  10803. * This defines an action responsible to start an animation once triggered.
  10804. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10805. */
  10806. export class PlayAnimationAction extends Action {
  10807. /**
  10808. * Where the animation should start (animation frame)
  10809. */
  10810. from: number;
  10811. /**
  10812. * Where the animation should stop (animation frame)
  10813. */
  10814. to: number;
  10815. /**
  10816. * Define if the animation should loop or stop after the first play.
  10817. */
  10818. loop?: boolean;
  10819. private _target;
  10820. /**
  10821. * Instantiate the action
  10822. * @param triggerOptions defines the trigger options
  10823. * @param target defines the target animation or animation name
  10824. * @param from defines from where the animation should start (animation frame)
  10825. * @param end defines where the animation should stop (animation frame)
  10826. * @param loop defines if the animation should loop or stop after the first play
  10827. * @param condition defines the trigger related conditions
  10828. */
  10829. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10830. /** @hidden */
  10831. _prepare(): void;
  10832. /**
  10833. * Execute the action and play the animation.
  10834. */
  10835. execute(): void;
  10836. /**
  10837. * Serializes the actions and its related information.
  10838. * @param parent defines the object to serialize in
  10839. * @returns the serialized object
  10840. */
  10841. serialize(parent: any): any;
  10842. }
  10843. /**
  10844. * This defines an action responsible to stop an animation once triggered.
  10845. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10846. */
  10847. export class StopAnimationAction extends Action {
  10848. private _target;
  10849. /**
  10850. * Instantiate the action
  10851. * @param triggerOptions defines the trigger options
  10852. * @param target defines the target animation or animation name
  10853. * @param condition defines the trigger related conditions
  10854. */
  10855. constructor(triggerOptions: any, target: any, condition?: Condition);
  10856. /** @hidden */
  10857. _prepare(): void;
  10858. /**
  10859. * Execute the action and stop the animation.
  10860. */
  10861. execute(): void;
  10862. /**
  10863. * Serializes the actions and its related information.
  10864. * @param parent defines the object to serialize in
  10865. * @returns the serialized object
  10866. */
  10867. serialize(parent: any): any;
  10868. }
  10869. /**
  10870. * This defines an action responsible that does nothing once triggered.
  10871. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10872. */
  10873. export class DoNothingAction extends Action {
  10874. /**
  10875. * Instantiate the action
  10876. * @param triggerOptions defines the trigger options
  10877. * @param condition defines the trigger related conditions
  10878. */
  10879. constructor(triggerOptions?: any, condition?: Condition);
  10880. /**
  10881. * Execute the action and do nothing.
  10882. */
  10883. execute(): void;
  10884. /**
  10885. * Serializes the actions and its related information.
  10886. * @param parent defines the object to serialize in
  10887. * @returns the serialized object
  10888. */
  10889. serialize(parent: any): any;
  10890. }
  10891. /**
  10892. * This defines an action responsible to trigger several actions once triggered.
  10893. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10894. */
  10895. export class CombineAction extends Action {
  10896. /**
  10897. * The list of aggregated animations to run.
  10898. */
  10899. children: Action[];
  10900. /**
  10901. * Instantiate the action
  10902. * @param triggerOptions defines the trigger options
  10903. * @param children defines the list of aggregated animations to run
  10904. * @param condition defines the trigger related conditions
  10905. */
  10906. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10907. /** @hidden */
  10908. _prepare(): void;
  10909. /**
  10910. * Execute the action and executes all the aggregated actions.
  10911. */
  10912. execute(evt: ActionEvent): void;
  10913. /**
  10914. * Serializes the actions and its related information.
  10915. * @param parent defines the object to serialize in
  10916. * @returns the serialized object
  10917. */
  10918. serialize(parent: any): any;
  10919. }
  10920. /**
  10921. * This defines an action responsible to run code (external event) once triggered.
  10922. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10923. */
  10924. export class ExecuteCodeAction extends Action {
  10925. /**
  10926. * The callback function to run.
  10927. */
  10928. func: (evt: ActionEvent) => void;
  10929. /**
  10930. * Instantiate the action
  10931. * @param triggerOptions defines the trigger options
  10932. * @param func defines the callback function to run
  10933. * @param condition defines the trigger related conditions
  10934. */
  10935. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10936. /**
  10937. * Execute the action and run the attached code.
  10938. */
  10939. execute(evt: ActionEvent): void;
  10940. }
  10941. /**
  10942. * This defines an action responsible to set the parent property of the target once triggered.
  10943. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10944. */
  10945. export class SetParentAction extends Action {
  10946. private _parent;
  10947. private _target;
  10948. /**
  10949. * Instantiate the action
  10950. * @param triggerOptions defines the trigger options
  10951. * @param target defines the target containing the parent property
  10952. * @param parent defines from where the animation should start (animation frame)
  10953. * @param condition defines the trigger related conditions
  10954. */
  10955. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10956. /** @hidden */
  10957. _prepare(): void;
  10958. /**
  10959. * Execute the action and set the parent property.
  10960. */
  10961. execute(): void;
  10962. /**
  10963. * Serializes the actions and its related information.
  10964. * @param parent defines the object to serialize in
  10965. * @returns the serialized object
  10966. */
  10967. serialize(parent: any): any;
  10968. }
  10969. }
  10970. declare module "babylonjs/Actions/actionManager" {
  10971. import { Nullable } from "babylonjs/types";
  10972. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10973. import { Scene } from "babylonjs/scene";
  10974. import { IAction } from "babylonjs/Actions/action";
  10975. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10976. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10977. /**
  10978. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10979. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10980. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10981. */
  10982. export class ActionManager extends AbstractActionManager {
  10983. /**
  10984. * Nothing
  10985. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10986. */
  10987. static readonly NothingTrigger: number;
  10988. /**
  10989. * On pick
  10990. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10991. */
  10992. static readonly OnPickTrigger: number;
  10993. /**
  10994. * On left pick
  10995. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10996. */
  10997. static readonly OnLeftPickTrigger: number;
  10998. /**
  10999. * On right pick
  11000. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11001. */
  11002. static readonly OnRightPickTrigger: number;
  11003. /**
  11004. * On center pick
  11005. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11006. */
  11007. static readonly OnCenterPickTrigger: number;
  11008. /**
  11009. * On pick down
  11010. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11011. */
  11012. static readonly OnPickDownTrigger: number;
  11013. /**
  11014. * On double pick
  11015. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11016. */
  11017. static readonly OnDoublePickTrigger: number;
  11018. /**
  11019. * On pick up
  11020. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11021. */
  11022. static readonly OnPickUpTrigger: number;
  11023. /**
  11024. * On pick out.
  11025. * This trigger will only be raised if you also declared a OnPickDown
  11026. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11027. */
  11028. static readonly OnPickOutTrigger: number;
  11029. /**
  11030. * On long press
  11031. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11032. */
  11033. static readonly OnLongPressTrigger: number;
  11034. /**
  11035. * On pointer over
  11036. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11037. */
  11038. static readonly OnPointerOverTrigger: number;
  11039. /**
  11040. * On pointer out
  11041. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11042. */
  11043. static readonly OnPointerOutTrigger: number;
  11044. /**
  11045. * On every frame
  11046. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11047. */
  11048. static readonly OnEveryFrameTrigger: number;
  11049. /**
  11050. * On intersection enter
  11051. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11052. */
  11053. static readonly OnIntersectionEnterTrigger: number;
  11054. /**
  11055. * On intersection exit
  11056. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11057. */
  11058. static readonly OnIntersectionExitTrigger: number;
  11059. /**
  11060. * On key down
  11061. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11062. */
  11063. static readonly OnKeyDownTrigger: number;
  11064. /**
  11065. * On key up
  11066. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11067. */
  11068. static readonly OnKeyUpTrigger: number;
  11069. private _scene;
  11070. /**
  11071. * Creates a new action manager
  11072. * @param scene defines the hosting scene
  11073. */
  11074. constructor(scene: Scene);
  11075. /**
  11076. * Releases all associated resources
  11077. */
  11078. dispose(): void;
  11079. /**
  11080. * Gets hosting scene
  11081. * @returns the hosting scene
  11082. */
  11083. getScene(): Scene;
  11084. /**
  11085. * Does this action manager handles actions of any of the given triggers
  11086. * @param triggers defines the triggers to be tested
  11087. * @return a boolean indicating whether one (or more) of the triggers is handled
  11088. */
  11089. hasSpecificTriggers(triggers: number[]): boolean;
  11090. /**
  11091. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11092. * speed.
  11093. * @param triggerA defines the trigger to be tested
  11094. * @param triggerB defines the trigger to be tested
  11095. * @return a boolean indicating whether one (or more) of the triggers is handled
  11096. */
  11097. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11098. /**
  11099. * Does this action manager handles actions of a given trigger
  11100. * @param trigger defines the trigger to be tested
  11101. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11102. * @return whether the trigger is handled
  11103. */
  11104. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11105. /**
  11106. * Does this action manager has pointer triggers
  11107. */
  11108. readonly hasPointerTriggers: boolean;
  11109. /**
  11110. * Does this action manager has pick triggers
  11111. */
  11112. readonly hasPickTriggers: boolean;
  11113. /**
  11114. * Registers an action to this action manager
  11115. * @param action defines the action to be registered
  11116. * @return the action amended (prepared) after registration
  11117. */
  11118. registerAction(action: IAction): Nullable<IAction>;
  11119. /**
  11120. * Unregisters an action to this action manager
  11121. * @param action defines the action to be unregistered
  11122. * @return a boolean indicating whether the action has been unregistered
  11123. */
  11124. unregisterAction(action: IAction): Boolean;
  11125. /**
  11126. * Process a specific trigger
  11127. * @param trigger defines the trigger to process
  11128. * @param evt defines the event details to be processed
  11129. */
  11130. processTrigger(trigger: number, evt?: IActionEvent): void;
  11131. /** @hidden */
  11132. _getEffectiveTarget(target: any, propertyPath: string): any;
  11133. /** @hidden */
  11134. _getProperty(propertyPath: string): string;
  11135. /**
  11136. * Serialize this manager to a JSON object
  11137. * @param name defines the property name to store this manager
  11138. * @returns a JSON representation of this manager
  11139. */
  11140. serialize(name: string): any;
  11141. /**
  11142. * Creates a new ActionManager from a JSON data
  11143. * @param parsedActions defines the JSON data to read from
  11144. * @param object defines the hosting mesh
  11145. * @param scene defines the hosting scene
  11146. */
  11147. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11148. /**
  11149. * Get a trigger name by index
  11150. * @param trigger defines the trigger index
  11151. * @returns a trigger name
  11152. */
  11153. static GetTriggerName(trigger: number): string;
  11154. }
  11155. }
  11156. declare module "babylonjs/Culling/ray" {
  11157. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11158. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  11159. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11160. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11161. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11162. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11163. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11164. import { Plane } from "babylonjs/Maths/math.plane";
  11165. /**
  11166. * Class representing a ray with position and direction
  11167. */
  11168. export class Ray {
  11169. /** origin point */
  11170. origin: Vector3;
  11171. /** direction */
  11172. direction: Vector3;
  11173. /** length of the ray */
  11174. length: number;
  11175. private static readonly TmpVector3;
  11176. private _tmpRay;
  11177. /**
  11178. * Creates a new ray
  11179. * @param origin origin point
  11180. * @param direction direction
  11181. * @param length length of the ray
  11182. */
  11183. constructor(
  11184. /** origin point */
  11185. origin: Vector3,
  11186. /** direction */
  11187. direction: Vector3,
  11188. /** length of the ray */
  11189. length?: number);
  11190. /**
  11191. * Checks if the ray intersects a box
  11192. * @param minimum bound of the box
  11193. * @param maximum bound of the box
  11194. * @param intersectionTreshold extra extend to be added to the box in all direction
  11195. * @returns if the box was hit
  11196. */
  11197. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11198. /**
  11199. * Checks if the ray intersects a box
  11200. * @param box the bounding box to check
  11201. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11202. * @returns if the box was hit
  11203. */
  11204. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11205. /**
  11206. * If the ray hits a sphere
  11207. * @param sphere the bounding sphere to check
  11208. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11209. * @returns true if it hits the sphere
  11210. */
  11211. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11212. /**
  11213. * If the ray hits a triange
  11214. * @param vertex0 triangle vertex
  11215. * @param vertex1 triangle vertex
  11216. * @param vertex2 triangle vertex
  11217. * @returns intersection information if hit
  11218. */
  11219. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11220. /**
  11221. * Checks if ray intersects a plane
  11222. * @param plane the plane to check
  11223. * @returns the distance away it was hit
  11224. */
  11225. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11226. /**
  11227. * Calculate the intercept of a ray on a given axis
  11228. * @param axis to check 'x' | 'y' | 'z'
  11229. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11230. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11231. */
  11232. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11233. /**
  11234. * Checks if ray intersects a mesh
  11235. * @param mesh the mesh to check
  11236. * @param fastCheck if only the bounding box should checked
  11237. * @returns picking info of the intersecton
  11238. */
  11239. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11240. /**
  11241. * Checks if ray intersects a mesh
  11242. * @param meshes the meshes to check
  11243. * @param fastCheck if only the bounding box should checked
  11244. * @param results array to store result in
  11245. * @returns Array of picking infos
  11246. */
  11247. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11248. private _comparePickingInfo;
  11249. private static smallnum;
  11250. private static rayl;
  11251. /**
  11252. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11253. * @param sega the first point of the segment to test the intersection against
  11254. * @param segb the second point of the segment to test the intersection against
  11255. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11256. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11257. */
  11258. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11259. /**
  11260. * Update the ray from viewport position
  11261. * @param x position
  11262. * @param y y position
  11263. * @param viewportWidth viewport width
  11264. * @param viewportHeight viewport height
  11265. * @param world world matrix
  11266. * @param view view matrix
  11267. * @param projection projection matrix
  11268. * @returns this ray updated
  11269. */
  11270. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11271. /**
  11272. * Creates a ray with origin and direction of 0,0,0
  11273. * @returns the new ray
  11274. */
  11275. static Zero(): Ray;
  11276. /**
  11277. * Creates a new ray from screen space and viewport
  11278. * @param x position
  11279. * @param y y position
  11280. * @param viewportWidth viewport width
  11281. * @param viewportHeight viewport height
  11282. * @param world world matrix
  11283. * @param view view matrix
  11284. * @param projection projection matrix
  11285. * @returns new ray
  11286. */
  11287. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11288. /**
  11289. * 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
  11290. * transformed to the given world matrix.
  11291. * @param origin The origin point
  11292. * @param end The end point
  11293. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11294. * @returns the new ray
  11295. */
  11296. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11297. /**
  11298. * Transforms a ray by a matrix
  11299. * @param ray ray to transform
  11300. * @param matrix matrix to apply
  11301. * @returns the resulting new ray
  11302. */
  11303. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11304. /**
  11305. * Transforms a ray by a matrix
  11306. * @param ray ray to transform
  11307. * @param matrix matrix to apply
  11308. * @param result ray to store result in
  11309. */
  11310. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11311. /**
  11312. * Unproject a ray from screen space to object space
  11313. * @param sourceX defines the screen space x coordinate to use
  11314. * @param sourceY defines the screen space y coordinate to use
  11315. * @param viewportWidth defines the current width of the viewport
  11316. * @param viewportHeight defines the current height of the viewport
  11317. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11318. * @param view defines the view matrix to use
  11319. * @param projection defines the projection matrix to use
  11320. */
  11321. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11322. }
  11323. /**
  11324. * Type used to define predicate used to select faces when a mesh intersection is detected
  11325. */
  11326. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11327. module "babylonjs/scene" {
  11328. interface Scene {
  11329. /** @hidden */
  11330. _tempPickingRay: Nullable<Ray>;
  11331. /** @hidden */
  11332. _cachedRayForTransform: Ray;
  11333. /** @hidden */
  11334. _pickWithRayInverseMatrix: Matrix;
  11335. /** @hidden */
  11336. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11337. /** @hidden */
  11338. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11339. }
  11340. }
  11341. }
  11342. declare module "babylonjs/sceneComponent" {
  11343. import { Scene } from "babylonjs/scene";
  11344. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11345. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11346. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11347. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11348. import { Nullable } from "babylonjs/types";
  11349. import { Camera } from "babylonjs/Cameras/camera";
  11350. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11351. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11352. import { AbstractScene } from "babylonjs/abstractScene";
  11353. /**
  11354. * Groups all the scene component constants in one place to ease maintenance.
  11355. * @hidden
  11356. */
  11357. export class SceneComponentConstants {
  11358. static readonly NAME_EFFECTLAYER: string;
  11359. static readonly NAME_LAYER: string;
  11360. static readonly NAME_LENSFLARESYSTEM: string;
  11361. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11362. static readonly NAME_PARTICLESYSTEM: string;
  11363. static readonly NAME_GAMEPAD: string;
  11364. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11365. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11366. static readonly NAME_DEPTHRENDERER: string;
  11367. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11368. static readonly NAME_SPRITE: string;
  11369. static readonly NAME_OUTLINERENDERER: string;
  11370. static readonly NAME_PROCEDURALTEXTURE: string;
  11371. static readonly NAME_SHADOWGENERATOR: string;
  11372. static readonly NAME_OCTREE: string;
  11373. static readonly NAME_PHYSICSENGINE: string;
  11374. static readonly NAME_AUDIO: string;
  11375. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11376. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11377. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11378. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11379. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11380. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11381. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11382. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11383. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11384. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11385. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11386. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11387. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11388. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11389. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11390. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11391. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11392. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11393. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11394. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11395. static readonly STEP_AFTERRENDER_AUDIO: number;
  11396. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11397. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11398. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11399. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11400. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11401. static readonly STEP_POINTERMOVE_SPRITE: number;
  11402. static readonly STEP_POINTERDOWN_SPRITE: number;
  11403. static readonly STEP_POINTERUP_SPRITE: number;
  11404. }
  11405. /**
  11406. * This represents a scene component.
  11407. *
  11408. * This is used to decouple the dependency the scene is having on the different workloads like
  11409. * layers, post processes...
  11410. */
  11411. export interface ISceneComponent {
  11412. /**
  11413. * The name of the component. Each component must have a unique name.
  11414. */
  11415. name: string;
  11416. /**
  11417. * The scene the component belongs to.
  11418. */
  11419. scene: Scene;
  11420. /**
  11421. * Register the component to one instance of a scene.
  11422. */
  11423. register(): void;
  11424. /**
  11425. * Rebuilds the elements related to this component in case of
  11426. * context lost for instance.
  11427. */
  11428. rebuild(): void;
  11429. /**
  11430. * Disposes the component and the associated ressources.
  11431. */
  11432. dispose(): void;
  11433. }
  11434. /**
  11435. * This represents a SERIALIZABLE scene component.
  11436. *
  11437. * This extends Scene Component to add Serialization methods on top.
  11438. */
  11439. export interface ISceneSerializableComponent extends ISceneComponent {
  11440. /**
  11441. * Adds all the elements from the container to the scene
  11442. * @param container the container holding the elements
  11443. */
  11444. addFromContainer(container: AbstractScene): void;
  11445. /**
  11446. * Removes all the elements in the container from the scene
  11447. * @param container contains the elements to remove
  11448. * @param dispose if the removed element should be disposed (default: false)
  11449. */
  11450. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11451. /**
  11452. * Serializes the component data to the specified json object
  11453. * @param serializationObject The object to serialize to
  11454. */
  11455. serialize(serializationObject: any): void;
  11456. }
  11457. /**
  11458. * Strong typing of a Mesh related stage step action
  11459. */
  11460. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11461. /**
  11462. * Strong typing of a Evaluate Sub Mesh related stage step action
  11463. */
  11464. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11465. /**
  11466. * Strong typing of a Active Mesh related stage step action
  11467. */
  11468. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11469. /**
  11470. * Strong typing of a Camera related stage step action
  11471. */
  11472. export type CameraStageAction = (camera: Camera) => void;
  11473. /**
  11474. * Strong typing of a Camera Frame buffer related stage step action
  11475. */
  11476. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11477. /**
  11478. * Strong typing of a Render Target related stage step action
  11479. */
  11480. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11481. /**
  11482. * Strong typing of a RenderingGroup related stage step action
  11483. */
  11484. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11485. /**
  11486. * Strong typing of a Mesh Render related stage step action
  11487. */
  11488. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11489. /**
  11490. * Strong typing of a simple stage step action
  11491. */
  11492. export type SimpleStageAction = () => void;
  11493. /**
  11494. * Strong typing of a render target action.
  11495. */
  11496. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11497. /**
  11498. * Strong typing of a pointer move action.
  11499. */
  11500. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11501. /**
  11502. * Strong typing of a pointer up/down action.
  11503. */
  11504. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11505. /**
  11506. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11507. * @hidden
  11508. */
  11509. export class Stage<T extends Function> extends Array<{
  11510. index: number;
  11511. component: ISceneComponent;
  11512. action: T;
  11513. }> {
  11514. /**
  11515. * Hide ctor from the rest of the world.
  11516. * @param items The items to add.
  11517. */
  11518. private constructor();
  11519. /**
  11520. * Creates a new Stage.
  11521. * @returns A new instance of a Stage
  11522. */
  11523. static Create<T extends Function>(): Stage<T>;
  11524. /**
  11525. * Registers a step in an ordered way in the targeted stage.
  11526. * @param index Defines the position to register the step in
  11527. * @param component Defines the component attached to the step
  11528. * @param action Defines the action to launch during the step
  11529. */
  11530. registerStep(index: number, component: ISceneComponent, action: T): void;
  11531. /**
  11532. * Clears all the steps from the stage.
  11533. */
  11534. clear(): void;
  11535. }
  11536. }
  11537. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11538. import { Nullable } from "babylonjs/types";
  11539. import { Observable } from "babylonjs/Misc/observable";
  11540. import { Scene } from "babylonjs/scene";
  11541. import { Sprite } from "babylonjs/Sprites/sprite";
  11542. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11543. import { Ray } from "babylonjs/Culling/ray";
  11544. import { Camera } from "babylonjs/Cameras/camera";
  11545. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11546. import { ISceneComponent } from "babylonjs/sceneComponent";
  11547. module "babylonjs/scene" {
  11548. interface Scene {
  11549. /** @hidden */
  11550. _pointerOverSprite: Nullable<Sprite>;
  11551. /** @hidden */
  11552. _pickedDownSprite: Nullable<Sprite>;
  11553. /** @hidden */
  11554. _tempSpritePickingRay: Nullable<Ray>;
  11555. /**
  11556. * All of the sprite managers added to this scene
  11557. * @see http://doc.babylonjs.com/babylon101/sprites
  11558. */
  11559. spriteManagers: Array<ISpriteManager>;
  11560. /**
  11561. * An event triggered when sprites rendering is about to start
  11562. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11563. */
  11564. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11565. /**
  11566. * An event triggered when sprites rendering is done
  11567. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11568. */
  11569. onAfterSpritesRenderingObservable: Observable<Scene>;
  11570. /** @hidden */
  11571. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11572. /** Launch a ray to try to pick a sprite in the scene
  11573. * @param x position on screen
  11574. * @param y position on screen
  11575. * @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
  11576. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11577. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11578. * @returns a PickingInfo
  11579. */
  11580. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11581. /** Use the given ray to pick a sprite in the scene
  11582. * @param ray The ray (in world space) to use to pick meshes
  11583. * @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
  11584. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11585. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11586. * @returns a PickingInfo
  11587. */
  11588. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11589. /** @hidden */
  11590. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11591. /** Launch a ray to try to pick sprites in the scene
  11592. * @param x position on screen
  11593. * @param y position on screen
  11594. * @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
  11595. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11596. * @returns a PickingInfo array
  11597. */
  11598. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11599. /** Use the given ray to pick sprites in the scene
  11600. * @param ray The ray (in world space) to use to pick meshes
  11601. * @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
  11602. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11603. * @returns a PickingInfo array
  11604. */
  11605. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11606. /**
  11607. * Force the sprite under the pointer
  11608. * @param sprite defines the sprite to use
  11609. */
  11610. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11611. /**
  11612. * Gets the sprite under the pointer
  11613. * @returns a Sprite or null if no sprite is under the pointer
  11614. */
  11615. getPointerOverSprite(): Nullable<Sprite>;
  11616. }
  11617. }
  11618. /**
  11619. * Defines the sprite scene component responsible to manage sprites
  11620. * in a given scene.
  11621. */
  11622. export class SpriteSceneComponent implements ISceneComponent {
  11623. /**
  11624. * The component name helpfull to identify the component in the list of scene components.
  11625. */
  11626. readonly name: string;
  11627. /**
  11628. * The scene the component belongs to.
  11629. */
  11630. scene: Scene;
  11631. /** @hidden */
  11632. private _spritePredicate;
  11633. /**
  11634. * Creates a new instance of the component for the given scene
  11635. * @param scene Defines the scene to register the component in
  11636. */
  11637. constructor(scene: Scene);
  11638. /**
  11639. * Registers the component in a given scene
  11640. */
  11641. register(): void;
  11642. /**
  11643. * Rebuilds the elements related to this component in case of
  11644. * context lost for instance.
  11645. */
  11646. rebuild(): void;
  11647. /**
  11648. * Disposes the component and the associated ressources.
  11649. */
  11650. dispose(): void;
  11651. private _pickSpriteButKeepRay;
  11652. private _pointerMove;
  11653. private _pointerDown;
  11654. private _pointerUp;
  11655. }
  11656. }
  11657. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11658. /** @hidden */
  11659. export var fogFragmentDeclaration: {
  11660. name: string;
  11661. shader: string;
  11662. };
  11663. }
  11664. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11665. /** @hidden */
  11666. export var fogFragment: {
  11667. name: string;
  11668. shader: string;
  11669. };
  11670. }
  11671. declare module "babylonjs/Shaders/sprites.fragment" {
  11672. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11673. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11674. /** @hidden */
  11675. export var spritesPixelShader: {
  11676. name: string;
  11677. shader: string;
  11678. };
  11679. }
  11680. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11681. /** @hidden */
  11682. export var fogVertexDeclaration: {
  11683. name: string;
  11684. shader: string;
  11685. };
  11686. }
  11687. declare module "babylonjs/Shaders/sprites.vertex" {
  11688. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11689. /** @hidden */
  11690. export var spritesVertexShader: {
  11691. name: string;
  11692. shader: string;
  11693. };
  11694. }
  11695. declare module "babylonjs/Sprites/spriteManager" {
  11696. import { IDisposable, Scene } from "babylonjs/scene";
  11697. import { Nullable } from "babylonjs/types";
  11698. import { Observable } from "babylonjs/Misc/observable";
  11699. import { Sprite } from "babylonjs/Sprites/sprite";
  11700. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11701. import { Camera } from "babylonjs/Cameras/camera";
  11702. import { Texture } from "babylonjs/Materials/Textures/texture";
  11703. import "babylonjs/Shaders/sprites.fragment";
  11704. import "babylonjs/Shaders/sprites.vertex";
  11705. import { Ray } from "babylonjs/Culling/ray";
  11706. /**
  11707. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11708. */
  11709. export interface ISpriteManager extends IDisposable {
  11710. /**
  11711. * Restricts the camera to viewing objects with the same layerMask.
  11712. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11713. */
  11714. layerMask: number;
  11715. /**
  11716. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11717. */
  11718. isPickable: boolean;
  11719. /**
  11720. * Specifies the rendering group id for this mesh (0 by default)
  11721. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11722. */
  11723. renderingGroupId: number;
  11724. /**
  11725. * Defines the list of sprites managed by the manager.
  11726. */
  11727. sprites: Array<Sprite>;
  11728. /**
  11729. * Tests the intersection of a sprite with a specific ray.
  11730. * @param ray The ray we are sending to test the collision
  11731. * @param camera The camera space we are sending rays in
  11732. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11733. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11734. * @returns picking info or null.
  11735. */
  11736. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11737. /**
  11738. * Intersects the sprites with a ray
  11739. * @param ray defines the ray to intersect with
  11740. * @param camera defines the current active camera
  11741. * @param predicate defines a predicate used to select candidate sprites
  11742. * @returns null if no hit or a PickingInfo array
  11743. */
  11744. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11745. /**
  11746. * Renders the list of sprites on screen.
  11747. */
  11748. render(): void;
  11749. }
  11750. /**
  11751. * Class used to manage multiple sprites on the same spritesheet
  11752. * @see http://doc.babylonjs.com/babylon101/sprites
  11753. */
  11754. export class SpriteManager implements ISpriteManager {
  11755. /** defines the manager's name */
  11756. name: string;
  11757. /** Gets the list of sprites */
  11758. sprites: Sprite[];
  11759. /** Gets or sets the rendering group id (0 by default) */
  11760. renderingGroupId: number;
  11761. /** Gets or sets camera layer mask */
  11762. layerMask: number;
  11763. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11764. fogEnabled: boolean;
  11765. /** Gets or sets a boolean indicating if the sprites are pickable */
  11766. isPickable: boolean;
  11767. /** Defines the default width of a cell in the spritesheet */
  11768. cellWidth: number;
  11769. /** Defines the default height of a cell in the spritesheet */
  11770. cellHeight: number;
  11771. /** Associative array from JSON sprite data file */
  11772. private _cellData;
  11773. /** Array of sprite names from JSON sprite data file */
  11774. private _spriteMap;
  11775. /** True when packed cell data from JSON file is ready*/
  11776. private _packedAndReady;
  11777. /**
  11778. * An event triggered when the manager is disposed.
  11779. */
  11780. onDisposeObservable: Observable<SpriteManager>;
  11781. private _onDisposeObserver;
  11782. /**
  11783. * Callback called when the manager is disposed
  11784. */
  11785. onDispose: () => void;
  11786. private _capacity;
  11787. private _fromPacked;
  11788. private _spriteTexture;
  11789. private _epsilon;
  11790. private _scene;
  11791. private _vertexData;
  11792. private _buffer;
  11793. private _vertexBuffers;
  11794. private _indexBuffer;
  11795. private _effectBase;
  11796. private _effectFog;
  11797. /**
  11798. * Gets or sets the spritesheet texture
  11799. */
  11800. texture: Texture;
  11801. /**
  11802. * Creates a new sprite manager
  11803. * @param name defines the manager's name
  11804. * @param imgUrl defines the sprite sheet url
  11805. * @param capacity defines the maximum allowed number of sprites
  11806. * @param cellSize defines the size of a sprite cell
  11807. * @param scene defines the hosting scene
  11808. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11809. * @param samplingMode defines the smapling mode to use with spritesheet
  11810. * @param fromPacked set to false; do not alter
  11811. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11812. */
  11813. constructor(
  11814. /** defines the manager's name */
  11815. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11816. private _makePacked;
  11817. private _appendSpriteVertex;
  11818. /**
  11819. * Intersects the sprites with a ray
  11820. * @param ray defines the ray to intersect with
  11821. * @param camera defines the current active camera
  11822. * @param predicate defines a predicate used to select candidate sprites
  11823. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11824. * @returns null if no hit or a PickingInfo
  11825. */
  11826. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11827. /**
  11828. * Intersects the sprites with a ray
  11829. * @param ray defines the ray to intersect with
  11830. * @param camera defines the current active camera
  11831. * @param predicate defines a predicate used to select candidate sprites
  11832. * @returns null if no hit or a PickingInfo array
  11833. */
  11834. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11835. /**
  11836. * Render all child sprites
  11837. */
  11838. render(): void;
  11839. /**
  11840. * Release associated resources
  11841. */
  11842. dispose(): void;
  11843. }
  11844. }
  11845. declare module "babylonjs/Sprites/sprite" {
  11846. import { Vector3 } from "babylonjs/Maths/math.vector";
  11847. import { Nullable } from "babylonjs/types";
  11848. import { ActionManager } from "babylonjs/Actions/actionManager";
  11849. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11850. import { Color4 } from "babylonjs/Maths/math.color";
  11851. /**
  11852. * Class used to represent a sprite
  11853. * @see http://doc.babylonjs.com/babylon101/sprites
  11854. */
  11855. export class Sprite {
  11856. /** defines the name */
  11857. name: string;
  11858. /** Gets or sets the current world position */
  11859. position: Vector3;
  11860. /** Gets or sets the main color */
  11861. color: Color4;
  11862. /** Gets or sets the width */
  11863. width: number;
  11864. /** Gets or sets the height */
  11865. height: number;
  11866. /** Gets or sets rotation angle */
  11867. angle: number;
  11868. /** Gets or sets the cell index in the sprite sheet */
  11869. cellIndex: number;
  11870. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11871. cellRef: string;
  11872. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11873. invertU: number;
  11874. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11875. invertV: number;
  11876. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11877. disposeWhenFinishedAnimating: boolean;
  11878. /** Gets the list of attached animations */
  11879. animations: Animation[];
  11880. /** Gets or sets a boolean indicating if the sprite can be picked */
  11881. isPickable: boolean;
  11882. /**
  11883. * Gets or sets the associated action manager
  11884. */
  11885. actionManager: Nullable<ActionManager>;
  11886. private _animationStarted;
  11887. private _loopAnimation;
  11888. private _fromIndex;
  11889. private _toIndex;
  11890. private _delay;
  11891. private _direction;
  11892. private _manager;
  11893. private _time;
  11894. private _onAnimationEnd;
  11895. /**
  11896. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11897. */
  11898. isVisible: boolean;
  11899. /**
  11900. * Gets or sets the sprite size
  11901. */
  11902. size: number;
  11903. /**
  11904. * Creates a new Sprite
  11905. * @param name defines the name
  11906. * @param manager defines the manager
  11907. */
  11908. constructor(
  11909. /** defines the name */
  11910. name: string, manager: ISpriteManager);
  11911. /**
  11912. * Starts an animation
  11913. * @param from defines the initial key
  11914. * @param to defines the end key
  11915. * @param loop defines if the animation must loop
  11916. * @param delay defines the start delay (in ms)
  11917. * @param onAnimationEnd defines a callback to call when animation ends
  11918. */
  11919. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11920. /** Stops current animation (if any) */
  11921. stopAnimation(): void;
  11922. /** @hidden */
  11923. _animate(deltaTime: number): void;
  11924. /** Release associated resources */
  11925. dispose(): void;
  11926. }
  11927. }
  11928. declare module "babylonjs/Collisions/pickingInfo" {
  11929. import { Nullable } from "babylonjs/types";
  11930. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11931. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11932. import { Sprite } from "babylonjs/Sprites/sprite";
  11933. import { Ray } from "babylonjs/Culling/ray";
  11934. /**
  11935. * Information about the result of picking within a scene
  11936. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11937. */
  11938. export class PickingInfo {
  11939. /** @hidden */
  11940. _pickingUnavailable: boolean;
  11941. /**
  11942. * If the pick collided with an object
  11943. */
  11944. hit: boolean;
  11945. /**
  11946. * Distance away where the pick collided
  11947. */
  11948. distance: number;
  11949. /**
  11950. * The location of pick collision
  11951. */
  11952. pickedPoint: Nullable<Vector3>;
  11953. /**
  11954. * The mesh corresponding the the pick collision
  11955. */
  11956. pickedMesh: Nullable<AbstractMesh>;
  11957. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11958. bu: number;
  11959. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11960. bv: number;
  11961. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11962. faceId: number;
  11963. /** Id of the the submesh that was picked */
  11964. subMeshId: number;
  11965. /** If a sprite was picked, this will be the sprite the pick collided with */
  11966. pickedSprite: Nullable<Sprite>;
  11967. /**
  11968. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11969. */
  11970. originMesh: Nullable<AbstractMesh>;
  11971. /**
  11972. * The ray that was used to perform the picking.
  11973. */
  11974. ray: Nullable<Ray>;
  11975. /**
  11976. * Gets the normal correspodning to the face the pick collided with
  11977. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11978. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11979. * @returns The normal correspodning to the face the pick collided with
  11980. */
  11981. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11982. /**
  11983. * Gets the texture coordinates of where the pick occured
  11984. * @returns the vector containing the coordnates of the texture
  11985. */
  11986. getTextureCoordinates(): Nullable<Vector2>;
  11987. }
  11988. }
  11989. declare module "babylonjs/Events/pointerEvents" {
  11990. import { Nullable } from "babylonjs/types";
  11991. import { Vector2 } from "babylonjs/Maths/math.vector";
  11992. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11993. import { Ray } from "babylonjs/Culling/ray";
  11994. /**
  11995. * Gather the list of pointer event types as constants.
  11996. */
  11997. export class PointerEventTypes {
  11998. /**
  11999. * 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.
  12000. */
  12001. static readonly POINTERDOWN: number;
  12002. /**
  12003. * The pointerup event is fired when a pointer is no longer active.
  12004. */
  12005. static readonly POINTERUP: number;
  12006. /**
  12007. * The pointermove event is fired when a pointer changes coordinates.
  12008. */
  12009. static readonly POINTERMOVE: number;
  12010. /**
  12011. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12012. */
  12013. static readonly POINTERWHEEL: number;
  12014. /**
  12015. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12016. */
  12017. static readonly POINTERPICK: number;
  12018. /**
  12019. * The pointertap event is fired when a the object has been touched and released without drag.
  12020. */
  12021. static readonly POINTERTAP: number;
  12022. /**
  12023. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12024. */
  12025. static readonly POINTERDOUBLETAP: number;
  12026. }
  12027. /**
  12028. * Base class of pointer info types.
  12029. */
  12030. export class PointerInfoBase {
  12031. /**
  12032. * Defines the type of event (PointerEventTypes)
  12033. */
  12034. type: number;
  12035. /**
  12036. * Defines the related dom event
  12037. */
  12038. event: PointerEvent | MouseWheelEvent;
  12039. /**
  12040. * Instantiates the base class of pointers info.
  12041. * @param type Defines the type of event (PointerEventTypes)
  12042. * @param event Defines the related dom event
  12043. */
  12044. constructor(
  12045. /**
  12046. * Defines the type of event (PointerEventTypes)
  12047. */
  12048. type: number,
  12049. /**
  12050. * Defines the related dom event
  12051. */
  12052. event: PointerEvent | MouseWheelEvent);
  12053. }
  12054. /**
  12055. * This class is used to store pointer related info for the onPrePointerObservable event.
  12056. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12057. */
  12058. export class PointerInfoPre extends PointerInfoBase {
  12059. /**
  12060. * Ray from a pointer if availible (eg. 6dof controller)
  12061. */
  12062. ray: Nullable<Ray>;
  12063. /**
  12064. * Defines the local position of the pointer on the canvas.
  12065. */
  12066. localPosition: Vector2;
  12067. /**
  12068. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12069. */
  12070. skipOnPointerObservable: boolean;
  12071. /**
  12072. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12073. * @param type Defines the type of event (PointerEventTypes)
  12074. * @param event Defines the related dom event
  12075. * @param localX Defines the local x coordinates of the pointer when the event occured
  12076. * @param localY Defines the local y coordinates of the pointer when the event occured
  12077. */
  12078. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12079. }
  12080. /**
  12081. * This type contains all the data related to a pointer event in Babylon.js.
  12082. * 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.
  12083. */
  12084. export class PointerInfo extends PointerInfoBase {
  12085. /**
  12086. * Defines the picking info associated to the info (if any)\
  12087. */
  12088. pickInfo: Nullable<PickingInfo>;
  12089. /**
  12090. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12091. * @param type Defines the type of event (PointerEventTypes)
  12092. * @param event Defines the related dom event
  12093. * @param pickInfo Defines the picking info associated to the info (if any)\
  12094. */
  12095. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12096. /**
  12097. * Defines the picking info associated to the info (if any)\
  12098. */
  12099. pickInfo: Nullable<PickingInfo>);
  12100. }
  12101. /**
  12102. * Data relating to a touch event on the screen.
  12103. */
  12104. export interface PointerTouch {
  12105. /**
  12106. * X coordinate of touch.
  12107. */
  12108. x: number;
  12109. /**
  12110. * Y coordinate of touch.
  12111. */
  12112. y: number;
  12113. /**
  12114. * Id of touch. Unique for each finger.
  12115. */
  12116. pointerId: number;
  12117. /**
  12118. * Event type passed from DOM.
  12119. */
  12120. type: any;
  12121. }
  12122. }
  12123. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12124. import { Observable } from "babylonjs/Misc/observable";
  12125. import { Nullable } from "babylonjs/types";
  12126. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12127. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12128. /**
  12129. * Manage the mouse inputs to control the movement of a free camera.
  12130. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12131. */
  12132. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12133. /**
  12134. * Define if touch is enabled in the mouse input
  12135. */
  12136. touchEnabled: boolean;
  12137. /**
  12138. * Defines the camera the input is attached to.
  12139. */
  12140. camera: FreeCamera;
  12141. /**
  12142. * Defines the buttons associated with the input to handle camera move.
  12143. */
  12144. buttons: number[];
  12145. /**
  12146. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12147. */
  12148. angularSensibility: number;
  12149. private _pointerInput;
  12150. private _onMouseMove;
  12151. private _observer;
  12152. private previousPosition;
  12153. /**
  12154. * Observable for when a pointer move event occurs containing the move offset
  12155. */
  12156. onPointerMovedObservable: Observable<{
  12157. offsetX: number;
  12158. offsetY: number;
  12159. }>;
  12160. /**
  12161. * @hidden
  12162. * If the camera should be rotated automatically based on pointer movement
  12163. */
  12164. _allowCameraRotation: boolean;
  12165. /**
  12166. * Manage the mouse inputs to control the movement of a free camera.
  12167. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12168. * @param touchEnabled Defines if touch is enabled or not
  12169. */
  12170. constructor(
  12171. /**
  12172. * Define if touch is enabled in the mouse input
  12173. */
  12174. touchEnabled?: boolean);
  12175. /**
  12176. * Attach the input controls to a specific dom element to get the input from.
  12177. * @param element Defines the element the controls should be listened from
  12178. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12179. */
  12180. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12181. /**
  12182. * Called on JS contextmenu event.
  12183. * Override this method to provide functionality.
  12184. */
  12185. protected onContextMenu(evt: PointerEvent): void;
  12186. /**
  12187. * Detach the current controls from the specified dom element.
  12188. * @param element Defines the element to stop listening the inputs from
  12189. */
  12190. detachControl(element: Nullable<HTMLElement>): void;
  12191. /**
  12192. * Gets the class name of the current intput.
  12193. * @returns the class name
  12194. */
  12195. getClassName(): string;
  12196. /**
  12197. * Get the friendly name associated with the input class.
  12198. * @returns the input friendly name
  12199. */
  12200. getSimpleName(): string;
  12201. }
  12202. }
  12203. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12204. import { Nullable } from "babylonjs/types";
  12205. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12206. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12207. /**
  12208. * Manage the touch inputs to control the movement of a free camera.
  12209. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12210. */
  12211. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12212. /**
  12213. * Defines the camera the input is attached to.
  12214. */
  12215. camera: FreeCamera;
  12216. /**
  12217. * Defines the touch sensibility for rotation.
  12218. * The higher the faster.
  12219. */
  12220. touchAngularSensibility: number;
  12221. /**
  12222. * Defines the touch sensibility for move.
  12223. * The higher the faster.
  12224. */
  12225. touchMoveSensibility: number;
  12226. private _offsetX;
  12227. private _offsetY;
  12228. private _pointerPressed;
  12229. private _pointerInput;
  12230. private _observer;
  12231. private _onLostFocus;
  12232. /**
  12233. * Attach the input controls to a specific dom element to get the input from.
  12234. * @param element Defines the element the controls should be listened from
  12235. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12236. */
  12237. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12238. /**
  12239. * Detach the current controls from the specified dom element.
  12240. * @param element Defines the element to stop listening the inputs from
  12241. */
  12242. detachControl(element: Nullable<HTMLElement>): void;
  12243. /**
  12244. * Update the current camera state depending on the inputs that have been used this frame.
  12245. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12246. */
  12247. checkInputs(): void;
  12248. /**
  12249. * Gets the class name of the current intput.
  12250. * @returns the class name
  12251. */
  12252. getClassName(): string;
  12253. /**
  12254. * Get the friendly name associated with the input class.
  12255. * @returns the input friendly name
  12256. */
  12257. getSimpleName(): string;
  12258. }
  12259. }
  12260. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12261. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12262. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12263. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12264. import { Nullable } from "babylonjs/types";
  12265. /**
  12266. * Default Inputs manager for the FreeCamera.
  12267. * It groups all the default supported inputs for ease of use.
  12268. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12269. */
  12270. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12271. /**
  12272. * @hidden
  12273. */
  12274. _mouseInput: Nullable<FreeCameraMouseInput>;
  12275. /**
  12276. * Instantiates a new FreeCameraInputsManager.
  12277. * @param camera Defines the camera the inputs belong to
  12278. */
  12279. constructor(camera: FreeCamera);
  12280. /**
  12281. * Add keyboard input support to the input manager.
  12282. * @returns the current input manager
  12283. */
  12284. addKeyboard(): FreeCameraInputsManager;
  12285. /**
  12286. * Add mouse input support to the input manager.
  12287. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12288. * @returns the current input manager
  12289. */
  12290. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12291. /**
  12292. * Removes the mouse input support from the manager
  12293. * @returns the current input manager
  12294. */
  12295. removeMouse(): FreeCameraInputsManager;
  12296. /**
  12297. * Add touch input support to the input manager.
  12298. * @returns the current input manager
  12299. */
  12300. addTouch(): FreeCameraInputsManager;
  12301. /**
  12302. * Remove all attached input methods from a camera
  12303. */
  12304. clear(): void;
  12305. }
  12306. }
  12307. declare module "babylonjs/Cameras/freeCamera" {
  12308. import { Vector3 } from "babylonjs/Maths/math.vector";
  12309. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12310. import { Scene } from "babylonjs/scene";
  12311. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12312. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12313. /**
  12314. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12315. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12316. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12317. */
  12318. export class FreeCamera extends TargetCamera {
  12319. /**
  12320. * Define the collision ellipsoid of the camera.
  12321. * This is helpful to simulate a camera body like the player body around the camera
  12322. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12323. */
  12324. ellipsoid: Vector3;
  12325. /**
  12326. * Define an offset for the position of the ellipsoid around the camera.
  12327. * This can be helpful to determine the center of the body near the gravity center of the body
  12328. * instead of its head.
  12329. */
  12330. ellipsoidOffset: Vector3;
  12331. /**
  12332. * Enable or disable collisions of the camera with the rest of the scene objects.
  12333. */
  12334. checkCollisions: boolean;
  12335. /**
  12336. * Enable or disable gravity on the camera.
  12337. */
  12338. applyGravity: boolean;
  12339. /**
  12340. * Define the input manager associated to the camera.
  12341. */
  12342. inputs: FreeCameraInputsManager;
  12343. /**
  12344. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12345. * Higher values reduce sensitivity.
  12346. */
  12347. /**
  12348. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12349. * Higher values reduce sensitivity.
  12350. */
  12351. angularSensibility: number;
  12352. /**
  12353. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12354. */
  12355. keysUp: number[];
  12356. /**
  12357. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12358. */
  12359. keysDown: number[];
  12360. /**
  12361. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12362. */
  12363. keysLeft: number[];
  12364. /**
  12365. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12366. */
  12367. keysRight: number[];
  12368. /**
  12369. * Event raised when the camera collide with a mesh in the scene.
  12370. */
  12371. onCollide: (collidedMesh: AbstractMesh) => void;
  12372. private _collider;
  12373. private _needMoveForGravity;
  12374. private _oldPosition;
  12375. private _diffPosition;
  12376. private _newPosition;
  12377. /** @hidden */
  12378. _localDirection: Vector3;
  12379. /** @hidden */
  12380. _transformedDirection: Vector3;
  12381. /**
  12382. * Instantiates a Free Camera.
  12383. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12384. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12385. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12386. * @param name Define the name of the camera in the scene
  12387. * @param position Define the start position of the camera in the scene
  12388. * @param scene Define the scene the camera belongs to
  12389. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12390. */
  12391. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12392. /**
  12393. * Attached controls to the current camera.
  12394. * @param element Defines the element the controls should be listened from
  12395. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12396. */
  12397. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12398. /**
  12399. * Detach the current controls from the camera.
  12400. * The camera will stop reacting to inputs.
  12401. * @param element Defines the element to stop listening the inputs from
  12402. */
  12403. detachControl(element: HTMLElement): void;
  12404. private _collisionMask;
  12405. /**
  12406. * Define a collision mask to limit the list of object the camera can collide with
  12407. */
  12408. collisionMask: number;
  12409. /** @hidden */
  12410. _collideWithWorld(displacement: Vector3): void;
  12411. private _onCollisionPositionChange;
  12412. /** @hidden */
  12413. _checkInputs(): void;
  12414. /** @hidden */
  12415. _decideIfNeedsToMove(): boolean;
  12416. /** @hidden */
  12417. _updatePosition(): void;
  12418. /**
  12419. * Destroy the camera and release the current resources hold by it.
  12420. */
  12421. dispose(): void;
  12422. /**
  12423. * Gets the current object class name.
  12424. * @return the class name
  12425. */
  12426. getClassName(): string;
  12427. }
  12428. }
  12429. declare module "babylonjs/Gamepads/gamepad" {
  12430. import { Observable } from "babylonjs/Misc/observable";
  12431. /**
  12432. * Represents a gamepad control stick position
  12433. */
  12434. export class StickValues {
  12435. /**
  12436. * The x component of the control stick
  12437. */
  12438. x: number;
  12439. /**
  12440. * The y component of the control stick
  12441. */
  12442. y: number;
  12443. /**
  12444. * Initializes the gamepad x and y control stick values
  12445. * @param x The x component of the gamepad control stick value
  12446. * @param y The y component of the gamepad control stick value
  12447. */
  12448. constructor(
  12449. /**
  12450. * The x component of the control stick
  12451. */
  12452. x: number,
  12453. /**
  12454. * The y component of the control stick
  12455. */
  12456. y: number);
  12457. }
  12458. /**
  12459. * An interface which manages callbacks for gamepad button changes
  12460. */
  12461. export interface GamepadButtonChanges {
  12462. /**
  12463. * Called when a gamepad has been changed
  12464. */
  12465. changed: boolean;
  12466. /**
  12467. * Called when a gamepad press event has been triggered
  12468. */
  12469. pressChanged: boolean;
  12470. /**
  12471. * Called when a touch event has been triggered
  12472. */
  12473. touchChanged: boolean;
  12474. /**
  12475. * Called when a value has changed
  12476. */
  12477. valueChanged: boolean;
  12478. }
  12479. /**
  12480. * Represents a gamepad
  12481. */
  12482. export class Gamepad {
  12483. /**
  12484. * The id of the gamepad
  12485. */
  12486. id: string;
  12487. /**
  12488. * The index of the gamepad
  12489. */
  12490. index: number;
  12491. /**
  12492. * The browser gamepad
  12493. */
  12494. browserGamepad: any;
  12495. /**
  12496. * Specifies what type of gamepad this represents
  12497. */
  12498. type: number;
  12499. private _leftStick;
  12500. private _rightStick;
  12501. /** @hidden */
  12502. _isConnected: boolean;
  12503. private _leftStickAxisX;
  12504. private _leftStickAxisY;
  12505. private _rightStickAxisX;
  12506. private _rightStickAxisY;
  12507. /**
  12508. * Triggered when the left control stick has been changed
  12509. */
  12510. private _onleftstickchanged;
  12511. /**
  12512. * Triggered when the right control stick has been changed
  12513. */
  12514. private _onrightstickchanged;
  12515. /**
  12516. * Represents a gamepad controller
  12517. */
  12518. static GAMEPAD: number;
  12519. /**
  12520. * Represents a generic controller
  12521. */
  12522. static GENERIC: number;
  12523. /**
  12524. * Represents an XBox controller
  12525. */
  12526. static XBOX: number;
  12527. /**
  12528. * Represents a pose-enabled controller
  12529. */
  12530. static POSE_ENABLED: number;
  12531. /**
  12532. * Represents an Dual Shock controller
  12533. */
  12534. static DUALSHOCK: number;
  12535. /**
  12536. * Specifies whether the left control stick should be Y-inverted
  12537. */
  12538. protected _invertLeftStickY: boolean;
  12539. /**
  12540. * Specifies if the gamepad has been connected
  12541. */
  12542. readonly isConnected: boolean;
  12543. /**
  12544. * Initializes the gamepad
  12545. * @param id The id of the gamepad
  12546. * @param index The index of the gamepad
  12547. * @param browserGamepad The browser gamepad
  12548. * @param leftStickX The x component of the left joystick
  12549. * @param leftStickY The y component of the left joystick
  12550. * @param rightStickX The x component of the right joystick
  12551. * @param rightStickY The y component of the right joystick
  12552. */
  12553. constructor(
  12554. /**
  12555. * The id of the gamepad
  12556. */
  12557. id: string,
  12558. /**
  12559. * The index of the gamepad
  12560. */
  12561. index: number,
  12562. /**
  12563. * The browser gamepad
  12564. */
  12565. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12566. /**
  12567. * Callback triggered when the left joystick has changed
  12568. * @param callback
  12569. */
  12570. onleftstickchanged(callback: (values: StickValues) => void): void;
  12571. /**
  12572. * Callback triggered when the right joystick has changed
  12573. * @param callback
  12574. */
  12575. onrightstickchanged(callback: (values: StickValues) => void): void;
  12576. /**
  12577. * Gets the left joystick
  12578. */
  12579. /**
  12580. * Sets the left joystick values
  12581. */
  12582. leftStick: StickValues;
  12583. /**
  12584. * Gets the right joystick
  12585. */
  12586. /**
  12587. * Sets the right joystick value
  12588. */
  12589. rightStick: StickValues;
  12590. /**
  12591. * Updates the gamepad joystick positions
  12592. */
  12593. update(): void;
  12594. /**
  12595. * Disposes the gamepad
  12596. */
  12597. dispose(): void;
  12598. }
  12599. /**
  12600. * Represents a generic gamepad
  12601. */
  12602. export class GenericPad extends Gamepad {
  12603. private _buttons;
  12604. private _onbuttondown;
  12605. private _onbuttonup;
  12606. /**
  12607. * Observable triggered when a button has been pressed
  12608. */
  12609. onButtonDownObservable: Observable<number>;
  12610. /**
  12611. * Observable triggered when a button has been released
  12612. */
  12613. onButtonUpObservable: Observable<number>;
  12614. /**
  12615. * Callback triggered when a button has been pressed
  12616. * @param callback Called when a button has been pressed
  12617. */
  12618. onbuttondown(callback: (buttonPressed: number) => void): void;
  12619. /**
  12620. * Callback triggered when a button has been released
  12621. * @param callback Called when a button has been released
  12622. */
  12623. onbuttonup(callback: (buttonReleased: number) => void): void;
  12624. /**
  12625. * Initializes the generic gamepad
  12626. * @param id The id of the generic gamepad
  12627. * @param index The index of the generic gamepad
  12628. * @param browserGamepad The browser gamepad
  12629. */
  12630. constructor(id: string, index: number, browserGamepad: any);
  12631. private _setButtonValue;
  12632. /**
  12633. * Updates the generic gamepad
  12634. */
  12635. update(): void;
  12636. /**
  12637. * Disposes the generic gamepad
  12638. */
  12639. dispose(): void;
  12640. }
  12641. }
  12642. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  12643. import { Nullable } from "babylonjs/types";
  12644. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12645. import { Scene } from "babylonjs/scene";
  12646. module "babylonjs/Engines/engine" {
  12647. interface Engine {
  12648. /**
  12649. * Creates a raw texture
  12650. * @param data defines the data to store in the texture
  12651. * @param width defines the width of the texture
  12652. * @param height defines the height of the texture
  12653. * @param format defines the format of the data
  12654. * @param generateMipMaps defines if the engine should generate the mip levels
  12655. * @param invertY defines if data must be stored with Y axis inverted
  12656. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12657. * @param compression defines the compression used (null by default)
  12658. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12659. * @returns the raw texture inside an InternalTexture
  12660. */
  12661. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12662. /**
  12663. * Update a raw texture
  12664. * @param texture defines the texture to update
  12665. * @param data defines the data to store in the texture
  12666. * @param format defines the format of the data
  12667. * @param invertY defines if data must be stored with Y axis inverted
  12668. */
  12669. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12670. /**
  12671. * Update a raw texture
  12672. * @param texture defines the texture to update
  12673. * @param data defines the data to store in the texture
  12674. * @param format defines the format of the data
  12675. * @param invertY defines if data must be stored with Y axis inverted
  12676. * @param compression defines the compression used (null by default)
  12677. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12678. */
  12679. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12680. /**
  12681. * Creates a new raw cube texture
  12682. * @param data defines the array of data to use to create each face
  12683. * @param size defines the size of the textures
  12684. * @param format defines the format of the data
  12685. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12686. * @param generateMipMaps defines if the engine should generate the mip levels
  12687. * @param invertY defines if data must be stored with Y axis inverted
  12688. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12689. * @param compression defines the compression used (null by default)
  12690. * @returns the cube texture as an InternalTexture
  12691. */
  12692. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12693. /**
  12694. * Update a raw cube texture
  12695. * @param texture defines the texture to udpdate
  12696. * @param data defines the data to store
  12697. * @param format defines the data format
  12698. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12699. * @param invertY defines if data must be stored with Y axis inverted
  12700. */
  12701. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12702. /**
  12703. * Update a raw cube texture
  12704. * @param texture defines the texture to udpdate
  12705. * @param data defines the data to store
  12706. * @param format defines the data format
  12707. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12708. * @param invertY defines if data must be stored with Y axis inverted
  12709. * @param compression defines the compression used (null by default)
  12710. */
  12711. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12712. /**
  12713. * Update a raw cube texture
  12714. * @param texture defines the texture to udpdate
  12715. * @param data defines the data to store
  12716. * @param format defines the data format
  12717. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12718. * @param invertY defines if data must be stored with Y axis inverted
  12719. * @param compression defines the compression used (null by default)
  12720. * @param level defines which level of the texture to update
  12721. */
  12722. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12723. /**
  12724. * Creates a new raw cube texture from a specified url
  12725. * @param url defines the url where the data is located
  12726. * @param scene defines the current scene
  12727. * @param size defines the size of the textures
  12728. * @param format defines the format of the data
  12729. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12730. * @param noMipmap defines if the engine should avoid generating the mip levels
  12731. * @param callback defines a callback used to extract texture data from loaded data
  12732. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12733. * @param onLoad defines a callback called when texture is loaded
  12734. * @param onError defines a callback called if there is an error
  12735. * @returns the cube texture as an InternalTexture
  12736. */
  12737. 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;
  12738. /**
  12739. * Creates a new raw cube texture from a specified url
  12740. * @param url defines the url where the data is located
  12741. * @param scene defines the current scene
  12742. * @param size defines the size of the textures
  12743. * @param format defines the format of the data
  12744. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12745. * @param noMipmap defines if the engine should avoid generating the mip levels
  12746. * @param callback defines a callback used to extract texture data from loaded data
  12747. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12748. * @param onLoad defines a callback called when texture is loaded
  12749. * @param onError defines a callback called if there is an error
  12750. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12751. * @param invertY defines if data must be stored with Y axis inverted
  12752. * @returns the cube texture as an InternalTexture
  12753. */
  12754. 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;
  12755. /**
  12756. * Creates a new raw 3D texture
  12757. * @param data defines the data used to create the texture
  12758. * @param width defines the width of the texture
  12759. * @param height defines the height of the texture
  12760. * @param depth defines the depth of the texture
  12761. * @param format defines the format of the texture
  12762. * @param generateMipMaps defines if the engine must generate mip levels
  12763. * @param invertY defines if data must be stored with Y axis inverted
  12764. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12765. * @param compression defines the compressed used (can be null)
  12766. * @param textureType defines the compressed used (can be null)
  12767. * @returns a new raw 3D texture (stored in an InternalTexture)
  12768. */
  12769. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12770. /**
  12771. * Update a raw 3D texture
  12772. * @param texture defines the texture to update
  12773. * @param data defines the data to store
  12774. * @param format defines the data format
  12775. * @param invertY defines if data must be stored with Y axis inverted
  12776. */
  12777. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12778. /**
  12779. * Update a raw 3D texture
  12780. * @param texture defines the texture to update
  12781. * @param data defines the data to store
  12782. * @param format defines the data format
  12783. * @param invertY defines if data must be stored with Y axis inverted
  12784. * @param compression defines the used compression (can be null)
  12785. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12786. */
  12787. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12788. }
  12789. }
  12790. }
  12791. declare module "babylonjs/Materials/Textures/rawTexture" {
  12792. import { Scene } from "babylonjs/scene";
  12793. import { Texture } from "babylonjs/Materials/Textures/texture";
  12794. import "babylonjs/Engines/Extensions/engine.rawTexture";
  12795. /**
  12796. * Raw texture can help creating a texture directly from an array of data.
  12797. * This can be super useful if you either get the data from an uncompressed source or
  12798. * if you wish to create your texture pixel by pixel.
  12799. */
  12800. export class RawTexture extends Texture {
  12801. /**
  12802. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12803. */
  12804. format: number;
  12805. private _engine;
  12806. /**
  12807. * Instantiates a new RawTexture.
  12808. * Raw texture can help creating a texture directly from an array of data.
  12809. * This can be super useful if you either get the data from an uncompressed source or
  12810. * if you wish to create your texture pixel by pixel.
  12811. * @param data define the array of data to use to create the texture
  12812. * @param width define the width of the texture
  12813. * @param height define the height of the texture
  12814. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12815. * @param scene define the scene the texture belongs to
  12816. * @param generateMipMaps define whether mip maps should be generated or not
  12817. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12818. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12819. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12820. */
  12821. constructor(data: ArrayBufferView, width: number, height: number,
  12822. /**
  12823. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12824. */
  12825. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12826. /**
  12827. * Updates the texture underlying data.
  12828. * @param data Define the new data of the texture
  12829. */
  12830. update(data: ArrayBufferView): void;
  12831. /**
  12832. * Creates a luminance texture from some data.
  12833. * @param data Define the texture data
  12834. * @param width Define the width of the texture
  12835. * @param height Define the height of the texture
  12836. * @param scene Define the scene the texture belongs to
  12837. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12838. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12839. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12840. * @returns the luminance texture
  12841. */
  12842. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12843. /**
  12844. * Creates a luminance alpha texture from some data.
  12845. * @param data Define the texture data
  12846. * @param width Define the width of the texture
  12847. * @param height Define the height of the texture
  12848. * @param scene Define the scene the texture belongs to
  12849. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12850. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12851. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12852. * @returns the luminance alpha texture
  12853. */
  12854. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12855. /**
  12856. * Creates an alpha texture from some data.
  12857. * @param data Define the texture data
  12858. * @param width Define the width of the texture
  12859. * @param height Define the height of the texture
  12860. * @param scene Define the scene the texture belongs to
  12861. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12862. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12863. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12864. * @returns the alpha texture
  12865. */
  12866. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12867. /**
  12868. * Creates a RGB texture from some data.
  12869. * @param data Define the texture data
  12870. * @param width Define the width of the texture
  12871. * @param height Define the height of the texture
  12872. * @param scene Define the scene the texture belongs to
  12873. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12874. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12875. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12876. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12877. * @returns the RGB alpha texture
  12878. */
  12879. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12880. /**
  12881. * Creates a RGBA texture from some data.
  12882. * @param data Define the texture data
  12883. * @param width Define the width of the texture
  12884. * @param height Define the height of the texture
  12885. * @param scene Define the scene the texture belongs to
  12886. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12887. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12888. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12889. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12890. * @returns the RGBA texture
  12891. */
  12892. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12893. /**
  12894. * Creates a R 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. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12903. * @returns the R texture
  12904. */
  12905. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12906. }
  12907. }
  12908. declare module "babylonjs/Maths/math.size" {
  12909. /**
  12910. * Interface for the size containing width and height
  12911. */
  12912. export interface ISize {
  12913. /**
  12914. * Width
  12915. */
  12916. width: number;
  12917. /**
  12918. * Heighht
  12919. */
  12920. height: number;
  12921. }
  12922. /**
  12923. * Size containing widht and height
  12924. */
  12925. export class Size implements ISize {
  12926. /**
  12927. * Width
  12928. */
  12929. width: number;
  12930. /**
  12931. * Height
  12932. */
  12933. height: number;
  12934. /**
  12935. * Creates a Size object from the given width and height (floats).
  12936. * @param width width of the new size
  12937. * @param height height of the new size
  12938. */
  12939. constructor(width: number, height: number);
  12940. /**
  12941. * Returns a string with the Size width and height
  12942. * @returns a string with the Size width and height
  12943. */
  12944. toString(): string;
  12945. /**
  12946. * "Size"
  12947. * @returns the string "Size"
  12948. */
  12949. getClassName(): string;
  12950. /**
  12951. * Returns the Size hash code.
  12952. * @returns a hash code for a unique width and height
  12953. */
  12954. getHashCode(): number;
  12955. /**
  12956. * Updates the current size from the given one.
  12957. * @param src the given size
  12958. */
  12959. copyFrom(src: Size): void;
  12960. /**
  12961. * Updates in place the current Size from the given floats.
  12962. * @param width width of the new size
  12963. * @param height height of the new size
  12964. * @returns the updated Size.
  12965. */
  12966. copyFromFloats(width: number, height: number): Size;
  12967. /**
  12968. * Updates in place the current Size from the given floats.
  12969. * @param width width to set
  12970. * @param height height to set
  12971. * @returns the updated Size.
  12972. */
  12973. set(width: number, height: number): Size;
  12974. /**
  12975. * Multiplies the width and height by numbers
  12976. * @param w factor to multiple the width by
  12977. * @param h factor to multiple the height by
  12978. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12979. */
  12980. multiplyByFloats(w: number, h: number): Size;
  12981. /**
  12982. * Clones the size
  12983. * @returns a new Size copied from the given one.
  12984. */
  12985. clone(): Size;
  12986. /**
  12987. * True if the current Size and the given one width and height are strictly equal.
  12988. * @param other the other size to compare against
  12989. * @returns True if the current Size and the given one width and height are strictly equal.
  12990. */
  12991. equals(other: Size): boolean;
  12992. /**
  12993. * The surface of the Size : width * height (float).
  12994. */
  12995. readonly surface: number;
  12996. /**
  12997. * Create a new size of zero
  12998. * @returns a new Size set to (0.0, 0.0)
  12999. */
  13000. static Zero(): Size;
  13001. /**
  13002. * Sums the width and height of two sizes
  13003. * @param otherSize size to add to this size
  13004. * @returns a new Size set as the addition result of the current Size and the given one.
  13005. */
  13006. add(otherSize: Size): Size;
  13007. /**
  13008. * Subtracts the width and height of two
  13009. * @param otherSize size to subtract to this size
  13010. * @returns a new Size set as the subtraction result of the given one from the current Size.
  13011. */
  13012. subtract(otherSize: Size): Size;
  13013. /**
  13014. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  13015. * @param start starting size to lerp between
  13016. * @param end end size to lerp between
  13017. * @param amount amount to lerp between the start and end values
  13018. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  13019. */
  13020. static Lerp(start: Size, end: Size, amount: number): Size;
  13021. }
  13022. }
  13023. declare module "babylonjs/Animations/runtimeAnimation" {
  13024. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  13025. import { Animatable } from "babylonjs/Animations/animatable";
  13026. import { Scene } from "babylonjs/scene";
  13027. /**
  13028. * Defines a runtime animation
  13029. */
  13030. export class RuntimeAnimation {
  13031. private _events;
  13032. /**
  13033. * The current frame of the runtime animation
  13034. */
  13035. private _currentFrame;
  13036. /**
  13037. * The animation used by the runtime animation
  13038. */
  13039. private _animation;
  13040. /**
  13041. * The target of the runtime animation
  13042. */
  13043. private _target;
  13044. /**
  13045. * The initiating animatable
  13046. */
  13047. private _host;
  13048. /**
  13049. * The original value of the runtime animation
  13050. */
  13051. private _originalValue;
  13052. /**
  13053. * The original blend value of the runtime animation
  13054. */
  13055. private _originalBlendValue;
  13056. /**
  13057. * The offsets cache of the runtime animation
  13058. */
  13059. private _offsetsCache;
  13060. /**
  13061. * The high limits cache of the runtime animation
  13062. */
  13063. private _highLimitsCache;
  13064. /**
  13065. * Specifies if the runtime animation has been stopped
  13066. */
  13067. private _stopped;
  13068. /**
  13069. * The blending factor of the runtime animation
  13070. */
  13071. private _blendingFactor;
  13072. /**
  13073. * The BabylonJS scene
  13074. */
  13075. private _scene;
  13076. /**
  13077. * The current value of the runtime animation
  13078. */
  13079. private _currentValue;
  13080. /** @hidden */
  13081. _animationState: _IAnimationState;
  13082. /**
  13083. * The active target of the runtime animation
  13084. */
  13085. private _activeTargets;
  13086. private _currentActiveTarget;
  13087. private _directTarget;
  13088. /**
  13089. * The target path of the runtime animation
  13090. */
  13091. private _targetPath;
  13092. /**
  13093. * The weight of the runtime animation
  13094. */
  13095. private _weight;
  13096. /**
  13097. * The ratio offset of the runtime animation
  13098. */
  13099. private _ratioOffset;
  13100. /**
  13101. * The previous delay of the runtime animation
  13102. */
  13103. private _previousDelay;
  13104. /**
  13105. * The previous ratio of the runtime animation
  13106. */
  13107. private _previousRatio;
  13108. private _enableBlending;
  13109. private _keys;
  13110. private _minFrame;
  13111. private _maxFrame;
  13112. private _minValue;
  13113. private _maxValue;
  13114. private _targetIsArray;
  13115. /**
  13116. * Gets the current frame of the runtime animation
  13117. */
  13118. readonly currentFrame: number;
  13119. /**
  13120. * Gets the weight of the runtime animation
  13121. */
  13122. readonly weight: number;
  13123. /**
  13124. * Gets the current value of the runtime animation
  13125. */
  13126. readonly currentValue: any;
  13127. /**
  13128. * Gets the target path of the runtime animation
  13129. */
  13130. readonly targetPath: string;
  13131. /**
  13132. * Gets the actual target of the runtime animation
  13133. */
  13134. readonly target: any;
  13135. /** @hidden */
  13136. _onLoop: () => void;
  13137. /**
  13138. * Create a new RuntimeAnimation object
  13139. * @param target defines the target of the animation
  13140. * @param animation defines the source animation object
  13141. * @param scene defines the hosting scene
  13142. * @param host defines the initiating Animatable
  13143. */
  13144. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  13145. private _preparePath;
  13146. /**
  13147. * Gets the animation from the runtime animation
  13148. */
  13149. readonly animation: Animation;
  13150. /**
  13151. * Resets the runtime animation to the beginning
  13152. * @param restoreOriginal defines whether to restore the target property to the original value
  13153. */
  13154. reset(restoreOriginal?: boolean): void;
  13155. /**
  13156. * Specifies if the runtime animation is stopped
  13157. * @returns Boolean specifying if the runtime animation is stopped
  13158. */
  13159. isStopped(): boolean;
  13160. /**
  13161. * Disposes of the runtime animation
  13162. */
  13163. dispose(): void;
  13164. /**
  13165. * Apply the interpolated value to the target
  13166. * @param currentValue defines the value computed by the animation
  13167. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  13168. */
  13169. setValue(currentValue: any, weight: number): void;
  13170. private _getOriginalValues;
  13171. private _setValue;
  13172. /**
  13173. * Gets the loop pmode of the runtime animation
  13174. * @returns Loop Mode
  13175. */
  13176. private _getCorrectLoopMode;
  13177. /**
  13178. * Move the current animation to a given frame
  13179. * @param frame defines the frame to move to
  13180. */
  13181. goToFrame(frame: number): void;
  13182. /**
  13183. * @hidden Internal use only
  13184. */
  13185. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13186. /**
  13187. * Execute the current animation
  13188. * @param delay defines the delay to add to the current frame
  13189. * @param from defines the lower bound of the animation range
  13190. * @param to defines the upper bound of the animation range
  13191. * @param loop defines if the current animation must loop
  13192. * @param speedRatio defines the current speed ratio
  13193. * @param weight defines the weight of the animation (default is -1 so no weight)
  13194. * @param onLoop optional callback called when animation loops
  13195. * @returns a boolean indicating if the animation is running
  13196. */
  13197. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13198. }
  13199. }
  13200. declare module "babylonjs/Animations/animatable" {
  13201. import { Animation } from "babylonjs/Animations/animation";
  13202. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  13203. import { Nullable } from "babylonjs/types";
  13204. import { Observable } from "babylonjs/Misc/observable";
  13205. import { Scene } from "babylonjs/scene";
  13206. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  13207. import { Node } from "babylonjs/node";
  13208. /**
  13209. * Class used to store an actual running animation
  13210. */
  13211. export class Animatable {
  13212. /** defines the target object */
  13213. target: any;
  13214. /** defines the starting frame number (default is 0) */
  13215. fromFrame: number;
  13216. /** defines the ending frame number (default is 100) */
  13217. toFrame: number;
  13218. /** defines if the animation must loop (default is false) */
  13219. loopAnimation: boolean;
  13220. /** defines a callback to call when animation ends if it is not looping */
  13221. onAnimationEnd?: (() => void) | null | undefined;
  13222. /** defines a callback to call when animation loops */
  13223. onAnimationLoop?: (() => void) | null | undefined;
  13224. private _localDelayOffset;
  13225. private _pausedDelay;
  13226. private _runtimeAnimations;
  13227. private _paused;
  13228. private _scene;
  13229. private _speedRatio;
  13230. private _weight;
  13231. private _syncRoot;
  13232. /**
  13233. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13234. * This will only apply for non looping animation (default is true)
  13235. */
  13236. disposeOnEnd: boolean;
  13237. /**
  13238. * Gets a boolean indicating if the animation has started
  13239. */
  13240. animationStarted: boolean;
  13241. /**
  13242. * Observer raised when the animation ends
  13243. */
  13244. onAnimationEndObservable: Observable<Animatable>;
  13245. /**
  13246. * Observer raised when the animation loops
  13247. */
  13248. onAnimationLoopObservable: Observable<Animatable>;
  13249. /**
  13250. * Gets the root Animatable used to synchronize and normalize animations
  13251. */
  13252. readonly syncRoot: Nullable<Animatable>;
  13253. /**
  13254. * Gets the current frame of the first RuntimeAnimation
  13255. * Used to synchronize Animatables
  13256. */
  13257. readonly masterFrame: number;
  13258. /**
  13259. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13260. */
  13261. weight: number;
  13262. /**
  13263. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13264. */
  13265. speedRatio: number;
  13266. /**
  13267. * Creates a new Animatable
  13268. * @param scene defines the hosting scene
  13269. * @param target defines the target object
  13270. * @param fromFrame defines the starting frame number (default is 0)
  13271. * @param toFrame defines the ending frame number (default is 100)
  13272. * @param loopAnimation defines if the animation must loop (default is false)
  13273. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13274. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13275. * @param animations defines a group of animation to add to the new Animatable
  13276. * @param onAnimationLoop defines a callback to call when animation loops
  13277. */
  13278. constructor(scene: Scene,
  13279. /** defines the target object */
  13280. target: any,
  13281. /** defines the starting frame number (default is 0) */
  13282. fromFrame?: number,
  13283. /** defines the ending frame number (default is 100) */
  13284. toFrame?: number,
  13285. /** defines if the animation must loop (default is false) */
  13286. loopAnimation?: boolean, speedRatio?: number,
  13287. /** defines a callback to call when animation ends if it is not looping */
  13288. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13289. /** defines a callback to call when animation loops */
  13290. onAnimationLoop?: (() => void) | null | undefined);
  13291. /**
  13292. * Synchronize and normalize current Animatable with a source Animatable
  13293. * This is useful when using animation weights and when animations are not of the same length
  13294. * @param root defines the root Animatable to synchronize with
  13295. * @returns the current Animatable
  13296. */
  13297. syncWith(root: Animatable): Animatable;
  13298. /**
  13299. * Gets the list of runtime animations
  13300. * @returns an array of RuntimeAnimation
  13301. */
  13302. getAnimations(): RuntimeAnimation[];
  13303. /**
  13304. * Adds more animations to the current animatable
  13305. * @param target defines the target of the animations
  13306. * @param animations defines the new animations to add
  13307. */
  13308. appendAnimations(target: any, animations: Animation[]): void;
  13309. /**
  13310. * Gets the source animation for a specific property
  13311. * @param property defines the propertyu to look for
  13312. * @returns null or the source animation for the given property
  13313. */
  13314. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13315. /**
  13316. * Gets the runtime animation for a specific property
  13317. * @param property defines the propertyu to look for
  13318. * @returns null or the runtime animation for the given property
  13319. */
  13320. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13321. /**
  13322. * Resets the animatable to its original state
  13323. */
  13324. reset(): void;
  13325. /**
  13326. * Allows the animatable to blend with current running animations
  13327. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13328. * @param blendingSpeed defines the blending speed to use
  13329. */
  13330. enableBlending(blendingSpeed: number): void;
  13331. /**
  13332. * Disable animation blending
  13333. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13334. */
  13335. disableBlending(): void;
  13336. /**
  13337. * Jump directly to a given frame
  13338. * @param frame defines the frame to jump to
  13339. */
  13340. goToFrame(frame: number): void;
  13341. /**
  13342. * Pause the animation
  13343. */
  13344. pause(): void;
  13345. /**
  13346. * Restart the animation
  13347. */
  13348. restart(): void;
  13349. private _raiseOnAnimationEnd;
  13350. /**
  13351. * Stop and delete the current animation
  13352. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13353. * @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)
  13354. */
  13355. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13356. /**
  13357. * Wait asynchronously for the animation to end
  13358. * @returns a promise which will be fullfilled when the animation ends
  13359. */
  13360. waitAsync(): Promise<Animatable>;
  13361. /** @hidden */
  13362. _animate(delay: number): boolean;
  13363. }
  13364. module "babylonjs/scene" {
  13365. interface Scene {
  13366. /** @hidden */
  13367. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13368. /** @hidden */
  13369. _processLateAnimationBindingsForMatrices(holder: {
  13370. totalWeight: number;
  13371. animations: RuntimeAnimation[];
  13372. originalValue: Matrix;
  13373. }): any;
  13374. /** @hidden */
  13375. _processLateAnimationBindingsForQuaternions(holder: {
  13376. totalWeight: number;
  13377. animations: RuntimeAnimation[];
  13378. originalValue: Quaternion;
  13379. }, refQuaternion: Quaternion): Quaternion;
  13380. /** @hidden */
  13381. _processLateAnimationBindings(): void;
  13382. /**
  13383. * Will start the animation sequence of a given target
  13384. * @param target defines the target
  13385. * @param from defines from which frame should animation start
  13386. * @param to defines until which frame should animation run.
  13387. * @param weight defines the weight to apply to the animation (1.0 by default)
  13388. * @param loop defines if the animation loops
  13389. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13390. * @param onAnimationEnd defines the function to be executed when the animation ends
  13391. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13392. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13393. * @param onAnimationLoop defines the callback to call when an animation loops
  13394. * @returns the animatable object created for this animation
  13395. */
  13396. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13397. /**
  13398. * Will start the animation sequence of a given target
  13399. * @param target defines the target
  13400. * @param from defines from which frame should animation start
  13401. * @param to defines until which frame should animation run.
  13402. * @param loop defines if the animation loops
  13403. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13404. * @param onAnimationEnd defines the function to be executed when the animation ends
  13405. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13406. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13407. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13408. * @param onAnimationLoop defines the callback to call when an animation loops
  13409. * @returns the animatable object created for this animation
  13410. */
  13411. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13412. /**
  13413. * Will start the animation sequence of a given target and its hierarchy
  13414. * @param target defines the target
  13415. * @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.
  13416. * @param from defines from which frame should animation start
  13417. * @param to defines until which frame should animation run.
  13418. * @param loop defines if the animation loops
  13419. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13420. * @param onAnimationEnd defines the function to be executed when the animation ends
  13421. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13422. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13423. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13424. * @param onAnimationLoop defines the callback to call when an animation loops
  13425. * @returns the list of created animatables
  13426. */
  13427. 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[];
  13428. /**
  13429. * Begin a new animation on a given node
  13430. * @param target defines the target where the animation will take place
  13431. * @param animations defines the list of animations to start
  13432. * @param from defines the initial value
  13433. * @param to defines the final value
  13434. * @param loop defines if you want animation to loop (off by default)
  13435. * @param speedRatio defines the speed ratio to apply to all animations
  13436. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13437. * @param onAnimationLoop defines the callback to call when an animation loops
  13438. * @returns the list of created animatables
  13439. */
  13440. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13441. /**
  13442. * Begin a new animation on a given node and its hierarchy
  13443. * @param target defines the root node where the animation will take place
  13444. * @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.
  13445. * @param animations defines the list of animations to start
  13446. * @param from defines the initial value
  13447. * @param to defines the final value
  13448. * @param loop defines if you want animation to loop (off by default)
  13449. * @param speedRatio defines the speed ratio to apply to all animations
  13450. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13451. * @param onAnimationLoop defines the callback to call when an animation loops
  13452. * @returns the list of animatables created for all nodes
  13453. */
  13454. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13455. /**
  13456. * Gets the animatable associated with a specific target
  13457. * @param target defines the target of the animatable
  13458. * @returns the required animatable if found
  13459. */
  13460. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13461. /**
  13462. * Gets all animatables associated with a given target
  13463. * @param target defines the target to look animatables for
  13464. * @returns an array of Animatables
  13465. */
  13466. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13467. /**
  13468. * Stops and removes all animations that have been applied to the scene
  13469. */
  13470. stopAllAnimations(): void;
  13471. /**
  13472. * Gets the current delta time used by animation engine
  13473. */
  13474. deltaTime: number;
  13475. }
  13476. }
  13477. module "babylonjs/Bones/bone" {
  13478. interface Bone {
  13479. /**
  13480. * Copy an animation range from another bone
  13481. * @param source defines the source bone
  13482. * @param rangeName defines the range name to copy
  13483. * @param frameOffset defines the frame offset
  13484. * @param rescaleAsRequired defines if rescaling must be applied if required
  13485. * @param skelDimensionsRatio defines the scaling ratio
  13486. * @returns true if operation was successful
  13487. */
  13488. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13489. }
  13490. }
  13491. }
  13492. declare module "babylonjs/Animations/animationPropertiesOverride" {
  13493. /**
  13494. * Class used to override all child animations of a given target
  13495. */
  13496. export class AnimationPropertiesOverride {
  13497. /**
  13498. * Gets or sets a value indicating if animation blending must be used
  13499. */
  13500. enableBlending: boolean;
  13501. /**
  13502. * Gets or sets the blending speed to use when enableBlending is true
  13503. */
  13504. blendingSpeed: number;
  13505. /**
  13506. * Gets or sets the default loop mode to use
  13507. */
  13508. loopMode: number;
  13509. }
  13510. }
  13511. declare module "babylonjs/Bones/skeleton" {
  13512. import { Bone } from "babylonjs/Bones/bone";
  13513. import { Observable } from "babylonjs/Misc/observable";
  13514. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13515. import { Scene } from "babylonjs/scene";
  13516. import { Nullable } from "babylonjs/types";
  13517. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13518. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13519. import { Animatable } from "babylonjs/Animations/animatable";
  13520. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13521. import { Animation } from "babylonjs/Animations/animation";
  13522. import { AnimationRange } from "babylonjs/Animations/animationRange";
  13523. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13524. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  13525. /**
  13526. * Class used to handle skinning animations
  13527. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13528. */
  13529. export class Skeleton implements IAnimatable {
  13530. /** defines the skeleton name */
  13531. name: string;
  13532. /** defines the skeleton Id */
  13533. id: string;
  13534. /**
  13535. * Defines the list of child bones
  13536. */
  13537. bones: Bone[];
  13538. /**
  13539. * Defines an estimate of the dimension of the skeleton at rest
  13540. */
  13541. dimensionsAtRest: Vector3;
  13542. /**
  13543. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13544. */
  13545. needInitialSkinMatrix: boolean;
  13546. /**
  13547. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13548. */
  13549. overrideMesh: Nullable<AbstractMesh>;
  13550. /**
  13551. * Gets the list of animations attached to this skeleton
  13552. */
  13553. animations: Array<Animation>;
  13554. private _scene;
  13555. private _isDirty;
  13556. private _transformMatrices;
  13557. private _transformMatrixTexture;
  13558. private _meshesWithPoseMatrix;
  13559. private _animatables;
  13560. private _identity;
  13561. private _synchronizedWithMesh;
  13562. private _ranges;
  13563. private _lastAbsoluteTransformsUpdateId;
  13564. private _canUseTextureForBones;
  13565. private _uniqueId;
  13566. /** @hidden */
  13567. _numBonesWithLinkedTransformNode: number;
  13568. /** @hidden */
  13569. _hasWaitingData: Nullable<boolean>;
  13570. /**
  13571. * Specifies if the skeleton should be serialized
  13572. */
  13573. doNotSerialize: boolean;
  13574. private _useTextureToStoreBoneMatrices;
  13575. /**
  13576. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13577. * Please note that this option is not available if the hardware does not support it
  13578. */
  13579. useTextureToStoreBoneMatrices: boolean;
  13580. private _animationPropertiesOverride;
  13581. /**
  13582. * Gets or sets the animation properties override
  13583. */
  13584. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13585. /**
  13586. * List of inspectable custom properties (used by the Inspector)
  13587. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13588. */
  13589. inspectableCustomProperties: IInspectable[];
  13590. /**
  13591. * An observable triggered before computing the skeleton's matrices
  13592. */
  13593. onBeforeComputeObservable: Observable<Skeleton>;
  13594. /**
  13595. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13596. */
  13597. readonly isUsingTextureForMatrices: boolean;
  13598. /**
  13599. * Gets the unique ID of this skeleton
  13600. */
  13601. readonly uniqueId: number;
  13602. /**
  13603. * Creates a new skeleton
  13604. * @param name defines the skeleton name
  13605. * @param id defines the skeleton Id
  13606. * @param scene defines the hosting scene
  13607. */
  13608. constructor(
  13609. /** defines the skeleton name */
  13610. name: string,
  13611. /** defines the skeleton Id */
  13612. id: string, scene: Scene);
  13613. /**
  13614. * Gets the current object class name.
  13615. * @return the class name
  13616. */
  13617. getClassName(): string;
  13618. /**
  13619. * Returns an array containing the root bones
  13620. * @returns an array containing the root bones
  13621. */
  13622. getChildren(): Array<Bone>;
  13623. /**
  13624. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13625. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13626. * @returns a Float32Array containing matrices data
  13627. */
  13628. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13629. /**
  13630. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13631. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13632. * @returns a raw texture containing the data
  13633. */
  13634. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13635. /**
  13636. * Gets the current hosting scene
  13637. * @returns a scene object
  13638. */
  13639. getScene(): Scene;
  13640. /**
  13641. * Gets a string representing the current skeleton data
  13642. * @param fullDetails defines a boolean indicating if we want a verbose version
  13643. * @returns a string representing the current skeleton data
  13644. */
  13645. toString(fullDetails?: boolean): string;
  13646. /**
  13647. * Get bone's index searching by name
  13648. * @param name defines bone's name to search for
  13649. * @return the indice of the bone. Returns -1 if not found
  13650. */
  13651. getBoneIndexByName(name: string): number;
  13652. /**
  13653. * Creater a new animation range
  13654. * @param name defines the name of the range
  13655. * @param from defines the start key
  13656. * @param to defines the end key
  13657. */
  13658. createAnimationRange(name: string, from: number, to: number): void;
  13659. /**
  13660. * Delete a specific animation range
  13661. * @param name defines the name of the range
  13662. * @param deleteFrames defines if frames must be removed as well
  13663. */
  13664. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13665. /**
  13666. * Gets a specific animation range
  13667. * @param name defines the name of the range to look for
  13668. * @returns the requested animation range or null if not found
  13669. */
  13670. getAnimationRange(name: string): Nullable<AnimationRange>;
  13671. /**
  13672. * Gets the list of all animation ranges defined on this skeleton
  13673. * @returns an array
  13674. */
  13675. getAnimationRanges(): Nullable<AnimationRange>[];
  13676. /**
  13677. * Copy animation range from a source skeleton.
  13678. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13679. * @param source defines the source skeleton
  13680. * @param name defines the name of the range to copy
  13681. * @param rescaleAsRequired defines if rescaling must be applied if required
  13682. * @returns true if operation was successful
  13683. */
  13684. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13685. /**
  13686. * Forces the skeleton to go to rest pose
  13687. */
  13688. returnToRest(): void;
  13689. private _getHighestAnimationFrame;
  13690. /**
  13691. * Begin a specific animation range
  13692. * @param name defines the name of the range to start
  13693. * @param loop defines if looping must be turned on (false by default)
  13694. * @param speedRatio defines the speed ratio to apply (1 by default)
  13695. * @param onAnimationEnd defines a callback which will be called when animation will end
  13696. * @returns a new animatable
  13697. */
  13698. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13699. /** @hidden */
  13700. _markAsDirty(): void;
  13701. /** @hidden */
  13702. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13703. /** @hidden */
  13704. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13705. private _computeTransformMatrices;
  13706. /**
  13707. * Build all resources required to render a skeleton
  13708. */
  13709. prepare(): void;
  13710. /**
  13711. * Gets the list of animatables currently running for this skeleton
  13712. * @returns an array of animatables
  13713. */
  13714. getAnimatables(): IAnimatable[];
  13715. /**
  13716. * Clone the current skeleton
  13717. * @param name defines the name of the new skeleton
  13718. * @param id defines the id of the new skeleton
  13719. * @returns the new skeleton
  13720. */
  13721. clone(name: string, id: string): Skeleton;
  13722. /**
  13723. * Enable animation blending for this skeleton
  13724. * @param blendingSpeed defines the blending speed to apply
  13725. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13726. */
  13727. enableBlending(blendingSpeed?: number): void;
  13728. /**
  13729. * Releases all resources associated with the current skeleton
  13730. */
  13731. dispose(): void;
  13732. /**
  13733. * Serialize the skeleton in a JSON object
  13734. * @returns a JSON object
  13735. */
  13736. serialize(): any;
  13737. /**
  13738. * Creates a new skeleton from serialized data
  13739. * @param parsedSkeleton defines the serialized data
  13740. * @param scene defines the hosting scene
  13741. * @returns a new skeleton
  13742. */
  13743. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13744. /**
  13745. * Compute all node absolute transforms
  13746. * @param forceUpdate defines if computation must be done even if cache is up to date
  13747. */
  13748. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13749. /**
  13750. * Gets the root pose matrix
  13751. * @returns a matrix
  13752. */
  13753. getPoseMatrix(): Nullable<Matrix>;
  13754. /**
  13755. * Sorts bones per internal index
  13756. */
  13757. sortBones(): void;
  13758. private _sortBones;
  13759. }
  13760. }
  13761. declare module "babylonjs/Bones/bone" {
  13762. import { Skeleton } from "babylonjs/Bones/skeleton";
  13763. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  13764. import { Nullable } from "babylonjs/types";
  13765. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13766. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13767. import { Node } from "babylonjs/node";
  13768. import { Space } from "babylonjs/Maths/math.axis";
  13769. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13770. /**
  13771. * Class used to store bone information
  13772. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13773. */
  13774. export class Bone extends Node {
  13775. /**
  13776. * defines the bone name
  13777. */
  13778. name: string;
  13779. private static _tmpVecs;
  13780. private static _tmpQuat;
  13781. private static _tmpMats;
  13782. /**
  13783. * Gets the list of child bones
  13784. */
  13785. children: Bone[];
  13786. /** Gets the animations associated with this bone */
  13787. animations: import("babylonjs/Animations/animation").Animation[];
  13788. /**
  13789. * Gets or sets bone length
  13790. */
  13791. length: number;
  13792. /**
  13793. * @hidden Internal only
  13794. * Set this value to map this bone to a different index in the transform matrices
  13795. * Set this value to -1 to exclude the bone from the transform matrices
  13796. */
  13797. _index: Nullable<number>;
  13798. private _skeleton;
  13799. private _localMatrix;
  13800. private _restPose;
  13801. private _baseMatrix;
  13802. private _absoluteTransform;
  13803. private _invertedAbsoluteTransform;
  13804. private _parent;
  13805. private _scalingDeterminant;
  13806. private _worldTransform;
  13807. private _localScaling;
  13808. private _localRotation;
  13809. private _localPosition;
  13810. private _needToDecompose;
  13811. private _needToCompose;
  13812. /** @hidden */
  13813. _linkedTransformNode: Nullable<TransformNode>;
  13814. /** @hidden */
  13815. _waitingTransformNodeId: Nullable<string>;
  13816. /** @hidden */
  13817. /** @hidden */
  13818. _matrix: Matrix;
  13819. /**
  13820. * Create a new bone
  13821. * @param name defines the bone name
  13822. * @param skeleton defines the parent skeleton
  13823. * @param parentBone defines the parent (can be null if the bone is the root)
  13824. * @param localMatrix defines the local matrix
  13825. * @param restPose defines the rest pose matrix
  13826. * @param baseMatrix defines the base matrix
  13827. * @param index defines index of the bone in the hiearchy
  13828. */
  13829. constructor(
  13830. /**
  13831. * defines the bone name
  13832. */
  13833. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13834. /**
  13835. * Gets the current object class name.
  13836. * @return the class name
  13837. */
  13838. getClassName(): string;
  13839. /**
  13840. * Gets the parent skeleton
  13841. * @returns a skeleton
  13842. */
  13843. getSkeleton(): Skeleton;
  13844. /**
  13845. * Gets parent bone
  13846. * @returns a bone or null if the bone is the root of the bone hierarchy
  13847. */
  13848. getParent(): Nullable<Bone>;
  13849. /**
  13850. * Returns an array containing the root bones
  13851. * @returns an array containing the root bones
  13852. */
  13853. getChildren(): Array<Bone>;
  13854. /**
  13855. * Sets the parent bone
  13856. * @param parent defines the parent (can be null if the bone is the root)
  13857. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13858. */
  13859. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13860. /**
  13861. * Gets the local matrix
  13862. * @returns a matrix
  13863. */
  13864. getLocalMatrix(): Matrix;
  13865. /**
  13866. * Gets the base matrix (initial matrix which remains unchanged)
  13867. * @returns a matrix
  13868. */
  13869. getBaseMatrix(): Matrix;
  13870. /**
  13871. * Gets the rest pose matrix
  13872. * @returns a matrix
  13873. */
  13874. getRestPose(): Matrix;
  13875. /**
  13876. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13877. */
  13878. getWorldMatrix(): Matrix;
  13879. /**
  13880. * Sets the local matrix to rest pose matrix
  13881. */
  13882. returnToRest(): void;
  13883. /**
  13884. * Gets the inverse of the absolute transform matrix.
  13885. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13886. * @returns a matrix
  13887. */
  13888. getInvertedAbsoluteTransform(): Matrix;
  13889. /**
  13890. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13891. * @returns a matrix
  13892. */
  13893. getAbsoluteTransform(): Matrix;
  13894. /**
  13895. * Links with the given transform node.
  13896. * The local matrix of this bone is copied from the transform node every frame.
  13897. * @param transformNode defines the transform node to link to
  13898. */
  13899. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13900. /**
  13901. * Gets the node used to drive the bone's transformation
  13902. * @returns a transform node or null
  13903. */
  13904. getTransformNode(): Nullable<TransformNode>;
  13905. /** Gets or sets current position (in local space) */
  13906. position: Vector3;
  13907. /** Gets or sets current rotation (in local space) */
  13908. rotation: Vector3;
  13909. /** Gets or sets current rotation quaternion (in local space) */
  13910. rotationQuaternion: Quaternion;
  13911. /** Gets or sets current scaling (in local space) */
  13912. scaling: Vector3;
  13913. /**
  13914. * Gets the animation properties override
  13915. */
  13916. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13917. private _decompose;
  13918. private _compose;
  13919. /**
  13920. * Update the base and local matrices
  13921. * @param matrix defines the new base or local matrix
  13922. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13923. * @param updateLocalMatrix defines if the local matrix should be updated
  13924. */
  13925. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13926. /** @hidden */
  13927. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13928. /**
  13929. * Flag the bone as dirty (Forcing it to update everything)
  13930. */
  13931. markAsDirty(): void;
  13932. /** @hidden */
  13933. _markAsDirtyAndCompose(): void;
  13934. private _markAsDirtyAndDecompose;
  13935. /**
  13936. * Translate the bone in local or world space
  13937. * @param vec The amount to translate the bone
  13938. * @param space The space that the translation is in
  13939. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13940. */
  13941. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13942. /**
  13943. * Set the postion of the bone in local or world space
  13944. * @param position The position to set the bone
  13945. * @param space The space that the position is in
  13946. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13947. */
  13948. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13949. /**
  13950. * Set the absolute position of the bone (world space)
  13951. * @param position The position to set the bone
  13952. * @param mesh The mesh that this bone is attached to
  13953. */
  13954. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13955. /**
  13956. * Scale the bone on the x, y and z axes (in local space)
  13957. * @param x The amount to scale the bone on the x axis
  13958. * @param y The amount to scale the bone on the y axis
  13959. * @param z The amount to scale the bone on the z axis
  13960. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13961. */
  13962. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13963. /**
  13964. * Set the bone scaling in local space
  13965. * @param scale defines the scaling vector
  13966. */
  13967. setScale(scale: Vector3): void;
  13968. /**
  13969. * Gets the current scaling in local space
  13970. * @returns the current scaling vector
  13971. */
  13972. getScale(): Vector3;
  13973. /**
  13974. * Gets the current scaling in local space and stores it in a target vector
  13975. * @param result defines the target vector
  13976. */
  13977. getScaleToRef(result: Vector3): void;
  13978. /**
  13979. * Set the yaw, pitch, and roll of the bone in local or world space
  13980. * @param yaw The rotation of the bone on the y axis
  13981. * @param pitch The rotation of the bone on the x axis
  13982. * @param roll The rotation of the bone on the z axis
  13983. * @param space The space that the axes of rotation are in
  13984. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13985. */
  13986. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13987. /**
  13988. * Add a rotation to the bone on an axis in local or world space
  13989. * @param axis The axis to rotate the bone on
  13990. * @param amount The amount to rotate the bone
  13991. * @param space The space that the axis is in
  13992. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13993. */
  13994. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13995. /**
  13996. * Set the rotation of the bone to a particular axis angle in local or world space
  13997. * @param axis The axis to rotate the bone on
  13998. * @param angle The angle that the bone should be rotated to
  13999. * @param space The space that the axis is in
  14000. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14001. */
  14002. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14003. /**
  14004. * Set the euler rotation of the bone in local of world space
  14005. * @param rotation The euler rotation that the bone should be set to
  14006. * @param space The space that the rotation is in
  14007. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14008. */
  14009. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14010. /**
  14011. * Set the quaternion rotation of the bone in local of world space
  14012. * @param quat The quaternion rotation that the bone should be set to
  14013. * @param space The space that the rotation is in
  14014. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14015. */
  14016. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14017. /**
  14018. * Set the rotation matrix of the bone in local of world space
  14019. * @param rotMat The rotation matrix that the bone should be set to
  14020. * @param space The space that the rotation is in
  14021. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14022. */
  14023. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14024. private _rotateWithMatrix;
  14025. private _getNegativeRotationToRef;
  14026. /**
  14027. * Get the position of the bone in local or world space
  14028. * @param space The space that the returned position is in
  14029. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14030. * @returns The position of the bone
  14031. */
  14032. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14033. /**
  14034. * Copy the position of the bone to a vector3 in local or world space
  14035. * @param space The space that the returned position is in
  14036. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14037. * @param result The vector3 to copy the position to
  14038. */
  14039. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14040. /**
  14041. * Get the absolute position of the bone (world space)
  14042. * @param mesh The mesh that this bone is attached to
  14043. * @returns The absolute position of the bone
  14044. */
  14045. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14046. /**
  14047. * Copy the absolute position of the bone (world space) to the result param
  14048. * @param mesh The mesh that this bone is attached to
  14049. * @param result The vector3 to copy the absolute position to
  14050. */
  14051. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14052. /**
  14053. * Compute the absolute transforms of this bone and its children
  14054. */
  14055. computeAbsoluteTransforms(): void;
  14056. /**
  14057. * Get the world direction from an axis that is in the local space of the bone
  14058. * @param localAxis The local direction that is used to compute the world direction
  14059. * @param mesh The mesh that this bone is attached to
  14060. * @returns The world direction
  14061. */
  14062. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14063. /**
  14064. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14065. * @param localAxis The local direction that is used to compute the world direction
  14066. * @param mesh The mesh that this bone is attached to
  14067. * @param result The vector3 that the world direction will be copied to
  14068. */
  14069. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14070. /**
  14071. * Get the euler rotation of the bone in local or world space
  14072. * @param space The space that the rotation should be in
  14073. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14074. * @returns The euler rotation
  14075. */
  14076. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14077. /**
  14078. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14079. * @param space The space that the rotation should be in
  14080. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14081. * @param result The vector3 that the rotation should be copied to
  14082. */
  14083. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14084. /**
  14085. * Get the quaternion rotation of the bone in either local or world space
  14086. * @param space The space that the rotation should be in
  14087. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14088. * @returns The quaternion rotation
  14089. */
  14090. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14091. /**
  14092. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14093. * @param space The space that the rotation should be in
  14094. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14095. * @param result The quaternion that the rotation should be copied to
  14096. */
  14097. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14098. /**
  14099. * Get the rotation matrix of the bone in local or world space
  14100. * @param space The space that the rotation should be in
  14101. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14102. * @returns The rotation matrix
  14103. */
  14104. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14105. /**
  14106. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14107. * @param space The space that the rotation should be in
  14108. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14109. * @param result The quaternion that the rotation should be copied to
  14110. */
  14111. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14112. /**
  14113. * Get the world position of a point that is in the local space of the bone
  14114. * @param position The local position
  14115. * @param mesh The mesh that this bone is attached to
  14116. * @returns The world position
  14117. */
  14118. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14119. /**
  14120. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14121. * @param position The local position
  14122. * @param mesh The mesh that this bone is attached to
  14123. * @param result The vector3 that the world position should be copied to
  14124. */
  14125. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14126. /**
  14127. * Get the local position of a point that is in world space
  14128. * @param position The world position
  14129. * @param mesh The mesh that this bone is attached to
  14130. * @returns The local position
  14131. */
  14132. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14133. /**
  14134. * Get the local position of a point that is in world space and copy it to the result param
  14135. * @param position The world position
  14136. * @param mesh The mesh that this bone is attached to
  14137. * @param result The vector3 that the local position should be copied to
  14138. */
  14139. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14140. }
  14141. }
  14142. declare module "babylonjs/Meshes/transformNode" {
  14143. import { DeepImmutable } from "babylonjs/types";
  14144. import { Observable } from "babylonjs/Misc/observable";
  14145. import { Nullable } from "babylonjs/types";
  14146. import { Camera } from "babylonjs/Cameras/camera";
  14147. import { Scene } from "babylonjs/scene";
  14148. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14149. import { Node } from "babylonjs/node";
  14150. import { Bone } from "babylonjs/Bones/bone";
  14151. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14152. import { Space } from "babylonjs/Maths/math.axis";
  14153. /**
  14154. * 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.
  14155. * @see https://doc.babylonjs.com/how_to/transformnode
  14156. */
  14157. export class TransformNode extends Node {
  14158. /**
  14159. * Object will not rotate to face the camera
  14160. */
  14161. static BILLBOARDMODE_NONE: number;
  14162. /**
  14163. * Object will rotate to face the camera but only on the x axis
  14164. */
  14165. static BILLBOARDMODE_X: number;
  14166. /**
  14167. * Object will rotate to face the camera but only on the y axis
  14168. */
  14169. static BILLBOARDMODE_Y: number;
  14170. /**
  14171. * Object will rotate to face the camera but only on the z axis
  14172. */
  14173. static BILLBOARDMODE_Z: number;
  14174. /**
  14175. * Object will rotate to face the camera
  14176. */
  14177. static BILLBOARDMODE_ALL: number;
  14178. /**
  14179. * Object will rotate to face the camera's position instead of orientation
  14180. */
  14181. static BILLBOARDMODE_USE_POSITION: number;
  14182. private _forward;
  14183. private _forwardInverted;
  14184. private _up;
  14185. private _right;
  14186. private _rightInverted;
  14187. private _position;
  14188. private _rotation;
  14189. private _rotationQuaternion;
  14190. protected _scaling: Vector3;
  14191. protected _isDirty: boolean;
  14192. private _transformToBoneReferal;
  14193. private _isAbsoluteSynced;
  14194. private _billboardMode;
  14195. /**
  14196. * Gets or sets the billboard mode. Default is 0.
  14197. *
  14198. * | Value | Type | Description |
  14199. * | --- | --- | --- |
  14200. * | 0 | BILLBOARDMODE_NONE | |
  14201. * | 1 | BILLBOARDMODE_X | |
  14202. * | 2 | BILLBOARDMODE_Y | |
  14203. * | 4 | BILLBOARDMODE_Z | |
  14204. * | 7 | BILLBOARDMODE_ALL | |
  14205. *
  14206. */
  14207. billboardMode: number;
  14208. private _preserveParentRotationForBillboard;
  14209. /**
  14210. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14211. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14212. */
  14213. preserveParentRotationForBillboard: boolean;
  14214. /**
  14215. * 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
  14216. */
  14217. scalingDeterminant: number;
  14218. private _infiniteDistance;
  14219. /**
  14220. * Gets or sets the distance of the object to max, often used by skybox
  14221. */
  14222. infiniteDistance: boolean;
  14223. /**
  14224. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14225. * By default the system will update normals to compensate
  14226. */
  14227. ignoreNonUniformScaling: boolean;
  14228. /**
  14229. * 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
  14230. */
  14231. reIntegrateRotationIntoRotationQuaternion: boolean;
  14232. /** @hidden */
  14233. _poseMatrix: Nullable<Matrix>;
  14234. /** @hidden */
  14235. _localMatrix: Matrix;
  14236. private _usePivotMatrix;
  14237. private _absolutePosition;
  14238. private _absoluteScaling;
  14239. private _absoluteRotationQuaternion;
  14240. private _pivotMatrix;
  14241. private _pivotMatrixInverse;
  14242. protected _postMultiplyPivotMatrix: boolean;
  14243. protected _isWorldMatrixFrozen: boolean;
  14244. /** @hidden */
  14245. _indexInSceneTransformNodesArray: number;
  14246. /**
  14247. * An event triggered after the world matrix is updated
  14248. */
  14249. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14250. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14251. /**
  14252. * Gets a string identifying the name of the class
  14253. * @returns "TransformNode" string
  14254. */
  14255. getClassName(): string;
  14256. /**
  14257. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14258. */
  14259. position: Vector3;
  14260. /**
  14261. * 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)).
  14262. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14263. */
  14264. rotation: Vector3;
  14265. /**
  14266. * 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)).
  14267. */
  14268. scaling: Vector3;
  14269. /**
  14270. * 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).
  14271. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14272. */
  14273. rotationQuaternion: Nullable<Quaternion>;
  14274. /**
  14275. * The forward direction of that transform in world space.
  14276. */
  14277. readonly forward: Vector3;
  14278. /**
  14279. * The up direction of that transform in world space.
  14280. */
  14281. readonly up: Vector3;
  14282. /**
  14283. * The right direction of that transform in world space.
  14284. */
  14285. readonly right: Vector3;
  14286. /**
  14287. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14288. * @param matrix the matrix to copy the pose from
  14289. * @returns this TransformNode.
  14290. */
  14291. updatePoseMatrix(matrix: Matrix): TransformNode;
  14292. /**
  14293. * Returns the mesh Pose matrix.
  14294. * @returns the pose matrix
  14295. */
  14296. getPoseMatrix(): Matrix;
  14297. /** @hidden */
  14298. _isSynchronized(): boolean;
  14299. /** @hidden */
  14300. _initCache(): void;
  14301. /**
  14302. * Flag the transform node as dirty (Forcing it to update everything)
  14303. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14304. * @returns this transform node
  14305. */
  14306. markAsDirty(property: string): TransformNode;
  14307. /**
  14308. * Returns the current mesh absolute position.
  14309. * Returns a Vector3.
  14310. */
  14311. readonly absolutePosition: Vector3;
  14312. /**
  14313. * Returns the current mesh absolute scaling.
  14314. * Returns a Vector3.
  14315. */
  14316. readonly absoluteScaling: Vector3;
  14317. /**
  14318. * Returns the current mesh absolute rotation.
  14319. * Returns a Quaternion.
  14320. */
  14321. readonly absoluteRotationQuaternion: Quaternion;
  14322. /**
  14323. * Sets a new matrix to apply before all other transformation
  14324. * @param matrix defines the transform matrix
  14325. * @returns the current TransformNode
  14326. */
  14327. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14328. /**
  14329. * Sets a new pivot matrix to the current node
  14330. * @param matrix defines the new pivot matrix to use
  14331. * @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
  14332. * @returns the current TransformNode
  14333. */
  14334. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14335. /**
  14336. * Returns the mesh pivot matrix.
  14337. * Default : Identity.
  14338. * @returns the matrix
  14339. */
  14340. getPivotMatrix(): Matrix;
  14341. /**
  14342. * Instantiate (when possible) or clone that node with its hierarchy
  14343. * @param newParent defines the new parent to use for the instance (or clone)
  14344. * @returns an instance (or a clone) of the current node with its hiearchy
  14345. */
  14346. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  14347. /**
  14348. * Prevents the World matrix to be computed any longer
  14349. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14350. * @returns the TransformNode.
  14351. */
  14352. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14353. /**
  14354. * Allows back the World matrix computation.
  14355. * @returns the TransformNode.
  14356. */
  14357. unfreezeWorldMatrix(): this;
  14358. /**
  14359. * True if the World matrix has been frozen.
  14360. */
  14361. readonly isWorldMatrixFrozen: boolean;
  14362. /**
  14363. * Retuns the mesh absolute position in the World.
  14364. * @returns a Vector3.
  14365. */
  14366. getAbsolutePosition(): Vector3;
  14367. /**
  14368. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14369. * @param absolutePosition the absolute position to set
  14370. * @returns the TransformNode.
  14371. */
  14372. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14373. /**
  14374. * Sets the mesh position in its local space.
  14375. * @param vector3 the position to set in localspace
  14376. * @returns the TransformNode.
  14377. */
  14378. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14379. /**
  14380. * Returns the mesh position in the local space from the current World matrix values.
  14381. * @returns a new Vector3.
  14382. */
  14383. getPositionExpressedInLocalSpace(): Vector3;
  14384. /**
  14385. * Translates the mesh along the passed Vector3 in its local space.
  14386. * @param vector3 the distance to translate in localspace
  14387. * @returns the TransformNode.
  14388. */
  14389. locallyTranslate(vector3: Vector3): TransformNode;
  14390. private static _lookAtVectorCache;
  14391. /**
  14392. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14393. * @param targetPoint the position (must be in same space as current mesh) to look at
  14394. * @param yawCor optional yaw (y-axis) correction in radians
  14395. * @param pitchCor optional pitch (x-axis) correction in radians
  14396. * @param rollCor optional roll (z-axis) correction in radians
  14397. * @param space the choosen space of the target
  14398. * @returns the TransformNode.
  14399. */
  14400. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14401. /**
  14402. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14403. * This Vector3 is expressed in the World space.
  14404. * @param localAxis axis to rotate
  14405. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14406. */
  14407. getDirection(localAxis: Vector3): Vector3;
  14408. /**
  14409. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14410. * localAxis is expressed in the mesh local space.
  14411. * result is computed in the Wordl space from the mesh World matrix.
  14412. * @param localAxis axis to rotate
  14413. * @param result the resulting transformnode
  14414. * @returns this TransformNode.
  14415. */
  14416. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14417. /**
  14418. * Sets this transform node rotation to the given local axis.
  14419. * @param localAxis the axis in local space
  14420. * @param yawCor optional yaw (y-axis) correction in radians
  14421. * @param pitchCor optional pitch (x-axis) correction in radians
  14422. * @param rollCor optional roll (z-axis) correction in radians
  14423. * @returns this TransformNode
  14424. */
  14425. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14426. /**
  14427. * Sets a new pivot point to the current node
  14428. * @param point defines the new pivot point to use
  14429. * @param space defines if the point is in world or local space (local by default)
  14430. * @returns the current TransformNode
  14431. */
  14432. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14433. /**
  14434. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14435. * @returns the pivot point
  14436. */
  14437. getPivotPoint(): Vector3;
  14438. /**
  14439. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14440. * @param result the vector3 to store the result
  14441. * @returns this TransformNode.
  14442. */
  14443. getPivotPointToRef(result: Vector3): TransformNode;
  14444. /**
  14445. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14446. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14447. */
  14448. getAbsolutePivotPoint(): Vector3;
  14449. /**
  14450. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14451. * @param result vector3 to store the result
  14452. * @returns this TransformNode.
  14453. */
  14454. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14455. /**
  14456. * Defines the passed node as the parent of the current node.
  14457. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14458. * @see https://doc.babylonjs.com/how_to/parenting
  14459. * @param node the node ot set as the parent
  14460. * @returns this TransformNode.
  14461. */
  14462. setParent(node: Nullable<Node>): TransformNode;
  14463. private _nonUniformScaling;
  14464. /**
  14465. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14466. */
  14467. readonly nonUniformScaling: boolean;
  14468. /** @hidden */
  14469. _updateNonUniformScalingState(value: boolean): boolean;
  14470. /**
  14471. * Attach the current TransformNode to another TransformNode associated with a bone
  14472. * @param bone Bone affecting the TransformNode
  14473. * @param affectedTransformNode TransformNode associated with the bone
  14474. * @returns this object
  14475. */
  14476. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14477. /**
  14478. * Detach the transform node if its associated with a bone
  14479. * @returns this object
  14480. */
  14481. detachFromBone(): TransformNode;
  14482. private static _rotationAxisCache;
  14483. /**
  14484. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14485. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14486. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14487. * The passed axis is also normalized.
  14488. * @param axis the axis to rotate around
  14489. * @param amount the amount to rotate in radians
  14490. * @param space Space to rotate in (Default: local)
  14491. * @returns the TransformNode.
  14492. */
  14493. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14494. /**
  14495. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14496. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14497. * The passed axis is also normalized. .
  14498. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14499. * @param point the point to rotate around
  14500. * @param axis the axis to rotate around
  14501. * @param amount the amount to rotate in radians
  14502. * @returns the TransformNode
  14503. */
  14504. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14505. /**
  14506. * Translates the mesh along the axis vector for the passed distance in the given space.
  14507. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14508. * @param axis the axis to translate in
  14509. * @param distance the distance to translate
  14510. * @param space Space to rotate in (Default: local)
  14511. * @returns the TransformNode.
  14512. */
  14513. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14514. /**
  14515. * Adds a rotation step to the mesh current rotation.
  14516. * x, y, z are Euler angles expressed in radians.
  14517. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14518. * This means this rotation is made in the mesh local space only.
  14519. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14520. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14521. * ```javascript
  14522. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14523. * ```
  14524. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14525. * 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.
  14526. * @param x Rotation to add
  14527. * @param y Rotation to add
  14528. * @param z Rotation to add
  14529. * @returns the TransformNode.
  14530. */
  14531. addRotation(x: number, y: number, z: number): TransformNode;
  14532. /**
  14533. * @hidden
  14534. */
  14535. protected _getEffectiveParent(): Nullable<Node>;
  14536. /**
  14537. * Computes the world matrix of the node
  14538. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14539. * @returns the world matrix
  14540. */
  14541. computeWorldMatrix(force?: boolean): Matrix;
  14542. protected _afterComputeWorldMatrix(): void;
  14543. /**
  14544. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14545. * @param func callback function to add
  14546. *
  14547. * @returns the TransformNode.
  14548. */
  14549. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14550. /**
  14551. * Removes a registered callback function.
  14552. * @param func callback function to remove
  14553. * @returns the TransformNode.
  14554. */
  14555. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14556. /**
  14557. * Gets the position of the current mesh in camera space
  14558. * @param camera defines the camera to use
  14559. * @returns a position
  14560. */
  14561. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14562. /**
  14563. * Returns the distance from the mesh to the active camera
  14564. * @param camera defines the camera to use
  14565. * @returns the distance
  14566. */
  14567. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14568. /**
  14569. * Clone the current transform node
  14570. * @param name Name of the new clone
  14571. * @param newParent New parent for the clone
  14572. * @param doNotCloneChildren Do not clone children hierarchy
  14573. * @returns the new transform node
  14574. */
  14575. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14576. /**
  14577. * Serializes the objects information.
  14578. * @param currentSerializationObject defines the object to serialize in
  14579. * @returns the serialized object
  14580. */
  14581. serialize(currentSerializationObject?: any): any;
  14582. /**
  14583. * Returns a new TransformNode object parsed from the source provided.
  14584. * @param parsedTransformNode is the source.
  14585. * @param scene the scne the object belongs to
  14586. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14587. * @returns a new TransformNode object parsed from the source provided.
  14588. */
  14589. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14590. /**
  14591. * Get all child-transformNodes of this node
  14592. * @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
  14593. * @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
  14594. * @returns an array of TransformNode
  14595. */
  14596. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14597. /**
  14598. * Releases resources associated with this transform node.
  14599. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14600. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14601. */
  14602. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14603. /**
  14604. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14605. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14606. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14607. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14608. * @returns the current mesh
  14609. */
  14610. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14611. private _syncAbsoluteScalingAndRotation;
  14612. }
  14613. }
  14614. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  14615. import { Observable } from "babylonjs/Misc/observable";
  14616. import { Nullable } from "babylonjs/types";
  14617. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14618. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14619. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14620. import { Ray } from "babylonjs/Culling/ray";
  14621. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  14622. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  14623. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  14624. /**
  14625. * Defines the types of pose enabled controllers that are supported
  14626. */
  14627. export enum PoseEnabledControllerType {
  14628. /**
  14629. * HTC Vive
  14630. */
  14631. VIVE = 0,
  14632. /**
  14633. * Oculus Rift
  14634. */
  14635. OCULUS = 1,
  14636. /**
  14637. * Windows mixed reality
  14638. */
  14639. WINDOWS = 2,
  14640. /**
  14641. * Samsung gear VR
  14642. */
  14643. GEAR_VR = 3,
  14644. /**
  14645. * Google Daydream
  14646. */
  14647. DAYDREAM = 4,
  14648. /**
  14649. * Generic
  14650. */
  14651. GENERIC = 5
  14652. }
  14653. /**
  14654. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14655. */
  14656. export interface MutableGamepadButton {
  14657. /**
  14658. * Value of the button/trigger
  14659. */
  14660. value: number;
  14661. /**
  14662. * If the button/trigger is currently touched
  14663. */
  14664. touched: boolean;
  14665. /**
  14666. * If the button/trigger is currently pressed
  14667. */
  14668. pressed: boolean;
  14669. }
  14670. /**
  14671. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14672. * @hidden
  14673. */
  14674. export interface ExtendedGamepadButton extends GamepadButton {
  14675. /**
  14676. * If the button/trigger is currently pressed
  14677. */
  14678. readonly pressed: boolean;
  14679. /**
  14680. * If the button/trigger is currently touched
  14681. */
  14682. readonly touched: boolean;
  14683. /**
  14684. * Value of the button/trigger
  14685. */
  14686. readonly value: number;
  14687. }
  14688. /** @hidden */
  14689. export interface _GamePadFactory {
  14690. /**
  14691. * Returns wether or not the current gamepad can be created for this type of controller.
  14692. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14693. * @returns true if it can be created, otherwise false
  14694. */
  14695. canCreate(gamepadInfo: any): boolean;
  14696. /**
  14697. * Creates a new instance of the Gamepad.
  14698. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14699. * @returns the new gamepad instance
  14700. */
  14701. create(gamepadInfo: any): Gamepad;
  14702. }
  14703. /**
  14704. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14705. */
  14706. export class PoseEnabledControllerHelper {
  14707. /** @hidden */
  14708. static _ControllerFactories: _GamePadFactory[];
  14709. /** @hidden */
  14710. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14711. /**
  14712. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14713. * @param vrGamepad the gamepad to initialized
  14714. * @returns a vr controller of the type the gamepad identified as
  14715. */
  14716. static InitiateController(vrGamepad: any): Gamepad;
  14717. }
  14718. /**
  14719. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14720. */
  14721. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14722. /**
  14723. * If the controller is used in a webXR session
  14724. */
  14725. isXR: boolean;
  14726. private _deviceRoomPosition;
  14727. private _deviceRoomRotationQuaternion;
  14728. /**
  14729. * The device position in babylon space
  14730. */
  14731. devicePosition: Vector3;
  14732. /**
  14733. * The device rotation in babylon space
  14734. */
  14735. deviceRotationQuaternion: Quaternion;
  14736. /**
  14737. * The scale factor of the device in babylon space
  14738. */
  14739. deviceScaleFactor: number;
  14740. /**
  14741. * (Likely devicePosition should be used instead) The device position in its room space
  14742. */
  14743. position: Vector3;
  14744. /**
  14745. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14746. */
  14747. rotationQuaternion: Quaternion;
  14748. /**
  14749. * The type of controller (Eg. Windows mixed reality)
  14750. */
  14751. controllerType: PoseEnabledControllerType;
  14752. protected _calculatedPosition: Vector3;
  14753. private _calculatedRotation;
  14754. /**
  14755. * The raw pose from the device
  14756. */
  14757. rawPose: DevicePose;
  14758. private _trackPosition;
  14759. private _maxRotationDistFromHeadset;
  14760. private _draggedRoomRotation;
  14761. /**
  14762. * @hidden
  14763. */
  14764. _disableTrackPosition(fixedPosition: Vector3): void;
  14765. /**
  14766. * Internal, the mesh attached to the controller
  14767. * @hidden
  14768. */
  14769. _mesh: Nullable<AbstractMesh>;
  14770. private _poseControlledCamera;
  14771. private _leftHandSystemQuaternion;
  14772. /**
  14773. * Internal, matrix used to convert room space to babylon space
  14774. * @hidden
  14775. */
  14776. _deviceToWorld: Matrix;
  14777. /**
  14778. * Node to be used when casting a ray from the controller
  14779. * @hidden
  14780. */
  14781. _pointingPoseNode: Nullable<TransformNode>;
  14782. /**
  14783. * Name of the child mesh that can be used to cast a ray from the controller
  14784. */
  14785. static readonly POINTING_POSE: string;
  14786. /**
  14787. * Creates a new PoseEnabledController from a gamepad
  14788. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14789. */
  14790. constructor(browserGamepad: any);
  14791. private _workingMatrix;
  14792. /**
  14793. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14794. */
  14795. update(): void;
  14796. /**
  14797. * Updates only the pose device and mesh without doing any button event checking
  14798. */
  14799. protected _updatePoseAndMesh(): void;
  14800. /**
  14801. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14802. * @param poseData raw pose fromthe device
  14803. */
  14804. updateFromDevice(poseData: DevicePose): void;
  14805. /**
  14806. * @hidden
  14807. */
  14808. _meshAttachedObservable: Observable<AbstractMesh>;
  14809. /**
  14810. * Attaches a mesh to the controller
  14811. * @param mesh the mesh to be attached
  14812. */
  14813. attachToMesh(mesh: AbstractMesh): void;
  14814. /**
  14815. * Attaches the controllers mesh to a camera
  14816. * @param camera the camera the mesh should be attached to
  14817. */
  14818. attachToPoseControlledCamera(camera: TargetCamera): void;
  14819. /**
  14820. * Disposes of the controller
  14821. */
  14822. dispose(): void;
  14823. /**
  14824. * The mesh that is attached to the controller
  14825. */
  14826. readonly mesh: Nullable<AbstractMesh>;
  14827. /**
  14828. * Gets the ray of the controller in the direction the controller is pointing
  14829. * @param length the length the resulting ray should be
  14830. * @returns a ray in the direction the controller is pointing
  14831. */
  14832. getForwardRay(length?: number): Ray;
  14833. }
  14834. }
  14835. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  14836. import { Observable } from "babylonjs/Misc/observable";
  14837. import { Scene } from "babylonjs/scene";
  14838. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14839. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  14840. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  14841. import { Nullable } from "babylonjs/types";
  14842. /**
  14843. * Defines the WebVRController object that represents controllers tracked in 3D space
  14844. */
  14845. export abstract class WebVRController extends PoseEnabledController {
  14846. /**
  14847. * Internal, the default controller model for the controller
  14848. */
  14849. protected _defaultModel: Nullable<AbstractMesh>;
  14850. /**
  14851. * Fired when the trigger state has changed
  14852. */
  14853. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14854. /**
  14855. * Fired when the main button state has changed
  14856. */
  14857. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14858. /**
  14859. * Fired when the secondary button state has changed
  14860. */
  14861. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14862. /**
  14863. * Fired when the pad state has changed
  14864. */
  14865. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14866. /**
  14867. * Fired when controllers stick values have changed
  14868. */
  14869. onPadValuesChangedObservable: Observable<StickValues>;
  14870. /**
  14871. * Array of button availible on the controller
  14872. */
  14873. protected _buttons: Array<MutableGamepadButton>;
  14874. private _onButtonStateChange;
  14875. /**
  14876. * Fired when a controller button's state has changed
  14877. * @param callback the callback containing the button that was modified
  14878. */
  14879. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14880. /**
  14881. * X and Y axis corresponding to the controllers joystick
  14882. */
  14883. pad: StickValues;
  14884. /**
  14885. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14886. */
  14887. hand: string;
  14888. /**
  14889. * The default controller model for the controller
  14890. */
  14891. readonly defaultModel: Nullable<AbstractMesh>;
  14892. /**
  14893. * Creates a new WebVRController from a gamepad
  14894. * @param vrGamepad the gamepad that the WebVRController should be created from
  14895. */
  14896. constructor(vrGamepad: any);
  14897. /**
  14898. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14899. */
  14900. update(): void;
  14901. /**
  14902. * Function to be called when a button is modified
  14903. */
  14904. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14905. /**
  14906. * Loads a mesh and attaches it to the controller
  14907. * @param scene the scene the mesh should be added to
  14908. * @param meshLoaded callback for when the mesh has been loaded
  14909. */
  14910. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14911. private _setButtonValue;
  14912. private _changes;
  14913. private _checkChanges;
  14914. /**
  14915. * Disposes of th webVRCOntroller
  14916. */
  14917. dispose(): void;
  14918. }
  14919. }
  14920. declare module "babylonjs/Lights/hemisphericLight" {
  14921. import { Nullable } from "babylonjs/types";
  14922. import { Scene } from "babylonjs/scene";
  14923. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14924. import { Color3 } from "babylonjs/Maths/math.color";
  14925. import { Effect } from "babylonjs/Materials/effect";
  14926. import { Light } from "babylonjs/Lights/light";
  14927. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  14928. /**
  14929. * The HemisphericLight simulates the ambient environment light,
  14930. * so the passed direction is the light reflection direction, not the incoming direction.
  14931. */
  14932. export class HemisphericLight extends Light {
  14933. /**
  14934. * The groundColor is the light in the opposite direction to the one specified during creation.
  14935. * 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.
  14936. */
  14937. groundColor: Color3;
  14938. /**
  14939. * The light reflection direction, not the incoming direction.
  14940. */
  14941. direction: Vector3;
  14942. /**
  14943. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14944. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14945. * The HemisphericLight can't cast shadows.
  14946. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14947. * @param name The friendly name of the light
  14948. * @param direction The direction of the light reflection
  14949. * @param scene The scene the light belongs to
  14950. */
  14951. constructor(name: string, direction: Vector3, scene: Scene);
  14952. protected _buildUniformLayout(): void;
  14953. /**
  14954. * Returns the string "HemisphericLight".
  14955. * @return The class name
  14956. */
  14957. getClassName(): string;
  14958. /**
  14959. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14960. * Returns the updated direction.
  14961. * @param target The target the direction should point to
  14962. * @return The computed direction
  14963. */
  14964. setDirectionToTarget(target: Vector3): Vector3;
  14965. /**
  14966. * Returns the shadow generator associated to the light.
  14967. * @returns Always null for hemispheric lights because it does not support shadows.
  14968. */
  14969. getShadowGenerator(): Nullable<IShadowGenerator>;
  14970. /**
  14971. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14972. * @param effect The effect to update
  14973. * @param lightIndex The index of the light in the effect to update
  14974. * @returns The hemispheric light
  14975. */
  14976. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14977. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14978. /**
  14979. * Computes the world matrix of the node
  14980. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14981. * @param useWasUpdatedFlag defines a reserved property
  14982. * @returns the world matrix
  14983. */
  14984. computeWorldMatrix(): Matrix;
  14985. /**
  14986. * Returns the integer 3.
  14987. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14988. */
  14989. getTypeID(): number;
  14990. /**
  14991. * Prepares the list of defines specific to the light type.
  14992. * @param defines the list of defines
  14993. * @param lightIndex defines the index of the light for the effect
  14994. */
  14995. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14996. }
  14997. }
  14998. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  14999. /** @hidden */
  15000. export var vrMultiviewToSingleviewPixelShader: {
  15001. name: string;
  15002. shader: string;
  15003. };
  15004. }
  15005. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  15006. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15007. import { Scene } from "babylonjs/scene";
  15008. /**
  15009. * Renders to multiple views with a single draw call
  15010. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  15011. */
  15012. export class MultiviewRenderTarget extends RenderTargetTexture {
  15013. /**
  15014. * Creates a multiview render target
  15015. * @param scene scene used with the render target
  15016. * @param size the size of the render target (used for each view)
  15017. */
  15018. constructor(scene: Scene, size?: number | {
  15019. width: number;
  15020. height: number;
  15021. } | {
  15022. ratio: number;
  15023. });
  15024. /**
  15025. * @hidden
  15026. * @param faceIndex the face index, if its a cube texture
  15027. */
  15028. _bindFrameBuffer(faceIndex?: number): void;
  15029. /**
  15030. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  15031. * @returns the view count
  15032. */
  15033. getViewCount(): number;
  15034. }
  15035. }
  15036. declare module "babylonjs/Maths/math.frustum" {
  15037. import { Matrix } from "babylonjs/Maths/math.vector";
  15038. import { DeepImmutable } from "babylonjs/types";
  15039. import { Plane } from "babylonjs/Maths/math.plane";
  15040. /**
  15041. * Represents a camera frustum
  15042. */
  15043. export class Frustum {
  15044. /**
  15045. * Gets the planes representing the frustum
  15046. * @param transform matrix to be applied to the returned planes
  15047. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  15048. */
  15049. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  15050. /**
  15051. * Gets the near frustum plane transformed by the transform matrix
  15052. * @param transform transformation matrix to be applied to the resulting frustum plane
  15053. * @param frustumPlane the resuling frustum plane
  15054. */
  15055. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15056. /**
  15057. * Gets the far frustum plane transformed by the transform matrix
  15058. * @param transform transformation matrix to be applied to the resulting frustum plane
  15059. * @param frustumPlane the resuling frustum plane
  15060. */
  15061. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15062. /**
  15063. * Gets the left frustum plane transformed by the transform matrix
  15064. * @param transform transformation matrix to be applied to the resulting frustum plane
  15065. * @param frustumPlane the resuling frustum plane
  15066. */
  15067. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15068. /**
  15069. * Gets the right frustum plane transformed by the transform matrix
  15070. * @param transform transformation matrix to be applied to the resulting frustum plane
  15071. * @param frustumPlane the resuling frustum plane
  15072. */
  15073. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15074. /**
  15075. * Gets the top frustum plane transformed by the transform matrix
  15076. * @param transform transformation matrix to be applied to the resulting frustum plane
  15077. * @param frustumPlane the resuling frustum plane
  15078. */
  15079. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15080. /**
  15081. * Gets the bottom frustum plane transformed by the transform matrix
  15082. * @param transform transformation matrix to be applied to the resulting frustum plane
  15083. * @param frustumPlane the resuling frustum plane
  15084. */
  15085. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15086. /**
  15087. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  15088. * @param transform transformation matrix to be applied to the resulting frustum planes
  15089. * @param frustumPlanes the resuling frustum planes
  15090. */
  15091. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  15092. }
  15093. }
  15094. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  15095. import { Camera } from "babylonjs/Cameras/camera";
  15096. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15097. import { Nullable } from "babylonjs/types";
  15098. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15099. import { Matrix } from "babylonjs/Maths/math.vector";
  15100. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  15101. module "babylonjs/Engines/engine" {
  15102. interface Engine {
  15103. /**
  15104. * Creates a new multiview render target
  15105. * @param width defines the width of the texture
  15106. * @param height defines the height of the texture
  15107. * @returns the created multiview texture
  15108. */
  15109. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  15110. /**
  15111. * Binds a multiview framebuffer to be drawn to
  15112. * @param multiviewTexture texture to bind
  15113. */
  15114. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  15115. }
  15116. }
  15117. module "babylonjs/Cameras/camera" {
  15118. interface Camera {
  15119. /**
  15120. * @hidden
  15121. * 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)
  15122. */
  15123. _useMultiviewToSingleView: boolean;
  15124. /**
  15125. * @hidden
  15126. * 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)
  15127. */
  15128. _multiviewTexture: Nullable<RenderTargetTexture>;
  15129. /**
  15130. * @hidden
  15131. * ensures the multiview texture of the camera exists and has the specified width/height
  15132. * @param width height to set on the multiview texture
  15133. * @param height width to set on the multiview texture
  15134. */
  15135. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  15136. }
  15137. }
  15138. module "babylonjs/scene" {
  15139. interface Scene {
  15140. /** @hidden */
  15141. _transformMatrixR: Matrix;
  15142. /** @hidden */
  15143. _multiviewSceneUbo: Nullable<UniformBuffer>;
  15144. /** @hidden */
  15145. _createMultiviewUbo(): void;
  15146. /** @hidden */
  15147. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  15148. /** @hidden */
  15149. _renderMultiviewToSingleView(camera: Camera): void;
  15150. }
  15151. }
  15152. }
  15153. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  15154. import { Camera } from "babylonjs/Cameras/camera";
  15155. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  15156. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  15157. import "babylonjs/Engines/Extensions/engine.multiview";
  15158. /**
  15159. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  15160. * This will not be used for webXR as it supports displaying texture arrays directly
  15161. */
  15162. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  15163. /**
  15164. * Initializes a VRMultiviewToSingleview
  15165. * @param name name of the post process
  15166. * @param camera camera to be applied to
  15167. * @param scaleFactor scaling factor to the size of the output texture
  15168. */
  15169. constructor(name: string, camera: Camera, scaleFactor: number);
  15170. }
  15171. }
  15172. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  15173. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  15174. import { Nullable } from "babylonjs/types";
  15175. import { Size } from "babylonjs/Maths/math.size";
  15176. import { Observable } from "babylonjs/Misc/observable";
  15177. module "babylonjs/Engines/engine" {
  15178. interface Engine {
  15179. /** @hidden */
  15180. _vrDisplay: any;
  15181. /** @hidden */
  15182. _vrSupported: boolean;
  15183. /** @hidden */
  15184. _oldSize: Size;
  15185. /** @hidden */
  15186. _oldHardwareScaleFactor: number;
  15187. /** @hidden */
  15188. _vrExclusivePointerMode: boolean;
  15189. /** @hidden */
  15190. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  15191. /** @hidden */
  15192. _onVRDisplayPointerRestricted: () => void;
  15193. /** @hidden */
  15194. _onVRDisplayPointerUnrestricted: () => void;
  15195. /** @hidden */
  15196. _onVrDisplayConnect: Nullable<(display: any) => void>;
  15197. /** @hidden */
  15198. _onVrDisplayDisconnect: Nullable<() => void>;
  15199. /** @hidden */
  15200. _onVrDisplayPresentChange: Nullable<() => void>;
  15201. /**
  15202. * Observable signaled when VR display mode changes
  15203. */
  15204. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  15205. /**
  15206. * Observable signaled when VR request present is complete
  15207. */
  15208. onVRRequestPresentComplete: Observable<boolean>;
  15209. /**
  15210. * Observable signaled when VR request present starts
  15211. */
  15212. onVRRequestPresentStart: Observable<Engine>;
  15213. /**
  15214. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  15215. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  15216. */
  15217. isInVRExclusivePointerMode: boolean;
  15218. /**
  15219. * Gets a boolean indicating if a webVR device was detected
  15220. * @returns true if a webVR device was detected
  15221. */
  15222. isVRDevicePresent(): boolean;
  15223. /**
  15224. * Gets the current webVR device
  15225. * @returns the current webVR device (or null)
  15226. */
  15227. getVRDevice(): any;
  15228. /**
  15229. * Initializes a webVR display and starts listening to display change events
  15230. * The onVRDisplayChangedObservable will be notified upon these changes
  15231. * @returns A promise containing a VRDisplay and if vr is supported
  15232. */
  15233. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15234. /** @hidden */
  15235. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15236. /**
  15237. * Call this function to switch to webVR mode
  15238. * Will do nothing if webVR is not supported or if there is no webVR device
  15239. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15240. */
  15241. enableVR(): void;
  15242. /** @hidden */
  15243. _onVRFullScreenTriggered(): void;
  15244. }
  15245. }
  15246. }
  15247. declare module "babylonjs/Cameras/VR/webVRCamera" {
  15248. import { Nullable } from "babylonjs/types";
  15249. import { Observable } from "babylonjs/Misc/observable";
  15250. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  15251. import { Scene } from "babylonjs/scene";
  15252. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15253. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  15254. import { Node } from "babylonjs/node";
  15255. import { Ray } from "babylonjs/Culling/ray";
  15256. import "babylonjs/Cameras/RigModes/webVRRigMode";
  15257. import "babylonjs/Engines/Extensions/engine.webVR";
  15258. /**
  15259. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15260. * IMPORTANT!! The data is right-hand data.
  15261. * @export
  15262. * @interface DevicePose
  15263. */
  15264. export interface DevicePose {
  15265. /**
  15266. * The position of the device, values in array are [x,y,z].
  15267. */
  15268. readonly position: Nullable<Float32Array>;
  15269. /**
  15270. * The linearVelocity of the device, values in array are [x,y,z].
  15271. */
  15272. readonly linearVelocity: Nullable<Float32Array>;
  15273. /**
  15274. * The linearAcceleration of the device, values in array are [x,y,z].
  15275. */
  15276. readonly linearAcceleration: Nullable<Float32Array>;
  15277. /**
  15278. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15279. */
  15280. readonly orientation: Nullable<Float32Array>;
  15281. /**
  15282. * The angularVelocity of the device, values in array are [x,y,z].
  15283. */
  15284. readonly angularVelocity: Nullable<Float32Array>;
  15285. /**
  15286. * The angularAcceleration of the device, values in array are [x,y,z].
  15287. */
  15288. readonly angularAcceleration: Nullable<Float32Array>;
  15289. }
  15290. /**
  15291. * Interface representing a pose controlled object in Babylon.
  15292. * A pose controlled object has both regular pose values as well as pose values
  15293. * from an external device such as a VR head mounted display
  15294. */
  15295. export interface PoseControlled {
  15296. /**
  15297. * The position of the object in babylon space.
  15298. */
  15299. position: Vector3;
  15300. /**
  15301. * The rotation quaternion of the object in babylon space.
  15302. */
  15303. rotationQuaternion: Quaternion;
  15304. /**
  15305. * The position of the device in babylon space.
  15306. */
  15307. devicePosition?: Vector3;
  15308. /**
  15309. * The rotation quaternion of the device in babylon space.
  15310. */
  15311. deviceRotationQuaternion: Quaternion;
  15312. /**
  15313. * The raw pose coming from the device.
  15314. */
  15315. rawPose: Nullable<DevicePose>;
  15316. /**
  15317. * The scale of the device to be used when translating from device space to babylon space.
  15318. */
  15319. deviceScaleFactor: number;
  15320. /**
  15321. * Updates the poseControlled values based on the input device pose.
  15322. * @param poseData the pose data to update the object with
  15323. */
  15324. updateFromDevice(poseData: DevicePose): void;
  15325. }
  15326. /**
  15327. * Set of options to customize the webVRCamera
  15328. */
  15329. export interface WebVROptions {
  15330. /**
  15331. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15332. */
  15333. trackPosition?: boolean;
  15334. /**
  15335. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15336. */
  15337. positionScale?: number;
  15338. /**
  15339. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15340. */
  15341. displayName?: string;
  15342. /**
  15343. * Should the native controller meshes be initialized. (default: true)
  15344. */
  15345. controllerMeshes?: boolean;
  15346. /**
  15347. * Creating a default HemiLight only on controllers. (default: true)
  15348. */
  15349. defaultLightingOnControllers?: boolean;
  15350. /**
  15351. * If you don't want to use the default VR button of the helper. (default: false)
  15352. */
  15353. useCustomVRButton?: boolean;
  15354. /**
  15355. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15356. */
  15357. customVRButton?: HTMLButtonElement;
  15358. /**
  15359. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15360. */
  15361. rayLength?: number;
  15362. /**
  15363. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15364. */
  15365. defaultHeight?: number;
  15366. /**
  15367. * If multiview should be used if availible (default: false)
  15368. */
  15369. useMultiview?: boolean;
  15370. }
  15371. /**
  15372. * This represents a WebVR camera.
  15373. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15374. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15375. */
  15376. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15377. private webVROptions;
  15378. /**
  15379. * @hidden
  15380. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15381. */
  15382. _vrDevice: any;
  15383. /**
  15384. * The rawPose of the vrDevice.
  15385. */
  15386. rawPose: Nullable<DevicePose>;
  15387. private _onVREnabled;
  15388. private _specsVersion;
  15389. private _attached;
  15390. private _frameData;
  15391. protected _descendants: Array<Node>;
  15392. private _deviceRoomPosition;
  15393. /** @hidden */
  15394. _deviceRoomRotationQuaternion: Quaternion;
  15395. private _standingMatrix;
  15396. /**
  15397. * Represents device position in babylon space.
  15398. */
  15399. devicePosition: Vector3;
  15400. /**
  15401. * Represents device rotation in babylon space.
  15402. */
  15403. deviceRotationQuaternion: Quaternion;
  15404. /**
  15405. * The scale of the device to be used when translating from device space to babylon space.
  15406. */
  15407. deviceScaleFactor: number;
  15408. private _deviceToWorld;
  15409. private _worldToDevice;
  15410. /**
  15411. * References to the webVR controllers for the vrDevice.
  15412. */
  15413. controllers: Array<WebVRController>;
  15414. /**
  15415. * Emits an event when a controller is attached.
  15416. */
  15417. onControllersAttachedObservable: Observable<WebVRController[]>;
  15418. /**
  15419. * Emits an event when a controller's mesh has been loaded;
  15420. */
  15421. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15422. /**
  15423. * Emits an event when the HMD's pose has been updated.
  15424. */
  15425. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15426. private _poseSet;
  15427. /**
  15428. * If the rig cameras be used as parent instead of this camera.
  15429. */
  15430. rigParenting: boolean;
  15431. private _lightOnControllers;
  15432. private _defaultHeight?;
  15433. /**
  15434. * Instantiates a WebVRFreeCamera.
  15435. * @param name The name of the WebVRFreeCamera
  15436. * @param position The starting anchor position for the camera
  15437. * @param scene The scene the camera belongs to
  15438. * @param webVROptions a set of customizable options for the webVRCamera
  15439. */
  15440. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15441. /**
  15442. * Gets the device distance from the ground in meters.
  15443. * @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.
  15444. */
  15445. deviceDistanceToRoomGround(): number;
  15446. /**
  15447. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15448. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15449. */
  15450. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15451. /**
  15452. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15453. * @returns A promise with a boolean set to if the standing matrix is supported.
  15454. */
  15455. useStandingMatrixAsync(): Promise<boolean>;
  15456. /**
  15457. * Disposes the camera
  15458. */
  15459. dispose(): void;
  15460. /**
  15461. * Gets a vrController by name.
  15462. * @param name The name of the controller to retreive
  15463. * @returns the controller matching the name specified or null if not found
  15464. */
  15465. getControllerByName(name: string): Nullable<WebVRController>;
  15466. private _leftController;
  15467. /**
  15468. * The controller corresponding to the users left hand.
  15469. */
  15470. readonly leftController: Nullable<WebVRController>;
  15471. private _rightController;
  15472. /**
  15473. * The controller corresponding to the users right hand.
  15474. */
  15475. readonly rightController: Nullable<WebVRController>;
  15476. /**
  15477. * Casts a ray forward from the vrCamera's gaze.
  15478. * @param length Length of the ray (default: 100)
  15479. * @returns the ray corresponding to the gaze
  15480. */
  15481. getForwardRay(length?: number): Ray;
  15482. /**
  15483. * @hidden
  15484. * Updates the camera based on device's frame data
  15485. */
  15486. _checkInputs(): void;
  15487. /**
  15488. * Updates the poseControlled values based on the input device pose.
  15489. * @param poseData Pose coming from the device
  15490. */
  15491. updateFromDevice(poseData: DevicePose): void;
  15492. private _htmlElementAttached;
  15493. private _detachIfAttached;
  15494. /**
  15495. * WebVR's attach control will start broadcasting frames to the device.
  15496. * Note that in certain browsers (chrome for example) this function must be called
  15497. * within a user-interaction callback. Example:
  15498. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15499. *
  15500. * @param element html element to attach the vrDevice to
  15501. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15502. */
  15503. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15504. /**
  15505. * Detaches the camera from the html element and disables VR
  15506. *
  15507. * @param element html element to detach from
  15508. */
  15509. detachControl(element: HTMLElement): void;
  15510. /**
  15511. * @returns the name of this class
  15512. */
  15513. getClassName(): string;
  15514. /**
  15515. * Calls resetPose on the vrDisplay
  15516. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15517. */
  15518. resetToCurrentRotation(): void;
  15519. /**
  15520. * @hidden
  15521. * Updates the rig cameras (left and right eye)
  15522. */
  15523. _updateRigCameras(): void;
  15524. private _workingVector;
  15525. private _oneVector;
  15526. private _workingMatrix;
  15527. private updateCacheCalled;
  15528. private _correctPositionIfNotTrackPosition;
  15529. /**
  15530. * @hidden
  15531. * Updates the cached values of the camera
  15532. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15533. */
  15534. _updateCache(ignoreParentClass?: boolean): void;
  15535. /**
  15536. * @hidden
  15537. * Get current device position in babylon world
  15538. */
  15539. _computeDevicePosition(): void;
  15540. /**
  15541. * Updates the current device position and rotation in the babylon world
  15542. */
  15543. update(): void;
  15544. /**
  15545. * @hidden
  15546. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15547. * @returns an identity matrix
  15548. */
  15549. _getViewMatrix(): Matrix;
  15550. private _tmpMatrix;
  15551. /**
  15552. * This function is called by the two RIG cameras.
  15553. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15554. * @hidden
  15555. */
  15556. _getWebVRViewMatrix(): Matrix;
  15557. /** @hidden */
  15558. _getWebVRProjectionMatrix(): Matrix;
  15559. private _onGamepadConnectedObserver;
  15560. private _onGamepadDisconnectedObserver;
  15561. private _updateCacheWhenTrackingDisabledObserver;
  15562. /**
  15563. * Initializes the controllers and their meshes
  15564. */
  15565. initControllers(): void;
  15566. }
  15567. }
  15568. declare module "babylonjs/PostProcesses/postProcess" {
  15569. import { Nullable } from "babylonjs/types";
  15570. import { SmartArray } from "babylonjs/Misc/smartArray";
  15571. import { Observable } from "babylonjs/Misc/observable";
  15572. import { Vector2 } from "babylonjs/Maths/math.vector";
  15573. import { Camera } from "babylonjs/Cameras/camera";
  15574. import { Effect } from "babylonjs/Materials/effect";
  15575. import "babylonjs/Shaders/postprocess.vertex";
  15576. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15577. import { Engine } from "babylonjs/Engines/engine";
  15578. import { Color4 } from "babylonjs/Maths/math.color";
  15579. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15580. /**
  15581. * Size options for a post process
  15582. */
  15583. export type PostProcessOptions = {
  15584. width: number;
  15585. height: number;
  15586. };
  15587. /**
  15588. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15589. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15590. */
  15591. export class PostProcess {
  15592. /** Name of the PostProcess. */
  15593. name: string;
  15594. /**
  15595. * Gets or sets the unique id of the post process
  15596. */
  15597. uniqueId: number;
  15598. /**
  15599. * Width of the texture to apply the post process on
  15600. */
  15601. width: number;
  15602. /**
  15603. * Height of the texture to apply the post process on
  15604. */
  15605. height: number;
  15606. /**
  15607. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15608. * @hidden
  15609. */
  15610. _outputTexture: Nullable<InternalTexture>;
  15611. /**
  15612. * Sampling mode used by the shader
  15613. * See https://doc.babylonjs.com/classes/3.1/texture
  15614. */
  15615. renderTargetSamplingMode: number;
  15616. /**
  15617. * Clear color to use when screen clearing
  15618. */
  15619. clearColor: Color4;
  15620. /**
  15621. * If the buffer needs to be cleared before applying the post process. (default: true)
  15622. * Should be set to false if shader will overwrite all previous pixels.
  15623. */
  15624. autoClear: boolean;
  15625. /**
  15626. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15627. */
  15628. alphaMode: number;
  15629. /**
  15630. * Sets the setAlphaBlendConstants of the babylon engine
  15631. */
  15632. alphaConstants: Color4;
  15633. /**
  15634. * Animations to be used for the post processing
  15635. */
  15636. animations: import("babylonjs/Animations/animation").Animation[];
  15637. /**
  15638. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15639. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15640. */
  15641. enablePixelPerfectMode: boolean;
  15642. /**
  15643. * Force the postprocess to be applied without taking in account viewport
  15644. */
  15645. forceFullscreenViewport: boolean;
  15646. /**
  15647. * List of inspectable custom properties (used by the Inspector)
  15648. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15649. */
  15650. inspectableCustomProperties: IInspectable[];
  15651. /**
  15652. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15653. *
  15654. * | Value | Type | Description |
  15655. * | ----- | ----------------------------------- | ----------- |
  15656. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15657. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15658. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15659. *
  15660. */
  15661. scaleMode: number;
  15662. /**
  15663. * Force textures to be a power of two (default: false)
  15664. */
  15665. alwaysForcePOT: boolean;
  15666. private _samples;
  15667. /**
  15668. * Number of sample textures (default: 1)
  15669. */
  15670. samples: number;
  15671. /**
  15672. * Modify the scale of the post process to be the same as the viewport (default: false)
  15673. */
  15674. adaptScaleToCurrentViewport: boolean;
  15675. private _camera;
  15676. private _scene;
  15677. private _engine;
  15678. private _options;
  15679. private _reusable;
  15680. private _textureType;
  15681. /**
  15682. * Smart array of input and output textures for the post process.
  15683. * @hidden
  15684. */
  15685. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  15686. /**
  15687. * The index in _textures that corresponds to the output texture.
  15688. * @hidden
  15689. */
  15690. _currentRenderTextureInd: number;
  15691. private _effect;
  15692. private _samplers;
  15693. private _fragmentUrl;
  15694. private _vertexUrl;
  15695. private _parameters;
  15696. private _scaleRatio;
  15697. protected _indexParameters: any;
  15698. private _shareOutputWithPostProcess;
  15699. private _texelSize;
  15700. private _forcedOutputTexture;
  15701. /**
  15702. * Returns the fragment url or shader name used in the post process.
  15703. * @returns the fragment url or name in the shader store.
  15704. */
  15705. getEffectName(): string;
  15706. /**
  15707. * An event triggered when the postprocess is activated.
  15708. */
  15709. onActivateObservable: Observable<Camera>;
  15710. private _onActivateObserver;
  15711. /**
  15712. * A function that is added to the onActivateObservable
  15713. */
  15714. onActivate: Nullable<(camera: Camera) => void>;
  15715. /**
  15716. * An event triggered when the postprocess changes its size.
  15717. */
  15718. onSizeChangedObservable: Observable<PostProcess>;
  15719. private _onSizeChangedObserver;
  15720. /**
  15721. * A function that is added to the onSizeChangedObservable
  15722. */
  15723. onSizeChanged: (postProcess: PostProcess) => void;
  15724. /**
  15725. * An event triggered when the postprocess applies its effect.
  15726. */
  15727. onApplyObservable: Observable<Effect>;
  15728. private _onApplyObserver;
  15729. /**
  15730. * A function that is added to the onApplyObservable
  15731. */
  15732. onApply: (effect: Effect) => void;
  15733. /**
  15734. * An event triggered before rendering the postprocess
  15735. */
  15736. onBeforeRenderObservable: Observable<Effect>;
  15737. private _onBeforeRenderObserver;
  15738. /**
  15739. * A function that is added to the onBeforeRenderObservable
  15740. */
  15741. onBeforeRender: (effect: Effect) => void;
  15742. /**
  15743. * An event triggered after rendering the postprocess
  15744. */
  15745. onAfterRenderObservable: Observable<Effect>;
  15746. private _onAfterRenderObserver;
  15747. /**
  15748. * A function that is added to the onAfterRenderObservable
  15749. */
  15750. onAfterRender: (efect: Effect) => void;
  15751. /**
  15752. * 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
  15753. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15754. */
  15755. inputTexture: InternalTexture;
  15756. /**
  15757. * Gets the camera which post process is applied to.
  15758. * @returns The camera the post process is applied to.
  15759. */
  15760. getCamera(): Camera;
  15761. /**
  15762. * Gets the texel size of the postprocess.
  15763. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15764. */
  15765. readonly texelSize: Vector2;
  15766. /**
  15767. * Creates a new instance PostProcess
  15768. * @param name The name of the PostProcess.
  15769. * @param fragmentUrl The url of the fragment shader to be used.
  15770. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15771. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15772. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15773. * @param camera The camera to apply the render pass to.
  15774. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15775. * @param engine The engine which the post process will be applied. (default: current engine)
  15776. * @param reusable If the post process can be reused on the same frame. (default: false)
  15777. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15778. * @param textureType Type of textures used when performing the post process. (default: 0)
  15779. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15780. * @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
  15781. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15782. */
  15783. constructor(
  15784. /** Name of the PostProcess. */
  15785. 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);
  15786. /**
  15787. * Gets a string idenfifying the name of the class
  15788. * @returns "PostProcess" string
  15789. */
  15790. getClassName(): string;
  15791. /**
  15792. * Gets the engine which this post process belongs to.
  15793. * @returns The engine the post process was enabled with.
  15794. */
  15795. getEngine(): Engine;
  15796. /**
  15797. * The effect that is created when initializing the post process.
  15798. * @returns The created effect corresponding the the postprocess.
  15799. */
  15800. getEffect(): Effect;
  15801. /**
  15802. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15803. * @param postProcess The post process to share the output with.
  15804. * @returns This post process.
  15805. */
  15806. shareOutputWith(postProcess: PostProcess): PostProcess;
  15807. /**
  15808. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15809. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15810. */
  15811. useOwnOutput(): void;
  15812. /**
  15813. * Updates the effect with the current post process compile time values and recompiles the shader.
  15814. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15815. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15816. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15817. * @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
  15818. * @param onCompiled Called when the shader has been compiled.
  15819. * @param onError Called if there is an error when compiling a shader.
  15820. */
  15821. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15822. /**
  15823. * The post process is reusable if it can be used multiple times within one frame.
  15824. * @returns If the post process is reusable
  15825. */
  15826. isReusable(): boolean;
  15827. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15828. markTextureDirty(): void;
  15829. /**
  15830. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15831. * 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.
  15832. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15833. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15834. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15835. * @returns The target texture that was bound to be written to.
  15836. */
  15837. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15838. /**
  15839. * If the post process is supported.
  15840. */
  15841. readonly isSupported: boolean;
  15842. /**
  15843. * The aspect ratio of the output texture.
  15844. */
  15845. readonly aspectRatio: number;
  15846. /**
  15847. * Get a value indicating if the post-process is ready to be used
  15848. * @returns true if the post-process is ready (shader is compiled)
  15849. */
  15850. isReady(): boolean;
  15851. /**
  15852. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15853. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15854. */
  15855. apply(): Nullable<Effect>;
  15856. private _disposeTextures;
  15857. /**
  15858. * Disposes the post process.
  15859. * @param camera The camera to dispose the post process on.
  15860. */
  15861. dispose(camera?: Camera): void;
  15862. }
  15863. }
  15864. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  15865. /** @hidden */
  15866. export var kernelBlurVaryingDeclaration: {
  15867. name: string;
  15868. shader: string;
  15869. };
  15870. }
  15871. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  15872. /** @hidden */
  15873. export var kernelBlurFragment: {
  15874. name: string;
  15875. shader: string;
  15876. };
  15877. }
  15878. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  15879. /** @hidden */
  15880. export var kernelBlurFragment2: {
  15881. name: string;
  15882. shader: string;
  15883. };
  15884. }
  15885. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  15886. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15887. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  15888. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  15889. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  15890. /** @hidden */
  15891. export var kernelBlurPixelShader: {
  15892. name: string;
  15893. shader: string;
  15894. };
  15895. }
  15896. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  15897. /** @hidden */
  15898. export var kernelBlurVertex: {
  15899. name: string;
  15900. shader: string;
  15901. };
  15902. }
  15903. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  15904. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15905. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  15906. /** @hidden */
  15907. export var kernelBlurVertexShader: {
  15908. name: string;
  15909. shader: string;
  15910. };
  15911. }
  15912. declare module "babylonjs/PostProcesses/blurPostProcess" {
  15913. import { Vector2 } from "babylonjs/Maths/math.vector";
  15914. import { Nullable } from "babylonjs/types";
  15915. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  15916. import { Camera } from "babylonjs/Cameras/camera";
  15917. import { Effect } from "babylonjs/Materials/effect";
  15918. import { Engine } from "babylonjs/Engines/engine";
  15919. import "babylonjs/Shaders/kernelBlur.fragment";
  15920. import "babylonjs/Shaders/kernelBlur.vertex";
  15921. /**
  15922. * The Blur Post Process which blurs an image based on a kernel and direction.
  15923. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15924. */
  15925. export class BlurPostProcess extends PostProcess {
  15926. /** The direction in which to blur the image. */
  15927. direction: Vector2;
  15928. private blockCompilation;
  15929. protected _kernel: number;
  15930. protected _idealKernel: number;
  15931. protected _packedFloat: boolean;
  15932. private _staticDefines;
  15933. /**
  15934. * Sets the length in pixels of the blur sample region
  15935. */
  15936. /**
  15937. * Gets the length in pixels of the blur sample region
  15938. */
  15939. kernel: number;
  15940. /**
  15941. * Sets wether or not the blur needs to unpack/repack floats
  15942. */
  15943. /**
  15944. * Gets wether or not the blur is unpacking/repacking floats
  15945. */
  15946. packedFloat: boolean;
  15947. /**
  15948. * Creates a new instance BlurPostProcess
  15949. * @param name The name of the effect.
  15950. * @param direction The direction in which to blur the image.
  15951. * @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.
  15952. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15953. * @param camera The camera to apply the render pass to.
  15954. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15955. * @param engine The engine which the post process will be applied. (default: current engine)
  15956. * @param reusable If the post process can be reused on the same frame. (default: false)
  15957. * @param textureType Type of textures used when performing the post process. (default: 0)
  15958. * @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)
  15959. */
  15960. constructor(name: string,
  15961. /** The direction in which to blur the image. */
  15962. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15963. /**
  15964. * Updates the effect with the current post process compile time values and recompiles the shader.
  15965. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15966. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15967. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15968. * @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
  15969. * @param onCompiled Called when the shader has been compiled.
  15970. * @param onError Called if there is an error when compiling a shader.
  15971. */
  15972. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15973. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15974. /**
  15975. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15976. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15977. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15978. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15979. * The gaps between physical kernels are compensated for in the weighting of the samples
  15980. * @param idealKernel Ideal blur kernel.
  15981. * @return Nearest best kernel.
  15982. */
  15983. protected _nearestBestKernel(idealKernel: number): number;
  15984. /**
  15985. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15986. * @param x The point on the Gaussian distribution to sample.
  15987. * @return the value of the Gaussian function at x.
  15988. */
  15989. protected _gaussianWeight(x: number): number;
  15990. /**
  15991. * Generates a string that can be used as a floating point number in GLSL.
  15992. * @param x Value to print.
  15993. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15994. * @return GLSL float string.
  15995. */
  15996. protected _glslFloat(x: number, decimalFigures?: number): string;
  15997. }
  15998. }
  15999. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  16000. import { Scene } from "babylonjs/scene";
  16001. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  16002. import { Plane } from "babylonjs/Maths/math.plane";
  16003. /**
  16004. * Mirror texture can be used to simulate the view from a mirror in a scene.
  16005. * It will dynamically be rendered every frame to adapt to the camera point of view.
  16006. * You can then easily use it as a reflectionTexture on a flat surface.
  16007. * In case the surface is not a plane, please consider relying on reflection probes.
  16008. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16009. */
  16010. export class MirrorTexture extends RenderTargetTexture {
  16011. private scene;
  16012. /**
  16013. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  16014. * 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.
  16015. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16016. */
  16017. mirrorPlane: Plane;
  16018. /**
  16019. * Define the blur ratio used to blur the reflection if needed.
  16020. */
  16021. blurRatio: number;
  16022. /**
  16023. * Define the adaptive blur kernel used to blur the reflection if needed.
  16024. * This will autocompute the closest best match for the `blurKernel`
  16025. */
  16026. adaptiveBlurKernel: number;
  16027. /**
  16028. * Define the blur kernel used to blur the reflection if needed.
  16029. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16030. */
  16031. blurKernel: number;
  16032. /**
  16033. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  16034. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16035. */
  16036. blurKernelX: number;
  16037. /**
  16038. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  16039. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16040. */
  16041. blurKernelY: number;
  16042. private _autoComputeBlurKernel;
  16043. protected _onRatioRescale(): void;
  16044. private _updateGammaSpace;
  16045. private _imageProcessingConfigChangeObserver;
  16046. private _transformMatrix;
  16047. private _mirrorMatrix;
  16048. private _savedViewMatrix;
  16049. private _blurX;
  16050. private _blurY;
  16051. private _adaptiveBlurKernel;
  16052. private _blurKernelX;
  16053. private _blurKernelY;
  16054. private _blurRatio;
  16055. /**
  16056. * Instantiates a Mirror Texture.
  16057. * Mirror texture can be used to simulate the view from a mirror in a scene.
  16058. * It will dynamically be rendered every frame to adapt to the camera point of view.
  16059. * You can then easily use it as a reflectionTexture on a flat surface.
  16060. * In case the surface is not a plane, please consider relying on reflection probes.
  16061. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16062. * @param name
  16063. * @param size
  16064. * @param scene
  16065. * @param generateMipMaps
  16066. * @param type
  16067. * @param samplingMode
  16068. * @param generateDepthBuffer
  16069. */
  16070. constructor(name: string, size: number | {
  16071. width: number;
  16072. height: number;
  16073. } | {
  16074. ratio: number;
  16075. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  16076. private _preparePostProcesses;
  16077. /**
  16078. * Clone the mirror texture.
  16079. * @returns the cloned texture
  16080. */
  16081. clone(): MirrorTexture;
  16082. /**
  16083. * Serialize the texture to a JSON representation you could use in Parse later on
  16084. * @returns the serialized JSON representation
  16085. */
  16086. serialize(): any;
  16087. /**
  16088. * Dispose the texture and release its associated resources.
  16089. */
  16090. dispose(): void;
  16091. }
  16092. }
  16093. declare module "babylonjs/Materials/Textures/texture" {
  16094. import { Observable } from "babylonjs/Misc/observable";
  16095. import { Nullable } from "babylonjs/types";
  16096. import { Scene } from "babylonjs/scene";
  16097. import { Matrix } from "babylonjs/Maths/math.vector";
  16098. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16099. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16100. import { Engine } from "babylonjs/Engines/engine";
  16101. /**
  16102. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16103. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16104. */
  16105. export class Texture extends BaseTexture {
  16106. /**
  16107. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  16108. */
  16109. static SerializeBuffers: boolean;
  16110. /** @hidden */
  16111. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  16112. /** @hidden */
  16113. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  16114. /** @hidden */
  16115. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  16116. /** nearest is mag = nearest and min = nearest and mip = linear */
  16117. static readonly NEAREST_SAMPLINGMODE: number;
  16118. /** nearest is mag = nearest and min = nearest and mip = linear */
  16119. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  16120. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16121. static readonly BILINEAR_SAMPLINGMODE: number;
  16122. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16123. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  16124. /** Trilinear is mag = linear and min = linear and mip = linear */
  16125. static readonly TRILINEAR_SAMPLINGMODE: number;
  16126. /** Trilinear is mag = linear and min = linear and mip = linear */
  16127. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  16128. /** mag = nearest and min = nearest and mip = nearest */
  16129. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  16130. /** mag = nearest and min = linear and mip = nearest */
  16131. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  16132. /** mag = nearest and min = linear and mip = linear */
  16133. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  16134. /** mag = nearest and min = linear and mip = none */
  16135. static readonly NEAREST_LINEAR: number;
  16136. /** mag = nearest and min = nearest and mip = none */
  16137. static readonly NEAREST_NEAREST: number;
  16138. /** mag = linear and min = nearest and mip = nearest */
  16139. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  16140. /** mag = linear and min = nearest and mip = linear */
  16141. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  16142. /** mag = linear and min = linear and mip = none */
  16143. static readonly LINEAR_LINEAR: number;
  16144. /** mag = linear and min = nearest and mip = none */
  16145. static readonly LINEAR_NEAREST: number;
  16146. /** Explicit coordinates mode */
  16147. static readonly EXPLICIT_MODE: number;
  16148. /** Spherical coordinates mode */
  16149. static readonly SPHERICAL_MODE: number;
  16150. /** Planar coordinates mode */
  16151. static readonly PLANAR_MODE: number;
  16152. /** Cubic coordinates mode */
  16153. static readonly CUBIC_MODE: number;
  16154. /** Projection coordinates mode */
  16155. static readonly PROJECTION_MODE: number;
  16156. /** Inverse Cubic coordinates mode */
  16157. static readonly SKYBOX_MODE: number;
  16158. /** Inverse Cubic coordinates mode */
  16159. static readonly INVCUBIC_MODE: number;
  16160. /** Equirectangular coordinates mode */
  16161. static readonly EQUIRECTANGULAR_MODE: number;
  16162. /** Equirectangular Fixed coordinates mode */
  16163. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  16164. /** Equirectangular Fixed Mirrored coordinates mode */
  16165. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  16166. /** Texture is not repeating outside of 0..1 UVs */
  16167. static readonly CLAMP_ADDRESSMODE: number;
  16168. /** Texture is repeating outside of 0..1 UVs */
  16169. static readonly WRAP_ADDRESSMODE: number;
  16170. /** Texture is repeating and mirrored */
  16171. static readonly MIRROR_ADDRESSMODE: number;
  16172. /**
  16173. * 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
  16174. */
  16175. static UseSerializedUrlIfAny: boolean;
  16176. /**
  16177. * Define the url of the texture.
  16178. */
  16179. url: Nullable<string>;
  16180. /**
  16181. * Define an offset on the texture to offset the u coordinates of the UVs
  16182. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16183. */
  16184. uOffset: number;
  16185. /**
  16186. * Define an offset on the texture to offset the v coordinates of the UVs
  16187. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16188. */
  16189. vOffset: number;
  16190. /**
  16191. * Define an offset on the texture to scale the u coordinates of the UVs
  16192. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16193. */
  16194. uScale: number;
  16195. /**
  16196. * Define an offset on the texture to scale the v coordinates of the UVs
  16197. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16198. */
  16199. vScale: number;
  16200. /**
  16201. * Define an offset on the texture to rotate around the u coordinates of the UVs
  16202. * @see http://doc.babylonjs.com/how_to/more_materials
  16203. */
  16204. uAng: number;
  16205. /**
  16206. * Define an offset on the texture to rotate around the v coordinates of the UVs
  16207. * @see http://doc.babylonjs.com/how_to/more_materials
  16208. */
  16209. vAng: number;
  16210. /**
  16211. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  16212. * @see http://doc.babylonjs.com/how_to/more_materials
  16213. */
  16214. wAng: number;
  16215. /**
  16216. * Defines the center of rotation (U)
  16217. */
  16218. uRotationCenter: number;
  16219. /**
  16220. * Defines the center of rotation (V)
  16221. */
  16222. vRotationCenter: number;
  16223. /**
  16224. * Defines the center of rotation (W)
  16225. */
  16226. wRotationCenter: number;
  16227. /**
  16228. * Are mip maps generated for this texture or not.
  16229. */
  16230. readonly noMipmap: boolean;
  16231. /**
  16232. * List of inspectable custom properties (used by the Inspector)
  16233. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16234. */
  16235. inspectableCustomProperties: Nullable<IInspectable[]>;
  16236. private _noMipmap;
  16237. /** @hidden */
  16238. _invertY: boolean;
  16239. private _rowGenerationMatrix;
  16240. private _cachedTextureMatrix;
  16241. private _projectionModeMatrix;
  16242. private _t0;
  16243. private _t1;
  16244. private _t2;
  16245. private _cachedUOffset;
  16246. private _cachedVOffset;
  16247. private _cachedUScale;
  16248. private _cachedVScale;
  16249. private _cachedUAng;
  16250. private _cachedVAng;
  16251. private _cachedWAng;
  16252. private _cachedProjectionMatrixId;
  16253. private _cachedCoordinatesMode;
  16254. /** @hidden */
  16255. protected _initialSamplingMode: number;
  16256. /** @hidden */
  16257. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  16258. private _deleteBuffer;
  16259. protected _format: Nullable<number>;
  16260. private _delayedOnLoad;
  16261. private _delayedOnError;
  16262. /**
  16263. * Observable triggered once the texture has been loaded.
  16264. */
  16265. onLoadObservable: Observable<Texture>;
  16266. protected _isBlocking: boolean;
  16267. /**
  16268. * Is the texture preventing material to render while loading.
  16269. * If false, a default texture will be used instead of the loading one during the preparation step.
  16270. */
  16271. isBlocking: boolean;
  16272. /**
  16273. * Get the current sampling mode associated with the texture.
  16274. */
  16275. readonly samplingMode: number;
  16276. /**
  16277. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16278. */
  16279. readonly invertY: boolean;
  16280. /**
  16281. * Instantiates a new texture.
  16282. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16283. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16284. * @param url define the url of the picture to load as a texture
  16285. * @param scene define the scene or engine the texture will belong to
  16286. * @param noMipmap define if the texture will require mip maps or not
  16287. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16288. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16289. * @param onLoad define a callback triggered when the texture has been loaded
  16290. * @param onError define a callback triggered when an error occurred during the loading session
  16291. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16292. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16293. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16294. */
  16295. 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);
  16296. /**
  16297. * Update the url (and optional buffer) of this texture if url was null during construction.
  16298. * @param url the url of the texture
  16299. * @param buffer the buffer of the texture (defaults to null)
  16300. * @param onLoad callback called when the texture is loaded (defaults to null)
  16301. */
  16302. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16303. /**
  16304. * Finish the loading sequence of a texture flagged as delayed load.
  16305. * @hidden
  16306. */
  16307. delayLoad(): void;
  16308. private _prepareRowForTextureGeneration;
  16309. /**
  16310. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16311. * @returns the transform matrix of the texture.
  16312. */
  16313. getTextureMatrix(): Matrix;
  16314. /**
  16315. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16316. * @returns The reflection texture transform
  16317. */
  16318. getReflectionTextureMatrix(): Matrix;
  16319. /**
  16320. * Clones the texture.
  16321. * @returns the cloned texture
  16322. */
  16323. clone(): Texture;
  16324. /**
  16325. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16326. * @returns The JSON representation of the texture
  16327. */
  16328. serialize(): any;
  16329. /**
  16330. * Get the current class name of the texture useful for serialization or dynamic coding.
  16331. * @returns "Texture"
  16332. */
  16333. getClassName(): string;
  16334. /**
  16335. * Dispose the texture and release its associated resources.
  16336. */
  16337. dispose(): void;
  16338. /**
  16339. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16340. * @param parsedTexture Define the JSON representation of the texture
  16341. * @param scene Define the scene the parsed texture should be instantiated in
  16342. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16343. * @returns The parsed texture if successful
  16344. */
  16345. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16346. /**
  16347. * Creates a texture from its base 64 representation.
  16348. * @param data Define the base64 payload without the data: prefix
  16349. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16350. * @param scene Define the scene the texture should belong to
  16351. * @param noMipmap Forces the texture to not create mip map information if true
  16352. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16353. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16354. * @param onLoad define a callback triggered when the texture has been loaded
  16355. * @param onError define a callback triggered when an error occurred during the loading session
  16356. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16357. * @returns the created texture
  16358. */
  16359. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16360. /**
  16361. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16362. * @param data Define the base64 payload without the data: prefix
  16363. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16364. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16365. * @param scene Define the scene the texture should belong to
  16366. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16367. * @param noMipmap Forces the texture to not create mip map information if true
  16368. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16369. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16370. * @param onLoad define a callback triggered when the texture has been loaded
  16371. * @param onError define a callback triggered when an error occurred during the loading session
  16372. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16373. * @returns the created texture
  16374. */
  16375. 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;
  16376. }
  16377. }
  16378. declare module "babylonjs/PostProcesses/postProcessManager" {
  16379. import { Nullable } from "babylonjs/types";
  16380. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16381. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16382. import { Scene } from "babylonjs/scene";
  16383. /**
  16384. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16385. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16386. */
  16387. export class PostProcessManager {
  16388. private _scene;
  16389. private _indexBuffer;
  16390. private _vertexBuffers;
  16391. /**
  16392. * Creates a new instance PostProcess
  16393. * @param scene The scene that the post process is associated with.
  16394. */
  16395. constructor(scene: Scene);
  16396. private _prepareBuffers;
  16397. private _buildIndexBuffer;
  16398. /**
  16399. * Rebuilds the vertex buffers of the manager.
  16400. * @hidden
  16401. */
  16402. _rebuild(): void;
  16403. /**
  16404. * Prepares a frame to be run through a post process.
  16405. * @param sourceTexture The input texture to the post procesess. (default: null)
  16406. * @param postProcesses An array of post processes to be run. (default: null)
  16407. * @returns True if the post processes were able to be run.
  16408. * @hidden
  16409. */
  16410. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16411. /**
  16412. * Manually render a set of post processes to a texture.
  16413. * @param postProcesses An array of post processes to be run.
  16414. * @param targetTexture The target texture to render to.
  16415. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16416. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16417. * @param lodLevel defines which lod of the texture to render to
  16418. */
  16419. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16420. /**
  16421. * Finalize the result of the output of the postprocesses.
  16422. * @param doNotPresent If true the result will not be displayed to the screen.
  16423. * @param targetTexture The target texture to render to.
  16424. * @param faceIndex The index of the face to bind the target texture to.
  16425. * @param postProcesses The array of post processes to render.
  16426. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16427. * @hidden
  16428. */
  16429. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16430. /**
  16431. * Disposes of the post process manager.
  16432. */
  16433. dispose(): void;
  16434. }
  16435. }
  16436. declare module "babylonjs/Misc/gradients" {
  16437. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16438. /** Interface used by value gradients (color, factor, ...) */
  16439. export interface IValueGradient {
  16440. /**
  16441. * Gets or sets the gradient value (between 0 and 1)
  16442. */
  16443. gradient: number;
  16444. }
  16445. /** Class used to store color4 gradient */
  16446. export class ColorGradient implements IValueGradient {
  16447. /**
  16448. * Gets or sets the gradient value (between 0 and 1)
  16449. */
  16450. gradient: number;
  16451. /**
  16452. * Gets or sets first associated color
  16453. */
  16454. color1: Color4;
  16455. /**
  16456. * Gets or sets second associated color
  16457. */
  16458. color2?: Color4;
  16459. /**
  16460. * Will get a color picked randomly between color1 and color2.
  16461. * If color2 is undefined then color1 will be used
  16462. * @param result defines the target Color4 to store the result in
  16463. */
  16464. getColorToRef(result: Color4): void;
  16465. }
  16466. /** Class used to store color 3 gradient */
  16467. export class Color3Gradient implements IValueGradient {
  16468. /**
  16469. * Gets or sets the gradient value (between 0 and 1)
  16470. */
  16471. gradient: number;
  16472. /**
  16473. * Gets or sets the associated color
  16474. */
  16475. color: Color3;
  16476. }
  16477. /** Class used to store factor gradient */
  16478. export class FactorGradient implements IValueGradient {
  16479. /**
  16480. * Gets or sets the gradient value (between 0 and 1)
  16481. */
  16482. gradient: number;
  16483. /**
  16484. * Gets or sets first associated factor
  16485. */
  16486. factor1: number;
  16487. /**
  16488. * Gets or sets second associated factor
  16489. */
  16490. factor2?: number;
  16491. /**
  16492. * Will get a number picked randomly between factor1 and factor2.
  16493. * If factor2 is undefined then factor1 will be used
  16494. * @returns the picked number
  16495. */
  16496. getFactor(): number;
  16497. }
  16498. /**
  16499. * Helper used to simplify some generic gradient tasks
  16500. */
  16501. export class GradientHelper {
  16502. /**
  16503. * Gets the current gradient from an array of IValueGradient
  16504. * @param ratio defines the current ratio to get
  16505. * @param gradients defines the array of IValueGradient
  16506. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16507. */
  16508. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16509. }
  16510. }
  16511. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  16512. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16513. import { Nullable } from "babylonjs/types";
  16514. module "babylonjs/Engines/thinEngine" {
  16515. interface ThinEngine {
  16516. /**
  16517. * Creates a dynamic texture
  16518. * @param width defines the width of the texture
  16519. * @param height defines the height of the texture
  16520. * @param generateMipMaps defines if the engine should generate the mip levels
  16521. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  16522. * @returns the dynamic texture inside an InternalTexture
  16523. */
  16524. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  16525. /**
  16526. * Update the content of a dynamic texture
  16527. * @param texture defines the texture to update
  16528. * @param canvas defines the canvas containing the source
  16529. * @param invertY defines if data must be stored with Y axis inverted
  16530. * @param premulAlpha defines if alpha is stored as premultiplied
  16531. * @param format defines the format of the data
  16532. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  16533. */
  16534. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  16535. }
  16536. }
  16537. }
  16538. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  16539. import { Scene } from "babylonjs/scene";
  16540. import { Texture } from "babylonjs/Materials/Textures/texture";
  16541. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  16542. /**
  16543. * A class extending Texture allowing drawing on a texture
  16544. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16545. */
  16546. export class DynamicTexture extends Texture {
  16547. private _generateMipMaps;
  16548. private _canvas;
  16549. private _context;
  16550. private _engine;
  16551. /**
  16552. * Creates a DynamicTexture
  16553. * @param name defines the name of the texture
  16554. * @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
  16555. * @param scene defines the scene where you want the texture
  16556. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16557. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16558. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16559. */
  16560. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16561. /**
  16562. * Get the current class name of the texture useful for serialization or dynamic coding.
  16563. * @returns "DynamicTexture"
  16564. */
  16565. getClassName(): string;
  16566. /**
  16567. * Gets the current state of canRescale
  16568. */
  16569. readonly canRescale: boolean;
  16570. private _recreate;
  16571. /**
  16572. * Scales the texture
  16573. * @param ratio the scale factor to apply to both width and height
  16574. */
  16575. scale(ratio: number): void;
  16576. /**
  16577. * Resizes the texture
  16578. * @param width the new width
  16579. * @param height the new height
  16580. */
  16581. scaleTo(width: number, height: number): void;
  16582. /**
  16583. * Gets the context of the canvas used by the texture
  16584. * @returns the canvas context of the dynamic texture
  16585. */
  16586. getContext(): CanvasRenderingContext2D;
  16587. /**
  16588. * Clears the texture
  16589. */
  16590. clear(): void;
  16591. /**
  16592. * Updates the texture
  16593. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16594. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16595. */
  16596. update(invertY?: boolean, premulAlpha?: boolean): void;
  16597. /**
  16598. * Draws text onto the texture
  16599. * @param text defines the text to be drawn
  16600. * @param x defines the placement of the text from the left
  16601. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16602. * @param font defines the font to be used with font-style, font-size, font-name
  16603. * @param color defines the color used for the text
  16604. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16605. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16606. * @param update defines whether texture is immediately update (default is true)
  16607. */
  16608. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16609. /**
  16610. * Clones the texture
  16611. * @returns the clone of the texture.
  16612. */
  16613. clone(): DynamicTexture;
  16614. /**
  16615. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16616. * @returns a serialized dynamic texture object
  16617. */
  16618. serialize(): any;
  16619. /** @hidden */
  16620. _rebuild(): void;
  16621. }
  16622. }
  16623. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  16624. import { Scene } from "babylonjs/scene";
  16625. import { ISceneComponent } from "babylonjs/sceneComponent";
  16626. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16627. module "babylonjs/abstractScene" {
  16628. interface AbstractScene {
  16629. /**
  16630. * The list of procedural textures added to the scene
  16631. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16632. */
  16633. proceduralTextures: Array<ProceduralTexture>;
  16634. }
  16635. }
  16636. /**
  16637. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16638. * in a given scene.
  16639. */
  16640. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16641. /**
  16642. * The component name helpfull to identify the component in the list of scene components.
  16643. */
  16644. readonly name: string;
  16645. /**
  16646. * The scene the component belongs to.
  16647. */
  16648. scene: Scene;
  16649. /**
  16650. * Creates a new instance of the component for the given scene
  16651. * @param scene Defines the scene to register the component in
  16652. */
  16653. constructor(scene: Scene);
  16654. /**
  16655. * Registers the component in a given scene
  16656. */
  16657. register(): void;
  16658. /**
  16659. * Rebuilds the elements related to this component in case of
  16660. * context lost for instance.
  16661. */
  16662. rebuild(): void;
  16663. /**
  16664. * Disposes the component and the associated ressources.
  16665. */
  16666. dispose(): void;
  16667. private _beforeClear;
  16668. }
  16669. }
  16670. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  16671. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16672. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  16673. module "babylonjs/Engines/thinEngine" {
  16674. interface ThinEngine {
  16675. /**
  16676. * Creates a new render target cube texture
  16677. * @param size defines the size of the texture
  16678. * @param options defines the options used to create the texture
  16679. * @returns a new render target cube texture stored in an InternalTexture
  16680. */
  16681. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16682. }
  16683. }
  16684. }
  16685. declare module "babylonjs/Shaders/procedural.vertex" {
  16686. /** @hidden */
  16687. export var proceduralVertexShader: {
  16688. name: string;
  16689. shader: string;
  16690. };
  16691. }
  16692. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  16693. import { Observable } from "babylonjs/Misc/observable";
  16694. import { Nullable } from "babylonjs/types";
  16695. import { Scene } from "babylonjs/scene";
  16696. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  16697. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  16698. import { Effect } from "babylonjs/Materials/effect";
  16699. import { Texture } from "babylonjs/Materials/Textures/texture";
  16700. import "babylonjs/Engines/Extensions/engine.renderTarget";
  16701. import "babylonjs/Shaders/procedural.vertex";
  16702. /**
  16703. * 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.
  16704. * This is the base class of any Procedural texture and contains most of the shareable code.
  16705. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16706. */
  16707. export class ProceduralTexture extends Texture {
  16708. isCube: boolean;
  16709. /**
  16710. * Define if the texture is enabled or not (disabled texture will not render)
  16711. */
  16712. isEnabled: boolean;
  16713. /**
  16714. * Define if the texture must be cleared before rendering (default is true)
  16715. */
  16716. autoClear: boolean;
  16717. /**
  16718. * Callback called when the texture is generated
  16719. */
  16720. onGenerated: () => void;
  16721. /**
  16722. * Event raised when the texture is generated
  16723. */
  16724. onGeneratedObservable: Observable<ProceduralTexture>;
  16725. /** @hidden */
  16726. _generateMipMaps: boolean;
  16727. /** @hidden **/
  16728. _effect: Effect;
  16729. /** @hidden */
  16730. _textures: {
  16731. [key: string]: Texture;
  16732. };
  16733. private _size;
  16734. private _currentRefreshId;
  16735. private _refreshRate;
  16736. private _vertexBuffers;
  16737. private _indexBuffer;
  16738. private _uniforms;
  16739. private _samplers;
  16740. private _fragment;
  16741. private _floats;
  16742. private _ints;
  16743. private _floatsArrays;
  16744. private _colors3;
  16745. private _colors4;
  16746. private _vectors2;
  16747. private _vectors3;
  16748. private _matrices;
  16749. private _fallbackTexture;
  16750. private _fallbackTextureUsed;
  16751. private _engine;
  16752. private _cachedDefines;
  16753. private _contentUpdateId;
  16754. private _contentData;
  16755. /**
  16756. * Instantiates a new procedural texture.
  16757. * 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.
  16758. * This is the base class of any Procedural texture and contains most of the shareable code.
  16759. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16760. * @param name Define the name of the texture
  16761. * @param size Define the size of the texture to create
  16762. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16763. * @param scene Define the scene the texture belongs to
  16764. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16765. * @param generateMipMaps Define if the texture should creates mip maps or not
  16766. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16767. */
  16768. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16769. /**
  16770. * The effect that is created when initializing the post process.
  16771. * @returns The created effect corresponding the the postprocess.
  16772. */
  16773. getEffect(): Effect;
  16774. /**
  16775. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16776. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16777. */
  16778. getContent(): Nullable<ArrayBufferView>;
  16779. private _createIndexBuffer;
  16780. /** @hidden */
  16781. _rebuild(): void;
  16782. /**
  16783. * Resets the texture in order to recreate its associated resources.
  16784. * This can be called in case of context loss
  16785. */
  16786. reset(): void;
  16787. protected _getDefines(): string;
  16788. /**
  16789. * Is the texture ready to be used ? (rendered at least once)
  16790. * @returns true if ready, otherwise, false.
  16791. */
  16792. isReady(): boolean;
  16793. /**
  16794. * Resets the refresh counter of the texture and start bak from scratch.
  16795. * Could be useful to regenerate the texture if it is setup to render only once.
  16796. */
  16797. resetRefreshCounter(): void;
  16798. /**
  16799. * Set the fragment shader to use in order to render the texture.
  16800. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16801. */
  16802. setFragment(fragment: any): void;
  16803. /**
  16804. * Define the refresh rate of the texture or the rendering frequency.
  16805. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16806. */
  16807. refreshRate: number;
  16808. /** @hidden */
  16809. _shouldRender(): boolean;
  16810. /**
  16811. * Get the size the texture is rendering at.
  16812. * @returns the size (texture is always squared)
  16813. */
  16814. getRenderSize(): number;
  16815. /**
  16816. * Resize the texture to new value.
  16817. * @param size Define the new size the texture should have
  16818. * @param generateMipMaps Define whether the new texture should create mip maps
  16819. */
  16820. resize(size: number, generateMipMaps: boolean): void;
  16821. private _checkUniform;
  16822. /**
  16823. * Set a texture in the shader program used to render.
  16824. * @param name Define the name of the uniform samplers as defined in the shader
  16825. * @param texture Define the texture to bind to this sampler
  16826. * @return the texture itself allowing "fluent" like uniform updates
  16827. */
  16828. setTexture(name: string, texture: Texture): ProceduralTexture;
  16829. /**
  16830. * Set a float in the shader.
  16831. * @param name Define the name of the uniform as defined in the shader
  16832. * @param value Define the value to give to the uniform
  16833. * @return the texture itself allowing "fluent" like uniform updates
  16834. */
  16835. setFloat(name: string, value: number): ProceduralTexture;
  16836. /**
  16837. * Set a int in the shader.
  16838. * @param name Define the name of the uniform as defined in the shader
  16839. * @param value Define the value to give to the uniform
  16840. * @return the texture itself allowing "fluent" like uniform updates
  16841. */
  16842. setInt(name: string, value: number): ProceduralTexture;
  16843. /**
  16844. * Set an array of floats in the shader.
  16845. * @param name Define the name of the uniform as defined in the shader
  16846. * @param value Define the value to give to the uniform
  16847. * @return the texture itself allowing "fluent" like uniform updates
  16848. */
  16849. setFloats(name: string, value: number[]): ProceduralTexture;
  16850. /**
  16851. * Set a vec3 in the shader from a Color3.
  16852. * @param name Define the name of the uniform as defined in the shader
  16853. * @param value Define the value to give to the uniform
  16854. * @return the texture itself allowing "fluent" like uniform updates
  16855. */
  16856. setColor3(name: string, value: Color3): ProceduralTexture;
  16857. /**
  16858. * Set a vec4 in the shader from a Color4.
  16859. * @param name Define the name of the uniform as defined in the shader
  16860. * @param value Define the value to give to the uniform
  16861. * @return the texture itself allowing "fluent" like uniform updates
  16862. */
  16863. setColor4(name: string, value: Color4): ProceduralTexture;
  16864. /**
  16865. * Set a vec2 in the shader from a Vector2.
  16866. * @param name Define the name of the uniform as defined in the shader
  16867. * @param value Define the value to give to the uniform
  16868. * @return the texture itself allowing "fluent" like uniform updates
  16869. */
  16870. setVector2(name: string, value: Vector2): ProceduralTexture;
  16871. /**
  16872. * Set a vec3 in the shader from a Vector3.
  16873. * @param name Define the name of the uniform as defined in the shader
  16874. * @param value Define the value to give to the uniform
  16875. * @return the texture itself allowing "fluent" like uniform updates
  16876. */
  16877. setVector3(name: string, value: Vector3): ProceduralTexture;
  16878. /**
  16879. * Set a mat4 in the shader from a MAtrix.
  16880. * @param name Define the name of the uniform as defined in the shader
  16881. * @param value Define the value to give to the uniform
  16882. * @return the texture itself allowing "fluent" like uniform updates
  16883. */
  16884. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16885. /**
  16886. * Render the texture to its associated render target.
  16887. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16888. */
  16889. render(useCameraPostProcess?: boolean): void;
  16890. /**
  16891. * Clone the texture.
  16892. * @returns the cloned texture
  16893. */
  16894. clone(): ProceduralTexture;
  16895. /**
  16896. * Dispose the texture and release its asoociated resources.
  16897. */
  16898. dispose(): void;
  16899. }
  16900. }
  16901. declare module "babylonjs/Particles/baseParticleSystem" {
  16902. import { Nullable } from "babylonjs/types";
  16903. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  16904. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16905. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  16906. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16907. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16908. import { Scene } from "babylonjs/scene";
  16909. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  16910. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16911. import { Texture } from "babylonjs/Materials/Textures/texture";
  16912. import { Color4 } from "babylonjs/Maths/math.color";
  16913. import { Animation } from "babylonjs/Animations/animation";
  16914. /**
  16915. * This represents the base class for particle system in Babylon.
  16916. * 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.
  16917. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16918. * @example https://doc.babylonjs.com/babylon101/particles
  16919. */
  16920. export class BaseParticleSystem {
  16921. /**
  16922. * Source color is added to the destination color without alpha affecting the result
  16923. */
  16924. static BLENDMODE_ONEONE: number;
  16925. /**
  16926. * Blend current color and particle color using particle’s alpha
  16927. */
  16928. static BLENDMODE_STANDARD: number;
  16929. /**
  16930. * Add current color and particle color multiplied by particle’s alpha
  16931. */
  16932. static BLENDMODE_ADD: number;
  16933. /**
  16934. * Multiply current color with particle color
  16935. */
  16936. static BLENDMODE_MULTIPLY: number;
  16937. /**
  16938. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16939. */
  16940. static BLENDMODE_MULTIPLYADD: number;
  16941. /**
  16942. * List of animations used by the particle system.
  16943. */
  16944. animations: Animation[];
  16945. /**
  16946. * The id of the Particle system.
  16947. */
  16948. id: string;
  16949. /**
  16950. * The friendly name of the Particle system.
  16951. */
  16952. name: string;
  16953. /**
  16954. * The rendering group used by the Particle system to chose when to render.
  16955. */
  16956. renderingGroupId: number;
  16957. /**
  16958. * The emitter represents the Mesh or position we are attaching the particle system to.
  16959. */
  16960. emitter: Nullable<AbstractMesh | Vector3>;
  16961. /**
  16962. * The maximum number of particles to emit per frame
  16963. */
  16964. emitRate: number;
  16965. /**
  16966. * If you want to launch only a few particles at once, that can be done, as well.
  16967. */
  16968. manualEmitCount: number;
  16969. /**
  16970. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16971. */
  16972. updateSpeed: number;
  16973. /**
  16974. * The amount of time the particle system is running (depends of the overall update speed).
  16975. */
  16976. targetStopDuration: number;
  16977. /**
  16978. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16979. */
  16980. disposeOnStop: boolean;
  16981. /**
  16982. * Minimum power of emitting particles.
  16983. */
  16984. minEmitPower: number;
  16985. /**
  16986. * Maximum power of emitting particles.
  16987. */
  16988. maxEmitPower: number;
  16989. /**
  16990. * Minimum life time of emitting particles.
  16991. */
  16992. minLifeTime: number;
  16993. /**
  16994. * Maximum life time of emitting particles.
  16995. */
  16996. maxLifeTime: number;
  16997. /**
  16998. * Minimum Size of emitting particles.
  16999. */
  17000. minSize: number;
  17001. /**
  17002. * Maximum Size of emitting particles.
  17003. */
  17004. maxSize: number;
  17005. /**
  17006. * Minimum scale of emitting particles on X axis.
  17007. */
  17008. minScaleX: number;
  17009. /**
  17010. * Maximum scale of emitting particles on X axis.
  17011. */
  17012. maxScaleX: number;
  17013. /**
  17014. * Minimum scale of emitting particles on Y axis.
  17015. */
  17016. minScaleY: number;
  17017. /**
  17018. * Maximum scale of emitting particles on Y axis.
  17019. */
  17020. maxScaleY: number;
  17021. /**
  17022. * Gets or sets the minimal initial rotation in radians.
  17023. */
  17024. minInitialRotation: number;
  17025. /**
  17026. * Gets or sets the maximal initial rotation in radians.
  17027. */
  17028. maxInitialRotation: number;
  17029. /**
  17030. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  17031. */
  17032. minAngularSpeed: number;
  17033. /**
  17034. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  17035. */
  17036. maxAngularSpeed: number;
  17037. /**
  17038. * The texture used to render each particle. (this can be a spritesheet)
  17039. */
  17040. particleTexture: Nullable<Texture>;
  17041. /**
  17042. * The layer mask we are rendering the particles through.
  17043. */
  17044. layerMask: number;
  17045. /**
  17046. * This can help using your own shader to render the particle system.
  17047. * The according effect will be created
  17048. */
  17049. customShader: any;
  17050. /**
  17051. * By default particle system starts as soon as they are created. This prevents the
  17052. * automatic start to happen and let you decide when to start emitting particles.
  17053. */
  17054. preventAutoStart: boolean;
  17055. private _noiseTexture;
  17056. /**
  17057. * Gets or sets a texture used to add random noise to particle positions
  17058. */
  17059. noiseTexture: Nullable<ProceduralTexture>;
  17060. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  17061. noiseStrength: Vector3;
  17062. /**
  17063. * Callback triggered when the particle animation is ending.
  17064. */
  17065. onAnimationEnd: Nullable<() => void>;
  17066. /**
  17067. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  17068. */
  17069. blendMode: number;
  17070. /**
  17071. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  17072. * to override the particles.
  17073. */
  17074. forceDepthWrite: boolean;
  17075. /** 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 */
  17076. preWarmCycles: number;
  17077. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  17078. preWarmStepOffset: number;
  17079. /**
  17080. * 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)
  17081. */
  17082. spriteCellChangeSpeed: number;
  17083. /**
  17084. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  17085. */
  17086. startSpriteCellID: number;
  17087. /**
  17088. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  17089. */
  17090. endSpriteCellID: number;
  17091. /**
  17092. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  17093. */
  17094. spriteCellWidth: number;
  17095. /**
  17096. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  17097. */
  17098. spriteCellHeight: number;
  17099. /**
  17100. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  17101. */
  17102. spriteRandomStartCell: boolean;
  17103. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  17104. translationPivot: Vector2;
  17105. /** @hidden */
  17106. protected _isAnimationSheetEnabled: boolean;
  17107. /**
  17108. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  17109. */
  17110. beginAnimationOnStart: boolean;
  17111. /**
  17112. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  17113. */
  17114. beginAnimationFrom: number;
  17115. /**
  17116. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  17117. */
  17118. beginAnimationTo: number;
  17119. /**
  17120. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  17121. */
  17122. beginAnimationLoop: boolean;
  17123. /**
  17124. * Gets or sets a world offset applied to all particles
  17125. */
  17126. worldOffset: Vector3;
  17127. /**
  17128. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  17129. */
  17130. isAnimationSheetEnabled: boolean;
  17131. /**
  17132. * Get hosting scene
  17133. * @returns the scene
  17134. */
  17135. getScene(): Scene;
  17136. /**
  17137. * You can use gravity if you want to give an orientation to your particles.
  17138. */
  17139. gravity: Vector3;
  17140. protected _colorGradients: Nullable<Array<ColorGradient>>;
  17141. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  17142. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  17143. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  17144. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  17145. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  17146. protected _dragGradients: Nullable<Array<FactorGradient>>;
  17147. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  17148. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  17149. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  17150. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  17151. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  17152. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  17153. /**
  17154. * Defines the delay in milliseconds before starting the system (0 by default)
  17155. */
  17156. startDelay: number;
  17157. /**
  17158. * Gets the current list of drag gradients.
  17159. * You must use addDragGradient and removeDragGradient to udpate this list
  17160. * @returns the list of drag gradients
  17161. */
  17162. getDragGradients(): Nullable<Array<FactorGradient>>;
  17163. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17164. limitVelocityDamping: number;
  17165. /**
  17166. * Gets the current list of limit velocity gradients.
  17167. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  17168. * @returns the list of limit velocity gradients
  17169. */
  17170. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17171. /**
  17172. * Gets the current list of color gradients.
  17173. * You must use addColorGradient and removeColorGradient to udpate this list
  17174. * @returns the list of color gradients
  17175. */
  17176. getColorGradients(): Nullable<Array<ColorGradient>>;
  17177. /**
  17178. * Gets the current list of size gradients.
  17179. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17180. * @returns the list of size gradients
  17181. */
  17182. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17183. /**
  17184. * Gets the current list of color remap gradients.
  17185. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17186. * @returns the list of color remap gradients
  17187. */
  17188. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17189. /**
  17190. * Gets the current list of alpha remap gradients.
  17191. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17192. * @returns the list of alpha remap gradients
  17193. */
  17194. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17195. /**
  17196. * Gets the current list of life time gradients.
  17197. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17198. * @returns the list of life time gradients
  17199. */
  17200. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17201. /**
  17202. * Gets the current list of angular speed gradients.
  17203. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17204. * @returns the list of angular speed gradients
  17205. */
  17206. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17207. /**
  17208. * Gets the current list of velocity gradients.
  17209. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17210. * @returns the list of velocity gradients
  17211. */
  17212. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17213. /**
  17214. * Gets the current list of start size gradients.
  17215. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17216. * @returns the list of start size gradients
  17217. */
  17218. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17219. /**
  17220. * Gets the current list of emit rate gradients.
  17221. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17222. * @returns the list of emit rate gradients
  17223. */
  17224. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17225. /**
  17226. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17227. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17228. */
  17229. direction1: Vector3;
  17230. /**
  17231. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17232. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17233. */
  17234. direction2: Vector3;
  17235. /**
  17236. * 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.
  17237. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17238. */
  17239. minEmitBox: Vector3;
  17240. /**
  17241. * 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.
  17242. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17243. */
  17244. maxEmitBox: Vector3;
  17245. /**
  17246. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17247. */
  17248. color1: Color4;
  17249. /**
  17250. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17251. */
  17252. color2: Color4;
  17253. /**
  17254. * Color the particle will have at the end of its lifetime
  17255. */
  17256. colorDead: Color4;
  17257. /**
  17258. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  17259. */
  17260. textureMask: Color4;
  17261. /**
  17262. * The particle emitter type defines the emitter used by the particle system.
  17263. * It can be for example box, sphere, or cone...
  17264. */
  17265. particleEmitterType: IParticleEmitterType;
  17266. /** @hidden */
  17267. _isSubEmitter: boolean;
  17268. /**
  17269. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17270. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17271. */
  17272. billboardMode: number;
  17273. protected _isBillboardBased: boolean;
  17274. /**
  17275. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17276. */
  17277. isBillboardBased: boolean;
  17278. /**
  17279. * The scene the particle system belongs to.
  17280. */
  17281. protected _scene: Scene;
  17282. /**
  17283. * Local cache of defines for image processing.
  17284. */
  17285. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  17286. /**
  17287. * Default configuration related to image processing available in the standard Material.
  17288. */
  17289. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17290. /**
  17291. * Gets the image processing configuration used either in this material.
  17292. */
  17293. /**
  17294. * Sets the Default image processing configuration used either in the this material.
  17295. *
  17296. * If sets to null, the scene one is in use.
  17297. */
  17298. imageProcessingConfiguration: ImageProcessingConfiguration;
  17299. /**
  17300. * Attaches a new image processing configuration to the Standard Material.
  17301. * @param configuration
  17302. */
  17303. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17304. /** @hidden */
  17305. protected _reset(): void;
  17306. /** @hidden */
  17307. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17308. /**
  17309. * Instantiates a particle system.
  17310. * 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.
  17311. * @param name The name of the particle system
  17312. */
  17313. constructor(name: string);
  17314. /**
  17315. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17316. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17317. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17318. * @returns the emitter
  17319. */
  17320. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17321. /**
  17322. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17323. * @param radius The radius of the hemisphere to emit from
  17324. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17325. * @returns the emitter
  17326. */
  17327. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17328. /**
  17329. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17330. * @param radius The radius of the sphere to emit from
  17331. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17332. * @returns the emitter
  17333. */
  17334. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17335. /**
  17336. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17337. * @param radius The radius of the sphere to emit from
  17338. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17339. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17340. * @returns the emitter
  17341. */
  17342. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17343. /**
  17344. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17345. * @param radius The radius of the emission cylinder
  17346. * @param height The height of the emission cylinder
  17347. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17348. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17349. * @returns the emitter
  17350. */
  17351. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17352. /**
  17353. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17354. * @param radius The radius of the cylinder to emit from
  17355. * @param height The height of the emission cylinder
  17356. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17357. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17358. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17359. * @returns the emitter
  17360. */
  17361. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17362. /**
  17363. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17364. * @param radius The radius of the cone to emit from
  17365. * @param angle The base angle of the cone
  17366. * @returns the emitter
  17367. */
  17368. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17369. /**
  17370. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17371. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17372. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17373. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17374. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17375. * @returns the emitter
  17376. */
  17377. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17378. }
  17379. }
  17380. declare module "babylonjs/Particles/subEmitter" {
  17381. import { Scene } from "babylonjs/scene";
  17382. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17383. /**
  17384. * Type of sub emitter
  17385. */
  17386. export enum SubEmitterType {
  17387. /**
  17388. * Attached to the particle over it's lifetime
  17389. */
  17390. ATTACHED = 0,
  17391. /**
  17392. * Created when the particle dies
  17393. */
  17394. END = 1
  17395. }
  17396. /**
  17397. * Sub emitter class used to emit particles from an existing particle
  17398. */
  17399. export class SubEmitter {
  17400. /**
  17401. * the particle system to be used by the sub emitter
  17402. */
  17403. particleSystem: ParticleSystem;
  17404. /**
  17405. * Type of the submitter (Default: END)
  17406. */
  17407. type: SubEmitterType;
  17408. /**
  17409. * 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)
  17410. * Note: This only is supported when using an emitter of type Mesh
  17411. */
  17412. inheritDirection: boolean;
  17413. /**
  17414. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17415. */
  17416. inheritedVelocityAmount: number;
  17417. /**
  17418. * Creates a sub emitter
  17419. * @param particleSystem the particle system to be used by the sub emitter
  17420. */
  17421. constructor(
  17422. /**
  17423. * the particle system to be used by the sub emitter
  17424. */
  17425. particleSystem: ParticleSystem);
  17426. /**
  17427. * Clones the sub emitter
  17428. * @returns the cloned sub emitter
  17429. */
  17430. clone(): SubEmitter;
  17431. /**
  17432. * Serialize current object to a JSON object
  17433. * @returns the serialized object
  17434. */
  17435. serialize(): any;
  17436. /** @hidden */
  17437. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17438. /**
  17439. * Creates a new SubEmitter from a serialized JSON version
  17440. * @param serializationObject defines the JSON object to read from
  17441. * @param scene defines the hosting scene
  17442. * @param rootUrl defines the rootUrl for data loading
  17443. * @returns a new SubEmitter
  17444. */
  17445. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17446. /** Release associated resources */
  17447. dispose(): void;
  17448. }
  17449. }
  17450. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  17451. /** @hidden */
  17452. export var clipPlaneFragmentDeclaration: {
  17453. name: string;
  17454. shader: string;
  17455. };
  17456. }
  17457. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  17458. /** @hidden */
  17459. export var imageProcessingDeclaration: {
  17460. name: string;
  17461. shader: string;
  17462. };
  17463. }
  17464. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  17465. /** @hidden */
  17466. export var imageProcessingFunctions: {
  17467. name: string;
  17468. shader: string;
  17469. };
  17470. }
  17471. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  17472. /** @hidden */
  17473. export var clipPlaneFragment: {
  17474. name: string;
  17475. shader: string;
  17476. };
  17477. }
  17478. declare module "babylonjs/Shaders/particles.fragment" {
  17479. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17480. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  17481. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  17482. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  17483. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17484. /** @hidden */
  17485. export var particlesPixelShader: {
  17486. name: string;
  17487. shader: string;
  17488. };
  17489. }
  17490. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  17491. /** @hidden */
  17492. export var clipPlaneVertexDeclaration: {
  17493. name: string;
  17494. shader: string;
  17495. };
  17496. }
  17497. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  17498. /** @hidden */
  17499. export var clipPlaneVertex: {
  17500. name: string;
  17501. shader: string;
  17502. };
  17503. }
  17504. declare module "babylonjs/Shaders/particles.vertex" {
  17505. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17506. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17507. /** @hidden */
  17508. export var particlesVertexShader: {
  17509. name: string;
  17510. shader: string;
  17511. };
  17512. }
  17513. declare module "babylonjs/Particles/particleSystem" {
  17514. import { Nullable } from "babylonjs/types";
  17515. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17516. import { Observable } from "babylonjs/Misc/observable";
  17517. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17518. import { Effect } from "babylonjs/Materials/effect";
  17519. import { Scene, IDisposable } from "babylonjs/scene";
  17520. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17521. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  17522. import { Particle } from "babylonjs/Particles/particle";
  17523. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17524. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  17525. import "babylonjs/Shaders/particles.fragment";
  17526. import "babylonjs/Shaders/particles.vertex";
  17527. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17528. /**
  17529. * This represents a particle system in Babylon.
  17530. * 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.
  17531. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17532. * @example https://doc.babylonjs.com/babylon101/particles
  17533. */
  17534. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17535. /**
  17536. * Billboard mode will only apply to Y axis
  17537. */
  17538. static readonly BILLBOARDMODE_Y: number;
  17539. /**
  17540. * Billboard mode will apply to all axes
  17541. */
  17542. static readonly BILLBOARDMODE_ALL: number;
  17543. /**
  17544. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17545. */
  17546. static readonly BILLBOARDMODE_STRETCHED: number;
  17547. /**
  17548. * This function can be defined to provide custom update for active particles.
  17549. * This function will be called instead of regular update (age, position, color, etc.).
  17550. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17551. */
  17552. updateFunction: (particles: Particle[]) => void;
  17553. private _emitterWorldMatrix;
  17554. /**
  17555. * This function can be defined to specify initial direction for every new particle.
  17556. * It by default use the emitterType defined function
  17557. */
  17558. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17559. /**
  17560. * This function can be defined to specify initial position for every new particle.
  17561. * It by default use the emitterType defined function
  17562. */
  17563. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17564. /**
  17565. * @hidden
  17566. */
  17567. _inheritedVelocityOffset: Vector3;
  17568. /**
  17569. * An event triggered when the system is disposed
  17570. */
  17571. onDisposeObservable: Observable<ParticleSystem>;
  17572. private _onDisposeObserver;
  17573. /**
  17574. * Sets a callback that will be triggered when the system is disposed
  17575. */
  17576. onDispose: () => void;
  17577. private _particles;
  17578. private _epsilon;
  17579. private _capacity;
  17580. private _stockParticles;
  17581. private _newPartsExcess;
  17582. private _vertexData;
  17583. private _vertexBuffer;
  17584. private _vertexBuffers;
  17585. private _spriteBuffer;
  17586. private _indexBuffer;
  17587. private _effect;
  17588. private _customEffect;
  17589. private _cachedDefines;
  17590. private _scaledColorStep;
  17591. private _colorDiff;
  17592. private _scaledDirection;
  17593. private _scaledGravity;
  17594. private _currentRenderId;
  17595. private _alive;
  17596. private _useInstancing;
  17597. private _started;
  17598. private _stopped;
  17599. private _actualFrame;
  17600. private _scaledUpdateSpeed;
  17601. private _vertexBufferSize;
  17602. /** @hidden */
  17603. _currentEmitRateGradient: Nullable<FactorGradient>;
  17604. /** @hidden */
  17605. _currentEmitRate1: number;
  17606. /** @hidden */
  17607. _currentEmitRate2: number;
  17608. /** @hidden */
  17609. _currentStartSizeGradient: Nullable<FactorGradient>;
  17610. /** @hidden */
  17611. _currentStartSize1: number;
  17612. /** @hidden */
  17613. _currentStartSize2: number;
  17614. private readonly _rawTextureWidth;
  17615. private _rampGradientsTexture;
  17616. private _useRampGradients;
  17617. /** Gets or sets a boolean indicating that ramp gradients must be used
  17618. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17619. */
  17620. useRampGradients: boolean;
  17621. /**
  17622. * 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.
  17623. * 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: [])
  17624. */
  17625. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17626. private _subEmitters;
  17627. /**
  17628. * @hidden
  17629. * If the particle systems emitter should be disposed when the particle system is disposed
  17630. */
  17631. _disposeEmitterOnDispose: boolean;
  17632. /**
  17633. * The current active Sub-systems, this property is used by the root particle system only.
  17634. */
  17635. activeSubSystems: Array<ParticleSystem>;
  17636. private _rootParticleSystem;
  17637. /**
  17638. * Gets the current list of active particles
  17639. */
  17640. readonly particles: Particle[];
  17641. /**
  17642. * Returns the string "ParticleSystem"
  17643. * @returns a string containing the class name
  17644. */
  17645. getClassName(): string;
  17646. /**
  17647. * Instantiates a particle system.
  17648. * 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.
  17649. * @param name The name of the particle system
  17650. * @param capacity The max number of particles alive at the same time
  17651. * @param scene The scene the particle system belongs to
  17652. * @param customEffect a custom effect used to change the way particles are rendered by default
  17653. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17654. * @param epsilon Offset used to render the particles
  17655. */
  17656. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17657. private _addFactorGradient;
  17658. private _removeFactorGradient;
  17659. /**
  17660. * Adds a new life time gradient
  17661. * @param gradient defines the gradient to use (between 0 and 1)
  17662. * @param factor defines the life time factor to affect to the specified gradient
  17663. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17664. * @returns the current particle system
  17665. */
  17666. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17667. /**
  17668. * Remove a specific life time gradient
  17669. * @param gradient defines the gradient to remove
  17670. * @returns the current particle system
  17671. */
  17672. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17673. /**
  17674. * Adds a new size gradient
  17675. * @param gradient defines the gradient to use (between 0 and 1)
  17676. * @param factor defines the size factor to affect to the specified gradient
  17677. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17678. * @returns the current particle system
  17679. */
  17680. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17681. /**
  17682. * Remove a specific size gradient
  17683. * @param gradient defines the gradient to remove
  17684. * @returns the current particle system
  17685. */
  17686. removeSizeGradient(gradient: number): IParticleSystem;
  17687. /**
  17688. * Adds a new color remap gradient
  17689. * @param gradient defines the gradient to use (between 0 and 1)
  17690. * @param min defines the color remap minimal range
  17691. * @param max defines the color remap maximal range
  17692. * @returns the current particle system
  17693. */
  17694. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17695. /**
  17696. * Remove a specific color remap gradient
  17697. * @param gradient defines the gradient to remove
  17698. * @returns the current particle system
  17699. */
  17700. removeColorRemapGradient(gradient: number): IParticleSystem;
  17701. /**
  17702. * Adds a new alpha remap gradient
  17703. * @param gradient defines the gradient to use (between 0 and 1)
  17704. * @param min defines the alpha remap minimal range
  17705. * @param max defines the alpha remap maximal range
  17706. * @returns the current particle system
  17707. */
  17708. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17709. /**
  17710. * Remove a specific alpha remap gradient
  17711. * @param gradient defines the gradient to remove
  17712. * @returns the current particle system
  17713. */
  17714. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17715. /**
  17716. * Adds a new angular speed gradient
  17717. * @param gradient defines the gradient to use (between 0 and 1)
  17718. * @param factor defines the angular speed to affect to the specified gradient
  17719. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17720. * @returns the current particle system
  17721. */
  17722. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17723. /**
  17724. * Remove a specific angular speed gradient
  17725. * @param gradient defines the gradient to remove
  17726. * @returns the current particle system
  17727. */
  17728. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17729. /**
  17730. * Adds a new velocity gradient
  17731. * @param gradient defines the gradient to use (between 0 and 1)
  17732. * @param factor defines the velocity to affect to the specified gradient
  17733. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17734. * @returns the current particle system
  17735. */
  17736. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17737. /**
  17738. * Remove a specific velocity gradient
  17739. * @param gradient defines the gradient to remove
  17740. * @returns the current particle system
  17741. */
  17742. removeVelocityGradient(gradient: number): IParticleSystem;
  17743. /**
  17744. * Adds a new limit velocity gradient
  17745. * @param gradient defines the gradient to use (between 0 and 1)
  17746. * @param factor defines the limit velocity value to affect to the specified gradient
  17747. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17748. * @returns the current particle system
  17749. */
  17750. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17751. /**
  17752. * Remove a specific limit velocity gradient
  17753. * @param gradient defines the gradient to remove
  17754. * @returns the current particle system
  17755. */
  17756. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17757. /**
  17758. * Adds a new drag gradient
  17759. * @param gradient defines the gradient to use (between 0 and 1)
  17760. * @param factor defines the drag value to affect to the specified gradient
  17761. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17762. * @returns the current particle system
  17763. */
  17764. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17765. /**
  17766. * Remove a specific drag gradient
  17767. * @param gradient defines the gradient to remove
  17768. * @returns the current particle system
  17769. */
  17770. removeDragGradient(gradient: number): IParticleSystem;
  17771. /**
  17772. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17773. * @param gradient defines the gradient to use (between 0 and 1)
  17774. * @param factor defines the emit rate value to affect to the specified gradient
  17775. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17776. * @returns the current particle system
  17777. */
  17778. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17779. /**
  17780. * Remove a specific emit rate gradient
  17781. * @param gradient defines the gradient to remove
  17782. * @returns the current particle system
  17783. */
  17784. removeEmitRateGradient(gradient: number): IParticleSystem;
  17785. /**
  17786. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17787. * @param gradient defines the gradient to use (between 0 and 1)
  17788. * @param factor defines the start size value to affect to the specified gradient
  17789. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17790. * @returns the current particle system
  17791. */
  17792. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17793. /**
  17794. * Remove a specific start size gradient
  17795. * @param gradient defines the gradient to remove
  17796. * @returns the current particle system
  17797. */
  17798. removeStartSizeGradient(gradient: number): IParticleSystem;
  17799. private _createRampGradientTexture;
  17800. /**
  17801. * Gets the current list of ramp gradients.
  17802. * You must use addRampGradient and removeRampGradient to udpate this list
  17803. * @returns the list of ramp gradients
  17804. */
  17805. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17806. /**
  17807. * Adds a new ramp gradient used to remap particle colors
  17808. * @param gradient defines the gradient to use (between 0 and 1)
  17809. * @param color defines the color to affect to the specified gradient
  17810. * @returns the current particle system
  17811. */
  17812. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17813. /**
  17814. * Remove a specific ramp gradient
  17815. * @param gradient defines the gradient to remove
  17816. * @returns the current particle system
  17817. */
  17818. removeRampGradient(gradient: number): ParticleSystem;
  17819. /**
  17820. * Adds a new color gradient
  17821. * @param gradient defines the gradient to use (between 0 and 1)
  17822. * @param color1 defines the color to affect to the specified gradient
  17823. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17824. * @returns this particle system
  17825. */
  17826. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17827. /**
  17828. * Remove a specific color gradient
  17829. * @param gradient defines the gradient to remove
  17830. * @returns this particle system
  17831. */
  17832. removeColorGradient(gradient: number): IParticleSystem;
  17833. private _fetchR;
  17834. protected _reset(): void;
  17835. private _resetEffect;
  17836. private _createVertexBuffers;
  17837. private _createIndexBuffer;
  17838. /**
  17839. * Gets the maximum number of particles active at the same time.
  17840. * @returns The max number of active particles.
  17841. */
  17842. getCapacity(): number;
  17843. /**
  17844. * Gets whether there are still active particles in the system.
  17845. * @returns True if it is alive, otherwise false.
  17846. */
  17847. isAlive(): boolean;
  17848. /**
  17849. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17850. * @returns True if it has been started, otherwise false.
  17851. */
  17852. isStarted(): boolean;
  17853. private _prepareSubEmitterInternalArray;
  17854. /**
  17855. * Starts the particle system and begins to emit
  17856. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17857. */
  17858. start(delay?: number): void;
  17859. /**
  17860. * Stops the particle system.
  17861. * @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.
  17862. */
  17863. stop(stopSubEmitters?: boolean): void;
  17864. /**
  17865. * Remove all active particles
  17866. */
  17867. reset(): void;
  17868. /**
  17869. * @hidden (for internal use only)
  17870. */
  17871. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17872. /**
  17873. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17874. * Its lifetime will start back at 0.
  17875. */
  17876. recycleParticle: (particle: Particle) => void;
  17877. private _stopSubEmitters;
  17878. private _createParticle;
  17879. private _removeFromRoot;
  17880. private _emitFromParticle;
  17881. private _update;
  17882. /** @hidden */
  17883. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17884. /** @hidden */
  17885. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17886. /** @hidden */
  17887. private _getEffect;
  17888. /**
  17889. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17890. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17891. */
  17892. animate(preWarmOnly?: boolean): void;
  17893. private _appendParticleVertices;
  17894. /**
  17895. * Rebuilds the particle system.
  17896. */
  17897. rebuild(): void;
  17898. /**
  17899. * Is this system ready to be used/rendered
  17900. * @return true if the system is ready
  17901. */
  17902. isReady(): boolean;
  17903. private _render;
  17904. /**
  17905. * Renders the particle system in its current state.
  17906. * @returns the current number of particles
  17907. */
  17908. render(): number;
  17909. /**
  17910. * Disposes the particle system and free the associated resources
  17911. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17912. */
  17913. dispose(disposeTexture?: boolean): void;
  17914. /**
  17915. * Clones the particle system.
  17916. * @param name The name of the cloned object
  17917. * @param newEmitter The new emitter to use
  17918. * @returns the cloned particle system
  17919. */
  17920. clone(name: string, newEmitter: any): ParticleSystem;
  17921. /**
  17922. * Serializes the particle system to a JSON object.
  17923. * @returns the JSON object
  17924. */
  17925. serialize(): any;
  17926. /** @hidden */
  17927. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17928. /** @hidden */
  17929. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17930. /**
  17931. * Parses a JSON object to create a particle system.
  17932. * @param parsedParticleSystem The JSON object to parse
  17933. * @param scene The scene to create the particle system in
  17934. * @param rootUrl The root url to use to load external dependencies like texture
  17935. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17936. * @returns the Parsed particle system
  17937. */
  17938. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17939. }
  17940. }
  17941. declare module "babylonjs/Particles/particle" {
  17942. import { Nullable } from "babylonjs/types";
  17943. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  17944. import { Color4 } from "babylonjs/Maths/math.color";
  17945. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17946. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17947. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  17948. /**
  17949. * A particle represents one of the element emitted by a particle system.
  17950. * This is mainly define by its coordinates, direction, velocity and age.
  17951. */
  17952. export class Particle {
  17953. /**
  17954. * The particle system the particle belongs to.
  17955. */
  17956. particleSystem: ParticleSystem;
  17957. private static _Count;
  17958. /**
  17959. * Unique ID of the particle
  17960. */
  17961. id: number;
  17962. /**
  17963. * The world position of the particle in the scene.
  17964. */
  17965. position: Vector3;
  17966. /**
  17967. * The world direction of the particle in the scene.
  17968. */
  17969. direction: Vector3;
  17970. /**
  17971. * The color of the particle.
  17972. */
  17973. color: Color4;
  17974. /**
  17975. * The color change of the particle per step.
  17976. */
  17977. colorStep: Color4;
  17978. /**
  17979. * Defines how long will the life of the particle be.
  17980. */
  17981. lifeTime: number;
  17982. /**
  17983. * The current age of the particle.
  17984. */
  17985. age: number;
  17986. /**
  17987. * The current size of the particle.
  17988. */
  17989. size: number;
  17990. /**
  17991. * The current scale of the particle.
  17992. */
  17993. scale: Vector2;
  17994. /**
  17995. * The current angle of the particle.
  17996. */
  17997. angle: number;
  17998. /**
  17999. * Defines how fast is the angle changing.
  18000. */
  18001. angularSpeed: number;
  18002. /**
  18003. * Defines the cell index used by the particle to be rendered from a sprite.
  18004. */
  18005. cellIndex: number;
  18006. /**
  18007. * The information required to support color remapping
  18008. */
  18009. remapData: Vector4;
  18010. /** @hidden */
  18011. _randomCellOffset?: number;
  18012. /** @hidden */
  18013. _initialDirection: Nullable<Vector3>;
  18014. /** @hidden */
  18015. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  18016. /** @hidden */
  18017. _initialStartSpriteCellID: number;
  18018. /** @hidden */
  18019. _initialEndSpriteCellID: number;
  18020. /** @hidden */
  18021. _currentColorGradient: Nullable<ColorGradient>;
  18022. /** @hidden */
  18023. _currentColor1: Color4;
  18024. /** @hidden */
  18025. _currentColor2: Color4;
  18026. /** @hidden */
  18027. _currentSizeGradient: Nullable<FactorGradient>;
  18028. /** @hidden */
  18029. _currentSize1: number;
  18030. /** @hidden */
  18031. _currentSize2: number;
  18032. /** @hidden */
  18033. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  18034. /** @hidden */
  18035. _currentAngularSpeed1: number;
  18036. /** @hidden */
  18037. _currentAngularSpeed2: number;
  18038. /** @hidden */
  18039. _currentVelocityGradient: Nullable<FactorGradient>;
  18040. /** @hidden */
  18041. _currentVelocity1: number;
  18042. /** @hidden */
  18043. _currentVelocity2: number;
  18044. /** @hidden */
  18045. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  18046. /** @hidden */
  18047. _currentLimitVelocity1: number;
  18048. /** @hidden */
  18049. _currentLimitVelocity2: number;
  18050. /** @hidden */
  18051. _currentDragGradient: Nullable<FactorGradient>;
  18052. /** @hidden */
  18053. _currentDrag1: number;
  18054. /** @hidden */
  18055. _currentDrag2: number;
  18056. /** @hidden */
  18057. _randomNoiseCoordinates1: Vector3;
  18058. /** @hidden */
  18059. _randomNoiseCoordinates2: Vector3;
  18060. /**
  18061. * Creates a new instance Particle
  18062. * @param particleSystem the particle system the particle belongs to
  18063. */
  18064. constructor(
  18065. /**
  18066. * The particle system the particle belongs to.
  18067. */
  18068. particleSystem: ParticleSystem);
  18069. private updateCellInfoFromSystem;
  18070. /**
  18071. * Defines how the sprite cell index is updated for the particle
  18072. */
  18073. updateCellIndex(): void;
  18074. /** @hidden */
  18075. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  18076. /** @hidden */
  18077. _inheritParticleInfoToSubEmitters(): void;
  18078. /** @hidden */
  18079. _reset(): void;
  18080. /**
  18081. * Copy the properties of particle to another one.
  18082. * @param other the particle to copy the information to.
  18083. */
  18084. copyTo(other: Particle): void;
  18085. }
  18086. }
  18087. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  18088. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18089. import { Effect } from "babylonjs/Materials/effect";
  18090. import { Particle } from "babylonjs/Particles/particle";
  18091. /**
  18092. * Particle emitter represents a volume emitting particles.
  18093. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  18094. */
  18095. export interface IParticleEmitterType {
  18096. /**
  18097. * Called by the particle System when the direction is computed for the created particle.
  18098. * @param worldMatrix is the world matrix of the particle system
  18099. * @param directionToUpdate is the direction vector to update with the result
  18100. * @param particle is the particle we are computed the direction for
  18101. */
  18102. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18103. /**
  18104. * Called by the particle System when the position is computed for the created particle.
  18105. * @param worldMatrix is the world matrix of the particle system
  18106. * @param positionToUpdate is the position vector to update with the result
  18107. * @param particle is the particle we are computed the position for
  18108. */
  18109. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18110. /**
  18111. * Clones the current emitter and returns a copy of it
  18112. * @returns the new emitter
  18113. */
  18114. clone(): IParticleEmitterType;
  18115. /**
  18116. * Called by the GPUParticleSystem to setup the update shader
  18117. * @param effect defines the update shader
  18118. */
  18119. applyToShader(effect: Effect): void;
  18120. /**
  18121. * Returns a string to use to update the GPU particles update shader
  18122. * @returns the effect defines string
  18123. */
  18124. getEffectDefines(): string;
  18125. /**
  18126. * Returns a string representing the class name
  18127. * @returns a string containing the class name
  18128. */
  18129. getClassName(): string;
  18130. /**
  18131. * Serializes the particle system to a JSON object.
  18132. * @returns the JSON object
  18133. */
  18134. serialize(): any;
  18135. /**
  18136. * Parse properties from a JSON object
  18137. * @param serializationObject defines the JSON object
  18138. */
  18139. parse(serializationObject: any): void;
  18140. }
  18141. }
  18142. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  18143. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18144. import { Effect } from "babylonjs/Materials/effect";
  18145. import { Particle } from "babylonjs/Particles/particle";
  18146. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18147. /**
  18148. * Particle emitter emitting particles from the inside of a box.
  18149. * It emits the particles randomly between 2 given directions.
  18150. */
  18151. export class BoxParticleEmitter implements IParticleEmitterType {
  18152. /**
  18153. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18154. */
  18155. direction1: Vector3;
  18156. /**
  18157. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18158. */
  18159. direction2: Vector3;
  18160. /**
  18161. * 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.
  18162. */
  18163. minEmitBox: Vector3;
  18164. /**
  18165. * 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.
  18166. */
  18167. maxEmitBox: Vector3;
  18168. /**
  18169. * Creates a new instance BoxParticleEmitter
  18170. */
  18171. constructor();
  18172. /**
  18173. * Called by the particle System when the direction is computed for the created particle.
  18174. * @param worldMatrix is the world matrix of the particle system
  18175. * @param directionToUpdate is the direction vector to update with the result
  18176. * @param particle is the particle we are computed the direction for
  18177. */
  18178. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18179. /**
  18180. * Called by the particle System when the position is computed for the created particle.
  18181. * @param worldMatrix is the world matrix of the particle system
  18182. * @param positionToUpdate is the position vector to update with the result
  18183. * @param particle is the particle we are computed the position for
  18184. */
  18185. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18186. /**
  18187. * Clones the current emitter and returns a copy of it
  18188. * @returns the new emitter
  18189. */
  18190. clone(): BoxParticleEmitter;
  18191. /**
  18192. * Called by the GPUParticleSystem to setup the update shader
  18193. * @param effect defines the update shader
  18194. */
  18195. applyToShader(effect: Effect): void;
  18196. /**
  18197. * Returns a string to use to update the GPU particles update shader
  18198. * @returns a string containng the defines string
  18199. */
  18200. getEffectDefines(): string;
  18201. /**
  18202. * Returns the string "BoxParticleEmitter"
  18203. * @returns a string containing the class name
  18204. */
  18205. getClassName(): string;
  18206. /**
  18207. * Serializes the particle system to a JSON object.
  18208. * @returns the JSON object
  18209. */
  18210. serialize(): any;
  18211. /**
  18212. * Parse properties from a JSON object
  18213. * @param serializationObject defines the JSON object
  18214. */
  18215. parse(serializationObject: any): void;
  18216. }
  18217. }
  18218. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  18219. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18220. import { Effect } from "babylonjs/Materials/effect";
  18221. import { Particle } from "babylonjs/Particles/particle";
  18222. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18223. /**
  18224. * Particle emitter emitting particles from the inside of a cone.
  18225. * It emits the particles alongside the cone volume from the base to the particle.
  18226. * The emission direction might be randomized.
  18227. */
  18228. export class ConeParticleEmitter implements IParticleEmitterType {
  18229. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18230. directionRandomizer: number;
  18231. private _radius;
  18232. private _angle;
  18233. private _height;
  18234. /**
  18235. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  18236. */
  18237. radiusRange: number;
  18238. /**
  18239. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  18240. */
  18241. heightRange: number;
  18242. /**
  18243. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  18244. */
  18245. emitFromSpawnPointOnly: boolean;
  18246. /**
  18247. * Gets or sets the radius of the emission cone
  18248. */
  18249. radius: number;
  18250. /**
  18251. * Gets or sets the angle of the emission cone
  18252. */
  18253. angle: number;
  18254. private _buildHeight;
  18255. /**
  18256. * Creates a new instance ConeParticleEmitter
  18257. * @param radius the radius of the emission cone (1 by default)
  18258. * @param angle the cone base angle (PI by default)
  18259. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  18260. */
  18261. constructor(radius?: number, angle?: number,
  18262. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18263. directionRandomizer?: number);
  18264. /**
  18265. * Called by the particle System when the direction is computed for the created particle.
  18266. * @param worldMatrix is the world matrix of the particle system
  18267. * @param directionToUpdate is the direction vector to update with the result
  18268. * @param particle is the particle we are computed the direction for
  18269. */
  18270. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18271. /**
  18272. * Called by the particle System when the position is computed for the created particle.
  18273. * @param worldMatrix is the world matrix of the particle system
  18274. * @param positionToUpdate is the position vector to update with the result
  18275. * @param particle is the particle we are computed the position for
  18276. */
  18277. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18278. /**
  18279. * Clones the current emitter and returns a copy of it
  18280. * @returns the new emitter
  18281. */
  18282. clone(): ConeParticleEmitter;
  18283. /**
  18284. * Called by the GPUParticleSystem to setup the update shader
  18285. * @param effect defines the update shader
  18286. */
  18287. applyToShader(effect: Effect): void;
  18288. /**
  18289. * Returns a string to use to update the GPU particles update shader
  18290. * @returns a string containng the defines string
  18291. */
  18292. getEffectDefines(): string;
  18293. /**
  18294. * Returns the string "ConeParticleEmitter"
  18295. * @returns a string containing the class name
  18296. */
  18297. getClassName(): string;
  18298. /**
  18299. * Serializes the particle system to a JSON object.
  18300. * @returns the JSON object
  18301. */
  18302. serialize(): any;
  18303. /**
  18304. * Parse properties from a JSON object
  18305. * @param serializationObject defines the JSON object
  18306. */
  18307. parse(serializationObject: any): void;
  18308. }
  18309. }
  18310. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  18311. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18312. import { Effect } from "babylonjs/Materials/effect";
  18313. import { Particle } from "babylonjs/Particles/particle";
  18314. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18315. /**
  18316. * Particle emitter emitting particles from the inside of a cylinder.
  18317. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  18318. */
  18319. export class CylinderParticleEmitter implements IParticleEmitterType {
  18320. /**
  18321. * The radius of the emission cylinder.
  18322. */
  18323. radius: number;
  18324. /**
  18325. * The height of the emission cylinder.
  18326. */
  18327. height: number;
  18328. /**
  18329. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18330. */
  18331. radiusRange: number;
  18332. /**
  18333. * How much to randomize the particle direction [0-1].
  18334. */
  18335. directionRandomizer: number;
  18336. /**
  18337. * Creates a new instance CylinderParticleEmitter
  18338. * @param radius the radius of the emission cylinder (1 by default)
  18339. * @param height the height of the emission cylinder (1 by default)
  18340. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18341. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18342. */
  18343. constructor(
  18344. /**
  18345. * The radius of the emission cylinder.
  18346. */
  18347. radius?: number,
  18348. /**
  18349. * The height of the emission cylinder.
  18350. */
  18351. height?: number,
  18352. /**
  18353. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18354. */
  18355. radiusRange?: number,
  18356. /**
  18357. * How much to randomize the particle direction [0-1].
  18358. */
  18359. directionRandomizer?: number);
  18360. /**
  18361. * Called by the particle System when the direction is computed for the created particle.
  18362. * @param worldMatrix is the world matrix of the particle system
  18363. * @param directionToUpdate is the direction vector to update with the result
  18364. * @param particle is the particle we are computed the direction for
  18365. */
  18366. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18367. /**
  18368. * Called by the particle System when the position is computed for the created particle.
  18369. * @param worldMatrix is the world matrix of the particle system
  18370. * @param positionToUpdate is the position vector to update with the result
  18371. * @param particle is the particle we are computed the position for
  18372. */
  18373. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18374. /**
  18375. * Clones the current emitter and returns a copy of it
  18376. * @returns the new emitter
  18377. */
  18378. clone(): CylinderParticleEmitter;
  18379. /**
  18380. * Called by the GPUParticleSystem to setup the update shader
  18381. * @param effect defines the update shader
  18382. */
  18383. applyToShader(effect: Effect): void;
  18384. /**
  18385. * Returns a string to use to update the GPU particles update shader
  18386. * @returns a string containng the defines string
  18387. */
  18388. getEffectDefines(): string;
  18389. /**
  18390. * Returns the string "CylinderParticleEmitter"
  18391. * @returns a string containing the class name
  18392. */
  18393. getClassName(): string;
  18394. /**
  18395. * Serializes the particle system to a JSON object.
  18396. * @returns the JSON object
  18397. */
  18398. serialize(): any;
  18399. /**
  18400. * Parse properties from a JSON object
  18401. * @param serializationObject defines the JSON object
  18402. */
  18403. parse(serializationObject: any): void;
  18404. }
  18405. /**
  18406. * Particle emitter emitting particles from the inside of a cylinder.
  18407. * It emits the particles randomly between two vectors.
  18408. */
  18409. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18410. /**
  18411. * The min limit of the emission direction.
  18412. */
  18413. direction1: Vector3;
  18414. /**
  18415. * The max limit of the emission direction.
  18416. */
  18417. direction2: Vector3;
  18418. /**
  18419. * Creates a new instance CylinderDirectedParticleEmitter
  18420. * @param radius the radius of the emission cylinder (1 by default)
  18421. * @param height the height of the emission cylinder (1 by default)
  18422. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18423. * @param direction1 the min limit of the emission direction (up vector by default)
  18424. * @param direction2 the max limit of the emission direction (up vector by default)
  18425. */
  18426. constructor(radius?: number, height?: number, radiusRange?: number,
  18427. /**
  18428. * The min limit of the emission direction.
  18429. */
  18430. direction1?: Vector3,
  18431. /**
  18432. * The max limit of the emission direction.
  18433. */
  18434. direction2?: Vector3);
  18435. /**
  18436. * Called by the particle System when the direction is computed for the created particle.
  18437. * @param worldMatrix is the world matrix of the particle system
  18438. * @param directionToUpdate is the direction vector to update with the result
  18439. * @param particle is the particle we are computed the direction for
  18440. */
  18441. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18442. /**
  18443. * Clones the current emitter and returns a copy of it
  18444. * @returns the new emitter
  18445. */
  18446. clone(): CylinderDirectedParticleEmitter;
  18447. /**
  18448. * Called by the GPUParticleSystem to setup the update shader
  18449. * @param effect defines the update shader
  18450. */
  18451. applyToShader(effect: Effect): void;
  18452. /**
  18453. * Returns a string to use to update the GPU particles update shader
  18454. * @returns a string containng the defines string
  18455. */
  18456. getEffectDefines(): string;
  18457. /**
  18458. * Returns the string "CylinderDirectedParticleEmitter"
  18459. * @returns a string containing the class name
  18460. */
  18461. getClassName(): string;
  18462. /**
  18463. * Serializes the particle system to a JSON object.
  18464. * @returns the JSON object
  18465. */
  18466. serialize(): any;
  18467. /**
  18468. * Parse properties from a JSON object
  18469. * @param serializationObject defines the JSON object
  18470. */
  18471. parse(serializationObject: any): void;
  18472. }
  18473. }
  18474. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  18475. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18476. import { Effect } from "babylonjs/Materials/effect";
  18477. import { Particle } from "babylonjs/Particles/particle";
  18478. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18479. /**
  18480. * Particle emitter emitting particles from the inside of a hemisphere.
  18481. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18482. */
  18483. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18484. /**
  18485. * The radius of the emission hemisphere.
  18486. */
  18487. radius: number;
  18488. /**
  18489. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18490. */
  18491. radiusRange: number;
  18492. /**
  18493. * How much to randomize the particle direction [0-1].
  18494. */
  18495. directionRandomizer: number;
  18496. /**
  18497. * Creates a new instance HemisphericParticleEmitter
  18498. * @param radius the radius of the emission hemisphere (1 by default)
  18499. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18500. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18501. */
  18502. constructor(
  18503. /**
  18504. * The radius of the emission hemisphere.
  18505. */
  18506. radius?: number,
  18507. /**
  18508. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18509. */
  18510. radiusRange?: number,
  18511. /**
  18512. * How much to randomize the particle direction [0-1].
  18513. */
  18514. directionRandomizer?: number);
  18515. /**
  18516. * Called by the particle System when the direction is computed for the created particle.
  18517. * @param worldMatrix is the world matrix of the particle system
  18518. * @param directionToUpdate is the direction vector to update with the result
  18519. * @param particle is the particle we are computed the direction for
  18520. */
  18521. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18522. /**
  18523. * Called by the particle System when the position is computed for the created particle.
  18524. * @param worldMatrix is the world matrix of the particle system
  18525. * @param positionToUpdate is the position vector to update with the result
  18526. * @param particle is the particle we are computed the position for
  18527. */
  18528. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18529. /**
  18530. * Clones the current emitter and returns a copy of it
  18531. * @returns the new emitter
  18532. */
  18533. clone(): HemisphericParticleEmitter;
  18534. /**
  18535. * Called by the GPUParticleSystem to setup the update shader
  18536. * @param effect defines the update shader
  18537. */
  18538. applyToShader(effect: Effect): void;
  18539. /**
  18540. * Returns a string to use to update the GPU particles update shader
  18541. * @returns a string containng the defines string
  18542. */
  18543. getEffectDefines(): string;
  18544. /**
  18545. * Returns the string "HemisphericParticleEmitter"
  18546. * @returns a string containing the class name
  18547. */
  18548. getClassName(): string;
  18549. /**
  18550. * Serializes the particle system to a JSON object.
  18551. * @returns the JSON object
  18552. */
  18553. serialize(): any;
  18554. /**
  18555. * Parse properties from a JSON object
  18556. * @param serializationObject defines the JSON object
  18557. */
  18558. parse(serializationObject: any): void;
  18559. }
  18560. }
  18561. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  18562. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18563. import { Effect } from "babylonjs/Materials/effect";
  18564. import { Particle } from "babylonjs/Particles/particle";
  18565. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18566. /**
  18567. * Particle emitter emitting particles from a point.
  18568. * It emits the particles randomly between 2 given directions.
  18569. */
  18570. export class PointParticleEmitter implements IParticleEmitterType {
  18571. /**
  18572. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18573. */
  18574. direction1: Vector3;
  18575. /**
  18576. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18577. */
  18578. direction2: Vector3;
  18579. /**
  18580. * Creates a new instance PointParticleEmitter
  18581. */
  18582. constructor();
  18583. /**
  18584. * Called by the particle System when the direction is computed for the created particle.
  18585. * @param worldMatrix is the world matrix of the particle system
  18586. * @param directionToUpdate is the direction vector to update with the result
  18587. * @param particle is the particle we are computed the direction for
  18588. */
  18589. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18590. /**
  18591. * Called by the particle System when the position is computed for the created particle.
  18592. * @param worldMatrix is the world matrix of the particle system
  18593. * @param positionToUpdate is the position vector to update with the result
  18594. * @param particle is the particle we are computed the position for
  18595. */
  18596. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18597. /**
  18598. * Clones the current emitter and returns a copy of it
  18599. * @returns the new emitter
  18600. */
  18601. clone(): PointParticleEmitter;
  18602. /**
  18603. * Called by the GPUParticleSystem to setup the update shader
  18604. * @param effect defines the update shader
  18605. */
  18606. applyToShader(effect: Effect): void;
  18607. /**
  18608. * Returns a string to use to update the GPU particles update shader
  18609. * @returns a string containng the defines string
  18610. */
  18611. getEffectDefines(): string;
  18612. /**
  18613. * Returns the string "PointParticleEmitter"
  18614. * @returns a string containing the class name
  18615. */
  18616. getClassName(): string;
  18617. /**
  18618. * Serializes the particle system to a JSON object.
  18619. * @returns the JSON object
  18620. */
  18621. serialize(): any;
  18622. /**
  18623. * Parse properties from a JSON object
  18624. * @param serializationObject defines the JSON object
  18625. */
  18626. parse(serializationObject: any): void;
  18627. }
  18628. }
  18629. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  18630. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18631. import { Effect } from "babylonjs/Materials/effect";
  18632. import { Particle } from "babylonjs/Particles/particle";
  18633. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18634. /**
  18635. * Particle emitter emitting particles from the inside of a sphere.
  18636. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18637. */
  18638. export class SphereParticleEmitter implements IParticleEmitterType {
  18639. /**
  18640. * The radius of the emission sphere.
  18641. */
  18642. radius: number;
  18643. /**
  18644. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18645. */
  18646. radiusRange: number;
  18647. /**
  18648. * How much to randomize the particle direction [0-1].
  18649. */
  18650. directionRandomizer: number;
  18651. /**
  18652. * Creates a new instance SphereParticleEmitter
  18653. * @param radius the radius of the emission sphere (1 by default)
  18654. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18655. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18656. */
  18657. constructor(
  18658. /**
  18659. * The radius of the emission sphere.
  18660. */
  18661. radius?: number,
  18662. /**
  18663. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18664. */
  18665. radiusRange?: number,
  18666. /**
  18667. * How much to randomize the particle direction [0-1].
  18668. */
  18669. directionRandomizer?: number);
  18670. /**
  18671. * Called by the particle System when the direction is computed for the created particle.
  18672. * @param worldMatrix is the world matrix of the particle system
  18673. * @param directionToUpdate is the direction vector to update with the result
  18674. * @param particle is the particle we are computed the direction for
  18675. */
  18676. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18677. /**
  18678. * Called by the particle System when the position is computed for the created particle.
  18679. * @param worldMatrix is the world matrix of the particle system
  18680. * @param positionToUpdate is the position vector to update with the result
  18681. * @param particle is the particle we are computed the position for
  18682. */
  18683. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18684. /**
  18685. * Clones the current emitter and returns a copy of it
  18686. * @returns the new emitter
  18687. */
  18688. clone(): SphereParticleEmitter;
  18689. /**
  18690. * Called by the GPUParticleSystem to setup the update shader
  18691. * @param effect defines the update shader
  18692. */
  18693. applyToShader(effect: Effect): void;
  18694. /**
  18695. * Returns a string to use to update the GPU particles update shader
  18696. * @returns a string containng the defines string
  18697. */
  18698. getEffectDefines(): string;
  18699. /**
  18700. * Returns the string "SphereParticleEmitter"
  18701. * @returns a string containing the class name
  18702. */
  18703. getClassName(): string;
  18704. /**
  18705. * Serializes the particle system to a JSON object.
  18706. * @returns the JSON object
  18707. */
  18708. serialize(): any;
  18709. /**
  18710. * Parse properties from a JSON object
  18711. * @param serializationObject defines the JSON object
  18712. */
  18713. parse(serializationObject: any): void;
  18714. }
  18715. /**
  18716. * Particle emitter emitting particles from the inside of a sphere.
  18717. * It emits the particles randomly between two vectors.
  18718. */
  18719. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18720. /**
  18721. * The min limit of the emission direction.
  18722. */
  18723. direction1: Vector3;
  18724. /**
  18725. * The max limit of the emission direction.
  18726. */
  18727. direction2: Vector3;
  18728. /**
  18729. * Creates a new instance SphereDirectedParticleEmitter
  18730. * @param radius the radius of the emission sphere (1 by default)
  18731. * @param direction1 the min limit of the emission direction (up vector by default)
  18732. * @param direction2 the max limit of the emission direction (up vector by default)
  18733. */
  18734. constructor(radius?: number,
  18735. /**
  18736. * The min limit of the emission direction.
  18737. */
  18738. direction1?: Vector3,
  18739. /**
  18740. * The max limit of the emission direction.
  18741. */
  18742. direction2?: Vector3);
  18743. /**
  18744. * Called by the particle System when the direction is computed for the created particle.
  18745. * @param worldMatrix is the world matrix of the particle system
  18746. * @param directionToUpdate is the direction vector to update with the result
  18747. * @param particle is the particle we are computed the direction for
  18748. */
  18749. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18750. /**
  18751. * Clones the current emitter and returns a copy of it
  18752. * @returns the new emitter
  18753. */
  18754. clone(): SphereDirectedParticleEmitter;
  18755. /**
  18756. * Called by the GPUParticleSystem to setup the update shader
  18757. * @param effect defines the update shader
  18758. */
  18759. applyToShader(effect: Effect): void;
  18760. /**
  18761. * Returns a string to use to update the GPU particles update shader
  18762. * @returns a string containng the defines string
  18763. */
  18764. getEffectDefines(): string;
  18765. /**
  18766. * Returns the string "SphereDirectedParticleEmitter"
  18767. * @returns a string containing the class name
  18768. */
  18769. getClassName(): string;
  18770. /**
  18771. * Serializes the particle system to a JSON object.
  18772. * @returns the JSON object
  18773. */
  18774. serialize(): any;
  18775. /**
  18776. * Parse properties from a JSON object
  18777. * @param serializationObject defines the JSON object
  18778. */
  18779. parse(serializationObject: any): void;
  18780. }
  18781. }
  18782. declare module "babylonjs/Particles/EmitterTypes/index" {
  18783. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  18784. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  18785. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  18786. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  18787. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18788. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  18789. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  18790. }
  18791. declare module "babylonjs/Particles/IParticleSystem" {
  18792. import { Nullable } from "babylonjs/types";
  18793. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  18794. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  18795. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18796. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18797. import { Texture } from "babylonjs/Materials/Textures/texture";
  18798. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  18799. import { Scene } from "babylonjs/scene";
  18800. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  18801. import { Animation } from "babylonjs/Animations/animation";
  18802. /**
  18803. * Interface representing a particle system in Babylon.js.
  18804. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18805. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18806. */
  18807. export interface IParticleSystem {
  18808. /**
  18809. * List of animations used by the particle system.
  18810. */
  18811. animations: Animation[];
  18812. /**
  18813. * The id of the Particle system.
  18814. */
  18815. id: string;
  18816. /**
  18817. * The name of the Particle system.
  18818. */
  18819. name: string;
  18820. /**
  18821. * The emitter represents the Mesh or position we are attaching the particle system to.
  18822. */
  18823. emitter: Nullable<AbstractMesh | Vector3>;
  18824. /**
  18825. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18826. */
  18827. isBillboardBased: boolean;
  18828. /**
  18829. * The rendering group used by the Particle system to chose when to render.
  18830. */
  18831. renderingGroupId: number;
  18832. /**
  18833. * The layer mask we are rendering the particles through.
  18834. */
  18835. layerMask: number;
  18836. /**
  18837. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18838. */
  18839. updateSpeed: number;
  18840. /**
  18841. * The amount of time the particle system is running (depends of the overall update speed).
  18842. */
  18843. targetStopDuration: number;
  18844. /**
  18845. * The texture used to render each particle. (this can be a spritesheet)
  18846. */
  18847. particleTexture: Nullable<Texture>;
  18848. /**
  18849. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18850. */
  18851. blendMode: number;
  18852. /**
  18853. * Minimum life time of emitting particles.
  18854. */
  18855. minLifeTime: number;
  18856. /**
  18857. * Maximum life time of emitting particles.
  18858. */
  18859. maxLifeTime: number;
  18860. /**
  18861. * Minimum Size of emitting particles.
  18862. */
  18863. minSize: number;
  18864. /**
  18865. * Maximum Size of emitting particles.
  18866. */
  18867. maxSize: number;
  18868. /**
  18869. * Minimum scale of emitting particles on X axis.
  18870. */
  18871. minScaleX: number;
  18872. /**
  18873. * Maximum scale of emitting particles on X axis.
  18874. */
  18875. maxScaleX: number;
  18876. /**
  18877. * Minimum scale of emitting particles on Y axis.
  18878. */
  18879. minScaleY: number;
  18880. /**
  18881. * Maximum scale of emitting particles on Y axis.
  18882. */
  18883. maxScaleY: number;
  18884. /**
  18885. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18886. */
  18887. color1: Color4;
  18888. /**
  18889. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18890. */
  18891. color2: Color4;
  18892. /**
  18893. * Color the particle will have at the end of its lifetime.
  18894. */
  18895. colorDead: Color4;
  18896. /**
  18897. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18898. */
  18899. emitRate: number;
  18900. /**
  18901. * You can use gravity if you want to give an orientation to your particles.
  18902. */
  18903. gravity: Vector3;
  18904. /**
  18905. * Minimum power of emitting particles.
  18906. */
  18907. minEmitPower: number;
  18908. /**
  18909. * Maximum power of emitting particles.
  18910. */
  18911. maxEmitPower: number;
  18912. /**
  18913. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18914. */
  18915. minAngularSpeed: number;
  18916. /**
  18917. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18918. */
  18919. maxAngularSpeed: number;
  18920. /**
  18921. * Gets or sets the minimal initial rotation in radians.
  18922. */
  18923. minInitialRotation: number;
  18924. /**
  18925. * Gets or sets the maximal initial rotation in radians.
  18926. */
  18927. maxInitialRotation: number;
  18928. /**
  18929. * The particle emitter type defines the emitter used by the particle system.
  18930. * It can be for example box, sphere, or cone...
  18931. */
  18932. particleEmitterType: Nullable<IParticleEmitterType>;
  18933. /**
  18934. * Defines the delay in milliseconds before starting the system (0 by default)
  18935. */
  18936. startDelay: number;
  18937. /**
  18938. * 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
  18939. */
  18940. preWarmCycles: number;
  18941. /**
  18942. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18943. */
  18944. preWarmStepOffset: number;
  18945. /**
  18946. * 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)
  18947. */
  18948. spriteCellChangeSpeed: number;
  18949. /**
  18950. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18951. */
  18952. startSpriteCellID: number;
  18953. /**
  18954. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18955. */
  18956. endSpriteCellID: number;
  18957. /**
  18958. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18959. */
  18960. spriteCellWidth: number;
  18961. /**
  18962. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18963. */
  18964. spriteCellHeight: number;
  18965. /**
  18966. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18967. */
  18968. spriteRandomStartCell: boolean;
  18969. /**
  18970. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18971. */
  18972. isAnimationSheetEnabled: boolean;
  18973. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18974. translationPivot: Vector2;
  18975. /**
  18976. * Gets or sets a texture used to add random noise to particle positions
  18977. */
  18978. noiseTexture: Nullable<BaseTexture>;
  18979. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18980. noiseStrength: Vector3;
  18981. /**
  18982. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18983. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18984. */
  18985. billboardMode: number;
  18986. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18987. limitVelocityDamping: number;
  18988. /**
  18989. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18990. */
  18991. beginAnimationOnStart: boolean;
  18992. /**
  18993. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18994. */
  18995. beginAnimationFrom: number;
  18996. /**
  18997. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18998. */
  18999. beginAnimationTo: number;
  19000. /**
  19001. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  19002. */
  19003. beginAnimationLoop: boolean;
  19004. /**
  19005. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  19006. */
  19007. disposeOnStop: boolean;
  19008. /**
  19009. * Gets the maximum number of particles active at the same time.
  19010. * @returns The max number of active particles.
  19011. */
  19012. getCapacity(): number;
  19013. /**
  19014. * Gets if the system has been started. (Note: this will still be true after stop is called)
  19015. * @returns True if it has been started, otherwise false.
  19016. */
  19017. isStarted(): boolean;
  19018. /**
  19019. * Animates the particle system for this frame.
  19020. */
  19021. animate(): void;
  19022. /**
  19023. * Renders the particle system in its current state.
  19024. * @returns the current number of particles
  19025. */
  19026. render(): number;
  19027. /**
  19028. * Dispose the particle system and frees its associated resources.
  19029. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  19030. */
  19031. dispose(disposeTexture?: boolean): void;
  19032. /**
  19033. * Clones the particle system.
  19034. * @param name The name of the cloned object
  19035. * @param newEmitter The new emitter to use
  19036. * @returns the cloned particle system
  19037. */
  19038. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  19039. /**
  19040. * Serializes the particle system to a JSON object.
  19041. * @returns the JSON object
  19042. */
  19043. serialize(): any;
  19044. /**
  19045. * Rebuild the particle system
  19046. */
  19047. rebuild(): void;
  19048. /**
  19049. * Starts the particle system and begins to emit
  19050. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  19051. */
  19052. start(delay?: number): void;
  19053. /**
  19054. * Stops the particle system.
  19055. */
  19056. stop(): void;
  19057. /**
  19058. * Remove all active particles
  19059. */
  19060. reset(): void;
  19061. /**
  19062. * Is this system ready to be used/rendered
  19063. * @return true if the system is ready
  19064. */
  19065. isReady(): boolean;
  19066. /**
  19067. * Adds a new color gradient
  19068. * @param gradient defines the gradient to use (between 0 and 1)
  19069. * @param color1 defines the color to affect to the specified gradient
  19070. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  19071. * @returns the current particle system
  19072. */
  19073. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  19074. /**
  19075. * Remove a specific color gradient
  19076. * @param gradient defines the gradient to remove
  19077. * @returns the current particle system
  19078. */
  19079. removeColorGradient(gradient: number): IParticleSystem;
  19080. /**
  19081. * Adds a new size gradient
  19082. * @param gradient defines the gradient to use (between 0 and 1)
  19083. * @param factor defines the size factor to affect to the specified gradient
  19084. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19085. * @returns the current particle system
  19086. */
  19087. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19088. /**
  19089. * Remove a specific size gradient
  19090. * @param gradient defines the gradient to remove
  19091. * @returns the current particle system
  19092. */
  19093. removeSizeGradient(gradient: number): IParticleSystem;
  19094. /**
  19095. * Gets the current list of color gradients.
  19096. * You must use addColorGradient and removeColorGradient to udpate this list
  19097. * @returns the list of color gradients
  19098. */
  19099. getColorGradients(): Nullable<Array<ColorGradient>>;
  19100. /**
  19101. * Gets the current list of size gradients.
  19102. * You must use addSizeGradient and removeSizeGradient to udpate this list
  19103. * @returns the list of size gradients
  19104. */
  19105. getSizeGradients(): Nullable<Array<FactorGradient>>;
  19106. /**
  19107. * Gets the current list of angular speed gradients.
  19108. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  19109. * @returns the list of angular speed gradients
  19110. */
  19111. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  19112. /**
  19113. * Adds a new angular speed gradient
  19114. * @param gradient defines the gradient to use (between 0 and 1)
  19115. * @param factor defines the angular speed to affect to the specified gradient
  19116. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19117. * @returns the current particle system
  19118. */
  19119. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19120. /**
  19121. * Remove a specific angular speed gradient
  19122. * @param gradient defines the gradient to remove
  19123. * @returns the current particle system
  19124. */
  19125. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  19126. /**
  19127. * Gets the current list of velocity gradients.
  19128. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  19129. * @returns the list of velocity gradients
  19130. */
  19131. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  19132. /**
  19133. * Adds a new velocity gradient
  19134. * @param gradient defines the gradient to use (between 0 and 1)
  19135. * @param factor defines the velocity to affect to the specified gradient
  19136. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19137. * @returns the current particle system
  19138. */
  19139. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19140. /**
  19141. * Remove a specific velocity gradient
  19142. * @param gradient defines the gradient to remove
  19143. * @returns the current particle system
  19144. */
  19145. removeVelocityGradient(gradient: number): IParticleSystem;
  19146. /**
  19147. * Gets the current list of limit velocity gradients.
  19148. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  19149. * @returns the list of limit velocity gradients
  19150. */
  19151. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  19152. /**
  19153. * Adds a new limit velocity gradient
  19154. * @param gradient defines the gradient to use (between 0 and 1)
  19155. * @param factor defines the limit velocity 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. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19160. /**
  19161. * Remove a specific limit velocity gradient
  19162. * @param gradient defines the gradient to remove
  19163. * @returns the current particle system
  19164. */
  19165. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  19166. /**
  19167. * Adds a new drag gradient
  19168. * @param gradient defines the gradient to use (between 0 and 1)
  19169. * @param factor defines the drag to affect to the specified gradient
  19170. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19171. * @returns the current particle system
  19172. */
  19173. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19174. /**
  19175. * Remove a specific drag gradient
  19176. * @param gradient defines the gradient to remove
  19177. * @returns the current particle system
  19178. */
  19179. removeDragGradient(gradient: number): IParticleSystem;
  19180. /**
  19181. * Gets the current list of drag gradients.
  19182. * You must use addDragGradient and removeDragGradient to udpate this list
  19183. * @returns the list of drag gradients
  19184. */
  19185. getDragGradients(): Nullable<Array<FactorGradient>>;
  19186. /**
  19187. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  19188. * @param gradient defines the gradient to use (between 0 and 1)
  19189. * @param factor defines the emit rate to affect to the specified gradient
  19190. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19191. * @returns the current particle system
  19192. */
  19193. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19194. /**
  19195. * Remove a specific emit rate gradient
  19196. * @param gradient defines the gradient to remove
  19197. * @returns the current particle system
  19198. */
  19199. removeEmitRateGradient(gradient: number): IParticleSystem;
  19200. /**
  19201. * Gets the current list of emit rate gradients.
  19202. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19203. * @returns the list of emit rate gradients
  19204. */
  19205. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19206. /**
  19207. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  19208. * @param gradient defines the gradient to use (between 0 and 1)
  19209. * @param factor defines the start size 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. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19214. /**
  19215. * Remove a specific start size gradient
  19216. * @param gradient defines the gradient to remove
  19217. * @returns the current particle system
  19218. */
  19219. removeStartSizeGradient(gradient: number): IParticleSystem;
  19220. /**
  19221. * Gets the current list of start size gradients.
  19222. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19223. * @returns the list of start size gradients
  19224. */
  19225. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19226. /**
  19227. * Adds a new life time gradient
  19228. * @param gradient defines the gradient to use (between 0 and 1)
  19229. * @param factor defines the life time factor 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. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19234. /**
  19235. * Remove a specific life time gradient
  19236. * @param gradient defines the gradient to remove
  19237. * @returns the current particle system
  19238. */
  19239. removeLifeTimeGradient(gradient: number): IParticleSystem;
  19240. /**
  19241. * Gets the current list of life time gradients.
  19242. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19243. * @returns the list of life time gradients
  19244. */
  19245. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19246. /**
  19247. * Gets the current list of color gradients.
  19248. * You must use addColorGradient and removeColorGradient to udpate this list
  19249. * @returns the list of color gradients
  19250. */
  19251. getColorGradients(): Nullable<Array<ColorGradient>>;
  19252. /**
  19253. * Adds a new ramp gradient used to remap particle colors
  19254. * @param gradient defines the gradient to use (between 0 and 1)
  19255. * @param color defines the color to affect to the specified gradient
  19256. * @returns the current particle system
  19257. */
  19258. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  19259. /**
  19260. * Gets the current list of ramp gradients.
  19261. * You must use addRampGradient and removeRampGradient to udpate this list
  19262. * @returns the list of ramp gradients
  19263. */
  19264. getRampGradients(): Nullable<Array<Color3Gradient>>;
  19265. /** Gets or sets a boolean indicating that ramp gradients must be used
  19266. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  19267. */
  19268. useRampGradients: boolean;
  19269. /**
  19270. * Adds a new color remap gradient
  19271. * @param gradient defines the gradient to use (between 0 and 1)
  19272. * @param min defines the color remap minimal range
  19273. * @param max defines the color remap maximal range
  19274. * @returns the current particle system
  19275. */
  19276. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19277. /**
  19278. * Gets the current list of color remap gradients.
  19279. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19280. * @returns the list of color remap gradients
  19281. */
  19282. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19283. /**
  19284. * Adds a new alpha remap gradient
  19285. * @param gradient defines the gradient to use (between 0 and 1)
  19286. * @param min defines the alpha remap minimal range
  19287. * @param max defines the alpha remap maximal range
  19288. * @returns the current particle system
  19289. */
  19290. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19291. /**
  19292. * Gets the current list of alpha remap gradients.
  19293. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19294. * @returns the list of alpha remap gradients
  19295. */
  19296. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19297. /**
  19298. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19299. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19300. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19301. * @returns the emitter
  19302. */
  19303. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19304. /**
  19305. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19306. * @param radius The radius of the hemisphere to emit from
  19307. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19308. * @returns the emitter
  19309. */
  19310. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  19311. /**
  19312. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19313. * @param radius The radius of the sphere to emit from
  19314. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19315. * @returns the emitter
  19316. */
  19317. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  19318. /**
  19319. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19320. * @param radius The radius of the sphere to emit from
  19321. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19322. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19323. * @returns the emitter
  19324. */
  19325. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19326. /**
  19327. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19328. * @param radius The radius of the emission cylinder
  19329. * @param height The height of the emission cylinder
  19330. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19331. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19332. * @returns the emitter
  19333. */
  19334. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  19335. /**
  19336. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19337. * @param radius The radius of the cylinder to emit from
  19338. * @param height The height of the emission cylinder
  19339. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19340. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19341. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19342. * @returns the emitter
  19343. */
  19344. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19345. /**
  19346. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19347. * @param radius The radius of the cone to emit from
  19348. * @param angle The base angle of the cone
  19349. * @returns the emitter
  19350. */
  19351. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  19352. /**
  19353. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19354. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19355. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19356. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19357. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19358. * @returns the emitter
  19359. */
  19360. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19361. /**
  19362. * Get hosting scene
  19363. * @returns the scene
  19364. */
  19365. getScene(): Scene;
  19366. }
  19367. }
  19368. declare module "babylonjs/Meshes/instancedMesh" {
  19369. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19370. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19371. import { Camera } from "babylonjs/Cameras/camera";
  19372. import { Node } from "babylonjs/node";
  19373. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19374. import { Mesh } from "babylonjs/Meshes/mesh";
  19375. import { Material } from "babylonjs/Materials/material";
  19376. import { Skeleton } from "babylonjs/Bones/skeleton";
  19377. import { Light } from "babylonjs/Lights/light";
  19378. /**
  19379. * Creates an instance based on a source mesh.
  19380. */
  19381. export class InstancedMesh extends AbstractMesh {
  19382. private _sourceMesh;
  19383. private _currentLOD;
  19384. /** @hidden */
  19385. _indexInSourceMeshInstanceArray: number;
  19386. constructor(name: string, source: Mesh);
  19387. /**
  19388. * Returns the string "InstancedMesh".
  19389. */
  19390. getClassName(): string;
  19391. /** Gets the list of lights affecting that mesh */
  19392. readonly lightSources: Light[];
  19393. _resyncLightSources(): void;
  19394. _resyncLighSource(light: Light): void;
  19395. _removeLightSource(light: Light, dispose: boolean): void;
  19396. /**
  19397. * If the source mesh receives shadows
  19398. */
  19399. readonly receiveShadows: boolean;
  19400. /**
  19401. * The material of the source mesh
  19402. */
  19403. readonly material: Nullable<Material>;
  19404. /**
  19405. * Visibility of the source mesh
  19406. */
  19407. readonly visibility: number;
  19408. /**
  19409. * Skeleton of the source mesh
  19410. */
  19411. readonly skeleton: Nullable<Skeleton>;
  19412. /**
  19413. * Rendering ground id of the source mesh
  19414. */
  19415. renderingGroupId: number;
  19416. /**
  19417. * Returns the total number of vertices (integer).
  19418. */
  19419. getTotalVertices(): number;
  19420. /**
  19421. * Returns a positive integer : the total number of indices in this mesh geometry.
  19422. * @returns the numner of indices or zero if the mesh has no geometry.
  19423. */
  19424. getTotalIndices(): number;
  19425. /**
  19426. * The source mesh of the instance
  19427. */
  19428. readonly sourceMesh: Mesh;
  19429. /**
  19430. * Is this node ready to be used/rendered
  19431. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19432. * @return {boolean} is it ready
  19433. */
  19434. isReady(completeCheck?: boolean): boolean;
  19435. /**
  19436. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19437. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19438. * @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.
  19439. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19440. */
  19441. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19442. /**
  19443. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19444. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19445. * The `data` are either a numeric array either a Float32Array.
  19446. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19447. * 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).
  19448. * Note that a new underlying VertexBuffer object is created each call.
  19449. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19450. *
  19451. * Possible `kind` values :
  19452. * - VertexBuffer.PositionKind
  19453. * - VertexBuffer.UVKind
  19454. * - VertexBuffer.UV2Kind
  19455. * - VertexBuffer.UV3Kind
  19456. * - VertexBuffer.UV4Kind
  19457. * - VertexBuffer.UV5Kind
  19458. * - VertexBuffer.UV6Kind
  19459. * - VertexBuffer.ColorKind
  19460. * - VertexBuffer.MatricesIndicesKind
  19461. * - VertexBuffer.MatricesIndicesExtraKind
  19462. * - VertexBuffer.MatricesWeightsKind
  19463. * - VertexBuffer.MatricesWeightsExtraKind
  19464. *
  19465. * Returns the Mesh.
  19466. */
  19467. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19468. /**
  19469. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19470. * If the mesh has no geometry, it is simply returned as it is.
  19471. * The `data` are either a numeric array either a Float32Array.
  19472. * No new underlying VertexBuffer object is created.
  19473. * 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.
  19474. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19475. *
  19476. * Possible `kind` values :
  19477. * - VertexBuffer.PositionKind
  19478. * - VertexBuffer.UVKind
  19479. * - VertexBuffer.UV2Kind
  19480. * - VertexBuffer.UV3Kind
  19481. * - VertexBuffer.UV4Kind
  19482. * - VertexBuffer.UV5Kind
  19483. * - VertexBuffer.UV6Kind
  19484. * - VertexBuffer.ColorKind
  19485. * - VertexBuffer.MatricesIndicesKind
  19486. * - VertexBuffer.MatricesIndicesExtraKind
  19487. * - VertexBuffer.MatricesWeightsKind
  19488. * - VertexBuffer.MatricesWeightsExtraKind
  19489. *
  19490. * Returns the Mesh.
  19491. */
  19492. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19493. /**
  19494. * Sets the mesh indices.
  19495. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19496. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19497. * This method creates a new index buffer each call.
  19498. * Returns the Mesh.
  19499. */
  19500. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19501. /**
  19502. * Boolean : True if the mesh owns the requested kind of data.
  19503. */
  19504. isVerticesDataPresent(kind: string): boolean;
  19505. /**
  19506. * Returns an array of indices (IndicesArray).
  19507. */
  19508. getIndices(): Nullable<IndicesArray>;
  19509. readonly _positions: Nullable<Vector3[]>;
  19510. /**
  19511. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19512. * This means the mesh underlying bounding box and sphere are recomputed.
  19513. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19514. * @returns the current mesh
  19515. */
  19516. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19517. /** @hidden */
  19518. _preActivate(): InstancedMesh;
  19519. /** @hidden */
  19520. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19521. /** @hidden */
  19522. _postActivate(): void;
  19523. getWorldMatrix(): Matrix;
  19524. readonly isAnInstance: boolean;
  19525. /**
  19526. * Returns the current associated LOD AbstractMesh.
  19527. */
  19528. getLOD(camera: Camera): AbstractMesh;
  19529. /** @hidden */
  19530. _syncSubMeshes(): InstancedMesh;
  19531. /** @hidden */
  19532. _generatePointsArray(): boolean;
  19533. /**
  19534. * Creates a new InstancedMesh from the current mesh.
  19535. * - name (string) : the cloned mesh name
  19536. * - newParent (optional Node) : the optional Node to parent the clone to.
  19537. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19538. *
  19539. * Returns the clone.
  19540. */
  19541. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19542. /**
  19543. * Disposes the InstancedMesh.
  19544. * Returns nothing.
  19545. */
  19546. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19547. }
  19548. }
  19549. declare module "babylonjs/Materials/shaderMaterial" {
  19550. import { Scene } from "babylonjs/scene";
  19551. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  19552. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19553. import { Mesh } from "babylonjs/Meshes/mesh";
  19554. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  19555. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19556. import { Texture } from "babylonjs/Materials/Textures/texture";
  19557. import { Material } from "babylonjs/Materials/material";
  19558. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19559. /**
  19560. * Defines the options associated with the creation of a shader material.
  19561. */
  19562. export interface IShaderMaterialOptions {
  19563. /**
  19564. * Does the material work in alpha blend mode
  19565. */
  19566. needAlphaBlending: boolean;
  19567. /**
  19568. * Does the material work in alpha test mode
  19569. */
  19570. needAlphaTesting: boolean;
  19571. /**
  19572. * The list of attribute names used in the shader
  19573. */
  19574. attributes: string[];
  19575. /**
  19576. * The list of unifrom names used in the shader
  19577. */
  19578. uniforms: string[];
  19579. /**
  19580. * The list of UBO names used in the shader
  19581. */
  19582. uniformBuffers: string[];
  19583. /**
  19584. * The list of sampler names used in the shader
  19585. */
  19586. samplers: string[];
  19587. /**
  19588. * The list of defines used in the shader
  19589. */
  19590. defines: string[];
  19591. }
  19592. /**
  19593. * 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.
  19594. *
  19595. * This returned material effects how the mesh will look based on the code in the shaders.
  19596. *
  19597. * @see http://doc.babylonjs.com/how_to/shader_material
  19598. */
  19599. export class ShaderMaterial extends Material {
  19600. private _shaderPath;
  19601. private _options;
  19602. private _textures;
  19603. private _textureArrays;
  19604. private _floats;
  19605. private _ints;
  19606. private _floatsArrays;
  19607. private _colors3;
  19608. private _colors3Arrays;
  19609. private _colors4;
  19610. private _colors4Arrays;
  19611. private _vectors2;
  19612. private _vectors3;
  19613. private _vectors4;
  19614. private _matrices;
  19615. private _matrices3x3;
  19616. private _matrices2x2;
  19617. private _vectors2Arrays;
  19618. private _vectors3Arrays;
  19619. private _vectors4Arrays;
  19620. private _cachedWorldViewMatrix;
  19621. private _cachedWorldViewProjectionMatrix;
  19622. private _renderId;
  19623. /**
  19624. * Instantiate a new shader material.
  19625. * 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.
  19626. * This returned material effects how the mesh will look based on the code in the shaders.
  19627. * @see http://doc.babylonjs.com/how_to/shader_material
  19628. * @param name Define the name of the material in the scene
  19629. * @param scene Define the scene the material belongs to
  19630. * @param shaderPath Defines the route to the shader code in one of three ways:
  19631. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19632. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19633. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19634. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19635. * @param options Define the options used to create the shader
  19636. */
  19637. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19638. /**
  19639. * Gets the options used to compile the shader.
  19640. * They can be modified to trigger a new compilation
  19641. */
  19642. readonly options: IShaderMaterialOptions;
  19643. /**
  19644. * Gets the current class name of the material e.g. "ShaderMaterial"
  19645. * Mainly use in serialization.
  19646. * @returns the class name
  19647. */
  19648. getClassName(): string;
  19649. /**
  19650. * Specifies if the material will require alpha blending
  19651. * @returns a boolean specifying if alpha blending is needed
  19652. */
  19653. needAlphaBlending(): boolean;
  19654. /**
  19655. * Specifies if this material should be rendered in alpha test mode
  19656. * @returns a boolean specifying if an alpha test is needed.
  19657. */
  19658. needAlphaTesting(): boolean;
  19659. private _checkUniform;
  19660. /**
  19661. * Set a texture in the shader.
  19662. * @param name Define the name of the uniform samplers as defined in the shader
  19663. * @param texture Define the texture to bind to this sampler
  19664. * @return the material itself allowing "fluent" like uniform updates
  19665. */
  19666. setTexture(name: string, texture: Texture): ShaderMaterial;
  19667. /**
  19668. * Set a texture array in the shader.
  19669. * @param name Define the name of the uniform sampler array as defined in the shader
  19670. * @param textures Define the list of textures to bind to this sampler
  19671. * @return the material itself allowing "fluent" like uniform updates
  19672. */
  19673. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19674. /**
  19675. * Set a float in the shader.
  19676. * @param name Define the name of the uniform as defined in the shader
  19677. * @param value Define the value to give to the uniform
  19678. * @return the material itself allowing "fluent" like uniform updates
  19679. */
  19680. setFloat(name: string, value: number): ShaderMaterial;
  19681. /**
  19682. * Set a int in the shader.
  19683. * @param name Define the name of the uniform as defined in the shader
  19684. * @param value Define the value to give to the uniform
  19685. * @return the material itself allowing "fluent" like uniform updates
  19686. */
  19687. setInt(name: string, value: number): ShaderMaterial;
  19688. /**
  19689. * Set an array of floats in the shader.
  19690. * @param name Define the name of the uniform as defined in the shader
  19691. * @param value Define the value to give to the uniform
  19692. * @return the material itself allowing "fluent" like uniform updates
  19693. */
  19694. setFloats(name: string, value: number[]): ShaderMaterial;
  19695. /**
  19696. * Set a vec3 in the shader from a Color3.
  19697. * @param name Define the name of the uniform as defined in the shader
  19698. * @param value Define the value to give to the uniform
  19699. * @return the material itself allowing "fluent" like uniform updates
  19700. */
  19701. setColor3(name: string, value: Color3): ShaderMaterial;
  19702. /**
  19703. * Set a vec3 array in the shader from a Color3 array.
  19704. * @param name Define the name of the uniform as defined in the shader
  19705. * @param value Define the value to give to the uniform
  19706. * @return the material itself allowing "fluent" like uniform updates
  19707. */
  19708. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19709. /**
  19710. * Set a vec4 in the shader from a Color4.
  19711. * @param name Define the name of the uniform as defined in the shader
  19712. * @param value Define the value to give to the uniform
  19713. * @return the material itself allowing "fluent" like uniform updates
  19714. */
  19715. setColor4(name: string, value: Color4): ShaderMaterial;
  19716. /**
  19717. * Set a vec4 array in the shader from a Color4 array.
  19718. * @param name Define the name of the uniform as defined in the shader
  19719. * @param value Define the value to give to the uniform
  19720. * @return the material itself allowing "fluent" like uniform updates
  19721. */
  19722. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19723. /**
  19724. * Set a vec2 in the shader from a Vector2.
  19725. * @param name Define the name of the uniform as defined in the shader
  19726. * @param value Define the value to give to the uniform
  19727. * @return the material itself allowing "fluent" like uniform updates
  19728. */
  19729. setVector2(name: string, value: Vector2): ShaderMaterial;
  19730. /**
  19731. * Set a vec3 in the shader from a Vector3.
  19732. * @param name Define the name of the uniform as defined in the shader
  19733. * @param value Define the value to give to the uniform
  19734. * @return the material itself allowing "fluent" like uniform updates
  19735. */
  19736. setVector3(name: string, value: Vector3): ShaderMaterial;
  19737. /**
  19738. * Set a vec4 in the shader from a Vector4.
  19739. * @param name Define the name of the uniform as defined in the shader
  19740. * @param value Define the value to give to the uniform
  19741. * @return the material itself allowing "fluent" like uniform updates
  19742. */
  19743. setVector4(name: string, value: Vector4): ShaderMaterial;
  19744. /**
  19745. * Set a mat4 in the shader from a Matrix.
  19746. * @param name Define the name of the uniform as defined in the shader
  19747. * @param value Define the value to give to the uniform
  19748. * @return the material itself allowing "fluent" like uniform updates
  19749. */
  19750. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19751. /**
  19752. * Set a mat3 in the shader from a Float32Array.
  19753. * @param name Define the name of the uniform as defined in the shader
  19754. * @param value Define the value to give to the uniform
  19755. * @return the material itself allowing "fluent" like uniform updates
  19756. */
  19757. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19758. /**
  19759. * Set a mat2 in the shader from a Float32Array.
  19760. * @param name Define the name of the uniform as defined in the shader
  19761. * @param value Define the value to give to the uniform
  19762. * @return the material itself allowing "fluent" like uniform updates
  19763. */
  19764. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19765. /**
  19766. * Set a vec2 array in the shader from a number array.
  19767. * @param name Define the name of the uniform as defined in the shader
  19768. * @param value Define the value to give to the uniform
  19769. * @return the material itself allowing "fluent" like uniform updates
  19770. */
  19771. setArray2(name: string, value: number[]): ShaderMaterial;
  19772. /**
  19773. * Set a vec3 array in the shader from a number array.
  19774. * @param name Define the name of the uniform as defined in the shader
  19775. * @param value Define the value to give to the uniform
  19776. * @return the material itself allowing "fluent" like uniform updates
  19777. */
  19778. setArray3(name: string, value: number[]): ShaderMaterial;
  19779. /**
  19780. * Set a vec4 array in the shader from a number array.
  19781. * @param name Define the name of the uniform as defined in the shader
  19782. * @param value Define the value to give to the uniform
  19783. * @return the material itself allowing "fluent" like uniform updates
  19784. */
  19785. setArray4(name: string, value: number[]): ShaderMaterial;
  19786. private _checkCache;
  19787. /**
  19788. * Specifies that the submesh is ready to be used
  19789. * @param mesh defines the mesh to check
  19790. * @param subMesh defines which submesh to check
  19791. * @param useInstances specifies that instances should be used
  19792. * @returns a boolean indicating that the submesh is ready or not
  19793. */
  19794. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19795. /**
  19796. * Checks if the material is ready to render the requested mesh
  19797. * @param mesh Define the mesh to render
  19798. * @param useInstances Define whether or not the material is used with instances
  19799. * @returns true if ready, otherwise false
  19800. */
  19801. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19802. /**
  19803. * Binds the world matrix to the material
  19804. * @param world defines the world transformation matrix
  19805. */
  19806. bindOnlyWorldMatrix(world: Matrix): void;
  19807. /**
  19808. * Binds the material to the mesh
  19809. * @param world defines the world transformation matrix
  19810. * @param mesh defines the mesh to bind the material to
  19811. */
  19812. bind(world: Matrix, mesh?: Mesh): void;
  19813. /**
  19814. * Gets the active textures from the material
  19815. * @returns an array of textures
  19816. */
  19817. getActiveTextures(): BaseTexture[];
  19818. /**
  19819. * Specifies if the material uses a texture
  19820. * @param texture defines the texture to check against the material
  19821. * @returns a boolean specifying if the material uses the texture
  19822. */
  19823. hasTexture(texture: BaseTexture): boolean;
  19824. /**
  19825. * Makes a duplicate of the material, and gives it a new name
  19826. * @param name defines the new name for the duplicated material
  19827. * @returns the cloned material
  19828. */
  19829. clone(name: string): ShaderMaterial;
  19830. /**
  19831. * Disposes the material
  19832. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19833. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19834. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19835. */
  19836. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19837. /**
  19838. * Serializes this material in a JSON representation
  19839. * @returns the serialized material object
  19840. */
  19841. serialize(): any;
  19842. /**
  19843. * Creates a shader material from parsed shader material data
  19844. * @param source defines the JSON represnetation of the material
  19845. * @param scene defines the hosting scene
  19846. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19847. * @returns a new material
  19848. */
  19849. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19850. }
  19851. }
  19852. declare module "babylonjs/Shaders/color.fragment" {
  19853. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  19854. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  19855. /** @hidden */
  19856. export var colorPixelShader: {
  19857. name: string;
  19858. shader: string;
  19859. };
  19860. }
  19861. declare module "babylonjs/Shaders/color.vertex" {
  19862. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  19863. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  19864. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  19865. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  19866. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  19867. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  19868. /** @hidden */
  19869. export var colorVertexShader: {
  19870. name: string;
  19871. shader: string;
  19872. };
  19873. }
  19874. declare module "babylonjs/Meshes/linesMesh" {
  19875. import { Nullable } from "babylonjs/types";
  19876. import { Scene } from "babylonjs/scene";
  19877. import { Color3 } from "babylonjs/Maths/math.color";
  19878. import { Node } from "babylonjs/node";
  19879. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19880. import { Mesh } from "babylonjs/Meshes/mesh";
  19881. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  19882. import { Effect } from "babylonjs/Materials/effect";
  19883. import { Material } from "babylonjs/Materials/material";
  19884. import "babylonjs/Shaders/color.fragment";
  19885. import "babylonjs/Shaders/color.vertex";
  19886. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19887. /**
  19888. * Line mesh
  19889. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19890. */
  19891. export class LinesMesh extends Mesh {
  19892. /**
  19893. * If vertex color should be applied to the mesh
  19894. */
  19895. readonly useVertexColor?: boolean | undefined;
  19896. /**
  19897. * If vertex alpha should be applied to the mesh
  19898. */
  19899. readonly useVertexAlpha?: boolean | undefined;
  19900. /**
  19901. * Color of the line (Default: White)
  19902. */
  19903. color: Color3;
  19904. /**
  19905. * Alpha of the line (Default: 1)
  19906. */
  19907. alpha: number;
  19908. /**
  19909. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19910. * This margin is expressed in world space coordinates, so its value may vary.
  19911. * Default value is 0.1
  19912. */
  19913. intersectionThreshold: number;
  19914. private _colorShader;
  19915. private color4;
  19916. /**
  19917. * Creates a new LinesMesh
  19918. * @param name defines the name
  19919. * @param scene defines the hosting scene
  19920. * @param parent defines the parent mesh if any
  19921. * @param source defines the optional source LinesMesh used to clone data from
  19922. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19923. * When false, achieved by calling a clone(), also passing False.
  19924. * This will make creation of children, recursive.
  19925. * @param useVertexColor defines if this LinesMesh supports vertex color
  19926. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19927. */
  19928. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19929. /**
  19930. * If vertex color should be applied to the mesh
  19931. */
  19932. useVertexColor?: boolean | undefined,
  19933. /**
  19934. * If vertex alpha should be applied to the mesh
  19935. */
  19936. useVertexAlpha?: boolean | undefined);
  19937. private _addClipPlaneDefine;
  19938. private _removeClipPlaneDefine;
  19939. isReady(): boolean;
  19940. /**
  19941. * Returns the string "LineMesh"
  19942. */
  19943. getClassName(): string;
  19944. /**
  19945. * @hidden
  19946. */
  19947. /**
  19948. * @hidden
  19949. */
  19950. material: Material;
  19951. /**
  19952. * @hidden
  19953. */
  19954. readonly checkCollisions: boolean;
  19955. /** @hidden */
  19956. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19957. /** @hidden */
  19958. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19959. /**
  19960. * Disposes of the line mesh
  19961. * @param doNotRecurse If children should be disposed
  19962. */
  19963. dispose(doNotRecurse?: boolean): void;
  19964. /**
  19965. * Returns a new LineMesh object cloned from the current one.
  19966. */
  19967. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19968. /**
  19969. * Creates a new InstancedLinesMesh object from the mesh model.
  19970. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19971. * @param name defines the name of the new instance
  19972. * @returns a new InstancedLinesMesh
  19973. */
  19974. createInstance(name: string): InstancedLinesMesh;
  19975. }
  19976. /**
  19977. * Creates an instance based on a source LinesMesh
  19978. */
  19979. export class InstancedLinesMesh extends InstancedMesh {
  19980. /**
  19981. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19982. * This margin is expressed in world space coordinates, so its value may vary.
  19983. * Initilized with the intersectionThreshold value of the source LinesMesh
  19984. */
  19985. intersectionThreshold: number;
  19986. constructor(name: string, source: LinesMesh);
  19987. /**
  19988. * Returns the string "InstancedLinesMesh".
  19989. */
  19990. getClassName(): string;
  19991. }
  19992. }
  19993. declare module "babylonjs/Shaders/line.fragment" {
  19994. /** @hidden */
  19995. export var linePixelShader: {
  19996. name: string;
  19997. shader: string;
  19998. };
  19999. }
  20000. declare module "babylonjs/Shaders/line.vertex" {
  20001. /** @hidden */
  20002. export var lineVertexShader: {
  20003. name: string;
  20004. shader: string;
  20005. };
  20006. }
  20007. declare module "babylonjs/Rendering/edgesRenderer" {
  20008. import { Nullable } from "babylonjs/types";
  20009. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  20010. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20011. import { Vector3 } from "babylonjs/Maths/math.vector";
  20012. import { IDisposable } from "babylonjs/scene";
  20013. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  20014. import "babylonjs/Shaders/line.fragment";
  20015. import "babylonjs/Shaders/line.vertex";
  20016. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  20017. module "babylonjs/Meshes/abstractMesh" {
  20018. interface AbstractMesh {
  20019. /**
  20020. * Gets the edgesRenderer associated with the mesh
  20021. */
  20022. edgesRenderer: Nullable<EdgesRenderer>;
  20023. }
  20024. }
  20025. module "babylonjs/Meshes/linesMesh" {
  20026. interface LinesMesh {
  20027. /**
  20028. * Enables the edge rendering mode on the mesh.
  20029. * This mode makes the mesh edges visible
  20030. * @param epsilon defines the maximal distance between two angles to detect a face
  20031. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20032. * @returns the currentAbstractMesh
  20033. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20034. */
  20035. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  20036. }
  20037. }
  20038. module "babylonjs/Meshes/linesMesh" {
  20039. interface InstancedLinesMesh {
  20040. /**
  20041. * Enables the edge rendering mode on the mesh.
  20042. * This mode makes the mesh edges visible
  20043. * @param epsilon defines the maximal distance between two angles to detect a face
  20044. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20045. * @returns the current InstancedLinesMesh
  20046. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20047. */
  20048. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  20049. }
  20050. }
  20051. /**
  20052. * Defines the minimum contract an Edges renderer should follow.
  20053. */
  20054. export interface IEdgesRenderer extends IDisposable {
  20055. /**
  20056. * Gets or sets a boolean indicating if the edgesRenderer is active
  20057. */
  20058. isEnabled: boolean;
  20059. /**
  20060. * Renders the edges of the attached mesh,
  20061. */
  20062. render(): void;
  20063. /**
  20064. * Checks wether or not the edges renderer is ready to render.
  20065. * @return true if ready, otherwise false.
  20066. */
  20067. isReady(): boolean;
  20068. }
  20069. /**
  20070. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  20071. */
  20072. export class EdgesRenderer implements IEdgesRenderer {
  20073. /**
  20074. * Define the size of the edges with an orthographic camera
  20075. */
  20076. edgesWidthScalerForOrthographic: number;
  20077. /**
  20078. * Define the size of the edges with a perspective camera
  20079. */
  20080. edgesWidthScalerForPerspective: number;
  20081. protected _source: AbstractMesh;
  20082. protected _linesPositions: number[];
  20083. protected _linesNormals: number[];
  20084. protected _linesIndices: number[];
  20085. protected _epsilon: number;
  20086. protected _indicesCount: number;
  20087. protected _lineShader: ShaderMaterial;
  20088. protected _ib: DataBuffer;
  20089. protected _buffers: {
  20090. [key: string]: Nullable<VertexBuffer>;
  20091. };
  20092. protected _checkVerticesInsteadOfIndices: boolean;
  20093. private _meshRebuildObserver;
  20094. private _meshDisposeObserver;
  20095. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  20096. isEnabled: boolean;
  20097. /**
  20098. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  20099. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  20100. * @param source Mesh used to create edges
  20101. * @param epsilon sum of angles in adjacency to check for edge
  20102. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  20103. * @param generateEdgesLines - should generate Lines or only prepare resources.
  20104. */
  20105. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  20106. protected _prepareRessources(): void;
  20107. /** @hidden */
  20108. _rebuild(): void;
  20109. /**
  20110. * Releases the required resources for the edges renderer
  20111. */
  20112. dispose(): void;
  20113. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  20114. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  20115. /**
  20116. * Checks if the pair of p0 and p1 is en edge
  20117. * @param faceIndex
  20118. * @param edge
  20119. * @param faceNormals
  20120. * @param p0
  20121. * @param p1
  20122. * @private
  20123. */
  20124. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  20125. /**
  20126. * push line into the position, normal and index buffer
  20127. * @protected
  20128. */
  20129. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  20130. /**
  20131. * Generates lines edges from adjacencjes
  20132. * @private
  20133. */
  20134. _generateEdgesLines(): void;
  20135. /**
  20136. * Checks wether or not the edges renderer is ready to render.
  20137. * @return true if ready, otherwise false.
  20138. */
  20139. isReady(): boolean;
  20140. /**
  20141. * Renders the edges of the attached mesh,
  20142. */
  20143. render(): void;
  20144. }
  20145. /**
  20146. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  20147. */
  20148. export class LineEdgesRenderer extends EdgesRenderer {
  20149. /**
  20150. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  20151. * @param source LineMesh used to generate edges
  20152. * @param epsilon not important (specified angle for edge detection)
  20153. * @param checkVerticesInsteadOfIndices not important for LineMesh
  20154. */
  20155. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  20156. /**
  20157. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  20158. */
  20159. _generateEdgesLines(): void;
  20160. }
  20161. }
  20162. declare module "babylonjs/Rendering/renderingGroup" {
  20163. import { SmartArray } from "babylonjs/Misc/smartArray";
  20164. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20165. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20166. import { Nullable } from "babylonjs/types";
  20167. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20168. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  20169. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20170. import { Material } from "babylonjs/Materials/material";
  20171. import { Scene } from "babylonjs/scene";
  20172. /**
  20173. * This represents the object necessary to create a rendering group.
  20174. * This is exclusively used and created by the rendering manager.
  20175. * To modify the behavior, you use the available helpers in your scene or meshes.
  20176. * @hidden
  20177. */
  20178. export class RenderingGroup {
  20179. index: number;
  20180. private static _zeroVector;
  20181. private _scene;
  20182. private _opaqueSubMeshes;
  20183. private _transparentSubMeshes;
  20184. private _alphaTestSubMeshes;
  20185. private _depthOnlySubMeshes;
  20186. private _particleSystems;
  20187. private _spriteManagers;
  20188. private _opaqueSortCompareFn;
  20189. private _alphaTestSortCompareFn;
  20190. private _transparentSortCompareFn;
  20191. private _renderOpaque;
  20192. private _renderAlphaTest;
  20193. private _renderTransparent;
  20194. /** @hidden */
  20195. _edgesRenderers: SmartArray<IEdgesRenderer>;
  20196. onBeforeTransparentRendering: () => void;
  20197. /**
  20198. * Set the opaque sort comparison function.
  20199. * If null the sub meshes will be render in the order they were created
  20200. */
  20201. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20202. /**
  20203. * Set the alpha test sort comparison function.
  20204. * If null the sub meshes will be render in the order they were created
  20205. */
  20206. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20207. /**
  20208. * Set the transparent sort comparison function.
  20209. * If null the sub meshes will be render in the order they were created
  20210. */
  20211. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20212. /**
  20213. * Creates a new rendering group.
  20214. * @param index The rendering group index
  20215. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  20216. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  20217. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  20218. */
  20219. 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>);
  20220. /**
  20221. * Render all the sub meshes contained in the group.
  20222. * @param customRenderFunction Used to override the default render behaviour of the group.
  20223. * @returns true if rendered some submeshes.
  20224. */
  20225. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  20226. /**
  20227. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  20228. * @param subMeshes The submeshes to render
  20229. */
  20230. private renderOpaqueSorted;
  20231. /**
  20232. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  20233. * @param subMeshes The submeshes to render
  20234. */
  20235. private renderAlphaTestSorted;
  20236. /**
  20237. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  20238. * @param subMeshes The submeshes to render
  20239. */
  20240. private renderTransparentSorted;
  20241. /**
  20242. * Renders the submeshes in a specified order.
  20243. * @param subMeshes The submeshes to sort before render
  20244. * @param sortCompareFn The comparison function use to sort
  20245. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  20246. * @param transparent Specifies to activate blending if true
  20247. */
  20248. private static renderSorted;
  20249. /**
  20250. * Renders the submeshes in the order they were dispatched (no sort applied).
  20251. * @param subMeshes The submeshes to render
  20252. */
  20253. private static renderUnsorted;
  20254. /**
  20255. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20256. * are rendered back to front if in the same alpha index.
  20257. *
  20258. * @param a The first submesh
  20259. * @param b The second submesh
  20260. * @returns The result of the comparison
  20261. */
  20262. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  20263. /**
  20264. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20265. * are rendered back to front.
  20266. *
  20267. * @param a The first submesh
  20268. * @param b The second submesh
  20269. * @returns The result of the comparison
  20270. */
  20271. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  20272. /**
  20273. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20274. * are rendered front to back (prevent overdraw).
  20275. *
  20276. * @param a The first submesh
  20277. * @param b The second submesh
  20278. * @returns The result of the comparison
  20279. */
  20280. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  20281. /**
  20282. * Resets the different lists of submeshes to prepare a new frame.
  20283. */
  20284. prepare(): void;
  20285. dispose(): void;
  20286. /**
  20287. * Inserts the submesh in its correct queue depending on its material.
  20288. * @param subMesh The submesh to dispatch
  20289. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20290. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20291. */
  20292. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20293. dispatchSprites(spriteManager: ISpriteManager): void;
  20294. dispatchParticles(particleSystem: IParticleSystem): void;
  20295. private _renderParticles;
  20296. private _renderSprites;
  20297. }
  20298. }
  20299. declare module "babylonjs/Rendering/renderingManager" {
  20300. import { Nullable } from "babylonjs/types";
  20301. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20302. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20303. import { SmartArray } from "babylonjs/Misc/smartArray";
  20304. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20305. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20306. import { Material } from "babylonjs/Materials/material";
  20307. import { Scene } from "babylonjs/scene";
  20308. import { Camera } from "babylonjs/Cameras/camera";
  20309. /**
  20310. * Interface describing the different options available in the rendering manager
  20311. * regarding Auto Clear between groups.
  20312. */
  20313. export interface IRenderingManagerAutoClearSetup {
  20314. /**
  20315. * Defines whether or not autoclear is enable.
  20316. */
  20317. autoClear: boolean;
  20318. /**
  20319. * Defines whether or not to autoclear the depth buffer.
  20320. */
  20321. depth: boolean;
  20322. /**
  20323. * Defines whether or not to autoclear the stencil buffer.
  20324. */
  20325. stencil: boolean;
  20326. }
  20327. /**
  20328. * This class is used by the onRenderingGroupObservable
  20329. */
  20330. export class RenderingGroupInfo {
  20331. /**
  20332. * The Scene that being rendered
  20333. */
  20334. scene: Scene;
  20335. /**
  20336. * The camera currently used for the rendering pass
  20337. */
  20338. camera: Nullable<Camera>;
  20339. /**
  20340. * The ID of the renderingGroup being processed
  20341. */
  20342. renderingGroupId: number;
  20343. }
  20344. /**
  20345. * This is the manager responsible of all the rendering for meshes sprites and particles.
  20346. * It is enable to manage the different groups as well as the different necessary sort functions.
  20347. * This should not be used directly aside of the few static configurations
  20348. */
  20349. export class RenderingManager {
  20350. /**
  20351. * The max id used for rendering groups (not included)
  20352. */
  20353. static MAX_RENDERINGGROUPS: number;
  20354. /**
  20355. * The min id used for rendering groups (included)
  20356. */
  20357. static MIN_RENDERINGGROUPS: number;
  20358. /**
  20359. * Used to globally prevent autoclearing scenes.
  20360. */
  20361. static AUTOCLEAR: boolean;
  20362. /**
  20363. * @hidden
  20364. */
  20365. _useSceneAutoClearSetup: boolean;
  20366. private _scene;
  20367. private _renderingGroups;
  20368. private _depthStencilBufferAlreadyCleaned;
  20369. private _autoClearDepthStencil;
  20370. private _customOpaqueSortCompareFn;
  20371. private _customAlphaTestSortCompareFn;
  20372. private _customTransparentSortCompareFn;
  20373. private _renderingGroupInfo;
  20374. /**
  20375. * Instantiates a new rendering group for a particular scene
  20376. * @param scene Defines the scene the groups belongs to
  20377. */
  20378. constructor(scene: Scene);
  20379. private _clearDepthStencilBuffer;
  20380. /**
  20381. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20382. * @hidden
  20383. */
  20384. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20385. /**
  20386. * Resets the different information of the group to prepare a new frame
  20387. * @hidden
  20388. */
  20389. reset(): void;
  20390. /**
  20391. * Dispose and release the group and its associated resources.
  20392. * @hidden
  20393. */
  20394. dispose(): void;
  20395. /**
  20396. * Clear the info related to rendering groups preventing retention points during dispose.
  20397. */
  20398. freeRenderingGroups(): void;
  20399. private _prepareRenderingGroup;
  20400. /**
  20401. * Add a sprite manager to the rendering manager in order to render it this frame.
  20402. * @param spriteManager Define the sprite manager to render
  20403. */
  20404. dispatchSprites(spriteManager: ISpriteManager): void;
  20405. /**
  20406. * Add a particle system to the rendering manager in order to render it this frame.
  20407. * @param particleSystem Define the particle system to render
  20408. */
  20409. dispatchParticles(particleSystem: IParticleSystem): void;
  20410. /**
  20411. * Add a submesh to the manager in order to render it this frame
  20412. * @param subMesh The submesh to dispatch
  20413. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20414. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20415. */
  20416. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20417. /**
  20418. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20419. * This allowed control for front to back rendering or reversly depending of the special needs.
  20420. *
  20421. * @param renderingGroupId The rendering group id corresponding to its index
  20422. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20423. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20424. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20425. */
  20426. 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;
  20427. /**
  20428. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20429. *
  20430. * @param renderingGroupId The rendering group id corresponding to its index
  20431. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20432. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20433. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20434. */
  20435. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20436. /**
  20437. * Gets the current auto clear configuration for one rendering group of the rendering
  20438. * manager.
  20439. * @param index the rendering group index to get the information for
  20440. * @returns The auto clear setup for the requested rendering group
  20441. */
  20442. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20443. }
  20444. }
  20445. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20446. import { Observable } from "babylonjs/Misc/observable";
  20447. import { SmartArray } from "babylonjs/Misc/smartArray";
  20448. import { Nullable } from "babylonjs/types";
  20449. import { Camera } from "babylonjs/Cameras/camera";
  20450. import { Scene } from "babylonjs/scene";
  20451. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20452. import { Color4 } from "babylonjs/Maths/math.color";
  20453. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20454. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20455. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20456. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20457. import { Texture } from "babylonjs/Materials/Textures/texture";
  20458. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20459. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20460. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20461. import { Engine } from "babylonjs/Engines/engine";
  20462. /**
  20463. * This Helps creating a texture that will be created from a camera in your scene.
  20464. * It is basically a dynamic texture that could be used to create special effects for instance.
  20465. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20466. */
  20467. export class RenderTargetTexture extends Texture {
  20468. isCube: boolean;
  20469. /**
  20470. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20471. */
  20472. static readonly REFRESHRATE_RENDER_ONCE: number;
  20473. /**
  20474. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20475. */
  20476. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20477. /**
  20478. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20479. * the central point of your effect and can save a lot of performances.
  20480. */
  20481. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20482. /**
  20483. * Use this predicate to dynamically define the list of mesh you want to render.
  20484. * If set, the renderList property will be overwritten.
  20485. */
  20486. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20487. private _renderList;
  20488. /**
  20489. * Use this list to define the list of mesh you want to render.
  20490. */
  20491. renderList: Nullable<Array<AbstractMesh>>;
  20492. private _hookArray;
  20493. /**
  20494. * Define if particles should be rendered in your texture.
  20495. */
  20496. renderParticles: boolean;
  20497. /**
  20498. * Define if sprites should be rendered in your texture.
  20499. */
  20500. renderSprites: boolean;
  20501. /**
  20502. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20503. */
  20504. coordinatesMode: number;
  20505. /**
  20506. * Define the camera used to render the texture.
  20507. */
  20508. activeCamera: Nullable<Camera>;
  20509. /**
  20510. * Override the render function of the texture with your own one.
  20511. */
  20512. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20513. /**
  20514. * Define if camera post processes should be use while rendering the texture.
  20515. */
  20516. useCameraPostProcesses: boolean;
  20517. /**
  20518. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20519. */
  20520. ignoreCameraViewport: boolean;
  20521. private _postProcessManager;
  20522. private _postProcesses;
  20523. private _resizeObserver;
  20524. /**
  20525. * An event triggered when the texture is unbind.
  20526. */
  20527. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20528. /**
  20529. * An event triggered when the texture is unbind.
  20530. */
  20531. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20532. private _onAfterUnbindObserver;
  20533. /**
  20534. * Set a after unbind callback in the texture.
  20535. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20536. */
  20537. onAfterUnbind: () => void;
  20538. /**
  20539. * An event triggered before rendering the texture
  20540. */
  20541. onBeforeRenderObservable: Observable<number>;
  20542. private _onBeforeRenderObserver;
  20543. /**
  20544. * Set a before render callback in the texture.
  20545. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20546. */
  20547. onBeforeRender: (faceIndex: number) => void;
  20548. /**
  20549. * An event triggered after rendering the texture
  20550. */
  20551. onAfterRenderObservable: Observable<number>;
  20552. private _onAfterRenderObserver;
  20553. /**
  20554. * Set a after render callback in the texture.
  20555. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20556. */
  20557. onAfterRender: (faceIndex: number) => void;
  20558. /**
  20559. * An event triggered after the texture clear
  20560. */
  20561. onClearObservable: Observable<Engine>;
  20562. private _onClearObserver;
  20563. /**
  20564. * Set a clear callback in the texture.
  20565. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20566. */
  20567. onClear: (Engine: Engine) => void;
  20568. /**
  20569. * An event triggered when the texture is resized.
  20570. */
  20571. onResizeObservable: Observable<RenderTargetTexture>;
  20572. /**
  20573. * Define the clear color of the Render Target if it should be different from the scene.
  20574. */
  20575. clearColor: Color4;
  20576. protected _size: number | {
  20577. width: number;
  20578. height: number;
  20579. };
  20580. protected _initialSizeParameter: number | {
  20581. width: number;
  20582. height: number;
  20583. } | {
  20584. ratio: number;
  20585. };
  20586. protected _sizeRatio: Nullable<number>;
  20587. /** @hidden */
  20588. _generateMipMaps: boolean;
  20589. protected _renderingManager: RenderingManager;
  20590. /** @hidden */
  20591. _waitingRenderList: string[];
  20592. protected _doNotChangeAspectRatio: boolean;
  20593. protected _currentRefreshId: number;
  20594. protected _refreshRate: number;
  20595. protected _textureMatrix: Matrix;
  20596. protected _samples: number;
  20597. protected _renderTargetOptions: RenderTargetCreationOptions;
  20598. /**
  20599. * Gets render target creation options that were used.
  20600. */
  20601. readonly renderTargetOptions: RenderTargetCreationOptions;
  20602. protected _engine: Engine;
  20603. protected _onRatioRescale(): void;
  20604. /**
  20605. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20606. * It must define where the camera used to render the texture is set
  20607. */
  20608. boundingBoxPosition: Vector3;
  20609. private _boundingBoxSize;
  20610. /**
  20611. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20612. * When defined, the cubemap will switch to local mode
  20613. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20614. * @example https://www.babylonjs-playground.com/#RNASML
  20615. */
  20616. boundingBoxSize: Vector3;
  20617. /**
  20618. * In case the RTT has been created with a depth texture, get the associated
  20619. * depth texture.
  20620. * Otherwise, return null.
  20621. */
  20622. depthStencilTexture: Nullable<InternalTexture>;
  20623. /**
  20624. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20625. * or used a shadow, depth texture...
  20626. * @param name The friendly name of the texture
  20627. * @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)
  20628. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20629. * @param generateMipMaps True if mip maps need to be generated after render.
  20630. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20631. * @param type The type of the buffer in the RTT (int, half float, float...)
  20632. * @param isCube True if a cube texture needs to be created
  20633. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20634. * @param generateDepthBuffer True to generate a depth buffer
  20635. * @param generateStencilBuffer True to generate a stencil buffer
  20636. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20637. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20638. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20639. */
  20640. constructor(name: string, size: number | {
  20641. width: number;
  20642. height: number;
  20643. } | {
  20644. ratio: number;
  20645. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20646. /**
  20647. * Creates a depth stencil texture.
  20648. * This is only available in WebGL 2 or with the depth texture extension available.
  20649. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20650. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20651. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20652. */
  20653. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20654. private _processSizeParameter;
  20655. /**
  20656. * Define the number of samples to use in case of MSAA.
  20657. * It defaults to one meaning no MSAA has been enabled.
  20658. */
  20659. samples: number;
  20660. /**
  20661. * Resets the refresh counter of the texture and start bak from scratch.
  20662. * Could be useful to regenerate the texture if it is setup to render only once.
  20663. */
  20664. resetRefreshCounter(): void;
  20665. /**
  20666. * Define the refresh rate of the texture or the rendering frequency.
  20667. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20668. */
  20669. refreshRate: number;
  20670. /**
  20671. * Adds a post process to the render target rendering passes.
  20672. * @param postProcess define the post process to add
  20673. */
  20674. addPostProcess(postProcess: PostProcess): void;
  20675. /**
  20676. * Clear all the post processes attached to the render target
  20677. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20678. */
  20679. clearPostProcesses(dispose?: boolean): void;
  20680. /**
  20681. * Remove one of the post process from the list of attached post processes to the texture
  20682. * @param postProcess define the post process to remove from the list
  20683. */
  20684. removePostProcess(postProcess: PostProcess): void;
  20685. /** @hidden */
  20686. _shouldRender(): boolean;
  20687. /**
  20688. * Gets the actual render size of the texture.
  20689. * @returns the width of the render size
  20690. */
  20691. getRenderSize(): number;
  20692. /**
  20693. * Gets the actual render width of the texture.
  20694. * @returns the width of the render size
  20695. */
  20696. getRenderWidth(): number;
  20697. /**
  20698. * Gets the actual render height of the texture.
  20699. * @returns the height of the render size
  20700. */
  20701. getRenderHeight(): number;
  20702. /**
  20703. * Get if the texture can be rescaled or not.
  20704. */
  20705. readonly canRescale: boolean;
  20706. /**
  20707. * Resize the texture using a ratio.
  20708. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20709. */
  20710. scale(ratio: number): void;
  20711. /**
  20712. * Get the texture reflection matrix used to rotate/transform the reflection.
  20713. * @returns the reflection matrix
  20714. */
  20715. getReflectionTextureMatrix(): Matrix;
  20716. /**
  20717. * Resize the texture to a new desired size.
  20718. * Be carrefull as it will recreate all the data in the new texture.
  20719. * @param size Define the new size. It can be:
  20720. * - a number for squared texture,
  20721. * - an object containing { width: number, height: number }
  20722. * - or an object containing a ratio { ratio: number }
  20723. */
  20724. resize(size: number | {
  20725. width: number;
  20726. height: number;
  20727. } | {
  20728. ratio: number;
  20729. }): void;
  20730. /**
  20731. * Renders all the objects from the render list into the texture.
  20732. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20733. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20734. */
  20735. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20736. private _bestReflectionRenderTargetDimension;
  20737. /**
  20738. * @hidden
  20739. * @param faceIndex face index to bind to if this is a cubetexture
  20740. */
  20741. _bindFrameBuffer(faceIndex?: number): void;
  20742. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20743. private renderToTarget;
  20744. /**
  20745. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20746. * This allowed control for front to back rendering or reversly depending of the special needs.
  20747. *
  20748. * @param renderingGroupId The rendering group id corresponding to its index
  20749. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20750. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20751. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20752. */
  20753. 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;
  20754. /**
  20755. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20756. *
  20757. * @param renderingGroupId The rendering group id corresponding to its index
  20758. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20759. */
  20760. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20761. /**
  20762. * Clones the texture.
  20763. * @returns the cloned texture
  20764. */
  20765. clone(): RenderTargetTexture;
  20766. /**
  20767. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20768. * @returns The JSON representation of the texture
  20769. */
  20770. serialize(): any;
  20771. /**
  20772. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20773. */
  20774. disposeFramebufferObjects(): void;
  20775. /**
  20776. * Dispose the texture and release its associated resources.
  20777. */
  20778. dispose(): void;
  20779. /** @hidden */
  20780. _rebuild(): void;
  20781. /**
  20782. * Clear the info related to rendering groups preventing retention point in material dispose.
  20783. */
  20784. freeRenderingGroups(): void;
  20785. /**
  20786. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20787. * @returns the view count
  20788. */
  20789. getViewCount(): number;
  20790. }
  20791. }
  20792. declare module "babylonjs/Materials/material" {
  20793. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20794. import { SmartArray } from "babylonjs/Misc/smartArray";
  20795. import { Observable } from "babylonjs/Misc/observable";
  20796. import { Nullable } from "babylonjs/types";
  20797. import { Scene } from "babylonjs/scene";
  20798. import { Matrix } from "babylonjs/Maths/math.vector";
  20799. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  20800. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20801. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20802. import { Effect } from "babylonjs/Materials/effect";
  20803. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20804. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20805. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20806. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20807. import { Mesh } from "babylonjs/Meshes/mesh";
  20808. import { Animation } from "babylonjs/Animations/animation";
  20809. /**
  20810. * Base class for the main features of a material in Babylon.js
  20811. */
  20812. export class Material implements IAnimatable {
  20813. /**
  20814. * Returns the triangle fill mode
  20815. */
  20816. static readonly TriangleFillMode: number;
  20817. /**
  20818. * Returns the wireframe mode
  20819. */
  20820. static readonly WireFrameFillMode: number;
  20821. /**
  20822. * Returns the point fill mode
  20823. */
  20824. static readonly PointFillMode: number;
  20825. /**
  20826. * Returns the point list draw mode
  20827. */
  20828. static readonly PointListDrawMode: number;
  20829. /**
  20830. * Returns the line list draw mode
  20831. */
  20832. static readonly LineListDrawMode: number;
  20833. /**
  20834. * Returns the line loop draw mode
  20835. */
  20836. static readonly LineLoopDrawMode: number;
  20837. /**
  20838. * Returns the line strip draw mode
  20839. */
  20840. static readonly LineStripDrawMode: number;
  20841. /**
  20842. * Returns the triangle strip draw mode
  20843. */
  20844. static readonly TriangleStripDrawMode: number;
  20845. /**
  20846. * Returns the triangle fan draw mode
  20847. */
  20848. static readonly TriangleFanDrawMode: number;
  20849. /**
  20850. * Stores the clock-wise side orientation
  20851. */
  20852. static readonly ClockWiseSideOrientation: number;
  20853. /**
  20854. * Stores the counter clock-wise side orientation
  20855. */
  20856. static readonly CounterClockWiseSideOrientation: number;
  20857. /**
  20858. * The dirty texture flag value
  20859. */
  20860. static readonly TextureDirtyFlag: number;
  20861. /**
  20862. * The dirty light flag value
  20863. */
  20864. static readonly LightDirtyFlag: number;
  20865. /**
  20866. * The dirty fresnel flag value
  20867. */
  20868. static readonly FresnelDirtyFlag: number;
  20869. /**
  20870. * The dirty attribute flag value
  20871. */
  20872. static readonly AttributesDirtyFlag: number;
  20873. /**
  20874. * The dirty misc flag value
  20875. */
  20876. static readonly MiscDirtyFlag: number;
  20877. /**
  20878. * The all dirty flag value
  20879. */
  20880. static readonly AllDirtyFlag: number;
  20881. /**
  20882. * The ID of the material
  20883. */
  20884. id: string;
  20885. /**
  20886. * Gets or sets the unique id of the material
  20887. */
  20888. uniqueId: number;
  20889. /**
  20890. * The name of the material
  20891. */
  20892. name: string;
  20893. /**
  20894. * Gets or sets user defined metadata
  20895. */
  20896. metadata: any;
  20897. /**
  20898. * For internal use only. Please do not use.
  20899. */
  20900. reservedDataStore: any;
  20901. /**
  20902. * Specifies if the ready state should be checked on each call
  20903. */
  20904. checkReadyOnEveryCall: boolean;
  20905. /**
  20906. * Specifies if the ready state should be checked once
  20907. */
  20908. checkReadyOnlyOnce: boolean;
  20909. /**
  20910. * The state of the material
  20911. */
  20912. state: string;
  20913. /**
  20914. * The alpha value of the material
  20915. */
  20916. protected _alpha: number;
  20917. /**
  20918. * List of inspectable custom properties (used by the Inspector)
  20919. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20920. */
  20921. inspectableCustomProperties: IInspectable[];
  20922. /**
  20923. * Sets the alpha value of the material
  20924. */
  20925. /**
  20926. * Gets the alpha value of the material
  20927. */
  20928. alpha: number;
  20929. /**
  20930. * Specifies if back face culling is enabled
  20931. */
  20932. protected _backFaceCulling: boolean;
  20933. /**
  20934. * Sets the back-face culling state
  20935. */
  20936. /**
  20937. * Gets the back-face culling state
  20938. */
  20939. backFaceCulling: boolean;
  20940. /**
  20941. * Stores the value for side orientation
  20942. */
  20943. sideOrientation: number;
  20944. /**
  20945. * Callback triggered when the material is compiled
  20946. */
  20947. onCompiled: Nullable<(effect: Effect) => void>;
  20948. /**
  20949. * Callback triggered when an error occurs
  20950. */
  20951. onError: Nullable<(effect: Effect, errors: string) => void>;
  20952. /**
  20953. * Callback triggered to get the render target textures
  20954. */
  20955. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20956. /**
  20957. * Gets a boolean indicating that current material needs to register RTT
  20958. */
  20959. readonly hasRenderTargetTextures: boolean;
  20960. /**
  20961. * Specifies if the material should be serialized
  20962. */
  20963. doNotSerialize: boolean;
  20964. /**
  20965. * @hidden
  20966. */
  20967. _storeEffectOnSubMeshes: boolean;
  20968. /**
  20969. * Stores the animations for the material
  20970. */
  20971. animations: Nullable<Array<Animation>>;
  20972. /**
  20973. * An event triggered when the material is disposed
  20974. */
  20975. onDisposeObservable: Observable<Material>;
  20976. /**
  20977. * An observer which watches for dispose events
  20978. */
  20979. private _onDisposeObserver;
  20980. private _onUnBindObservable;
  20981. /**
  20982. * Called during a dispose event
  20983. */
  20984. onDispose: () => void;
  20985. private _onBindObservable;
  20986. /**
  20987. * An event triggered when the material is bound
  20988. */
  20989. readonly onBindObservable: Observable<AbstractMesh>;
  20990. /**
  20991. * An observer which watches for bind events
  20992. */
  20993. private _onBindObserver;
  20994. /**
  20995. * Called during a bind event
  20996. */
  20997. onBind: (Mesh: AbstractMesh) => void;
  20998. /**
  20999. * An event triggered when the material is unbound
  21000. */
  21001. readonly onUnBindObservable: Observable<Material>;
  21002. /**
  21003. * Stores the value of the alpha mode
  21004. */
  21005. private _alphaMode;
  21006. /**
  21007. * Sets the value of the alpha mode.
  21008. *
  21009. * | Value | Type | Description |
  21010. * | --- | --- | --- |
  21011. * | 0 | ALPHA_DISABLE | |
  21012. * | 1 | ALPHA_ADD | |
  21013. * | 2 | ALPHA_COMBINE | |
  21014. * | 3 | ALPHA_SUBTRACT | |
  21015. * | 4 | ALPHA_MULTIPLY | |
  21016. * | 5 | ALPHA_MAXIMIZED | |
  21017. * | 6 | ALPHA_ONEONE | |
  21018. * | 7 | ALPHA_PREMULTIPLIED | |
  21019. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21020. * | 9 | ALPHA_INTERPOLATE | |
  21021. * | 10 | ALPHA_SCREENMODE | |
  21022. *
  21023. */
  21024. /**
  21025. * Gets the value of the alpha mode
  21026. */
  21027. alphaMode: number;
  21028. /**
  21029. * Stores the state of the need depth pre-pass value
  21030. */
  21031. private _needDepthPrePass;
  21032. /**
  21033. * Sets the need depth pre-pass value
  21034. */
  21035. /**
  21036. * Gets the depth pre-pass value
  21037. */
  21038. needDepthPrePass: boolean;
  21039. /**
  21040. * Specifies if depth writing should be disabled
  21041. */
  21042. disableDepthWrite: boolean;
  21043. /**
  21044. * Specifies if depth writing should be forced
  21045. */
  21046. forceDepthWrite: boolean;
  21047. /**
  21048. * Specifies if there should be a separate pass for culling
  21049. */
  21050. separateCullingPass: boolean;
  21051. /**
  21052. * Stores the state specifing if fog should be enabled
  21053. */
  21054. private _fogEnabled;
  21055. /**
  21056. * Sets the state for enabling fog
  21057. */
  21058. /**
  21059. * Gets the value of the fog enabled state
  21060. */
  21061. fogEnabled: boolean;
  21062. /**
  21063. * Stores the size of points
  21064. */
  21065. pointSize: number;
  21066. /**
  21067. * Stores the z offset value
  21068. */
  21069. zOffset: number;
  21070. /**
  21071. * Gets a value specifying if wireframe mode is enabled
  21072. */
  21073. /**
  21074. * Sets the state of wireframe mode
  21075. */
  21076. wireframe: boolean;
  21077. /**
  21078. * Gets the value specifying if point clouds are enabled
  21079. */
  21080. /**
  21081. * Sets the state of point cloud mode
  21082. */
  21083. pointsCloud: boolean;
  21084. /**
  21085. * Gets the material fill mode
  21086. */
  21087. /**
  21088. * Sets the material fill mode
  21089. */
  21090. fillMode: number;
  21091. /**
  21092. * @hidden
  21093. * Stores the effects for the material
  21094. */
  21095. _effect: Nullable<Effect>;
  21096. /**
  21097. * @hidden
  21098. * Specifies if the material was previously ready
  21099. */
  21100. _wasPreviouslyReady: boolean;
  21101. /**
  21102. * Specifies if uniform buffers should be used
  21103. */
  21104. private _useUBO;
  21105. /**
  21106. * Stores a reference to the scene
  21107. */
  21108. private _scene;
  21109. /**
  21110. * Stores the fill mode state
  21111. */
  21112. private _fillMode;
  21113. /**
  21114. * Specifies if the depth write state should be cached
  21115. */
  21116. private _cachedDepthWriteState;
  21117. /**
  21118. * Stores the uniform buffer
  21119. */
  21120. protected _uniformBuffer: UniformBuffer;
  21121. /** @hidden */
  21122. _indexInSceneMaterialArray: number;
  21123. /** @hidden */
  21124. meshMap: Nullable<{
  21125. [id: string]: AbstractMesh | undefined;
  21126. }>;
  21127. /**
  21128. * Creates a material instance
  21129. * @param name defines the name of the material
  21130. * @param scene defines the scene to reference
  21131. * @param doNotAdd specifies if the material should be added to the scene
  21132. */
  21133. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21134. /**
  21135. * Returns a string representation of the current material
  21136. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21137. * @returns a string with material information
  21138. */
  21139. toString(fullDetails?: boolean): string;
  21140. /**
  21141. * Gets the class name of the material
  21142. * @returns a string with the class name of the material
  21143. */
  21144. getClassName(): string;
  21145. /**
  21146. * Specifies if updates for the material been locked
  21147. */
  21148. readonly isFrozen: boolean;
  21149. /**
  21150. * Locks updates for the material
  21151. */
  21152. freeze(): void;
  21153. /**
  21154. * Unlocks updates for the material
  21155. */
  21156. unfreeze(): void;
  21157. /**
  21158. * Specifies if the material is ready to be used
  21159. * @param mesh defines the mesh to check
  21160. * @param useInstances specifies if instances should be used
  21161. * @returns a boolean indicating if the material is ready to be used
  21162. */
  21163. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21164. /**
  21165. * Specifies that the submesh is ready to be used
  21166. * @param mesh defines the mesh to check
  21167. * @param subMesh defines which submesh to check
  21168. * @param useInstances specifies that instances should be used
  21169. * @returns a boolean indicating that the submesh is ready or not
  21170. */
  21171. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21172. /**
  21173. * Returns the material effect
  21174. * @returns the effect associated with the material
  21175. */
  21176. getEffect(): Nullable<Effect>;
  21177. /**
  21178. * Returns the current scene
  21179. * @returns a Scene
  21180. */
  21181. getScene(): Scene;
  21182. /**
  21183. * Specifies if the material will require alpha blending
  21184. * @returns a boolean specifying if alpha blending is needed
  21185. */
  21186. needAlphaBlending(): boolean;
  21187. /**
  21188. * Specifies if the mesh will require alpha blending
  21189. * @param mesh defines the mesh to check
  21190. * @returns a boolean specifying if alpha blending is needed for the mesh
  21191. */
  21192. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21193. /**
  21194. * Specifies if this material should be rendered in alpha test mode
  21195. * @returns a boolean specifying if an alpha test is needed.
  21196. */
  21197. needAlphaTesting(): boolean;
  21198. /**
  21199. * Gets the texture used for the alpha test
  21200. * @returns the texture to use for alpha testing
  21201. */
  21202. getAlphaTestTexture(): Nullable<BaseTexture>;
  21203. /**
  21204. * Marks the material to indicate that it needs to be re-calculated
  21205. */
  21206. markDirty(): void;
  21207. /** @hidden */
  21208. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21209. /**
  21210. * Binds the material to the mesh
  21211. * @param world defines the world transformation matrix
  21212. * @param mesh defines the mesh to bind the material to
  21213. */
  21214. bind(world: Matrix, mesh?: Mesh): void;
  21215. /**
  21216. * Binds the submesh to the material
  21217. * @param world defines the world transformation matrix
  21218. * @param mesh defines the mesh containing the submesh
  21219. * @param subMesh defines the submesh to bind the material to
  21220. */
  21221. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21222. /**
  21223. * Binds the world matrix to the material
  21224. * @param world defines the world transformation matrix
  21225. */
  21226. bindOnlyWorldMatrix(world: Matrix): void;
  21227. /**
  21228. * Binds the scene's uniform buffer to the effect.
  21229. * @param effect defines the effect to bind to the scene uniform buffer
  21230. * @param sceneUbo defines the uniform buffer storing scene data
  21231. */
  21232. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21233. /**
  21234. * Binds the view matrix to the effect
  21235. * @param effect defines the effect to bind the view matrix to
  21236. */
  21237. bindView(effect: Effect): void;
  21238. /**
  21239. * Binds the view projection matrix to the effect
  21240. * @param effect defines the effect to bind the view projection matrix to
  21241. */
  21242. bindViewProjection(effect: Effect): void;
  21243. /**
  21244. * Specifies if material alpha testing should be turned on for the mesh
  21245. * @param mesh defines the mesh to check
  21246. */
  21247. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21248. /**
  21249. * Processes to execute after binding the material to a mesh
  21250. * @param mesh defines the rendered mesh
  21251. */
  21252. protected _afterBind(mesh?: Mesh): void;
  21253. /**
  21254. * Unbinds the material from the mesh
  21255. */
  21256. unbind(): void;
  21257. /**
  21258. * Gets the active textures from the material
  21259. * @returns an array of textures
  21260. */
  21261. getActiveTextures(): BaseTexture[];
  21262. /**
  21263. * Specifies if the material uses a texture
  21264. * @param texture defines the texture to check against the material
  21265. * @returns a boolean specifying if the material uses the texture
  21266. */
  21267. hasTexture(texture: BaseTexture): boolean;
  21268. /**
  21269. * Makes a duplicate of the material, and gives it a new name
  21270. * @param name defines the new name for the duplicated material
  21271. * @returns the cloned material
  21272. */
  21273. clone(name: string): Nullable<Material>;
  21274. /**
  21275. * Gets the meshes bound to the material
  21276. * @returns an array of meshes bound to the material
  21277. */
  21278. getBindedMeshes(): AbstractMesh[];
  21279. /**
  21280. * Force shader compilation
  21281. * @param mesh defines the mesh associated with this material
  21282. * @param onCompiled defines a function to execute once the material is compiled
  21283. * @param options defines the options to configure the compilation
  21284. */
  21285. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  21286. clipPlane: boolean;
  21287. }>): void;
  21288. /**
  21289. * Force shader compilation
  21290. * @param mesh defines the mesh that will use this material
  21291. * @param options defines additional options for compiling the shaders
  21292. * @returns a promise that resolves when the compilation completes
  21293. */
  21294. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  21295. clipPlane: boolean;
  21296. }>): Promise<void>;
  21297. private static readonly _AllDirtyCallBack;
  21298. private static readonly _ImageProcessingDirtyCallBack;
  21299. private static readonly _TextureDirtyCallBack;
  21300. private static readonly _FresnelDirtyCallBack;
  21301. private static readonly _MiscDirtyCallBack;
  21302. private static readonly _LightsDirtyCallBack;
  21303. private static readonly _AttributeDirtyCallBack;
  21304. private static _FresnelAndMiscDirtyCallBack;
  21305. private static _TextureAndMiscDirtyCallBack;
  21306. private static readonly _DirtyCallbackArray;
  21307. private static readonly _RunDirtyCallBacks;
  21308. /**
  21309. * Marks a define in the material to indicate that it needs to be re-computed
  21310. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21311. */
  21312. markAsDirty(flag: number): void;
  21313. /**
  21314. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21315. * @param func defines a function which checks material defines against the submeshes
  21316. */
  21317. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21318. /**
  21319. * Indicates that we need to re-calculated for all submeshes
  21320. */
  21321. protected _markAllSubMeshesAsAllDirty(): void;
  21322. /**
  21323. * Indicates that image processing needs to be re-calculated for all submeshes
  21324. */
  21325. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21326. /**
  21327. * Indicates that textures need to be re-calculated for all submeshes
  21328. */
  21329. protected _markAllSubMeshesAsTexturesDirty(): void;
  21330. /**
  21331. * Indicates that fresnel needs to be re-calculated for all submeshes
  21332. */
  21333. protected _markAllSubMeshesAsFresnelDirty(): void;
  21334. /**
  21335. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21336. */
  21337. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21338. /**
  21339. * Indicates that lights need to be re-calculated for all submeshes
  21340. */
  21341. protected _markAllSubMeshesAsLightsDirty(): void;
  21342. /**
  21343. * Indicates that attributes need to be re-calculated for all submeshes
  21344. */
  21345. protected _markAllSubMeshesAsAttributesDirty(): void;
  21346. /**
  21347. * Indicates that misc needs to be re-calculated for all submeshes
  21348. */
  21349. protected _markAllSubMeshesAsMiscDirty(): void;
  21350. /**
  21351. * Indicates that textures and misc need to be re-calculated for all submeshes
  21352. */
  21353. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21354. /**
  21355. * Disposes the material
  21356. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21357. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21358. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21359. */
  21360. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21361. /** @hidden */
  21362. private releaseVertexArrayObject;
  21363. /**
  21364. * Serializes this material
  21365. * @returns the serialized material object
  21366. */
  21367. serialize(): any;
  21368. /**
  21369. * Creates a material from parsed material data
  21370. * @param parsedMaterial defines parsed material data
  21371. * @param scene defines the hosting scene
  21372. * @param rootUrl defines the root URL to use to load textures
  21373. * @returns a new material
  21374. */
  21375. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21376. }
  21377. }
  21378. declare module "babylonjs/Materials/multiMaterial" {
  21379. import { Nullable } from "babylonjs/types";
  21380. import { Scene } from "babylonjs/scene";
  21381. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21382. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21383. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21384. import { Material } from "babylonjs/Materials/material";
  21385. /**
  21386. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21387. * separate meshes. This can be use to improve performances.
  21388. * @see http://doc.babylonjs.com/how_to/multi_materials
  21389. */
  21390. export class MultiMaterial extends Material {
  21391. private _subMaterials;
  21392. /**
  21393. * Gets or Sets the list of Materials used within the multi material.
  21394. * They need to be ordered according to the submeshes order in the associated mesh
  21395. */
  21396. subMaterials: Nullable<Material>[];
  21397. /**
  21398. * Function used to align with Node.getChildren()
  21399. * @returns the list of Materials used within the multi material
  21400. */
  21401. getChildren(): Nullable<Material>[];
  21402. /**
  21403. * Instantiates a new Multi Material
  21404. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21405. * separate meshes. This can be use to improve performances.
  21406. * @see http://doc.babylonjs.com/how_to/multi_materials
  21407. * @param name Define the name in the scene
  21408. * @param scene Define the scene the material belongs to
  21409. */
  21410. constructor(name: string, scene: Scene);
  21411. private _hookArray;
  21412. /**
  21413. * Get one of the submaterial by its index in the submaterials array
  21414. * @param index The index to look the sub material at
  21415. * @returns The Material if the index has been defined
  21416. */
  21417. getSubMaterial(index: number): Nullable<Material>;
  21418. /**
  21419. * Get the list of active textures for the whole sub materials list.
  21420. * @returns All the textures that will be used during the rendering
  21421. */
  21422. getActiveTextures(): BaseTexture[];
  21423. /**
  21424. * Gets the current class name of the material e.g. "MultiMaterial"
  21425. * Mainly use in serialization.
  21426. * @returns the class name
  21427. */
  21428. getClassName(): string;
  21429. /**
  21430. * Checks if the material is ready to render the requested sub mesh
  21431. * @param mesh Define the mesh the submesh belongs to
  21432. * @param subMesh Define the sub mesh to look readyness for
  21433. * @param useInstances Define whether or not the material is used with instances
  21434. * @returns true if ready, otherwise false
  21435. */
  21436. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21437. /**
  21438. * Clones the current material and its related sub materials
  21439. * @param name Define the name of the newly cloned material
  21440. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21441. * @returns the cloned material
  21442. */
  21443. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21444. /**
  21445. * Serializes the materials into a JSON representation.
  21446. * @returns the JSON representation
  21447. */
  21448. serialize(): any;
  21449. /**
  21450. * Dispose the material and release its associated resources
  21451. * @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)
  21452. * @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)
  21453. * @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)
  21454. */
  21455. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21456. /**
  21457. * Creates a MultiMaterial from parsed MultiMaterial data.
  21458. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21459. * @param scene defines the hosting scene
  21460. * @returns a new MultiMaterial
  21461. */
  21462. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21463. }
  21464. }
  21465. declare module "babylonjs/Meshes/subMesh" {
  21466. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21467. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21468. import { Engine } from "babylonjs/Engines/engine";
  21469. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21470. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21471. import { Effect } from "babylonjs/Materials/effect";
  21472. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21473. import { Plane } from "babylonjs/Maths/math.plane";
  21474. import { Collider } from "babylonjs/Collisions/collider";
  21475. import { Material } from "babylonjs/Materials/material";
  21476. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21477. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21478. import { Mesh } from "babylonjs/Meshes/mesh";
  21479. import { Ray } from "babylonjs/Culling/ray";
  21480. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  21481. /**
  21482. * Base class for submeshes
  21483. */
  21484. export class BaseSubMesh {
  21485. /** @hidden */
  21486. _materialDefines: Nullable<MaterialDefines>;
  21487. /** @hidden */
  21488. _materialEffect: Nullable<Effect>;
  21489. /**
  21490. * Gets associated effect
  21491. */
  21492. readonly effect: Nullable<Effect>;
  21493. /**
  21494. * Sets associated effect (effect used to render this submesh)
  21495. * @param effect defines the effect to associate with
  21496. * @param defines defines the set of defines used to compile this effect
  21497. */
  21498. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21499. }
  21500. /**
  21501. * Defines a subdivision inside a mesh
  21502. */
  21503. export class SubMesh extends BaseSubMesh implements ICullable {
  21504. /** the material index to use */
  21505. materialIndex: number;
  21506. /** vertex index start */
  21507. verticesStart: number;
  21508. /** vertices count */
  21509. verticesCount: number;
  21510. /** index start */
  21511. indexStart: number;
  21512. /** indices count */
  21513. indexCount: number;
  21514. /** @hidden */
  21515. _linesIndexCount: number;
  21516. private _mesh;
  21517. private _renderingMesh;
  21518. private _boundingInfo;
  21519. private _linesIndexBuffer;
  21520. /** @hidden */
  21521. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21522. /** @hidden */
  21523. _trianglePlanes: Plane[];
  21524. /** @hidden */
  21525. _lastColliderTransformMatrix: Nullable<Matrix>;
  21526. /** @hidden */
  21527. _renderId: number;
  21528. /** @hidden */
  21529. _alphaIndex: number;
  21530. /** @hidden */
  21531. _distanceToCamera: number;
  21532. /** @hidden */
  21533. _id: number;
  21534. private _currentMaterial;
  21535. /**
  21536. * Add a new submesh to a mesh
  21537. * @param materialIndex defines the material index to use
  21538. * @param verticesStart defines vertex index start
  21539. * @param verticesCount defines vertices count
  21540. * @param indexStart defines index start
  21541. * @param indexCount defines indices count
  21542. * @param mesh defines the parent mesh
  21543. * @param renderingMesh defines an optional rendering mesh
  21544. * @param createBoundingBox defines if bounding box should be created for this submesh
  21545. * @returns the new submesh
  21546. */
  21547. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21548. /**
  21549. * Creates a new submesh
  21550. * @param materialIndex defines the material index to use
  21551. * @param verticesStart defines vertex index start
  21552. * @param verticesCount defines vertices count
  21553. * @param indexStart defines index start
  21554. * @param indexCount defines indices count
  21555. * @param mesh defines the parent mesh
  21556. * @param renderingMesh defines an optional rendering mesh
  21557. * @param createBoundingBox defines if bounding box should be created for this submesh
  21558. */
  21559. constructor(
  21560. /** the material index to use */
  21561. materialIndex: number,
  21562. /** vertex index start */
  21563. verticesStart: number,
  21564. /** vertices count */
  21565. verticesCount: number,
  21566. /** index start */
  21567. indexStart: number,
  21568. /** indices count */
  21569. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21570. /**
  21571. * Returns true if this submesh covers the entire parent mesh
  21572. * @ignorenaming
  21573. */
  21574. readonly IsGlobal: boolean;
  21575. /**
  21576. * Returns the submesh BoudingInfo object
  21577. * @returns current bounding info (or mesh's one if the submesh is global)
  21578. */
  21579. getBoundingInfo(): BoundingInfo;
  21580. /**
  21581. * Sets the submesh BoundingInfo
  21582. * @param boundingInfo defines the new bounding info to use
  21583. * @returns the SubMesh
  21584. */
  21585. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21586. /**
  21587. * Returns the mesh of the current submesh
  21588. * @return the parent mesh
  21589. */
  21590. getMesh(): AbstractMesh;
  21591. /**
  21592. * Returns the rendering mesh of the submesh
  21593. * @returns the rendering mesh (could be different from parent mesh)
  21594. */
  21595. getRenderingMesh(): Mesh;
  21596. /**
  21597. * Returns the submesh material
  21598. * @returns null or the current material
  21599. */
  21600. getMaterial(): Nullable<Material>;
  21601. /**
  21602. * Sets a new updated BoundingInfo object to the submesh
  21603. * @param data defines an optional position array to use to determine the bounding info
  21604. * @returns the SubMesh
  21605. */
  21606. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21607. /** @hidden */
  21608. _checkCollision(collider: Collider): boolean;
  21609. /**
  21610. * Updates the submesh BoundingInfo
  21611. * @param world defines the world matrix to use to update the bounding info
  21612. * @returns the submesh
  21613. */
  21614. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21615. /**
  21616. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21617. * @param frustumPlanes defines the frustum planes
  21618. * @returns true if the submesh is intersecting with the frustum
  21619. */
  21620. isInFrustum(frustumPlanes: Plane[]): boolean;
  21621. /**
  21622. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21623. * @param frustumPlanes defines the frustum planes
  21624. * @returns true if the submesh is inside the frustum
  21625. */
  21626. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21627. /**
  21628. * Renders the submesh
  21629. * @param enableAlphaMode defines if alpha needs to be used
  21630. * @returns the submesh
  21631. */
  21632. render(enableAlphaMode: boolean): SubMesh;
  21633. /**
  21634. * @hidden
  21635. */
  21636. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21637. /**
  21638. * Checks if the submesh intersects with a ray
  21639. * @param ray defines the ray to test
  21640. * @returns true is the passed ray intersects the submesh bounding box
  21641. */
  21642. canIntersects(ray: Ray): boolean;
  21643. /**
  21644. * Intersects current submesh with a ray
  21645. * @param ray defines the ray to test
  21646. * @param positions defines mesh's positions array
  21647. * @param indices defines mesh's indices array
  21648. * @param fastCheck defines if only bounding info should be used
  21649. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21650. * @returns intersection info or null if no intersection
  21651. */
  21652. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21653. /** @hidden */
  21654. private _intersectLines;
  21655. /** @hidden */
  21656. private _intersectUnIndexedLines;
  21657. /** @hidden */
  21658. private _intersectTriangles;
  21659. /** @hidden */
  21660. private _intersectUnIndexedTriangles;
  21661. /** @hidden */
  21662. _rebuild(): void;
  21663. /**
  21664. * Creates a new submesh from the passed mesh
  21665. * @param newMesh defines the new hosting mesh
  21666. * @param newRenderingMesh defines an optional rendering mesh
  21667. * @returns the new submesh
  21668. */
  21669. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21670. /**
  21671. * Release associated resources
  21672. */
  21673. dispose(): void;
  21674. /**
  21675. * Gets the class name
  21676. * @returns the string "SubMesh".
  21677. */
  21678. getClassName(): string;
  21679. /**
  21680. * Creates a new submesh from indices data
  21681. * @param materialIndex the index of the main mesh material
  21682. * @param startIndex the index where to start the copy in the mesh indices array
  21683. * @param indexCount the number of indices to copy then from the startIndex
  21684. * @param mesh the main mesh to create the submesh from
  21685. * @param renderingMesh the optional rendering mesh
  21686. * @returns a new submesh
  21687. */
  21688. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21689. }
  21690. }
  21691. declare module "babylonjs/Loading/sceneLoaderFlags" {
  21692. /**
  21693. * Class used to represent data loading progression
  21694. */
  21695. export class SceneLoaderFlags {
  21696. private static _ForceFullSceneLoadingForIncremental;
  21697. private static _ShowLoadingScreen;
  21698. private static _CleanBoneMatrixWeights;
  21699. private static _loggingLevel;
  21700. /**
  21701. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21702. */
  21703. static ForceFullSceneLoadingForIncremental: boolean;
  21704. /**
  21705. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21706. */
  21707. static ShowLoadingScreen: boolean;
  21708. /**
  21709. * Defines the current logging level (while loading the scene)
  21710. * @ignorenaming
  21711. */
  21712. static loggingLevel: number;
  21713. /**
  21714. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21715. */
  21716. static CleanBoneMatrixWeights: boolean;
  21717. }
  21718. }
  21719. declare module "babylonjs/Meshes/geometry" {
  21720. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  21721. import { Scene } from "babylonjs/scene";
  21722. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  21723. import { Engine } from "babylonjs/Engines/engine";
  21724. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  21725. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21726. import { Effect } from "babylonjs/Materials/effect";
  21727. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21728. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21729. import { Mesh } from "babylonjs/Meshes/mesh";
  21730. /**
  21731. * Class used to store geometry data (vertex buffers + index buffer)
  21732. */
  21733. export class Geometry implements IGetSetVerticesData {
  21734. /**
  21735. * Gets or sets the ID of the geometry
  21736. */
  21737. id: string;
  21738. /**
  21739. * Gets or sets the unique ID of the geometry
  21740. */
  21741. uniqueId: number;
  21742. /**
  21743. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21744. */
  21745. delayLoadState: number;
  21746. /**
  21747. * Gets the file containing the data to load when running in delay load state
  21748. */
  21749. delayLoadingFile: Nullable<string>;
  21750. /**
  21751. * Callback called when the geometry is updated
  21752. */
  21753. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21754. private _scene;
  21755. private _engine;
  21756. private _meshes;
  21757. private _totalVertices;
  21758. /** @hidden */
  21759. _indices: IndicesArray;
  21760. /** @hidden */
  21761. _vertexBuffers: {
  21762. [key: string]: VertexBuffer;
  21763. };
  21764. private _isDisposed;
  21765. private _extend;
  21766. private _boundingBias;
  21767. /** @hidden */
  21768. _delayInfo: Array<string>;
  21769. private _indexBuffer;
  21770. private _indexBufferIsUpdatable;
  21771. /** @hidden */
  21772. _boundingInfo: Nullable<BoundingInfo>;
  21773. /** @hidden */
  21774. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21775. /** @hidden */
  21776. _softwareSkinningFrameId: number;
  21777. private _vertexArrayObjects;
  21778. private _updatable;
  21779. /** @hidden */
  21780. _positions: Nullable<Vector3[]>;
  21781. /**
  21782. * 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
  21783. */
  21784. /**
  21785. * 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
  21786. */
  21787. boundingBias: Vector2;
  21788. /**
  21789. * Static function used to attach a new empty geometry to a mesh
  21790. * @param mesh defines the mesh to attach the geometry to
  21791. * @returns the new Geometry
  21792. */
  21793. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21794. /**
  21795. * Creates a new geometry
  21796. * @param id defines the unique ID
  21797. * @param scene defines the hosting scene
  21798. * @param vertexData defines the VertexData used to get geometry data
  21799. * @param updatable defines if geometry must be updatable (false by default)
  21800. * @param mesh defines the mesh that will be associated with the geometry
  21801. */
  21802. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21803. /**
  21804. * Gets the current extend of the geometry
  21805. */
  21806. readonly extend: {
  21807. minimum: Vector3;
  21808. maximum: Vector3;
  21809. };
  21810. /**
  21811. * Gets the hosting scene
  21812. * @returns the hosting Scene
  21813. */
  21814. getScene(): Scene;
  21815. /**
  21816. * Gets the hosting engine
  21817. * @returns the hosting Engine
  21818. */
  21819. getEngine(): Engine;
  21820. /**
  21821. * Defines if the geometry is ready to use
  21822. * @returns true if the geometry is ready to be used
  21823. */
  21824. isReady(): boolean;
  21825. /**
  21826. * Gets a value indicating that the geometry should not be serialized
  21827. */
  21828. readonly doNotSerialize: boolean;
  21829. /** @hidden */
  21830. _rebuild(): void;
  21831. /**
  21832. * Affects all geometry data in one call
  21833. * @param vertexData defines the geometry data
  21834. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21835. */
  21836. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21837. /**
  21838. * Set specific vertex data
  21839. * @param kind defines the data kind (Position, normal, etc...)
  21840. * @param data defines the vertex data to use
  21841. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21842. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21843. */
  21844. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21845. /**
  21846. * Removes a specific vertex data
  21847. * @param kind defines the data kind (Position, normal, etc...)
  21848. */
  21849. removeVerticesData(kind: string): void;
  21850. /**
  21851. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21852. * @param buffer defines the vertex buffer to use
  21853. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21854. */
  21855. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21856. /**
  21857. * Update a specific vertex buffer
  21858. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21859. * It will do nothing if the buffer is not updatable
  21860. * @param kind defines the data kind (Position, normal, etc...)
  21861. * @param data defines the data to use
  21862. * @param offset defines the offset in the target buffer where to store the data
  21863. * @param useBytes set to true if the offset is in bytes
  21864. */
  21865. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21866. /**
  21867. * Update a specific vertex buffer
  21868. * This function will create a new buffer if the current one is not updatable
  21869. * @param kind defines the data kind (Position, normal, etc...)
  21870. * @param data defines the data to use
  21871. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21872. */
  21873. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21874. private _updateBoundingInfo;
  21875. /** @hidden */
  21876. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21877. /**
  21878. * Gets total number of vertices
  21879. * @returns the total number of vertices
  21880. */
  21881. getTotalVertices(): number;
  21882. /**
  21883. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21884. * @param kind defines the data kind (Position, normal, etc...)
  21885. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21886. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21887. * @returns a float array containing vertex data
  21888. */
  21889. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21890. /**
  21891. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21892. * @param kind defines the data kind (Position, normal, etc...)
  21893. * @returns true if the vertex buffer with the specified kind is updatable
  21894. */
  21895. isVertexBufferUpdatable(kind: string): boolean;
  21896. /**
  21897. * Gets a specific vertex buffer
  21898. * @param kind defines the data kind (Position, normal, etc...)
  21899. * @returns a VertexBuffer
  21900. */
  21901. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21902. /**
  21903. * Returns all vertex buffers
  21904. * @return an object holding all vertex buffers indexed by kind
  21905. */
  21906. getVertexBuffers(): Nullable<{
  21907. [key: string]: VertexBuffer;
  21908. }>;
  21909. /**
  21910. * Gets a boolean indicating if specific vertex buffer is present
  21911. * @param kind defines the data kind (Position, normal, etc...)
  21912. * @returns true if data is present
  21913. */
  21914. isVerticesDataPresent(kind: string): boolean;
  21915. /**
  21916. * Gets a list of all attached data kinds (Position, normal, etc...)
  21917. * @returns a list of string containing all kinds
  21918. */
  21919. getVerticesDataKinds(): string[];
  21920. /**
  21921. * Update index buffer
  21922. * @param indices defines the indices to store in the index buffer
  21923. * @param offset defines the offset in the target buffer where to store the data
  21924. * @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)
  21925. */
  21926. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21927. /**
  21928. * Creates a new index buffer
  21929. * @param indices defines the indices to store in the index buffer
  21930. * @param totalVertices defines the total number of vertices (could be null)
  21931. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21932. */
  21933. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21934. /**
  21935. * Return the total number of indices
  21936. * @returns the total number of indices
  21937. */
  21938. getTotalIndices(): number;
  21939. /**
  21940. * Gets the index buffer array
  21941. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21942. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21943. * @returns the index buffer array
  21944. */
  21945. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21946. /**
  21947. * Gets the index buffer
  21948. * @return the index buffer
  21949. */
  21950. getIndexBuffer(): Nullable<DataBuffer>;
  21951. /** @hidden */
  21952. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21953. /**
  21954. * Release the associated resources for a specific mesh
  21955. * @param mesh defines the source mesh
  21956. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21957. */
  21958. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21959. /**
  21960. * Apply current geometry to a given mesh
  21961. * @param mesh defines the mesh to apply geometry to
  21962. */
  21963. applyToMesh(mesh: Mesh): void;
  21964. private _updateExtend;
  21965. private _applyToMesh;
  21966. private notifyUpdate;
  21967. /**
  21968. * Load the geometry if it was flagged as delay loaded
  21969. * @param scene defines the hosting scene
  21970. * @param onLoaded defines a callback called when the geometry is loaded
  21971. */
  21972. load(scene: Scene, onLoaded?: () => void): void;
  21973. private _queueLoad;
  21974. /**
  21975. * Invert the geometry to move from a right handed system to a left handed one.
  21976. */
  21977. toLeftHanded(): void;
  21978. /** @hidden */
  21979. _resetPointsArrayCache(): void;
  21980. /** @hidden */
  21981. _generatePointsArray(): boolean;
  21982. /**
  21983. * Gets a value indicating if the geometry is disposed
  21984. * @returns true if the geometry was disposed
  21985. */
  21986. isDisposed(): boolean;
  21987. private _disposeVertexArrayObjects;
  21988. /**
  21989. * Free all associated resources
  21990. */
  21991. dispose(): void;
  21992. /**
  21993. * Clone the current geometry into a new geometry
  21994. * @param id defines the unique ID of the new geometry
  21995. * @returns a new geometry object
  21996. */
  21997. copy(id: string): Geometry;
  21998. /**
  21999. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22000. * @return a JSON representation of the current geometry data (without the vertices data)
  22001. */
  22002. serialize(): any;
  22003. private toNumberArray;
  22004. /**
  22005. * Serialize all vertices data into a JSON oject
  22006. * @returns a JSON representation of the current geometry data
  22007. */
  22008. serializeVerticeData(): any;
  22009. /**
  22010. * Extracts a clone of a mesh geometry
  22011. * @param mesh defines the source mesh
  22012. * @param id defines the unique ID of the new geometry object
  22013. * @returns the new geometry object
  22014. */
  22015. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22016. /**
  22017. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22018. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22019. * Be aware Math.random() could cause collisions, but:
  22020. * "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"
  22021. * @returns a string containing a new GUID
  22022. */
  22023. static RandomId(): string;
  22024. /** @hidden */
  22025. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22026. private static _CleanMatricesWeights;
  22027. /**
  22028. * Create a new geometry from persisted data (Using .babylon file format)
  22029. * @param parsedVertexData defines the persisted data
  22030. * @param scene defines the hosting scene
  22031. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22032. * @returns the new geometry object
  22033. */
  22034. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22035. }
  22036. }
  22037. declare module "babylonjs/Meshes/mesh.vertexData" {
  22038. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22039. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  22040. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  22041. import { Geometry } from "babylonjs/Meshes/geometry";
  22042. import { Mesh } from "babylonjs/Meshes/mesh";
  22043. /**
  22044. * Define an interface for all classes that will get and set the data on vertices
  22045. */
  22046. export interface IGetSetVerticesData {
  22047. /**
  22048. * Gets a boolean indicating if specific vertex data is present
  22049. * @param kind defines the vertex data kind to use
  22050. * @returns true is data kind is present
  22051. */
  22052. isVerticesDataPresent(kind: string): boolean;
  22053. /**
  22054. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22055. * @param kind defines the data kind (Position, normal, etc...)
  22056. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22057. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22058. * @returns a float array containing vertex data
  22059. */
  22060. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22061. /**
  22062. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22063. * @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.
  22064. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22065. * @returns the indices array or an empty array if the mesh has no geometry
  22066. */
  22067. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22068. /**
  22069. * Set specific vertex data
  22070. * @param kind defines the data kind (Position, normal, etc...)
  22071. * @param data defines the vertex data to use
  22072. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22073. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22074. */
  22075. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22076. /**
  22077. * Update a specific associated vertex buffer
  22078. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22079. * - VertexBuffer.PositionKind
  22080. * - VertexBuffer.UVKind
  22081. * - VertexBuffer.UV2Kind
  22082. * - VertexBuffer.UV3Kind
  22083. * - VertexBuffer.UV4Kind
  22084. * - VertexBuffer.UV5Kind
  22085. * - VertexBuffer.UV6Kind
  22086. * - VertexBuffer.ColorKind
  22087. * - VertexBuffer.MatricesIndicesKind
  22088. * - VertexBuffer.MatricesIndicesExtraKind
  22089. * - VertexBuffer.MatricesWeightsKind
  22090. * - VertexBuffer.MatricesWeightsExtraKind
  22091. * @param data defines the data source
  22092. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22093. * @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)
  22094. */
  22095. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22096. /**
  22097. * Creates a new index buffer
  22098. * @param indices defines the indices to store in the index buffer
  22099. * @param totalVertices defines the total number of vertices (could be null)
  22100. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22101. */
  22102. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22103. }
  22104. /**
  22105. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22106. */
  22107. export class VertexData {
  22108. /**
  22109. * Mesh side orientation : usually the external or front surface
  22110. */
  22111. static readonly FRONTSIDE: number;
  22112. /**
  22113. * Mesh side orientation : usually the internal or back surface
  22114. */
  22115. static readonly BACKSIDE: number;
  22116. /**
  22117. * Mesh side orientation : both internal and external or front and back surfaces
  22118. */
  22119. static readonly DOUBLESIDE: number;
  22120. /**
  22121. * Mesh side orientation : by default, `FRONTSIDE`
  22122. */
  22123. static readonly DEFAULTSIDE: number;
  22124. /**
  22125. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22126. */
  22127. positions: Nullable<FloatArray>;
  22128. /**
  22129. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22130. */
  22131. normals: Nullable<FloatArray>;
  22132. /**
  22133. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22134. */
  22135. tangents: Nullable<FloatArray>;
  22136. /**
  22137. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22138. */
  22139. uvs: Nullable<FloatArray>;
  22140. /**
  22141. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22142. */
  22143. uvs2: Nullable<FloatArray>;
  22144. /**
  22145. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22146. */
  22147. uvs3: Nullable<FloatArray>;
  22148. /**
  22149. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22150. */
  22151. uvs4: Nullable<FloatArray>;
  22152. /**
  22153. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22154. */
  22155. uvs5: Nullable<FloatArray>;
  22156. /**
  22157. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22158. */
  22159. uvs6: Nullable<FloatArray>;
  22160. /**
  22161. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22162. */
  22163. colors: Nullable<FloatArray>;
  22164. /**
  22165. * 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).
  22166. */
  22167. matricesIndices: Nullable<FloatArray>;
  22168. /**
  22169. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22170. */
  22171. matricesWeights: Nullable<FloatArray>;
  22172. /**
  22173. * An array extending the number of possible indices
  22174. */
  22175. matricesIndicesExtra: Nullable<FloatArray>;
  22176. /**
  22177. * An array extending the number of possible weights when the number of indices is extended
  22178. */
  22179. matricesWeightsExtra: Nullable<FloatArray>;
  22180. /**
  22181. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22182. */
  22183. indices: Nullable<IndicesArray>;
  22184. /**
  22185. * Uses the passed data array to set the set the values for the specified kind of data
  22186. * @param data a linear array of floating numbers
  22187. * @param kind the type of data that is being set, eg positions, colors etc
  22188. */
  22189. set(data: FloatArray, kind: string): void;
  22190. /**
  22191. * Associates the vertexData to the passed Mesh.
  22192. * Sets it as updatable or not (default `false`)
  22193. * @param mesh the mesh the vertexData is applied to
  22194. * @param updatable when used and having the value true allows new data to update the vertexData
  22195. * @returns the VertexData
  22196. */
  22197. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22198. /**
  22199. * Associates the vertexData to the passed Geometry.
  22200. * Sets it as updatable or not (default `false`)
  22201. * @param geometry the geometry the vertexData is applied to
  22202. * @param updatable when used and having the value true allows new data to update the vertexData
  22203. * @returns VertexData
  22204. */
  22205. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22206. /**
  22207. * Updates the associated mesh
  22208. * @param mesh the mesh to be updated
  22209. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22210. * @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
  22211. * @returns VertexData
  22212. */
  22213. updateMesh(mesh: Mesh): VertexData;
  22214. /**
  22215. * Updates the associated geometry
  22216. * @param geometry the geometry to be updated
  22217. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22218. * @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
  22219. * @returns VertexData.
  22220. */
  22221. updateGeometry(geometry: Geometry): VertexData;
  22222. private _applyTo;
  22223. private _update;
  22224. /**
  22225. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22226. * @param matrix the transforming matrix
  22227. * @returns the VertexData
  22228. */
  22229. transform(matrix: Matrix): VertexData;
  22230. /**
  22231. * Merges the passed VertexData into the current one
  22232. * @param other the VertexData to be merged into the current one
  22233. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22234. * @returns the modified VertexData
  22235. */
  22236. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22237. private _mergeElement;
  22238. private _validate;
  22239. /**
  22240. * Serializes the VertexData
  22241. * @returns a serialized object
  22242. */
  22243. serialize(): any;
  22244. /**
  22245. * Extracts the vertexData from a mesh
  22246. * @param mesh the mesh from which to extract the VertexData
  22247. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22248. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22249. * @returns the object VertexData associated to the passed mesh
  22250. */
  22251. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22252. /**
  22253. * Extracts the vertexData from the geometry
  22254. * @param geometry the geometry from which to extract the VertexData
  22255. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22256. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22257. * @returns the object VertexData associated to the passed mesh
  22258. */
  22259. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22260. private static _ExtractFrom;
  22261. /**
  22262. * Creates the VertexData for a Ribbon
  22263. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22264. * * pathArray array of paths, each of which an array of successive Vector3
  22265. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22266. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22267. * * 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
  22268. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22269. * * 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)
  22270. * * 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)
  22271. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22272. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22273. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22274. * @returns the VertexData of the ribbon
  22275. */
  22276. static CreateRibbon(options: {
  22277. pathArray: Vector3[][];
  22278. closeArray?: boolean;
  22279. closePath?: boolean;
  22280. offset?: number;
  22281. sideOrientation?: number;
  22282. frontUVs?: Vector4;
  22283. backUVs?: Vector4;
  22284. invertUV?: boolean;
  22285. uvs?: Vector2[];
  22286. colors?: Color4[];
  22287. }): VertexData;
  22288. /**
  22289. * Creates the VertexData for a box
  22290. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22291. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22292. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22293. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22294. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22295. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22296. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22297. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22298. * * 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)
  22299. * * 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)
  22300. * @returns the VertexData of the box
  22301. */
  22302. static CreateBox(options: {
  22303. size?: number;
  22304. width?: number;
  22305. height?: number;
  22306. depth?: number;
  22307. faceUV?: Vector4[];
  22308. faceColors?: Color4[];
  22309. sideOrientation?: number;
  22310. frontUVs?: Vector4;
  22311. backUVs?: Vector4;
  22312. }): VertexData;
  22313. /**
  22314. * Creates the VertexData for a tiled box
  22315. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22316. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22317. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22318. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22319. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22320. * @returns the VertexData of the box
  22321. */
  22322. static CreateTiledBox(options: {
  22323. pattern?: number;
  22324. width?: number;
  22325. height?: number;
  22326. depth?: number;
  22327. tileSize?: number;
  22328. tileWidth?: number;
  22329. tileHeight?: number;
  22330. alignHorizontal?: number;
  22331. alignVertical?: number;
  22332. faceUV?: Vector4[];
  22333. faceColors?: Color4[];
  22334. sideOrientation?: number;
  22335. }): VertexData;
  22336. /**
  22337. * Creates the VertexData for a tiled plane
  22338. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22339. * * pattern a limited pattern arrangement depending on the number
  22340. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22341. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22342. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22343. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22344. * * 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)
  22345. * * 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)
  22346. * @returns the VertexData of the tiled plane
  22347. */
  22348. static CreateTiledPlane(options: {
  22349. pattern?: number;
  22350. tileSize?: number;
  22351. tileWidth?: number;
  22352. tileHeight?: number;
  22353. size?: number;
  22354. width?: number;
  22355. height?: number;
  22356. alignHorizontal?: number;
  22357. alignVertical?: number;
  22358. sideOrientation?: number;
  22359. frontUVs?: Vector4;
  22360. backUVs?: Vector4;
  22361. }): VertexData;
  22362. /**
  22363. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22364. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22365. * * segments sets the number of horizontal strips optional, default 32
  22366. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22367. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22368. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22369. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22370. * * 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
  22371. * * 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
  22372. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22373. * * 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)
  22374. * * 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)
  22375. * @returns the VertexData of the ellipsoid
  22376. */
  22377. static CreateSphere(options: {
  22378. segments?: number;
  22379. diameter?: number;
  22380. diameterX?: number;
  22381. diameterY?: number;
  22382. diameterZ?: number;
  22383. arc?: number;
  22384. slice?: number;
  22385. sideOrientation?: number;
  22386. frontUVs?: Vector4;
  22387. backUVs?: Vector4;
  22388. }): VertexData;
  22389. /**
  22390. * Creates the VertexData for a cylinder, cone or prism
  22391. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22392. * * height sets the height (y direction) of the cylinder, optional, default 2
  22393. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22394. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22395. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22396. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22397. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22398. * * 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
  22399. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22400. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22401. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22402. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22403. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22404. * * 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)
  22405. * * 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)
  22406. * @returns the VertexData of the cylinder, cone or prism
  22407. */
  22408. static CreateCylinder(options: {
  22409. height?: number;
  22410. diameterTop?: number;
  22411. diameterBottom?: number;
  22412. diameter?: number;
  22413. tessellation?: number;
  22414. subdivisions?: number;
  22415. arc?: number;
  22416. faceColors?: Color4[];
  22417. faceUV?: Vector4[];
  22418. hasRings?: boolean;
  22419. enclose?: boolean;
  22420. sideOrientation?: number;
  22421. frontUVs?: Vector4;
  22422. backUVs?: Vector4;
  22423. }): VertexData;
  22424. /**
  22425. * Creates the VertexData for a torus
  22426. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22427. * * diameter the diameter of the torus, optional default 1
  22428. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22429. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22430. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22431. * * 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)
  22432. * * 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)
  22433. * @returns the VertexData of the torus
  22434. */
  22435. static CreateTorus(options: {
  22436. diameter?: number;
  22437. thickness?: number;
  22438. tessellation?: number;
  22439. sideOrientation?: number;
  22440. frontUVs?: Vector4;
  22441. backUVs?: Vector4;
  22442. }): VertexData;
  22443. /**
  22444. * Creates the VertexData of the LineSystem
  22445. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22446. * - lines an array of lines, each line being an array of successive Vector3
  22447. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22448. * @returns the VertexData of the LineSystem
  22449. */
  22450. static CreateLineSystem(options: {
  22451. lines: Vector3[][];
  22452. colors?: Nullable<Color4[][]>;
  22453. }): VertexData;
  22454. /**
  22455. * Create the VertexData for a DashedLines
  22456. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22457. * - points an array successive Vector3
  22458. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22459. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22460. * - dashNb the intended total number of dashes, optional, default 200
  22461. * @returns the VertexData for the DashedLines
  22462. */
  22463. static CreateDashedLines(options: {
  22464. points: Vector3[];
  22465. dashSize?: number;
  22466. gapSize?: number;
  22467. dashNb?: number;
  22468. }): VertexData;
  22469. /**
  22470. * Creates the VertexData for a Ground
  22471. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22472. * - width the width (x direction) of the ground, optional, default 1
  22473. * - height the height (z direction) of the ground, optional, default 1
  22474. * - subdivisions the number of subdivisions per side, optional, default 1
  22475. * @returns the VertexData of the Ground
  22476. */
  22477. static CreateGround(options: {
  22478. width?: number;
  22479. height?: number;
  22480. subdivisions?: number;
  22481. subdivisionsX?: number;
  22482. subdivisionsY?: number;
  22483. }): VertexData;
  22484. /**
  22485. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22486. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22487. * * xmin the ground minimum X coordinate, optional, default -1
  22488. * * zmin the ground minimum Z coordinate, optional, default -1
  22489. * * xmax the ground maximum X coordinate, optional, default 1
  22490. * * zmax the ground maximum Z coordinate, optional, default 1
  22491. * * 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}
  22492. * * 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}
  22493. * @returns the VertexData of the TiledGround
  22494. */
  22495. static CreateTiledGround(options: {
  22496. xmin: number;
  22497. zmin: number;
  22498. xmax: number;
  22499. zmax: number;
  22500. subdivisions?: {
  22501. w: number;
  22502. h: number;
  22503. };
  22504. precision?: {
  22505. w: number;
  22506. h: number;
  22507. };
  22508. }): VertexData;
  22509. /**
  22510. * Creates the VertexData of the Ground designed from a heightmap
  22511. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22512. * * width the width (x direction) of the ground
  22513. * * height the height (z direction) of the ground
  22514. * * subdivisions the number of subdivisions per side
  22515. * * minHeight the minimum altitude on the ground, optional, default 0
  22516. * * maxHeight the maximum altitude on the ground, optional default 1
  22517. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22518. * * buffer the array holding the image color data
  22519. * * bufferWidth the width of image
  22520. * * bufferHeight the height of image
  22521. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22522. * @returns the VertexData of the Ground designed from a heightmap
  22523. */
  22524. static CreateGroundFromHeightMap(options: {
  22525. width: number;
  22526. height: number;
  22527. subdivisions: number;
  22528. minHeight: number;
  22529. maxHeight: number;
  22530. colorFilter: Color3;
  22531. buffer: Uint8Array;
  22532. bufferWidth: number;
  22533. bufferHeight: number;
  22534. alphaFilter: number;
  22535. }): VertexData;
  22536. /**
  22537. * Creates the VertexData for a Plane
  22538. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22539. * * size sets the width and height of the plane to the value of size, optional default 1
  22540. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22541. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22542. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22543. * * 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)
  22544. * * 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)
  22545. * @returns the VertexData of the box
  22546. */
  22547. static CreatePlane(options: {
  22548. size?: number;
  22549. width?: number;
  22550. height?: number;
  22551. sideOrientation?: number;
  22552. frontUVs?: Vector4;
  22553. backUVs?: Vector4;
  22554. }): VertexData;
  22555. /**
  22556. * Creates the VertexData of the Disc or regular Polygon
  22557. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22558. * * radius the radius of the disc, optional default 0.5
  22559. * * tessellation the number of polygon sides, optional, default 64
  22560. * * 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
  22561. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22562. * * 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)
  22563. * * 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)
  22564. * @returns the VertexData of the box
  22565. */
  22566. static CreateDisc(options: {
  22567. radius?: number;
  22568. tessellation?: number;
  22569. arc?: number;
  22570. sideOrientation?: number;
  22571. frontUVs?: Vector4;
  22572. backUVs?: Vector4;
  22573. }): VertexData;
  22574. /**
  22575. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22576. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22577. * @param polygon a mesh built from polygonTriangulation.build()
  22578. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22579. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22580. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22581. * @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)
  22582. * @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)
  22583. * @returns the VertexData of the Polygon
  22584. */
  22585. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22586. /**
  22587. * Creates the VertexData of the IcoSphere
  22588. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22589. * * radius the radius of the IcoSphere, optional default 1
  22590. * * radiusX allows stretching in the x direction, optional, default radius
  22591. * * radiusY allows stretching in the y direction, optional, default radius
  22592. * * radiusZ allows stretching in the z direction, optional, default radius
  22593. * * flat when true creates a flat shaded mesh, optional, default true
  22594. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22595. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22596. * * 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)
  22597. * * 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)
  22598. * @returns the VertexData of the IcoSphere
  22599. */
  22600. static CreateIcoSphere(options: {
  22601. radius?: number;
  22602. radiusX?: number;
  22603. radiusY?: number;
  22604. radiusZ?: number;
  22605. flat?: boolean;
  22606. subdivisions?: number;
  22607. sideOrientation?: number;
  22608. frontUVs?: Vector4;
  22609. backUVs?: Vector4;
  22610. }): VertexData;
  22611. /**
  22612. * Creates the VertexData for a Polyhedron
  22613. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22614. * * type provided types are:
  22615. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22616. * * 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)
  22617. * * size the size of the IcoSphere, optional default 1
  22618. * * sizeX allows stretching in the x direction, optional, default size
  22619. * * sizeY allows stretching in the y direction, optional, default size
  22620. * * sizeZ allows stretching in the z direction, optional, default size
  22621. * * 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
  22622. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22623. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22624. * * flat when true creates a flat shaded mesh, optional, default true
  22625. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22626. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22627. * * 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)
  22628. * * 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)
  22629. * @returns the VertexData of the Polyhedron
  22630. */
  22631. static CreatePolyhedron(options: {
  22632. type?: number;
  22633. size?: number;
  22634. sizeX?: number;
  22635. sizeY?: number;
  22636. sizeZ?: number;
  22637. custom?: any;
  22638. faceUV?: Vector4[];
  22639. faceColors?: Color4[];
  22640. flat?: boolean;
  22641. sideOrientation?: number;
  22642. frontUVs?: Vector4;
  22643. backUVs?: Vector4;
  22644. }): VertexData;
  22645. /**
  22646. * Creates the VertexData for a TorusKnot
  22647. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22648. * * radius the radius of the torus knot, optional, default 2
  22649. * * tube the thickness of the tube, optional, default 0.5
  22650. * * radialSegments the number of sides on each tube segments, optional, default 32
  22651. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22652. * * p the number of windings around the z axis, optional, default 2
  22653. * * q the number of windings around the x axis, optional, default 3
  22654. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22655. * * 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)
  22656. * * 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)
  22657. * @returns the VertexData of the Torus Knot
  22658. */
  22659. static CreateTorusKnot(options: {
  22660. radius?: number;
  22661. tube?: number;
  22662. radialSegments?: number;
  22663. tubularSegments?: number;
  22664. p?: number;
  22665. q?: number;
  22666. sideOrientation?: number;
  22667. frontUVs?: Vector4;
  22668. backUVs?: Vector4;
  22669. }): VertexData;
  22670. /**
  22671. * Compute normals for given positions and indices
  22672. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22673. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22674. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22675. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22676. * * facetNormals : optional array of facet normals (vector3)
  22677. * * facetPositions : optional array of facet positions (vector3)
  22678. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22679. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22680. * * bInfo : optional bounding info, required for facetPartitioning computation
  22681. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22682. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22683. * * useRightHandedSystem: optional boolean to for right handed system computation
  22684. * * depthSort : optional boolean to enable the facet depth sort computation
  22685. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22686. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22687. */
  22688. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22689. facetNormals?: any;
  22690. facetPositions?: any;
  22691. facetPartitioning?: any;
  22692. ratio?: number;
  22693. bInfo?: any;
  22694. bbSize?: Vector3;
  22695. subDiv?: any;
  22696. useRightHandedSystem?: boolean;
  22697. depthSort?: boolean;
  22698. distanceTo?: Vector3;
  22699. depthSortedFacets?: any;
  22700. }): void;
  22701. /** @hidden */
  22702. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22703. /**
  22704. * Applies VertexData created from the imported parameters to the geometry
  22705. * @param parsedVertexData the parsed data from an imported file
  22706. * @param geometry the geometry to apply the VertexData to
  22707. */
  22708. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22709. }
  22710. }
  22711. declare module "babylonjs/Morph/morphTarget" {
  22712. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  22713. import { Observable } from "babylonjs/Misc/observable";
  22714. import { Nullable, FloatArray } from "babylonjs/types";
  22715. import { Scene } from "babylonjs/scene";
  22716. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22717. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  22718. /**
  22719. * Defines a target to use with MorphTargetManager
  22720. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22721. */
  22722. export class MorphTarget implements IAnimatable {
  22723. /** defines the name of the target */
  22724. name: string;
  22725. /**
  22726. * Gets or sets the list of animations
  22727. */
  22728. animations: import("babylonjs/Animations/animation").Animation[];
  22729. private _scene;
  22730. private _positions;
  22731. private _normals;
  22732. private _tangents;
  22733. private _uvs;
  22734. private _influence;
  22735. /**
  22736. * Observable raised when the influence changes
  22737. */
  22738. onInfluenceChanged: Observable<boolean>;
  22739. /** @hidden */
  22740. _onDataLayoutChanged: Observable<void>;
  22741. /**
  22742. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22743. */
  22744. influence: number;
  22745. /**
  22746. * Gets or sets the id of the morph Target
  22747. */
  22748. id: string;
  22749. private _animationPropertiesOverride;
  22750. /**
  22751. * Gets or sets the animation properties override
  22752. */
  22753. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22754. /**
  22755. * Creates a new MorphTarget
  22756. * @param name defines the name of the target
  22757. * @param influence defines the influence to use
  22758. * @param scene defines the scene the morphtarget belongs to
  22759. */
  22760. constructor(
  22761. /** defines the name of the target */
  22762. name: string, influence?: number, scene?: Nullable<Scene>);
  22763. /**
  22764. * Gets a boolean defining if the target contains position data
  22765. */
  22766. readonly hasPositions: boolean;
  22767. /**
  22768. * Gets a boolean defining if the target contains normal data
  22769. */
  22770. readonly hasNormals: boolean;
  22771. /**
  22772. * Gets a boolean defining if the target contains tangent data
  22773. */
  22774. readonly hasTangents: boolean;
  22775. /**
  22776. * Gets a boolean defining if the target contains texture coordinates data
  22777. */
  22778. readonly hasUVs: boolean;
  22779. /**
  22780. * Affects position data to this target
  22781. * @param data defines the position data to use
  22782. */
  22783. setPositions(data: Nullable<FloatArray>): void;
  22784. /**
  22785. * Gets the position data stored in this target
  22786. * @returns a FloatArray containing the position data (or null if not present)
  22787. */
  22788. getPositions(): Nullable<FloatArray>;
  22789. /**
  22790. * Affects normal data to this target
  22791. * @param data defines the normal data to use
  22792. */
  22793. setNormals(data: Nullable<FloatArray>): void;
  22794. /**
  22795. * Gets the normal data stored in this target
  22796. * @returns a FloatArray containing the normal data (or null if not present)
  22797. */
  22798. getNormals(): Nullable<FloatArray>;
  22799. /**
  22800. * Affects tangent data to this target
  22801. * @param data defines the tangent data to use
  22802. */
  22803. setTangents(data: Nullable<FloatArray>): void;
  22804. /**
  22805. * Gets the tangent data stored in this target
  22806. * @returns a FloatArray containing the tangent data (or null if not present)
  22807. */
  22808. getTangents(): Nullable<FloatArray>;
  22809. /**
  22810. * Affects texture coordinates data to this target
  22811. * @param data defines the texture coordinates data to use
  22812. */
  22813. setUVs(data: Nullable<FloatArray>): void;
  22814. /**
  22815. * Gets the texture coordinates data stored in this target
  22816. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22817. */
  22818. getUVs(): Nullable<FloatArray>;
  22819. /**
  22820. * Serializes the current target into a Serialization object
  22821. * @returns the serialized object
  22822. */
  22823. serialize(): any;
  22824. /**
  22825. * Returns the string "MorphTarget"
  22826. * @returns "MorphTarget"
  22827. */
  22828. getClassName(): string;
  22829. /**
  22830. * Creates a new target from serialized data
  22831. * @param serializationObject defines the serialized data to use
  22832. * @returns a new MorphTarget
  22833. */
  22834. static Parse(serializationObject: any): MorphTarget;
  22835. /**
  22836. * Creates a MorphTarget from mesh data
  22837. * @param mesh defines the source mesh
  22838. * @param name defines the name to use for the new target
  22839. * @param influence defines the influence to attach to the target
  22840. * @returns a new MorphTarget
  22841. */
  22842. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22843. }
  22844. }
  22845. declare module "babylonjs/Morph/morphTargetManager" {
  22846. import { Nullable } from "babylonjs/types";
  22847. import { Scene } from "babylonjs/scene";
  22848. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  22849. /**
  22850. * This class is used to deform meshes using morphing between different targets
  22851. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22852. */
  22853. export class MorphTargetManager {
  22854. private _targets;
  22855. private _targetInfluenceChangedObservers;
  22856. private _targetDataLayoutChangedObservers;
  22857. private _activeTargets;
  22858. private _scene;
  22859. private _influences;
  22860. private _supportsNormals;
  22861. private _supportsTangents;
  22862. private _supportsUVs;
  22863. private _vertexCount;
  22864. private _uniqueId;
  22865. private _tempInfluences;
  22866. /**
  22867. * Gets or sets a boolean indicating if normals must be morphed
  22868. */
  22869. enableNormalMorphing: boolean;
  22870. /**
  22871. * Gets or sets a boolean indicating if tangents must be morphed
  22872. */
  22873. enableTangentMorphing: boolean;
  22874. /**
  22875. * Gets or sets a boolean indicating if UV must be morphed
  22876. */
  22877. enableUVMorphing: boolean;
  22878. /**
  22879. * Creates a new MorphTargetManager
  22880. * @param scene defines the current scene
  22881. */
  22882. constructor(scene?: Nullable<Scene>);
  22883. /**
  22884. * Gets the unique ID of this manager
  22885. */
  22886. readonly uniqueId: number;
  22887. /**
  22888. * Gets the number of vertices handled by this manager
  22889. */
  22890. readonly vertexCount: number;
  22891. /**
  22892. * Gets a boolean indicating if this manager supports morphing of normals
  22893. */
  22894. readonly supportsNormals: boolean;
  22895. /**
  22896. * Gets a boolean indicating if this manager supports morphing of tangents
  22897. */
  22898. readonly supportsTangents: boolean;
  22899. /**
  22900. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22901. */
  22902. readonly supportsUVs: boolean;
  22903. /**
  22904. * Gets the number of targets stored in this manager
  22905. */
  22906. readonly numTargets: number;
  22907. /**
  22908. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22909. */
  22910. readonly numInfluencers: number;
  22911. /**
  22912. * Gets the list of influences (one per target)
  22913. */
  22914. readonly influences: Float32Array;
  22915. /**
  22916. * Gets the active target at specified index. An active target is a target with an influence > 0
  22917. * @param index defines the index to check
  22918. * @returns the requested target
  22919. */
  22920. getActiveTarget(index: number): MorphTarget;
  22921. /**
  22922. * Gets the target at specified index
  22923. * @param index defines the index to check
  22924. * @returns the requested target
  22925. */
  22926. getTarget(index: number): MorphTarget;
  22927. /**
  22928. * Add a new target to this manager
  22929. * @param target defines the target to add
  22930. */
  22931. addTarget(target: MorphTarget): void;
  22932. /**
  22933. * Removes a target from the manager
  22934. * @param target defines the target to remove
  22935. */
  22936. removeTarget(target: MorphTarget): void;
  22937. /**
  22938. * Serializes the current manager into a Serialization object
  22939. * @returns the serialized object
  22940. */
  22941. serialize(): any;
  22942. private _syncActiveTargets;
  22943. /**
  22944. * Syncrhonize the targets with all the meshes using this morph target manager
  22945. */
  22946. synchronize(): void;
  22947. /**
  22948. * Creates a new MorphTargetManager from serialized data
  22949. * @param serializationObject defines the serialized data
  22950. * @param scene defines the hosting scene
  22951. * @returns the new MorphTargetManager
  22952. */
  22953. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22954. }
  22955. }
  22956. declare module "babylonjs/Meshes/meshLODLevel" {
  22957. import { Mesh } from "babylonjs/Meshes/mesh";
  22958. import { Nullable } from "babylonjs/types";
  22959. /**
  22960. * Class used to represent a specific level of detail of a mesh
  22961. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22962. */
  22963. export class MeshLODLevel {
  22964. /** Defines the distance where this level should start being displayed */
  22965. distance: number;
  22966. /** Defines the mesh to use to render this level */
  22967. mesh: Nullable<Mesh>;
  22968. /**
  22969. * Creates a new LOD level
  22970. * @param distance defines the distance where this level should star being displayed
  22971. * @param mesh defines the mesh to use to render this level
  22972. */
  22973. constructor(
  22974. /** Defines the distance where this level should start being displayed */
  22975. distance: number,
  22976. /** Defines the mesh to use to render this level */
  22977. mesh: Nullable<Mesh>);
  22978. }
  22979. }
  22980. declare module "babylonjs/Meshes/groundMesh" {
  22981. import { Scene } from "babylonjs/scene";
  22982. import { Vector3 } from "babylonjs/Maths/math.vector";
  22983. import { Mesh } from "babylonjs/Meshes/mesh";
  22984. /**
  22985. * Mesh representing the gorund
  22986. */
  22987. export class GroundMesh extends Mesh {
  22988. /** If octree should be generated */
  22989. generateOctree: boolean;
  22990. private _heightQuads;
  22991. /** @hidden */
  22992. _subdivisionsX: number;
  22993. /** @hidden */
  22994. _subdivisionsY: number;
  22995. /** @hidden */
  22996. _width: number;
  22997. /** @hidden */
  22998. _height: number;
  22999. /** @hidden */
  23000. _minX: number;
  23001. /** @hidden */
  23002. _maxX: number;
  23003. /** @hidden */
  23004. _minZ: number;
  23005. /** @hidden */
  23006. _maxZ: number;
  23007. constructor(name: string, scene: Scene);
  23008. /**
  23009. * "GroundMesh"
  23010. * @returns "GroundMesh"
  23011. */
  23012. getClassName(): string;
  23013. /**
  23014. * The minimum of x and y subdivisions
  23015. */
  23016. readonly subdivisions: number;
  23017. /**
  23018. * X subdivisions
  23019. */
  23020. readonly subdivisionsX: number;
  23021. /**
  23022. * Y subdivisions
  23023. */
  23024. readonly subdivisionsY: number;
  23025. /**
  23026. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23027. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23028. * @param chunksCount the number of subdivisions for x and y
  23029. * @param octreeBlocksSize (Default: 32)
  23030. */
  23031. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23032. /**
  23033. * Returns a height (y) value in the Worl system :
  23034. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23035. * @param x x coordinate
  23036. * @param z z coordinate
  23037. * @returns the ground y position if (x, z) are outside the ground surface.
  23038. */
  23039. getHeightAtCoordinates(x: number, z: number): number;
  23040. /**
  23041. * Returns a normalized vector (Vector3) orthogonal to the ground
  23042. * at the ground coordinates (x, z) expressed in the World system.
  23043. * @param x x coordinate
  23044. * @param z z coordinate
  23045. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23046. */
  23047. getNormalAtCoordinates(x: number, z: number): Vector3;
  23048. /**
  23049. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23050. * at the ground coordinates (x, z) expressed in the World system.
  23051. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23052. * @param x x coordinate
  23053. * @param z z coordinate
  23054. * @param ref vector to store the result
  23055. * @returns the GroundMesh.
  23056. */
  23057. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23058. /**
  23059. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23060. * if the ground has been updated.
  23061. * This can be used in the render loop.
  23062. * @returns the GroundMesh.
  23063. */
  23064. updateCoordinateHeights(): GroundMesh;
  23065. private _getFacetAt;
  23066. private _initHeightQuads;
  23067. private _computeHeightQuads;
  23068. /**
  23069. * Serializes this ground mesh
  23070. * @param serializationObject object to write serialization to
  23071. */
  23072. serialize(serializationObject: any): void;
  23073. /**
  23074. * Parses a serialized ground mesh
  23075. * @param parsedMesh the serialized mesh
  23076. * @param scene the scene to create the ground mesh in
  23077. * @returns the created ground mesh
  23078. */
  23079. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23080. }
  23081. }
  23082. declare module "babylonjs/Physics/physicsJoint" {
  23083. import { Vector3 } from "babylonjs/Maths/math.vector";
  23084. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  23085. /**
  23086. * Interface for Physics-Joint data
  23087. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23088. */
  23089. export interface PhysicsJointData {
  23090. /**
  23091. * The main pivot of the joint
  23092. */
  23093. mainPivot?: Vector3;
  23094. /**
  23095. * The connected pivot of the joint
  23096. */
  23097. connectedPivot?: Vector3;
  23098. /**
  23099. * The main axis of the joint
  23100. */
  23101. mainAxis?: Vector3;
  23102. /**
  23103. * The connected axis of the joint
  23104. */
  23105. connectedAxis?: Vector3;
  23106. /**
  23107. * The collision of the joint
  23108. */
  23109. collision?: boolean;
  23110. /**
  23111. * Native Oimo/Cannon/Energy data
  23112. */
  23113. nativeParams?: any;
  23114. }
  23115. /**
  23116. * This is a holder class for the physics joint created by the physics plugin
  23117. * It holds a set of functions to control the underlying joint
  23118. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23119. */
  23120. export class PhysicsJoint {
  23121. /**
  23122. * The type of the physics joint
  23123. */
  23124. type: number;
  23125. /**
  23126. * The data for the physics joint
  23127. */
  23128. jointData: PhysicsJointData;
  23129. private _physicsJoint;
  23130. protected _physicsPlugin: IPhysicsEnginePlugin;
  23131. /**
  23132. * Initializes the physics joint
  23133. * @param type The type of the physics joint
  23134. * @param jointData The data for the physics joint
  23135. */
  23136. constructor(
  23137. /**
  23138. * The type of the physics joint
  23139. */
  23140. type: number,
  23141. /**
  23142. * The data for the physics joint
  23143. */
  23144. jointData: PhysicsJointData);
  23145. /**
  23146. * Gets the physics joint
  23147. */
  23148. /**
  23149. * Sets the physics joint
  23150. */
  23151. physicsJoint: any;
  23152. /**
  23153. * Sets the physics plugin
  23154. */
  23155. physicsPlugin: IPhysicsEnginePlugin;
  23156. /**
  23157. * Execute a function that is physics-plugin specific.
  23158. * @param {Function} func the function that will be executed.
  23159. * It accepts two parameters: the physics world and the physics joint
  23160. */
  23161. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23162. /**
  23163. * Distance-Joint type
  23164. */
  23165. static DistanceJoint: number;
  23166. /**
  23167. * Hinge-Joint type
  23168. */
  23169. static HingeJoint: number;
  23170. /**
  23171. * Ball-and-Socket joint type
  23172. */
  23173. static BallAndSocketJoint: number;
  23174. /**
  23175. * Wheel-Joint type
  23176. */
  23177. static WheelJoint: number;
  23178. /**
  23179. * Slider-Joint type
  23180. */
  23181. static SliderJoint: number;
  23182. /**
  23183. * Prismatic-Joint type
  23184. */
  23185. static PrismaticJoint: number;
  23186. /**
  23187. * Universal-Joint type
  23188. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23189. */
  23190. static UniversalJoint: number;
  23191. /**
  23192. * Hinge-Joint 2 type
  23193. */
  23194. static Hinge2Joint: number;
  23195. /**
  23196. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23197. */
  23198. static PointToPointJoint: number;
  23199. /**
  23200. * Spring-Joint type
  23201. */
  23202. static SpringJoint: number;
  23203. /**
  23204. * Lock-Joint type
  23205. */
  23206. static LockJoint: number;
  23207. }
  23208. /**
  23209. * A class representing a physics distance joint
  23210. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23211. */
  23212. export class DistanceJoint extends PhysicsJoint {
  23213. /**
  23214. *
  23215. * @param jointData The data for the Distance-Joint
  23216. */
  23217. constructor(jointData: DistanceJointData);
  23218. /**
  23219. * Update the predefined distance.
  23220. * @param maxDistance The maximum preferred distance
  23221. * @param minDistance The minimum preferred distance
  23222. */
  23223. updateDistance(maxDistance: number, minDistance?: number): void;
  23224. }
  23225. /**
  23226. * Represents a Motor-Enabled Joint
  23227. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23228. */
  23229. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23230. /**
  23231. * Initializes the Motor-Enabled Joint
  23232. * @param type The type of the joint
  23233. * @param jointData The physica joint data for the joint
  23234. */
  23235. constructor(type: number, jointData: PhysicsJointData);
  23236. /**
  23237. * Set the motor values.
  23238. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23239. * @param force the force to apply
  23240. * @param maxForce max force for this motor.
  23241. */
  23242. setMotor(force?: number, maxForce?: number): void;
  23243. /**
  23244. * Set the motor's limits.
  23245. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23246. * @param upperLimit The upper limit of the motor
  23247. * @param lowerLimit The lower limit of the motor
  23248. */
  23249. setLimit(upperLimit: number, lowerLimit?: number): void;
  23250. }
  23251. /**
  23252. * This class represents a single physics Hinge-Joint
  23253. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23254. */
  23255. export class HingeJoint extends MotorEnabledJoint {
  23256. /**
  23257. * Initializes the Hinge-Joint
  23258. * @param jointData The joint data for the Hinge-Joint
  23259. */
  23260. constructor(jointData: PhysicsJointData);
  23261. /**
  23262. * Set the motor values.
  23263. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23264. * @param {number} force the force to apply
  23265. * @param {number} maxForce max force for this motor.
  23266. */
  23267. setMotor(force?: number, maxForce?: number): void;
  23268. /**
  23269. * Set the motor's limits.
  23270. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23271. * @param upperLimit The upper limit of the motor
  23272. * @param lowerLimit The lower limit of the motor
  23273. */
  23274. setLimit(upperLimit: number, lowerLimit?: number): void;
  23275. }
  23276. /**
  23277. * This class represents a dual hinge physics joint (same as wheel joint)
  23278. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23279. */
  23280. export class Hinge2Joint extends MotorEnabledJoint {
  23281. /**
  23282. * Initializes the Hinge2-Joint
  23283. * @param jointData The joint data for the Hinge2-Joint
  23284. */
  23285. constructor(jointData: PhysicsJointData);
  23286. /**
  23287. * Set the motor values.
  23288. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23289. * @param {number} targetSpeed the speed the motor is to reach
  23290. * @param {number} maxForce max force for this motor.
  23291. * @param {motorIndex} the motor's index, 0 or 1.
  23292. */
  23293. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23294. /**
  23295. * Set the motor limits.
  23296. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23297. * @param {number} upperLimit the upper limit
  23298. * @param {number} lowerLimit lower limit
  23299. * @param {motorIndex} the motor's index, 0 or 1.
  23300. */
  23301. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23302. }
  23303. /**
  23304. * Interface for a motor enabled joint
  23305. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23306. */
  23307. export interface IMotorEnabledJoint {
  23308. /**
  23309. * Physics joint
  23310. */
  23311. physicsJoint: any;
  23312. /**
  23313. * Sets the motor of the motor-enabled joint
  23314. * @param force The force of the motor
  23315. * @param maxForce The maximum force of the motor
  23316. * @param motorIndex The index of the motor
  23317. */
  23318. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23319. /**
  23320. * Sets the limit of the motor
  23321. * @param upperLimit The upper limit of the motor
  23322. * @param lowerLimit The lower limit of the motor
  23323. * @param motorIndex The index of the motor
  23324. */
  23325. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23326. }
  23327. /**
  23328. * Joint data for a Distance-Joint
  23329. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23330. */
  23331. export interface DistanceJointData extends PhysicsJointData {
  23332. /**
  23333. * Max distance the 2 joint objects can be apart
  23334. */
  23335. maxDistance: number;
  23336. }
  23337. /**
  23338. * Joint data from a spring joint
  23339. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23340. */
  23341. export interface SpringJointData extends PhysicsJointData {
  23342. /**
  23343. * Length of the spring
  23344. */
  23345. length: number;
  23346. /**
  23347. * Stiffness of the spring
  23348. */
  23349. stiffness: number;
  23350. /**
  23351. * Damping of the spring
  23352. */
  23353. damping: number;
  23354. /** this callback will be called when applying the force to the impostors. */
  23355. forceApplicationCallback: () => void;
  23356. }
  23357. }
  23358. declare module "babylonjs/Physics/physicsRaycastResult" {
  23359. import { Vector3 } from "babylonjs/Maths/math.vector";
  23360. /**
  23361. * Holds the data for the raycast result
  23362. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23363. */
  23364. export class PhysicsRaycastResult {
  23365. private _hasHit;
  23366. private _hitDistance;
  23367. private _hitNormalWorld;
  23368. private _hitPointWorld;
  23369. private _rayFromWorld;
  23370. private _rayToWorld;
  23371. /**
  23372. * Gets if there was a hit
  23373. */
  23374. readonly hasHit: boolean;
  23375. /**
  23376. * Gets the distance from the hit
  23377. */
  23378. readonly hitDistance: number;
  23379. /**
  23380. * Gets the hit normal/direction in the world
  23381. */
  23382. readonly hitNormalWorld: Vector3;
  23383. /**
  23384. * Gets the hit point in the world
  23385. */
  23386. readonly hitPointWorld: Vector3;
  23387. /**
  23388. * Gets the ray "start point" of the ray in the world
  23389. */
  23390. readonly rayFromWorld: Vector3;
  23391. /**
  23392. * Gets the ray "end point" of the ray in the world
  23393. */
  23394. readonly rayToWorld: Vector3;
  23395. /**
  23396. * Sets the hit data (normal & point in world space)
  23397. * @param hitNormalWorld defines the normal in world space
  23398. * @param hitPointWorld defines the point in world space
  23399. */
  23400. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23401. /**
  23402. * Sets the distance from the start point to the hit point
  23403. * @param distance
  23404. */
  23405. setHitDistance(distance: number): void;
  23406. /**
  23407. * Calculates the distance manually
  23408. */
  23409. calculateHitDistance(): void;
  23410. /**
  23411. * Resets all the values to default
  23412. * @param from The from point on world space
  23413. * @param to The to point on world space
  23414. */
  23415. reset(from?: Vector3, to?: Vector3): void;
  23416. }
  23417. /**
  23418. * Interface for the size containing width and height
  23419. */
  23420. interface IXYZ {
  23421. /**
  23422. * X
  23423. */
  23424. x: number;
  23425. /**
  23426. * Y
  23427. */
  23428. y: number;
  23429. /**
  23430. * Z
  23431. */
  23432. z: number;
  23433. }
  23434. }
  23435. declare module "babylonjs/Physics/IPhysicsEngine" {
  23436. import { Nullable } from "babylonjs/types";
  23437. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23438. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23439. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23440. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23441. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23442. /**
  23443. * Interface used to describe a physics joint
  23444. */
  23445. export interface PhysicsImpostorJoint {
  23446. /** Defines the main impostor to which the joint is linked */
  23447. mainImpostor: PhysicsImpostor;
  23448. /** Defines the impostor that is connected to the main impostor using this joint */
  23449. connectedImpostor: PhysicsImpostor;
  23450. /** Defines the joint itself */
  23451. joint: PhysicsJoint;
  23452. }
  23453. /** @hidden */
  23454. export interface IPhysicsEnginePlugin {
  23455. world: any;
  23456. name: string;
  23457. setGravity(gravity: Vector3): void;
  23458. setTimeStep(timeStep: number): void;
  23459. getTimeStep(): number;
  23460. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23461. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23462. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23463. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23464. removePhysicsBody(impostor: PhysicsImpostor): void;
  23465. generateJoint(joint: PhysicsImpostorJoint): void;
  23466. removeJoint(joint: PhysicsImpostorJoint): void;
  23467. isSupported(): boolean;
  23468. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23469. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23470. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23471. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23472. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23473. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23474. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23475. getBodyMass(impostor: PhysicsImpostor): number;
  23476. getBodyFriction(impostor: PhysicsImpostor): number;
  23477. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23478. getBodyRestitution(impostor: PhysicsImpostor): number;
  23479. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23480. getBodyPressure?(impostor: PhysicsImpostor): number;
  23481. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23482. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23483. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23484. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23485. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23486. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23487. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23488. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23489. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23490. sleepBody(impostor: PhysicsImpostor): void;
  23491. wakeUpBody(impostor: PhysicsImpostor): void;
  23492. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23493. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23494. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23495. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23496. getRadius(impostor: PhysicsImpostor): number;
  23497. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23498. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23499. dispose(): void;
  23500. }
  23501. /**
  23502. * Interface used to define a physics engine
  23503. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23504. */
  23505. export interface IPhysicsEngine {
  23506. /**
  23507. * Gets the gravity vector used by the simulation
  23508. */
  23509. gravity: Vector3;
  23510. /**
  23511. * Sets the gravity vector used by the simulation
  23512. * @param gravity defines the gravity vector to use
  23513. */
  23514. setGravity(gravity: Vector3): void;
  23515. /**
  23516. * Set the time step of the physics engine.
  23517. * Default is 1/60.
  23518. * To slow it down, enter 1/600 for example.
  23519. * To speed it up, 1/30
  23520. * @param newTimeStep the new timestep to apply to this world.
  23521. */
  23522. setTimeStep(newTimeStep: number): void;
  23523. /**
  23524. * Get the time step of the physics engine.
  23525. * @returns the current time step
  23526. */
  23527. getTimeStep(): number;
  23528. /**
  23529. * Release all resources
  23530. */
  23531. dispose(): void;
  23532. /**
  23533. * Gets the name of the current physics plugin
  23534. * @returns the name of the plugin
  23535. */
  23536. getPhysicsPluginName(): string;
  23537. /**
  23538. * Adding a new impostor for the impostor tracking.
  23539. * This will be done by the impostor itself.
  23540. * @param impostor the impostor to add
  23541. */
  23542. addImpostor(impostor: PhysicsImpostor): void;
  23543. /**
  23544. * Remove an impostor from the engine.
  23545. * This impostor and its mesh will not longer be updated by the physics engine.
  23546. * @param impostor the impostor to remove
  23547. */
  23548. removeImpostor(impostor: PhysicsImpostor): void;
  23549. /**
  23550. * Add a joint to the physics engine
  23551. * @param mainImpostor defines the main impostor to which the joint is added.
  23552. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23553. * @param joint defines the joint that will connect both impostors.
  23554. */
  23555. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23556. /**
  23557. * Removes a joint from the simulation
  23558. * @param mainImpostor defines the impostor used with the joint
  23559. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23560. * @param joint defines the joint to remove
  23561. */
  23562. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23563. /**
  23564. * Gets the current plugin used to run the simulation
  23565. * @returns current plugin
  23566. */
  23567. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23568. /**
  23569. * Gets the list of physic impostors
  23570. * @returns an array of PhysicsImpostor
  23571. */
  23572. getImpostors(): Array<PhysicsImpostor>;
  23573. /**
  23574. * Gets the impostor for a physics enabled object
  23575. * @param object defines the object impersonated by the impostor
  23576. * @returns the PhysicsImpostor or null if not found
  23577. */
  23578. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23579. /**
  23580. * Gets the impostor for a physics body object
  23581. * @param body defines physics body used by the impostor
  23582. * @returns the PhysicsImpostor or null if not found
  23583. */
  23584. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23585. /**
  23586. * Does a raycast in the physics world
  23587. * @param from when should the ray start?
  23588. * @param to when should the ray end?
  23589. * @returns PhysicsRaycastResult
  23590. */
  23591. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23592. /**
  23593. * Called by the scene. No need to call it.
  23594. * @param delta defines the timespam between frames
  23595. */
  23596. _step(delta: number): void;
  23597. }
  23598. }
  23599. declare module "babylonjs/Physics/physicsImpostor" {
  23600. import { Nullable, IndicesArray } from "babylonjs/types";
  23601. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  23602. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23603. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23604. import { Scene } from "babylonjs/scene";
  23605. import { Bone } from "babylonjs/Bones/bone";
  23606. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23607. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  23608. import { Space } from "babylonjs/Maths/math.axis";
  23609. /**
  23610. * The interface for the physics imposter parameters
  23611. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23612. */
  23613. export interface PhysicsImpostorParameters {
  23614. /**
  23615. * The mass of the physics imposter
  23616. */
  23617. mass: number;
  23618. /**
  23619. * The friction of the physics imposter
  23620. */
  23621. friction?: number;
  23622. /**
  23623. * The coefficient of restitution of the physics imposter
  23624. */
  23625. restitution?: number;
  23626. /**
  23627. * The native options of the physics imposter
  23628. */
  23629. nativeOptions?: any;
  23630. /**
  23631. * Specifies if the parent should be ignored
  23632. */
  23633. ignoreParent?: boolean;
  23634. /**
  23635. * Specifies if bi-directional transformations should be disabled
  23636. */
  23637. disableBidirectionalTransformation?: boolean;
  23638. /**
  23639. * The pressure inside the physics imposter, soft object only
  23640. */
  23641. pressure?: number;
  23642. /**
  23643. * The stiffness the physics imposter, soft object only
  23644. */
  23645. stiffness?: number;
  23646. /**
  23647. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23648. */
  23649. velocityIterations?: number;
  23650. /**
  23651. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23652. */
  23653. positionIterations?: number;
  23654. /**
  23655. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23656. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23657. * Add to fix multiple points
  23658. */
  23659. fixedPoints?: number;
  23660. /**
  23661. * The collision margin around a soft object
  23662. */
  23663. margin?: number;
  23664. /**
  23665. * The collision margin around a soft object
  23666. */
  23667. damping?: number;
  23668. /**
  23669. * The path for a rope based on an extrusion
  23670. */
  23671. path?: any;
  23672. /**
  23673. * The shape of an extrusion used for a rope based on an extrusion
  23674. */
  23675. shape?: any;
  23676. }
  23677. /**
  23678. * Interface for a physics-enabled object
  23679. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23680. */
  23681. export interface IPhysicsEnabledObject {
  23682. /**
  23683. * The position of the physics-enabled object
  23684. */
  23685. position: Vector3;
  23686. /**
  23687. * The rotation of the physics-enabled object
  23688. */
  23689. rotationQuaternion: Nullable<Quaternion>;
  23690. /**
  23691. * The scale of the physics-enabled object
  23692. */
  23693. scaling: Vector3;
  23694. /**
  23695. * The rotation of the physics-enabled object
  23696. */
  23697. rotation?: Vector3;
  23698. /**
  23699. * The parent of the physics-enabled object
  23700. */
  23701. parent?: any;
  23702. /**
  23703. * The bounding info of the physics-enabled object
  23704. * @returns The bounding info of the physics-enabled object
  23705. */
  23706. getBoundingInfo(): BoundingInfo;
  23707. /**
  23708. * Computes the world matrix
  23709. * @param force Specifies if the world matrix should be computed by force
  23710. * @returns A world matrix
  23711. */
  23712. computeWorldMatrix(force: boolean): Matrix;
  23713. /**
  23714. * Gets the world matrix
  23715. * @returns A world matrix
  23716. */
  23717. getWorldMatrix?(): Matrix;
  23718. /**
  23719. * Gets the child meshes
  23720. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23721. * @returns An array of abstract meshes
  23722. */
  23723. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23724. /**
  23725. * Gets the vertex data
  23726. * @param kind The type of vertex data
  23727. * @returns A nullable array of numbers, or a float32 array
  23728. */
  23729. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23730. /**
  23731. * Gets the indices from the mesh
  23732. * @returns A nullable array of index arrays
  23733. */
  23734. getIndices?(): Nullable<IndicesArray>;
  23735. /**
  23736. * Gets the scene from the mesh
  23737. * @returns the indices array or null
  23738. */
  23739. getScene?(): Scene;
  23740. /**
  23741. * Gets the absolute position from the mesh
  23742. * @returns the absolute position
  23743. */
  23744. getAbsolutePosition(): Vector3;
  23745. /**
  23746. * Gets the absolute pivot point from the mesh
  23747. * @returns the absolute pivot point
  23748. */
  23749. getAbsolutePivotPoint(): Vector3;
  23750. /**
  23751. * Rotates the mesh
  23752. * @param axis The axis of rotation
  23753. * @param amount The amount of rotation
  23754. * @param space The space of the rotation
  23755. * @returns The rotation transform node
  23756. */
  23757. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23758. /**
  23759. * Translates the mesh
  23760. * @param axis The axis of translation
  23761. * @param distance The distance of translation
  23762. * @param space The space of the translation
  23763. * @returns The transform node
  23764. */
  23765. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23766. /**
  23767. * Sets the absolute position of the mesh
  23768. * @param absolutePosition The absolute position of the mesh
  23769. * @returns The transform node
  23770. */
  23771. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23772. /**
  23773. * Gets the class name of the mesh
  23774. * @returns The class name
  23775. */
  23776. getClassName(): string;
  23777. }
  23778. /**
  23779. * Represents a physics imposter
  23780. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23781. */
  23782. export class PhysicsImpostor {
  23783. /**
  23784. * The physics-enabled object used as the physics imposter
  23785. */
  23786. object: IPhysicsEnabledObject;
  23787. /**
  23788. * The type of the physics imposter
  23789. */
  23790. type: number;
  23791. private _options;
  23792. private _scene?;
  23793. /**
  23794. * The default object size of the imposter
  23795. */
  23796. static DEFAULT_OBJECT_SIZE: Vector3;
  23797. /**
  23798. * The identity quaternion of the imposter
  23799. */
  23800. static IDENTITY_QUATERNION: Quaternion;
  23801. /** @hidden */
  23802. _pluginData: any;
  23803. private _physicsEngine;
  23804. private _physicsBody;
  23805. private _bodyUpdateRequired;
  23806. private _onBeforePhysicsStepCallbacks;
  23807. private _onAfterPhysicsStepCallbacks;
  23808. /** @hidden */
  23809. _onPhysicsCollideCallbacks: Array<{
  23810. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23811. otherImpostors: Array<PhysicsImpostor>;
  23812. }>;
  23813. private _deltaPosition;
  23814. private _deltaRotation;
  23815. private _deltaRotationConjugated;
  23816. /** @hidden */
  23817. _isFromLine: boolean;
  23818. private _parent;
  23819. private _isDisposed;
  23820. private static _tmpVecs;
  23821. private static _tmpQuat;
  23822. /**
  23823. * Specifies if the physics imposter is disposed
  23824. */
  23825. readonly isDisposed: boolean;
  23826. /**
  23827. * Gets the mass of the physics imposter
  23828. */
  23829. mass: number;
  23830. /**
  23831. * Gets the coefficient of friction
  23832. */
  23833. /**
  23834. * Sets the coefficient of friction
  23835. */
  23836. friction: number;
  23837. /**
  23838. * Gets the coefficient of restitution
  23839. */
  23840. /**
  23841. * Sets the coefficient of restitution
  23842. */
  23843. restitution: number;
  23844. /**
  23845. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23846. */
  23847. /**
  23848. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23849. */
  23850. pressure: number;
  23851. /**
  23852. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23853. */
  23854. /**
  23855. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23856. */
  23857. stiffness: number;
  23858. /**
  23859. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23860. */
  23861. /**
  23862. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23863. */
  23864. velocityIterations: number;
  23865. /**
  23866. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23867. */
  23868. /**
  23869. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23870. */
  23871. positionIterations: number;
  23872. /**
  23873. * The unique id of the physics imposter
  23874. * set by the physics engine when adding this impostor to the array
  23875. */
  23876. uniqueId: number;
  23877. /**
  23878. * @hidden
  23879. */
  23880. soft: boolean;
  23881. /**
  23882. * @hidden
  23883. */
  23884. segments: number;
  23885. private _joints;
  23886. /**
  23887. * Initializes the physics imposter
  23888. * @param object The physics-enabled object used as the physics imposter
  23889. * @param type The type of the physics imposter
  23890. * @param _options The options for the physics imposter
  23891. * @param _scene The Babylon scene
  23892. */
  23893. constructor(
  23894. /**
  23895. * The physics-enabled object used as the physics imposter
  23896. */
  23897. object: IPhysicsEnabledObject,
  23898. /**
  23899. * The type of the physics imposter
  23900. */
  23901. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23902. /**
  23903. * This function will completly initialize this impostor.
  23904. * It will create a new body - but only if this mesh has no parent.
  23905. * If it has, this impostor will not be used other than to define the impostor
  23906. * of the child mesh.
  23907. * @hidden
  23908. */
  23909. _init(): void;
  23910. private _getPhysicsParent;
  23911. /**
  23912. * Should a new body be generated.
  23913. * @returns boolean specifying if body initialization is required
  23914. */
  23915. isBodyInitRequired(): boolean;
  23916. /**
  23917. * Sets the updated scaling
  23918. * @param updated Specifies if the scaling is updated
  23919. */
  23920. setScalingUpdated(): void;
  23921. /**
  23922. * Force a regeneration of this or the parent's impostor's body.
  23923. * Use under cautious - This will remove all joints already implemented.
  23924. */
  23925. forceUpdate(): void;
  23926. /**
  23927. * Gets the body that holds this impostor. Either its own, or its parent.
  23928. */
  23929. /**
  23930. * Set the physics body. Used mainly by the physics engine/plugin
  23931. */
  23932. physicsBody: any;
  23933. /**
  23934. * Get the parent of the physics imposter
  23935. * @returns Physics imposter or null
  23936. */
  23937. /**
  23938. * Sets the parent of the physics imposter
  23939. */
  23940. parent: Nullable<PhysicsImpostor>;
  23941. /**
  23942. * Resets the update flags
  23943. */
  23944. resetUpdateFlags(): void;
  23945. /**
  23946. * Gets the object extend size
  23947. * @returns the object extend size
  23948. */
  23949. getObjectExtendSize(): Vector3;
  23950. /**
  23951. * Gets the object center
  23952. * @returns The object center
  23953. */
  23954. getObjectCenter(): Vector3;
  23955. /**
  23956. * Get a specific parametes from the options parameter
  23957. * @param paramName The object parameter name
  23958. * @returns The object parameter
  23959. */
  23960. getParam(paramName: string): any;
  23961. /**
  23962. * Sets a specific parameter in the options given to the physics plugin
  23963. * @param paramName The parameter name
  23964. * @param value The value of the parameter
  23965. */
  23966. setParam(paramName: string, value: number): void;
  23967. /**
  23968. * Specifically change the body's mass option. Won't recreate the physics body object
  23969. * @param mass The mass of the physics imposter
  23970. */
  23971. setMass(mass: number): void;
  23972. /**
  23973. * Gets the linear velocity
  23974. * @returns linear velocity or null
  23975. */
  23976. getLinearVelocity(): Nullable<Vector3>;
  23977. /**
  23978. * Sets the linear velocity
  23979. * @param velocity linear velocity or null
  23980. */
  23981. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23982. /**
  23983. * Gets the angular velocity
  23984. * @returns angular velocity or null
  23985. */
  23986. getAngularVelocity(): Nullable<Vector3>;
  23987. /**
  23988. * Sets the angular velocity
  23989. * @param velocity The velocity or null
  23990. */
  23991. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23992. /**
  23993. * Execute a function with the physics plugin native code
  23994. * Provide a function the will have two variables - the world object and the physics body object
  23995. * @param func The function to execute with the physics plugin native code
  23996. */
  23997. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23998. /**
  23999. * Register a function that will be executed before the physics world is stepping forward
  24000. * @param func The function to execute before the physics world is stepped forward
  24001. */
  24002. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24003. /**
  24004. * Unregister a function that will be executed before the physics world is stepping forward
  24005. * @param func The function to execute before the physics world is stepped forward
  24006. */
  24007. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24008. /**
  24009. * Register a function that will be executed after the physics step
  24010. * @param func The function to execute after physics step
  24011. */
  24012. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24013. /**
  24014. * Unregisters a function that will be executed after the physics step
  24015. * @param func The function to execute after physics step
  24016. */
  24017. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24018. /**
  24019. * register a function that will be executed when this impostor collides against a different body
  24020. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24021. * @param func Callback that is executed on collision
  24022. */
  24023. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24024. /**
  24025. * Unregisters the physics imposter on contact
  24026. * @param collideAgainst The physics object to collide against
  24027. * @param func Callback to execute on collision
  24028. */
  24029. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24030. private _tmpQuat;
  24031. private _tmpQuat2;
  24032. /**
  24033. * Get the parent rotation
  24034. * @returns The parent rotation
  24035. */
  24036. getParentsRotation(): Quaternion;
  24037. /**
  24038. * this function is executed by the physics engine.
  24039. */
  24040. beforeStep: () => void;
  24041. /**
  24042. * this function is executed by the physics engine
  24043. */
  24044. afterStep: () => void;
  24045. /**
  24046. * Legacy collision detection event support
  24047. */
  24048. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24049. /**
  24050. * event and body object due to cannon's event-based architecture.
  24051. */
  24052. onCollide: (e: {
  24053. body: any;
  24054. }) => void;
  24055. /**
  24056. * Apply a force
  24057. * @param force The force to apply
  24058. * @param contactPoint The contact point for the force
  24059. * @returns The physics imposter
  24060. */
  24061. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24062. /**
  24063. * Apply an impulse
  24064. * @param force The impulse force
  24065. * @param contactPoint The contact point for the impulse force
  24066. * @returns The physics imposter
  24067. */
  24068. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24069. /**
  24070. * A help function to create a joint
  24071. * @param otherImpostor A physics imposter used to create a joint
  24072. * @param jointType The type of joint
  24073. * @param jointData The data for the joint
  24074. * @returns The physics imposter
  24075. */
  24076. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24077. /**
  24078. * Add a joint to this impostor with a different impostor
  24079. * @param otherImpostor A physics imposter used to add a joint
  24080. * @param joint The joint to add
  24081. * @returns The physics imposter
  24082. */
  24083. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24084. /**
  24085. * Add an anchor to a cloth impostor
  24086. * @param otherImpostor rigid impostor to anchor to
  24087. * @param width ratio across width from 0 to 1
  24088. * @param height ratio up height from 0 to 1
  24089. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24090. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24091. * @returns impostor the soft imposter
  24092. */
  24093. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24094. /**
  24095. * Add a hook to a rope impostor
  24096. * @param otherImpostor rigid impostor to anchor to
  24097. * @param length ratio across rope from 0 to 1
  24098. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24099. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24100. * @returns impostor the rope imposter
  24101. */
  24102. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24103. /**
  24104. * Will keep this body still, in a sleep mode.
  24105. * @returns the physics imposter
  24106. */
  24107. sleep(): PhysicsImpostor;
  24108. /**
  24109. * Wake the body up.
  24110. * @returns The physics imposter
  24111. */
  24112. wakeUp(): PhysicsImpostor;
  24113. /**
  24114. * Clones the physics imposter
  24115. * @param newObject The physics imposter clones to this physics-enabled object
  24116. * @returns A nullable physics imposter
  24117. */
  24118. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24119. /**
  24120. * Disposes the physics imposter
  24121. */
  24122. dispose(): void;
  24123. /**
  24124. * Sets the delta position
  24125. * @param position The delta position amount
  24126. */
  24127. setDeltaPosition(position: Vector3): void;
  24128. /**
  24129. * Sets the delta rotation
  24130. * @param rotation The delta rotation amount
  24131. */
  24132. setDeltaRotation(rotation: Quaternion): void;
  24133. /**
  24134. * Gets the box size of the physics imposter and stores the result in the input parameter
  24135. * @param result Stores the box size
  24136. * @returns The physics imposter
  24137. */
  24138. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24139. /**
  24140. * Gets the radius of the physics imposter
  24141. * @returns Radius of the physics imposter
  24142. */
  24143. getRadius(): number;
  24144. /**
  24145. * Sync a bone with this impostor
  24146. * @param bone The bone to sync to the impostor.
  24147. * @param boneMesh The mesh that the bone is influencing.
  24148. * @param jointPivot The pivot of the joint / bone in local space.
  24149. * @param distToJoint Optional distance from the impostor to the joint.
  24150. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24151. */
  24152. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24153. /**
  24154. * Sync impostor to a bone
  24155. * @param bone The bone that the impostor will be synced to.
  24156. * @param boneMesh The mesh that the bone is influencing.
  24157. * @param jointPivot The pivot of the joint / bone in local space.
  24158. * @param distToJoint Optional distance from the impostor to the joint.
  24159. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24160. * @param boneAxis Optional vector3 axis the bone is aligned with
  24161. */
  24162. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24163. /**
  24164. * No-Imposter type
  24165. */
  24166. static NoImpostor: number;
  24167. /**
  24168. * Sphere-Imposter type
  24169. */
  24170. static SphereImpostor: number;
  24171. /**
  24172. * Box-Imposter type
  24173. */
  24174. static BoxImpostor: number;
  24175. /**
  24176. * Plane-Imposter type
  24177. */
  24178. static PlaneImpostor: number;
  24179. /**
  24180. * Mesh-imposter type
  24181. */
  24182. static MeshImpostor: number;
  24183. /**
  24184. * Capsule-Impostor type (Ammo.js plugin only)
  24185. */
  24186. static CapsuleImpostor: number;
  24187. /**
  24188. * Cylinder-Imposter type
  24189. */
  24190. static CylinderImpostor: number;
  24191. /**
  24192. * Particle-Imposter type
  24193. */
  24194. static ParticleImpostor: number;
  24195. /**
  24196. * Heightmap-Imposter type
  24197. */
  24198. static HeightmapImpostor: number;
  24199. /**
  24200. * ConvexHull-Impostor type (Ammo.js plugin only)
  24201. */
  24202. static ConvexHullImpostor: number;
  24203. /**
  24204. * Rope-Imposter type
  24205. */
  24206. static RopeImpostor: number;
  24207. /**
  24208. * Cloth-Imposter type
  24209. */
  24210. static ClothImpostor: number;
  24211. /**
  24212. * Softbody-Imposter type
  24213. */
  24214. static SoftbodyImpostor: number;
  24215. }
  24216. }
  24217. declare module "babylonjs/Meshes/mesh" {
  24218. import { Observable } from "babylonjs/Misc/observable";
  24219. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24220. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  24221. import { Camera } from "babylonjs/Cameras/camera";
  24222. import { Scene } from "babylonjs/scene";
  24223. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  24224. import { Color4 } from "babylonjs/Maths/math.color";
  24225. import { Engine } from "babylonjs/Engines/engine";
  24226. import { Node } from "babylonjs/node";
  24227. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  24228. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24229. import { Buffer } from "babylonjs/Meshes/buffer";
  24230. import { Geometry } from "babylonjs/Meshes/geometry";
  24231. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24232. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24233. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  24234. import { Effect } from "babylonjs/Materials/effect";
  24235. import { Material } from "babylonjs/Materials/material";
  24236. import { Skeleton } from "babylonjs/Bones/skeleton";
  24237. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  24238. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  24239. import { Path3D } from "babylonjs/Maths/math.path";
  24240. import { Plane } from "babylonjs/Maths/math.plane";
  24241. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24242. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  24243. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  24244. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  24245. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24246. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  24247. /**
  24248. * @hidden
  24249. **/
  24250. export class _CreationDataStorage {
  24251. closePath?: boolean;
  24252. closeArray?: boolean;
  24253. idx: number[];
  24254. dashSize: number;
  24255. gapSize: number;
  24256. path3D: Path3D;
  24257. pathArray: Vector3[][];
  24258. arc: number;
  24259. radius: number;
  24260. cap: number;
  24261. tessellation: number;
  24262. }
  24263. /**
  24264. * @hidden
  24265. **/
  24266. class _InstanceDataStorage {
  24267. visibleInstances: any;
  24268. batchCache: _InstancesBatch;
  24269. instancesBufferSize: number;
  24270. instancesBuffer: Nullable<Buffer>;
  24271. instancesData: Float32Array;
  24272. overridenInstanceCount: number;
  24273. isFrozen: boolean;
  24274. previousBatch: Nullable<_InstancesBatch>;
  24275. hardwareInstancedRendering: boolean;
  24276. sideOrientation: number;
  24277. }
  24278. /**
  24279. * @hidden
  24280. **/
  24281. export class _InstancesBatch {
  24282. mustReturn: boolean;
  24283. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  24284. renderSelf: boolean[];
  24285. hardwareInstancedRendering: boolean[];
  24286. }
  24287. /**
  24288. * Class used to represent renderable models
  24289. */
  24290. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24291. /**
  24292. * Mesh side orientation : usually the external or front surface
  24293. */
  24294. static readonly FRONTSIDE: number;
  24295. /**
  24296. * Mesh side orientation : usually the internal or back surface
  24297. */
  24298. static readonly BACKSIDE: number;
  24299. /**
  24300. * Mesh side orientation : both internal and external or front and back surfaces
  24301. */
  24302. static readonly DOUBLESIDE: number;
  24303. /**
  24304. * Mesh side orientation : by default, `FRONTSIDE`
  24305. */
  24306. static readonly DEFAULTSIDE: number;
  24307. /**
  24308. * Mesh cap setting : no cap
  24309. */
  24310. static readonly NO_CAP: number;
  24311. /**
  24312. * Mesh cap setting : one cap at the beginning of the mesh
  24313. */
  24314. static readonly CAP_START: number;
  24315. /**
  24316. * Mesh cap setting : one cap at the end of the mesh
  24317. */
  24318. static readonly CAP_END: number;
  24319. /**
  24320. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24321. */
  24322. static readonly CAP_ALL: number;
  24323. /**
  24324. * Mesh pattern setting : no flip or rotate
  24325. */
  24326. static readonly NO_FLIP: number;
  24327. /**
  24328. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24329. */
  24330. static readonly FLIP_TILE: number;
  24331. /**
  24332. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24333. */
  24334. static readonly ROTATE_TILE: number;
  24335. /**
  24336. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24337. */
  24338. static readonly FLIP_ROW: number;
  24339. /**
  24340. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24341. */
  24342. static readonly ROTATE_ROW: number;
  24343. /**
  24344. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24345. */
  24346. static readonly FLIP_N_ROTATE_TILE: number;
  24347. /**
  24348. * Mesh pattern setting : rotate pattern and rotate
  24349. */
  24350. static readonly FLIP_N_ROTATE_ROW: number;
  24351. /**
  24352. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24353. */
  24354. static readonly CENTER: number;
  24355. /**
  24356. * Mesh tile positioning : part tiles on left
  24357. */
  24358. static readonly LEFT: number;
  24359. /**
  24360. * Mesh tile positioning : part tiles on right
  24361. */
  24362. static readonly RIGHT: number;
  24363. /**
  24364. * Mesh tile positioning : part tiles on top
  24365. */
  24366. static readonly TOP: number;
  24367. /**
  24368. * Mesh tile positioning : part tiles on bottom
  24369. */
  24370. static readonly BOTTOM: number;
  24371. /**
  24372. * Gets the default side orientation.
  24373. * @param orientation the orientation to value to attempt to get
  24374. * @returns the default orientation
  24375. * @hidden
  24376. */
  24377. static _GetDefaultSideOrientation(orientation?: number): number;
  24378. private _internalMeshDataInfo;
  24379. /**
  24380. * An event triggered before rendering the mesh
  24381. */
  24382. readonly onBeforeRenderObservable: Observable<Mesh>;
  24383. /**
  24384. * An event triggered before binding the mesh
  24385. */
  24386. readonly onBeforeBindObservable: Observable<Mesh>;
  24387. /**
  24388. * An event triggered after rendering the mesh
  24389. */
  24390. readonly onAfterRenderObservable: Observable<Mesh>;
  24391. /**
  24392. * An event triggered before drawing the mesh
  24393. */
  24394. readonly onBeforeDrawObservable: Observable<Mesh>;
  24395. private _onBeforeDrawObserver;
  24396. /**
  24397. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24398. */
  24399. onBeforeDraw: () => void;
  24400. readonly hasInstances: boolean;
  24401. /**
  24402. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24403. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24404. */
  24405. delayLoadState: number;
  24406. /**
  24407. * Gets the list of instances created from this mesh
  24408. * it is not supposed to be modified manually.
  24409. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24410. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24411. */
  24412. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24413. /**
  24414. * Gets the file containing delay loading data for this mesh
  24415. */
  24416. delayLoadingFile: string;
  24417. /** @hidden */
  24418. _binaryInfo: any;
  24419. /**
  24420. * User defined function used to change how LOD level selection is done
  24421. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24422. */
  24423. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24424. /**
  24425. * Gets or sets the morph target manager
  24426. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24427. */
  24428. morphTargetManager: Nullable<MorphTargetManager>;
  24429. /** @hidden */
  24430. _creationDataStorage: Nullable<_CreationDataStorage>;
  24431. /** @hidden */
  24432. _geometry: Nullable<Geometry>;
  24433. /** @hidden */
  24434. _delayInfo: Array<string>;
  24435. /** @hidden */
  24436. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24437. /** @hidden */
  24438. _instanceDataStorage: _InstanceDataStorage;
  24439. private _effectiveMaterial;
  24440. /** @hidden */
  24441. _shouldGenerateFlatShading: boolean;
  24442. /** @hidden */
  24443. _originalBuilderSideOrientation: number;
  24444. /**
  24445. * Use this property to change the original side orientation defined at construction time
  24446. */
  24447. overrideMaterialSideOrientation: Nullable<number>;
  24448. /**
  24449. * Gets the source mesh (the one used to clone this one from)
  24450. */
  24451. readonly source: Nullable<Mesh>;
  24452. /**
  24453. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24454. */
  24455. isUnIndexed: boolean;
  24456. /**
  24457. * @constructor
  24458. * @param name The value used by scene.getMeshByName() to do a lookup.
  24459. * @param scene The scene to add this mesh to.
  24460. * @param parent The parent of this mesh, if it has one
  24461. * @param source An optional Mesh from which geometry is shared, cloned.
  24462. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24463. * When false, achieved by calling a clone(), also passing False.
  24464. * This will make creation of children, recursive.
  24465. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24466. */
  24467. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24468. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  24469. /**
  24470. * Gets the class name
  24471. * @returns the string "Mesh".
  24472. */
  24473. getClassName(): string;
  24474. /** @hidden */
  24475. readonly _isMesh: boolean;
  24476. /**
  24477. * Returns a description of this mesh
  24478. * @param fullDetails define if full details about this mesh must be used
  24479. * @returns a descriptive string representing this mesh
  24480. */
  24481. toString(fullDetails?: boolean): string;
  24482. /** @hidden */
  24483. _unBindEffect(): void;
  24484. /**
  24485. * Gets a boolean indicating if this mesh has LOD
  24486. */
  24487. readonly hasLODLevels: boolean;
  24488. /**
  24489. * Gets the list of MeshLODLevel associated with the current mesh
  24490. * @returns an array of MeshLODLevel
  24491. */
  24492. getLODLevels(): MeshLODLevel[];
  24493. private _sortLODLevels;
  24494. /**
  24495. * Add a mesh as LOD level triggered at the given distance.
  24496. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24497. * @param distance The distance from the center of the object to show this level
  24498. * @param mesh The mesh to be added as LOD level (can be null)
  24499. * @return This mesh (for chaining)
  24500. */
  24501. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24502. /**
  24503. * Returns the LOD level mesh at the passed distance or null if not found.
  24504. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24505. * @param distance The distance from the center of the object to show this level
  24506. * @returns a Mesh or `null`
  24507. */
  24508. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24509. /**
  24510. * Remove a mesh from the LOD array
  24511. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24512. * @param mesh defines the mesh to be removed
  24513. * @return This mesh (for chaining)
  24514. */
  24515. removeLODLevel(mesh: Mesh): Mesh;
  24516. /**
  24517. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24518. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24519. * @param camera defines the camera to use to compute distance
  24520. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24521. * @return This mesh (for chaining)
  24522. */
  24523. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24524. /**
  24525. * Gets the mesh internal Geometry object
  24526. */
  24527. readonly geometry: Nullable<Geometry>;
  24528. /**
  24529. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24530. * @returns the total number of vertices
  24531. */
  24532. getTotalVertices(): number;
  24533. /**
  24534. * Returns the content of an associated vertex buffer
  24535. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24536. * - VertexBuffer.PositionKind
  24537. * - VertexBuffer.UVKind
  24538. * - VertexBuffer.UV2Kind
  24539. * - VertexBuffer.UV3Kind
  24540. * - VertexBuffer.UV4Kind
  24541. * - VertexBuffer.UV5Kind
  24542. * - VertexBuffer.UV6Kind
  24543. * - VertexBuffer.ColorKind
  24544. * - VertexBuffer.MatricesIndicesKind
  24545. * - VertexBuffer.MatricesIndicesExtraKind
  24546. * - VertexBuffer.MatricesWeightsKind
  24547. * - VertexBuffer.MatricesWeightsExtraKind
  24548. * @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
  24549. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24550. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24551. */
  24552. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24553. /**
  24554. * Returns the mesh VertexBuffer object from the requested `kind`
  24555. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24556. * - VertexBuffer.PositionKind
  24557. * - VertexBuffer.NormalKind
  24558. * - VertexBuffer.UVKind
  24559. * - VertexBuffer.UV2Kind
  24560. * - VertexBuffer.UV3Kind
  24561. * - VertexBuffer.UV4Kind
  24562. * - VertexBuffer.UV5Kind
  24563. * - VertexBuffer.UV6Kind
  24564. * - VertexBuffer.ColorKind
  24565. * - VertexBuffer.MatricesIndicesKind
  24566. * - VertexBuffer.MatricesIndicesExtraKind
  24567. * - VertexBuffer.MatricesWeightsKind
  24568. * - VertexBuffer.MatricesWeightsExtraKind
  24569. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24570. */
  24571. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24572. /**
  24573. * Tests if a specific vertex buffer is associated with this mesh
  24574. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24575. * - VertexBuffer.PositionKind
  24576. * - VertexBuffer.NormalKind
  24577. * - VertexBuffer.UVKind
  24578. * - VertexBuffer.UV2Kind
  24579. * - VertexBuffer.UV3Kind
  24580. * - VertexBuffer.UV4Kind
  24581. * - VertexBuffer.UV5Kind
  24582. * - VertexBuffer.UV6Kind
  24583. * - VertexBuffer.ColorKind
  24584. * - VertexBuffer.MatricesIndicesKind
  24585. * - VertexBuffer.MatricesIndicesExtraKind
  24586. * - VertexBuffer.MatricesWeightsKind
  24587. * - VertexBuffer.MatricesWeightsExtraKind
  24588. * @returns a boolean
  24589. */
  24590. isVerticesDataPresent(kind: string): boolean;
  24591. /**
  24592. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24593. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24594. * - VertexBuffer.PositionKind
  24595. * - VertexBuffer.UVKind
  24596. * - VertexBuffer.UV2Kind
  24597. * - VertexBuffer.UV3Kind
  24598. * - VertexBuffer.UV4Kind
  24599. * - VertexBuffer.UV5Kind
  24600. * - VertexBuffer.UV6Kind
  24601. * - VertexBuffer.ColorKind
  24602. * - VertexBuffer.MatricesIndicesKind
  24603. * - VertexBuffer.MatricesIndicesExtraKind
  24604. * - VertexBuffer.MatricesWeightsKind
  24605. * - VertexBuffer.MatricesWeightsExtraKind
  24606. * @returns a boolean
  24607. */
  24608. isVertexBufferUpdatable(kind: string): boolean;
  24609. /**
  24610. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24611. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24612. * - VertexBuffer.PositionKind
  24613. * - VertexBuffer.NormalKind
  24614. * - VertexBuffer.UVKind
  24615. * - VertexBuffer.UV2Kind
  24616. * - VertexBuffer.UV3Kind
  24617. * - VertexBuffer.UV4Kind
  24618. * - VertexBuffer.UV5Kind
  24619. * - VertexBuffer.UV6Kind
  24620. * - VertexBuffer.ColorKind
  24621. * - VertexBuffer.MatricesIndicesKind
  24622. * - VertexBuffer.MatricesIndicesExtraKind
  24623. * - VertexBuffer.MatricesWeightsKind
  24624. * - VertexBuffer.MatricesWeightsExtraKind
  24625. * @returns an array of strings
  24626. */
  24627. getVerticesDataKinds(): string[];
  24628. /**
  24629. * Returns a positive integer : the total number of indices in this mesh geometry.
  24630. * @returns the numner of indices or zero if the mesh has no geometry.
  24631. */
  24632. getTotalIndices(): number;
  24633. /**
  24634. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24635. * @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.
  24636. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24637. * @returns the indices array or an empty array if the mesh has no geometry
  24638. */
  24639. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24640. readonly isBlocked: boolean;
  24641. /**
  24642. * Determine if the current mesh is ready to be rendered
  24643. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24644. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24645. * @returns true if all associated assets are ready (material, textures, shaders)
  24646. */
  24647. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24648. /**
  24649. * 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.
  24650. */
  24651. readonly areNormalsFrozen: boolean;
  24652. /**
  24653. * 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.
  24654. * @returns the current mesh
  24655. */
  24656. freezeNormals(): Mesh;
  24657. /**
  24658. * 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
  24659. * @returns the current mesh
  24660. */
  24661. unfreezeNormals(): Mesh;
  24662. /**
  24663. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24664. */
  24665. overridenInstanceCount: number;
  24666. /** @hidden */
  24667. _preActivate(): Mesh;
  24668. /** @hidden */
  24669. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24670. /** @hidden */
  24671. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24672. /**
  24673. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24674. * This means the mesh underlying bounding box and sphere are recomputed.
  24675. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24676. * @returns the current mesh
  24677. */
  24678. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24679. /** @hidden */
  24680. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24681. /**
  24682. * This function will subdivide the mesh into multiple submeshes
  24683. * @param count defines the expected number of submeshes
  24684. */
  24685. subdivide(count: number): void;
  24686. /**
  24687. * Copy a FloatArray into a specific associated vertex buffer
  24688. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24689. * - VertexBuffer.PositionKind
  24690. * - VertexBuffer.UVKind
  24691. * - VertexBuffer.UV2Kind
  24692. * - VertexBuffer.UV3Kind
  24693. * - VertexBuffer.UV4Kind
  24694. * - VertexBuffer.UV5Kind
  24695. * - VertexBuffer.UV6Kind
  24696. * - VertexBuffer.ColorKind
  24697. * - VertexBuffer.MatricesIndicesKind
  24698. * - VertexBuffer.MatricesIndicesExtraKind
  24699. * - VertexBuffer.MatricesWeightsKind
  24700. * - VertexBuffer.MatricesWeightsExtraKind
  24701. * @param data defines the data source
  24702. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24703. * @param stride defines the data stride size (can be null)
  24704. * @returns the current mesh
  24705. */
  24706. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24707. /**
  24708. * Flags an associated vertex buffer as updatable
  24709. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24710. * - VertexBuffer.PositionKind
  24711. * - VertexBuffer.UVKind
  24712. * - VertexBuffer.UV2Kind
  24713. * - VertexBuffer.UV3Kind
  24714. * - VertexBuffer.UV4Kind
  24715. * - VertexBuffer.UV5Kind
  24716. * - VertexBuffer.UV6Kind
  24717. * - VertexBuffer.ColorKind
  24718. * - VertexBuffer.MatricesIndicesKind
  24719. * - VertexBuffer.MatricesIndicesExtraKind
  24720. * - VertexBuffer.MatricesWeightsKind
  24721. * - VertexBuffer.MatricesWeightsExtraKind
  24722. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24723. */
  24724. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24725. /**
  24726. * Sets the mesh global Vertex Buffer
  24727. * @param buffer defines the buffer to use
  24728. * @returns the current mesh
  24729. */
  24730. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24731. /**
  24732. * Update a specific associated vertex buffer
  24733. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24734. * - VertexBuffer.PositionKind
  24735. * - VertexBuffer.UVKind
  24736. * - VertexBuffer.UV2Kind
  24737. * - VertexBuffer.UV3Kind
  24738. * - VertexBuffer.UV4Kind
  24739. * - VertexBuffer.UV5Kind
  24740. * - VertexBuffer.UV6Kind
  24741. * - VertexBuffer.ColorKind
  24742. * - VertexBuffer.MatricesIndicesKind
  24743. * - VertexBuffer.MatricesIndicesExtraKind
  24744. * - VertexBuffer.MatricesWeightsKind
  24745. * - VertexBuffer.MatricesWeightsExtraKind
  24746. * @param data defines the data source
  24747. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24748. * @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)
  24749. * @returns the current mesh
  24750. */
  24751. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24752. /**
  24753. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24754. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24755. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24756. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24757. * @returns the current mesh
  24758. */
  24759. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24760. /**
  24761. * Creates a un-shared specific occurence of the geometry for the mesh.
  24762. * @returns the current mesh
  24763. */
  24764. makeGeometryUnique(): Mesh;
  24765. /**
  24766. * Set the index buffer of this mesh
  24767. * @param indices defines the source data
  24768. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24769. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24770. * @returns the current mesh
  24771. */
  24772. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24773. /**
  24774. * Update the current index buffer
  24775. * @param indices defines the source data
  24776. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24777. * @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)
  24778. * @returns the current mesh
  24779. */
  24780. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24781. /**
  24782. * Invert the geometry to move from a right handed system to a left handed one.
  24783. * @returns the current mesh
  24784. */
  24785. toLeftHanded(): Mesh;
  24786. /** @hidden */
  24787. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24788. /** @hidden */
  24789. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24790. /**
  24791. * Registers for this mesh a javascript function called just before the rendering process
  24792. * @param func defines the function to call before rendering this mesh
  24793. * @returns the current mesh
  24794. */
  24795. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24796. /**
  24797. * Disposes a previously registered javascript function called before the rendering
  24798. * @param func defines the function to remove
  24799. * @returns the current mesh
  24800. */
  24801. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24802. /**
  24803. * Registers for this mesh a javascript function called just after the rendering is complete
  24804. * @param func defines the function to call after rendering this mesh
  24805. * @returns the current mesh
  24806. */
  24807. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24808. /**
  24809. * Disposes a previously registered javascript function called after the rendering.
  24810. * @param func defines the function to remove
  24811. * @returns the current mesh
  24812. */
  24813. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24814. /** @hidden */
  24815. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  24816. /** @hidden */
  24817. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24818. /** @hidden */
  24819. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24820. /** @hidden */
  24821. _rebuild(): void;
  24822. /** @hidden */
  24823. _freeze(): void;
  24824. /** @hidden */
  24825. _unFreeze(): void;
  24826. /**
  24827. * 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
  24828. * @param subMesh defines the subMesh to render
  24829. * @param enableAlphaMode defines if alpha mode can be changed
  24830. * @returns the current mesh
  24831. */
  24832. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  24833. private _onBeforeDraw;
  24834. /**
  24835. * Renormalize the mesh and patch it up if there are no weights
  24836. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24837. * However in the case of zero weights then we set just a single influence to 1.
  24838. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24839. */
  24840. cleanMatrixWeights(): void;
  24841. private normalizeSkinFourWeights;
  24842. private normalizeSkinWeightsAndExtra;
  24843. /**
  24844. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24845. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24846. * the user know there was an issue with importing the mesh
  24847. * @returns a validation object with skinned, valid and report string
  24848. */
  24849. validateSkinning(): {
  24850. skinned: boolean;
  24851. valid: boolean;
  24852. report: string;
  24853. };
  24854. /** @hidden */
  24855. _checkDelayState(): Mesh;
  24856. private _queueLoad;
  24857. /**
  24858. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24859. * A mesh is in the frustum if its bounding box intersects the frustum
  24860. * @param frustumPlanes defines the frustum to test
  24861. * @returns true if the mesh is in the frustum planes
  24862. */
  24863. isInFrustum(frustumPlanes: Plane[]): boolean;
  24864. /**
  24865. * Sets the mesh material by the material or multiMaterial `id` property
  24866. * @param id is a string identifying the material or the multiMaterial
  24867. * @returns the current mesh
  24868. */
  24869. setMaterialByID(id: string): Mesh;
  24870. /**
  24871. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24872. * @returns an array of IAnimatable
  24873. */
  24874. getAnimatables(): IAnimatable[];
  24875. /**
  24876. * Modifies the mesh geometry according to the passed transformation matrix.
  24877. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24878. * The mesh normals are modified using the same transformation.
  24879. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24880. * @param transform defines the transform matrix to use
  24881. * @see http://doc.babylonjs.com/resources/baking_transformations
  24882. * @returns the current mesh
  24883. */
  24884. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24885. /**
  24886. * Modifies the mesh geometry according to its own current World Matrix.
  24887. * The mesh World Matrix is then reset.
  24888. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24889. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24890. * @see http://doc.babylonjs.com/resources/baking_transformations
  24891. * @returns the current mesh
  24892. */
  24893. bakeCurrentTransformIntoVertices(): Mesh;
  24894. /** @hidden */
  24895. readonly _positions: Nullable<Vector3[]>;
  24896. /** @hidden */
  24897. _resetPointsArrayCache(): Mesh;
  24898. /** @hidden */
  24899. _generatePointsArray(): boolean;
  24900. /**
  24901. * Returns a new Mesh object generated from the current mesh properties.
  24902. * This method must not get confused with createInstance()
  24903. * @param name is a string, the name given to the new mesh
  24904. * @param newParent can be any Node object (default `null`)
  24905. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24906. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24907. * @returns a new mesh
  24908. */
  24909. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  24910. /**
  24911. * Releases resources associated with this mesh.
  24912. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24913. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24914. */
  24915. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24916. /**
  24917. * Modifies the mesh geometry according to a displacement map.
  24918. * 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.
  24919. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24920. * @param url is a string, the URL from the image file is to be downloaded.
  24921. * @param minHeight is the lower limit of the displacement.
  24922. * @param maxHeight is the upper limit of the displacement.
  24923. * @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.
  24924. * @param uvOffset is an optional vector2 used to offset UV.
  24925. * @param uvScale is an optional vector2 used to scale UV.
  24926. * @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.
  24927. * @returns the Mesh.
  24928. */
  24929. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24930. /**
  24931. * Modifies the mesh geometry according to a displacementMap buffer.
  24932. * 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.
  24933. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24934. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24935. * @param heightMapWidth is the width of the buffer image.
  24936. * @param heightMapHeight is the height of the buffer image.
  24937. * @param minHeight is the lower limit of the displacement.
  24938. * @param maxHeight is the upper limit of the displacement.
  24939. * @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.
  24940. * @param uvOffset is an optional vector2 used to offset UV.
  24941. * @param uvScale is an optional vector2 used to scale UV.
  24942. * @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.
  24943. * @returns the Mesh.
  24944. */
  24945. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24946. /**
  24947. * Modify the mesh to get a flat shading rendering.
  24948. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24949. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24950. * @returns current mesh
  24951. */
  24952. convertToFlatShadedMesh(): Mesh;
  24953. /**
  24954. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24955. * In other words, more vertices, no more indices and a single bigger VBO.
  24956. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24957. * @returns current mesh
  24958. */
  24959. convertToUnIndexedMesh(): Mesh;
  24960. /**
  24961. * Inverses facet orientations.
  24962. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24963. * @param flipNormals will also inverts the normals
  24964. * @returns current mesh
  24965. */
  24966. flipFaces(flipNormals?: boolean): Mesh;
  24967. /**
  24968. * Increase the number of facets and hence vertices in a mesh
  24969. * Vertex normals are interpolated from existing vertex normals
  24970. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24971. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24972. */
  24973. increaseVertices(numberPerEdge: number): void;
  24974. /**
  24975. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24976. * This will undo any application of covertToFlatShadedMesh
  24977. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24978. */
  24979. forceSharedVertices(): void;
  24980. /** @hidden */
  24981. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24982. /** @hidden */
  24983. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24984. /**
  24985. * Creates a new InstancedMesh object from the mesh model.
  24986. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24987. * @param name defines the name of the new instance
  24988. * @returns a new InstancedMesh
  24989. */
  24990. createInstance(name: string): InstancedMesh;
  24991. /**
  24992. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24993. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24994. * @returns the current mesh
  24995. */
  24996. synchronizeInstances(): Mesh;
  24997. /**
  24998. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24999. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25000. * This should be used together with the simplification to avoid disappearing triangles.
  25001. * @param successCallback an optional success callback to be called after the optimization finished.
  25002. * @returns the current mesh
  25003. */
  25004. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25005. /**
  25006. * Serialize current mesh
  25007. * @param serializationObject defines the object which will receive the serialization data
  25008. */
  25009. serialize(serializationObject: any): void;
  25010. /** @hidden */
  25011. _syncGeometryWithMorphTargetManager(): void;
  25012. /** @hidden */
  25013. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25014. /**
  25015. * Returns a new Mesh object parsed from the source provided.
  25016. * @param parsedMesh is the source
  25017. * @param scene defines the hosting scene
  25018. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25019. * @returns a new Mesh
  25020. */
  25021. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25022. /**
  25023. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25024. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25025. * @param name defines the name of the mesh to create
  25026. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25027. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25028. * @param closePath creates a seam between the first and the last points of each path of the path array
  25029. * @param offset is taken in account only if the `pathArray` is containing a single path
  25030. * @param scene defines the hosting scene
  25031. * @param updatable defines if the mesh must be flagged as updatable
  25032. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25033. * @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)
  25034. * @returns a new Mesh
  25035. */
  25036. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25037. /**
  25038. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25039. * @param name defines the name of the mesh to create
  25040. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25041. * @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
  25042. * @param scene defines the hosting scene
  25043. * @param updatable defines if the mesh must be flagged as updatable
  25044. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25045. * @returns a new Mesh
  25046. */
  25047. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25048. /**
  25049. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25050. * @param name defines the name of the mesh to create
  25051. * @param size sets the size (float) of each box side (default 1)
  25052. * @param scene defines the hosting scene
  25053. * @param updatable defines if the mesh must be flagged as updatable
  25054. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25055. * @returns a new Mesh
  25056. */
  25057. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25058. /**
  25059. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25060. * @param name defines the name of the mesh to create
  25061. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25062. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25063. * @param scene defines the hosting scene
  25064. * @param updatable defines if the mesh must be flagged as updatable
  25065. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25066. * @returns a new Mesh
  25067. */
  25068. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25069. /**
  25070. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25071. * @param name defines the name of the mesh to create
  25072. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25073. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25074. * @param scene defines the hosting scene
  25075. * @returns a new Mesh
  25076. */
  25077. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25078. /**
  25079. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25080. * @param name defines the name of the mesh to create
  25081. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25082. * @param diameterTop set the top cap diameter (floats, default 1)
  25083. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25084. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25085. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25086. * @param scene defines the hosting scene
  25087. * @param updatable defines if the mesh must be flagged as updatable
  25088. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25089. * @returns a new Mesh
  25090. */
  25091. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25092. /**
  25093. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25094. * @param name defines the name of the mesh to create
  25095. * @param diameter sets the diameter size (float) of the torus (default 1)
  25096. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25097. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25098. * @param scene defines the hosting scene
  25099. * @param updatable defines if the mesh must be flagged as updatable
  25100. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25101. * @returns a new Mesh
  25102. */
  25103. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25104. /**
  25105. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25106. * @param name defines the name of the mesh to create
  25107. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25108. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25109. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25110. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25111. * @param p the number of windings on X axis (positive integers, default 2)
  25112. * @param q the number of windings on Y axis (positive integers, default 3)
  25113. * @param scene defines the hosting scene
  25114. * @param updatable defines if the mesh must be flagged as updatable
  25115. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25116. * @returns a new Mesh
  25117. */
  25118. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25119. /**
  25120. * Creates a line 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 points is an array successive Vector3
  25123. * @param scene defines the hosting scene
  25124. * @param updatable defines if the mesh must be flagged as updatable
  25125. * @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).
  25126. * @returns a new Mesh
  25127. */
  25128. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25129. /**
  25130. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25131. * @param name defines the name of the mesh to create
  25132. * @param points is an array successive Vector3
  25133. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25134. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25135. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25136. * @param scene defines the hosting scene
  25137. * @param updatable defines if the mesh must be flagged as updatable
  25138. * @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)
  25139. * @returns a new Mesh
  25140. */
  25141. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25142. /**
  25143. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25144. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25145. * 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.
  25146. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25147. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25148. * Remember you can only change the shape positions, not their number when updating a polygon.
  25149. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25150. * @param name defines the name of the mesh to create
  25151. * @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
  25152. * @param scene defines the hosting scene
  25153. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25154. * @param updatable defines if the mesh must be flagged as updatable
  25155. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25156. * @param earcutInjection can be used to inject your own earcut reference
  25157. * @returns a new Mesh
  25158. */
  25159. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25160. /**
  25161. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25162. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25163. * @param name defines the name of the mesh to create
  25164. * @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
  25165. * @param depth defines the height of extrusion
  25166. * @param scene defines the hosting scene
  25167. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25168. * @param updatable defines if the mesh must be flagged as updatable
  25169. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25170. * @param earcutInjection can be used to inject your own earcut reference
  25171. * @returns a new Mesh
  25172. */
  25173. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25174. /**
  25175. * Creates an extruded shape mesh.
  25176. * 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
  25177. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25178. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25179. * @param name defines the name of the mesh to create
  25180. * @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
  25181. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25182. * @param scale is the value to scale the shape
  25183. * @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
  25184. * @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
  25185. * @param scene defines the hosting scene
  25186. * @param updatable defines if the mesh must be flagged as updatable
  25187. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25188. * @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)
  25189. * @returns a new Mesh
  25190. */
  25191. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25192. /**
  25193. * Creates an custom extruded shape mesh.
  25194. * The custom extrusion is a parametric shape.
  25195. * It has no predefined shape. Its final shape will depend on the input parameters.
  25196. * Please consider using the same method from the MeshBuilder class instead
  25197. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25198. * @param name defines the name of the mesh to create
  25199. * @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
  25200. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25201. * @param scaleFunction is a custom Javascript function called on each path point
  25202. * @param rotationFunction is a custom Javascript function called on each path point
  25203. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25204. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25205. * @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
  25206. * @param scene defines the hosting scene
  25207. * @param updatable defines if the mesh must be flagged as updatable
  25208. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25209. * @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)
  25210. * @returns a new Mesh
  25211. */
  25212. 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;
  25213. /**
  25214. * Creates lathe mesh.
  25215. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25216. * Please consider using the same method from the MeshBuilder class instead
  25217. * @param name defines the name of the mesh to create
  25218. * @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
  25219. * @param radius is the radius value of the lathe
  25220. * @param tessellation is the side number of the lathe.
  25221. * @param scene defines the hosting scene
  25222. * @param updatable defines if the mesh must be flagged as updatable
  25223. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25224. * @returns a new Mesh
  25225. */
  25226. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25227. /**
  25228. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25229. * @param name defines the name of the mesh to create
  25230. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25231. * @param scene defines the hosting scene
  25232. * @param updatable defines if the mesh must be flagged as updatable
  25233. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25234. * @returns a new Mesh
  25235. */
  25236. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25237. /**
  25238. * Creates a ground mesh.
  25239. * Please consider using the same method from the MeshBuilder class instead
  25240. * @param name defines the name of the mesh to create
  25241. * @param width set the width of the ground
  25242. * @param height set the height of the ground
  25243. * @param subdivisions sets the number of subdivisions per side
  25244. * @param scene defines the hosting scene
  25245. * @param updatable defines if the mesh must be flagged as updatable
  25246. * @returns a new Mesh
  25247. */
  25248. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25249. /**
  25250. * Creates a tiled ground mesh.
  25251. * Please consider using the same method from the MeshBuilder class instead
  25252. * @param name defines the name of the mesh to create
  25253. * @param xmin set the ground minimum X coordinate
  25254. * @param zmin set the ground minimum Y coordinate
  25255. * @param xmax set the ground maximum X coordinate
  25256. * @param zmax set the ground maximum Z coordinate
  25257. * @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
  25258. * @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
  25259. * @param scene defines the hosting scene
  25260. * @param updatable defines if the mesh must be flagged as updatable
  25261. * @returns a new Mesh
  25262. */
  25263. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25264. w: number;
  25265. h: number;
  25266. }, precision: {
  25267. w: number;
  25268. h: number;
  25269. }, scene: Scene, updatable?: boolean): Mesh;
  25270. /**
  25271. * Creates a ground mesh from a height map.
  25272. * Please consider using the same method from the MeshBuilder class instead
  25273. * @see http://doc.babylonjs.com/babylon101/height_map
  25274. * @param name defines the name of the mesh to create
  25275. * @param url sets the URL of the height map image resource
  25276. * @param width set the ground width size
  25277. * @param height set the ground height size
  25278. * @param subdivisions sets the number of subdivision per side
  25279. * @param minHeight is the minimum altitude on the ground
  25280. * @param maxHeight is the maximum altitude on the ground
  25281. * @param scene defines the hosting scene
  25282. * @param updatable defines if the mesh must be flagged as updatable
  25283. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25284. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25285. * @returns a new Mesh
  25286. */
  25287. 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;
  25288. /**
  25289. * Creates a tube mesh.
  25290. * The tube is a parametric shape.
  25291. * It has no predefined shape. Its final shape will depend on the input parameters.
  25292. * Please consider using the same method from the MeshBuilder class instead
  25293. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25294. * @param name defines the name of the mesh to create
  25295. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25296. * @param radius sets the tube radius size
  25297. * @param tessellation is the number of sides on the tubular surface
  25298. * @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
  25299. * @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
  25300. * @param scene defines the hosting scene
  25301. * @param updatable defines if the mesh must be flagged as updatable
  25302. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25303. * @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)
  25304. * @returns a new Mesh
  25305. */
  25306. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25307. (i: number, distance: number): number;
  25308. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25309. /**
  25310. * Creates a polyhedron mesh.
  25311. * Please consider using the same method from the MeshBuilder class instead.
  25312. * * 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
  25313. * * The parameter `size` (positive float, default 1) sets the polygon size
  25314. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25315. * * 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`
  25316. * * 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
  25317. * * 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)`)
  25318. * * 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
  25319. * * 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
  25320. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25321. * * If you create a double-sided mesh, you can choose what parts of 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
  25322. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25323. * @param name defines the name of the mesh to create
  25324. * @param options defines the options used to create the mesh
  25325. * @param scene defines the hosting scene
  25326. * @returns a new Mesh
  25327. */
  25328. static CreatePolyhedron(name: string, options: {
  25329. type?: number;
  25330. size?: number;
  25331. sizeX?: number;
  25332. sizeY?: number;
  25333. sizeZ?: number;
  25334. custom?: any;
  25335. faceUV?: Vector4[];
  25336. faceColors?: Color4[];
  25337. updatable?: boolean;
  25338. sideOrientation?: number;
  25339. }, scene: Scene): Mesh;
  25340. /**
  25341. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25342. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25343. * * 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`)
  25344. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25345. * * 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
  25346. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25347. * * If you create a double-sided mesh, you can choose what parts of 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
  25348. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25349. * @param name defines the name of the mesh
  25350. * @param options defines the options used to create the mesh
  25351. * @param scene defines the hosting scene
  25352. * @returns a new Mesh
  25353. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25354. */
  25355. static CreateIcoSphere(name: string, options: {
  25356. radius?: number;
  25357. flat?: boolean;
  25358. subdivisions?: number;
  25359. sideOrientation?: number;
  25360. updatable?: boolean;
  25361. }, scene: Scene): Mesh;
  25362. /**
  25363. * Creates a decal mesh.
  25364. * Please consider using the same method from the MeshBuilder class instead.
  25365. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25366. * @param name defines the name of the mesh
  25367. * @param sourceMesh defines the mesh receiving the decal
  25368. * @param position sets the position of the decal in world coordinates
  25369. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25370. * @param size sets the decal scaling
  25371. * @param angle sets the angle to rotate the decal
  25372. * @returns a new Mesh
  25373. */
  25374. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25375. /**
  25376. * Prepare internal position array for software CPU skinning
  25377. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25378. */
  25379. setPositionsForCPUSkinning(): Float32Array;
  25380. /**
  25381. * Prepare internal normal array for software CPU skinning
  25382. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25383. */
  25384. setNormalsForCPUSkinning(): Float32Array;
  25385. /**
  25386. * Updates the vertex buffer by applying transformation from the bones
  25387. * @param skeleton defines the skeleton to apply to current mesh
  25388. * @returns the current mesh
  25389. */
  25390. applySkeleton(skeleton: Skeleton): Mesh;
  25391. /**
  25392. * 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
  25393. * @param meshes defines the list of meshes to scan
  25394. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25395. */
  25396. static MinMax(meshes: AbstractMesh[]): {
  25397. min: Vector3;
  25398. max: Vector3;
  25399. };
  25400. /**
  25401. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25402. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25403. * @returns a vector3
  25404. */
  25405. static Center(meshesOrMinMaxVector: {
  25406. min: Vector3;
  25407. max: Vector3;
  25408. } | AbstractMesh[]): Vector3;
  25409. /**
  25410. * Merge the array of meshes into a single mesh for performance reasons.
  25411. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25412. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25413. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25414. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25415. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25416. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25417. * @returns a new mesh
  25418. */
  25419. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25420. /** @hidden */
  25421. addInstance(instance: InstancedMesh): void;
  25422. /** @hidden */
  25423. removeInstance(instance: InstancedMesh): void;
  25424. }
  25425. }
  25426. declare module "babylonjs/Cameras/camera" {
  25427. import { SmartArray } from "babylonjs/Misc/smartArray";
  25428. import { Observable } from "babylonjs/Misc/observable";
  25429. import { Nullable } from "babylonjs/types";
  25430. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25431. import { Scene } from "babylonjs/scene";
  25432. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  25433. import { Node } from "babylonjs/node";
  25434. import { Mesh } from "babylonjs/Meshes/mesh";
  25435. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25436. import { ICullable } from "babylonjs/Culling/boundingInfo";
  25437. import { Viewport } from "babylonjs/Maths/math.viewport";
  25438. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25439. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25440. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25441. import { Ray } from "babylonjs/Culling/ray";
  25442. /**
  25443. * This is the base class of all the camera used in the application.
  25444. * @see http://doc.babylonjs.com/features/cameras
  25445. */
  25446. export class Camera extends Node {
  25447. /** @hidden */
  25448. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25449. /**
  25450. * This is the default projection mode used by the cameras.
  25451. * It helps recreating a feeling of perspective and better appreciate depth.
  25452. * This is the best way to simulate real life cameras.
  25453. */
  25454. static readonly PERSPECTIVE_CAMERA: number;
  25455. /**
  25456. * This helps creating camera with an orthographic mode.
  25457. * 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.
  25458. */
  25459. static readonly ORTHOGRAPHIC_CAMERA: number;
  25460. /**
  25461. * This is the default FOV mode for perspective cameras.
  25462. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25463. */
  25464. static readonly FOVMODE_VERTICAL_FIXED: number;
  25465. /**
  25466. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25467. */
  25468. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25469. /**
  25470. * This specifies ther is no need for a camera rig.
  25471. * Basically only one eye is rendered corresponding to the camera.
  25472. */
  25473. static readonly RIG_MODE_NONE: number;
  25474. /**
  25475. * Simulates a camera Rig with one blue eye and one red eye.
  25476. * This can be use with 3d blue and red glasses.
  25477. */
  25478. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25479. /**
  25480. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25481. */
  25482. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25483. /**
  25484. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25485. */
  25486. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25487. /**
  25488. * Defines that both eyes of the camera will be rendered over under each other.
  25489. */
  25490. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25491. /**
  25492. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25493. */
  25494. static readonly RIG_MODE_VR: number;
  25495. /**
  25496. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25497. */
  25498. static readonly RIG_MODE_WEBVR: number;
  25499. /**
  25500. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25501. */
  25502. static readonly RIG_MODE_CUSTOM: number;
  25503. /**
  25504. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25505. */
  25506. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25507. /**
  25508. * Define the input manager associated with the camera.
  25509. */
  25510. inputs: CameraInputsManager<Camera>;
  25511. /** @hidden */
  25512. _position: Vector3;
  25513. /**
  25514. * Define the current local position of the camera in the scene
  25515. */
  25516. position: Vector3;
  25517. /**
  25518. * The vector the camera should consider as up.
  25519. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25520. */
  25521. upVector: Vector3;
  25522. /**
  25523. * Define the current limit on the left side for an orthographic camera
  25524. * In scene unit
  25525. */
  25526. orthoLeft: Nullable<number>;
  25527. /**
  25528. * Define the current limit on the right side for an orthographic camera
  25529. * In scene unit
  25530. */
  25531. orthoRight: Nullable<number>;
  25532. /**
  25533. * Define the current limit on the bottom side for an orthographic camera
  25534. * In scene unit
  25535. */
  25536. orthoBottom: Nullable<number>;
  25537. /**
  25538. * Define the current limit on the top side for an orthographic camera
  25539. * In scene unit
  25540. */
  25541. orthoTop: Nullable<number>;
  25542. /**
  25543. * Field Of View is set in Radians. (default is 0.8)
  25544. */
  25545. fov: number;
  25546. /**
  25547. * Define the minimum distance the camera can see from.
  25548. * This is important to note that the depth buffer are not infinite and the closer it starts
  25549. * the more your scene might encounter depth fighting issue.
  25550. */
  25551. minZ: number;
  25552. /**
  25553. * Define the maximum distance the camera can see to.
  25554. * This is important to note that the depth buffer are not infinite and the further it end
  25555. * the more your scene might encounter depth fighting issue.
  25556. */
  25557. maxZ: number;
  25558. /**
  25559. * Define the default inertia of the camera.
  25560. * This helps giving a smooth feeling to the camera movement.
  25561. */
  25562. inertia: number;
  25563. /**
  25564. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25565. */
  25566. mode: number;
  25567. /**
  25568. * Define wether the camera is intermediate.
  25569. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25570. */
  25571. isIntermediate: boolean;
  25572. /**
  25573. * Define the viewport of the camera.
  25574. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25575. */
  25576. viewport: Viewport;
  25577. /**
  25578. * Restricts the camera to viewing objects with the same layerMask.
  25579. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25580. */
  25581. layerMask: number;
  25582. /**
  25583. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25584. */
  25585. fovMode: number;
  25586. /**
  25587. * Rig mode of the camera.
  25588. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25589. * This is normally controlled byt the camera themselves as internal use.
  25590. */
  25591. cameraRigMode: number;
  25592. /**
  25593. * Defines the distance between both "eyes" in case of a RIG
  25594. */
  25595. interaxialDistance: number;
  25596. /**
  25597. * Defines if stereoscopic rendering is done side by side or over under.
  25598. */
  25599. isStereoscopicSideBySide: boolean;
  25600. /**
  25601. * 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
  25602. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25603. * else in the scene. (Eg. security camera)
  25604. *
  25605. * 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)
  25606. */
  25607. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  25608. /**
  25609. * When set, the camera will render to this render target instead of the default canvas
  25610. *
  25611. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25612. */
  25613. outputRenderTarget: Nullable<RenderTargetTexture>;
  25614. /**
  25615. * Observable triggered when the camera view matrix has changed.
  25616. */
  25617. onViewMatrixChangedObservable: Observable<Camera>;
  25618. /**
  25619. * Observable triggered when the camera Projection matrix has changed.
  25620. */
  25621. onProjectionMatrixChangedObservable: Observable<Camera>;
  25622. /**
  25623. * Observable triggered when the inputs have been processed.
  25624. */
  25625. onAfterCheckInputsObservable: Observable<Camera>;
  25626. /**
  25627. * Observable triggered when reset has been called and applied to the camera.
  25628. */
  25629. onRestoreStateObservable: Observable<Camera>;
  25630. /** @hidden */
  25631. _cameraRigParams: any;
  25632. /** @hidden */
  25633. _rigCameras: Camera[];
  25634. /** @hidden */
  25635. _rigPostProcess: Nullable<PostProcess>;
  25636. protected _webvrViewMatrix: Matrix;
  25637. /** @hidden */
  25638. _skipRendering: boolean;
  25639. /** @hidden */
  25640. _projectionMatrix: Matrix;
  25641. /** @hidden */
  25642. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  25643. /** @hidden */
  25644. _activeMeshes: SmartArray<AbstractMesh>;
  25645. protected _globalPosition: Vector3;
  25646. /** @hidden */
  25647. _computedViewMatrix: Matrix;
  25648. private _doNotComputeProjectionMatrix;
  25649. private _transformMatrix;
  25650. private _frustumPlanes;
  25651. private _refreshFrustumPlanes;
  25652. private _storedFov;
  25653. private _stateStored;
  25654. /**
  25655. * Instantiates a new camera object.
  25656. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25657. * @see http://doc.babylonjs.com/features/cameras
  25658. * @param name Defines the name of the camera in the scene
  25659. * @param position Defines the position of the camera
  25660. * @param scene Defines the scene the camera belongs too
  25661. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25662. */
  25663. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25664. /**
  25665. * Store current camera state (fov, position, etc..)
  25666. * @returns the camera
  25667. */
  25668. storeState(): Camera;
  25669. /**
  25670. * Restores the camera state values if it has been stored. You must call storeState() first
  25671. */
  25672. protected _restoreStateValues(): boolean;
  25673. /**
  25674. * Restored camera state. You must call storeState() first.
  25675. * @returns true if restored and false otherwise
  25676. */
  25677. restoreState(): boolean;
  25678. /**
  25679. * Gets the class name of the camera.
  25680. * @returns the class name
  25681. */
  25682. getClassName(): string;
  25683. /** @hidden */
  25684. readonly _isCamera: boolean;
  25685. /**
  25686. * Gets a string representation of the camera useful for debug purpose.
  25687. * @param fullDetails Defines that a more verboe level of logging is required
  25688. * @returns the string representation
  25689. */
  25690. toString(fullDetails?: boolean): string;
  25691. /**
  25692. * Gets the current world space position of the camera.
  25693. */
  25694. readonly globalPosition: Vector3;
  25695. /**
  25696. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25697. * @returns the active meshe list
  25698. */
  25699. getActiveMeshes(): SmartArray<AbstractMesh>;
  25700. /**
  25701. * Check wether a mesh is part of the current active mesh list of the camera
  25702. * @param mesh Defines the mesh to check
  25703. * @returns true if active, false otherwise
  25704. */
  25705. isActiveMesh(mesh: Mesh): boolean;
  25706. /**
  25707. * Is this camera ready to be used/rendered
  25708. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25709. * @return true if the camera is ready
  25710. */
  25711. isReady(completeCheck?: boolean): boolean;
  25712. /** @hidden */
  25713. _initCache(): void;
  25714. /** @hidden */
  25715. _updateCache(ignoreParentClass?: boolean): void;
  25716. /** @hidden */
  25717. _isSynchronized(): boolean;
  25718. /** @hidden */
  25719. _isSynchronizedViewMatrix(): boolean;
  25720. /** @hidden */
  25721. _isSynchronizedProjectionMatrix(): boolean;
  25722. /**
  25723. * Attach the input controls to a specific dom element to get the input from.
  25724. * @param element Defines the element the controls should be listened from
  25725. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25726. */
  25727. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25728. /**
  25729. * Detach the current controls from the specified dom element.
  25730. * @param element Defines the element to stop listening the inputs from
  25731. */
  25732. detachControl(element: HTMLElement): void;
  25733. /**
  25734. * Update the camera state according to the different inputs gathered during the frame.
  25735. */
  25736. update(): void;
  25737. /** @hidden */
  25738. _checkInputs(): void;
  25739. /** @hidden */
  25740. readonly rigCameras: Camera[];
  25741. /**
  25742. * Gets the post process used by the rig cameras
  25743. */
  25744. readonly rigPostProcess: Nullable<PostProcess>;
  25745. /**
  25746. * Internal, gets the first post proces.
  25747. * @returns the first post process to be run on this camera.
  25748. */
  25749. _getFirstPostProcess(): Nullable<PostProcess>;
  25750. private _cascadePostProcessesToRigCams;
  25751. /**
  25752. * Attach a post process to the camera.
  25753. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25754. * @param postProcess The post process to attach to the camera
  25755. * @param insertAt The position of the post process in case several of them are in use in the scene
  25756. * @returns the position the post process has been inserted at
  25757. */
  25758. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25759. /**
  25760. * Detach a post process to the camera.
  25761. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25762. * @param postProcess The post process to detach from the camera
  25763. */
  25764. detachPostProcess(postProcess: PostProcess): void;
  25765. /**
  25766. * Gets the current world matrix of the camera
  25767. */
  25768. getWorldMatrix(): Matrix;
  25769. /** @hidden */
  25770. _getViewMatrix(): Matrix;
  25771. /**
  25772. * Gets the current view matrix of the camera.
  25773. * @param force forces the camera to recompute the matrix without looking at the cached state
  25774. * @returns the view matrix
  25775. */
  25776. getViewMatrix(force?: boolean): Matrix;
  25777. /**
  25778. * Freeze the projection matrix.
  25779. * It will prevent the cache check of the camera projection compute and can speed up perf
  25780. * if no parameter of the camera are meant to change
  25781. * @param projection Defines manually a projection if necessary
  25782. */
  25783. freezeProjectionMatrix(projection?: Matrix): void;
  25784. /**
  25785. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25786. */
  25787. unfreezeProjectionMatrix(): void;
  25788. /**
  25789. * Gets the current projection matrix of the camera.
  25790. * @param force forces the camera to recompute the matrix without looking at the cached state
  25791. * @returns the projection matrix
  25792. */
  25793. getProjectionMatrix(force?: boolean): Matrix;
  25794. /**
  25795. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25796. * @returns a Matrix
  25797. */
  25798. getTransformationMatrix(): Matrix;
  25799. private _updateFrustumPlanes;
  25800. /**
  25801. * Checks if a cullable object (mesh...) is in the camera frustum
  25802. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25803. * @param target The object to check
  25804. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25805. * @returns true if the object is in frustum otherwise false
  25806. */
  25807. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25808. /**
  25809. * Checks if a cullable object (mesh...) is in the camera frustum
  25810. * Unlike isInFrustum this cheks the full bounding box
  25811. * @param target The object to check
  25812. * @returns true if the object is in frustum otherwise false
  25813. */
  25814. isCompletelyInFrustum(target: ICullable): boolean;
  25815. /**
  25816. * Gets a ray in the forward direction from the camera.
  25817. * @param length Defines the length of the ray to create
  25818. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25819. * @param origin Defines the start point of the ray which defaults to the camera position
  25820. * @returns the forward ray
  25821. */
  25822. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25823. /**
  25824. * Releases resources associated with this node.
  25825. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25826. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25827. */
  25828. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25829. /** @hidden */
  25830. _isLeftCamera: boolean;
  25831. /**
  25832. * Gets the left camera of a rig setup in case of Rigged Camera
  25833. */
  25834. readonly isLeftCamera: boolean;
  25835. /** @hidden */
  25836. _isRightCamera: boolean;
  25837. /**
  25838. * Gets the right camera of a rig setup in case of Rigged Camera
  25839. */
  25840. readonly isRightCamera: boolean;
  25841. /**
  25842. * Gets the left camera of a rig setup in case of Rigged Camera
  25843. */
  25844. readonly leftCamera: Nullable<FreeCamera>;
  25845. /**
  25846. * Gets the right camera of a rig setup in case of Rigged Camera
  25847. */
  25848. readonly rightCamera: Nullable<FreeCamera>;
  25849. /**
  25850. * Gets the left camera target of a rig setup in case of Rigged Camera
  25851. * @returns the target position
  25852. */
  25853. getLeftTarget(): Nullable<Vector3>;
  25854. /**
  25855. * Gets the right camera target of a rig setup in case of Rigged Camera
  25856. * @returns the target position
  25857. */
  25858. getRightTarget(): Nullable<Vector3>;
  25859. /**
  25860. * @hidden
  25861. */
  25862. setCameraRigMode(mode: number, rigParams: any): void;
  25863. /** @hidden */
  25864. static _setStereoscopicRigMode(camera: Camera): void;
  25865. /** @hidden */
  25866. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25867. /** @hidden */
  25868. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25869. /** @hidden */
  25870. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25871. /** @hidden */
  25872. _getVRProjectionMatrix(): Matrix;
  25873. protected _updateCameraRotationMatrix(): void;
  25874. protected _updateWebVRCameraRotationMatrix(): void;
  25875. /**
  25876. * This function MUST be overwritten by the different WebVR cameras available.
  25877. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25878. * @hidden
  25879. */
  25880. _getWebVRProjectionMatrix(): Matrix;
  25881. /**
  25882. * This function MUST be overwritten by the different WebVR cameras available.
  25883. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25884. * @hidden
  25885. */
  25886. _getWebVRViewMatrix(): Matrix;
  25887. /** @hidden */
  25888. setCameraRigParameter(name: string, value: any): void;
  25889. /**
  25890. * needs to be overridden by children so sub has required properties to be copied
  25891. * @hidden
  25892. */
  25893. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25894. /**
  25895. * May need to be overridden by children
  25896. * @hidden
  25897. */
  25898. _updateRigCameras(): void;
  25899. /** @hidden */
  25900. _setupInputs(): void;
  25901. /**
  25902. * Serialiaze the camera setup to a json represention
  25903. * @returns the JSON representation
  25904. */
  25905. serialize(): any;
  25906. /**
  25907. * Clones the current camera.
  25908. * @param name The cloned camera name
  25909. * @returns the cloned camera
  25910. */
  25911. clone(name: string): Camera;
  25912. /**
  25913. * Gets the direction of the camera relative to a given local axis.
  25914. * @param localAxis Defines the reference axis to provide a relative direction.
  25915. * @return the direction
  25916. */
  25917. getDirection(localAxis: Vector3): Vector3;
  25918. /**
  25919. * Returns the current camera absolute rotation
  25920. */
  25921. readonly absoluteRotation: Quaternion;
  25922. /**
  25923. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25924. * @param localAxis Defines the reference axis to provide a relative direction.
  25925. * @param result Defines the vector to store the result in
  25926. */
  25927. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25928. /**
  25929. * Gets a camera constructor for a given camera type
  25930. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25931. * @param name The name of the camera the result will be able to instantiate
  25932. * @param scene The scene the result will construct the camera in
  25933. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25934. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25935. * @returns a factory method to construc the camera
  25936. */
  25937. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25938. /**
  25939. * Compute the world matrix of the camera.
  25940. * @returns the camera workd matrix
  25941. */
  25942. computeWorldMatrix(): Matrix;
  25943. /**
  25944. * Parse a JSON and creates the camera from the parsed information
  25945. * @param parsedCamera The JSON to parse
  25946. * @param scene The scene to instantiate the camera in
  25947. * @returns the newly constructed camera
  25948. */
  25949. static Parse(parsedCamera: any, scene: Scene): Camera;
  25950. }
  25951. }
  25952. declare module "babylonjs/Meshes/Builders/discBuilder" {
  25953. import { Nullable } from "babylonjs/types";
  25954. import { Scene } from "babylonjs/scene";
  25955. import { Vector4 } from "babylonjs/Maths/math.vector";
  25956. import { Mesh } from "babylonjs/Meshes/mesh";
  25957. /**
  25958. * Class containing static functions to help procedurally build meshes
  25959. */
  25960. export class DiscBuilder {
  25961. /**
  25962. * Creates a plane polygonal mesh. By default, this is a disc
  25963. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25964. * * 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
  25965. * * 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
  25966. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25967. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  25968. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25969. * @param name defines the name of the mesh
  25970. * @param options defines the options used to create the mesh
  25971. * @param scene defines the hosting scene
  25972. * @returns the plane polygonal mesh
  25973. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25974. */
  25975. static CreateDisc(name: string, options: {
  25976. radius?: number;
  25977. tessellation?: number;
  25978. arc?: number;
  25979. updatable?: boolean;
  25980. sideOrientation?: number;
  25981. frontUVs?: Vector4;
  25982. backUVs?: Vector4;
  25983. }, scene?: Nullable<Scene>): Mesh;
  25984. }
  25985. }
  25986. declare module "babylonjs/Particles/solidParticleSystem" {
  25987. import { Vector3 } from "babylonjs/Maths/math.vector";
  25988. import { Mesh } from "babylonjs/Meshes/mesh";
  25989. import { Scene, IDisposable } from "babylonjs/scene";
  25990. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  25991. /**
  25992. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  25993. *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.
  25994. * The SPS is also a particle system. It provides some methods to manage the particles.
  25995. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  25996. *
  25997. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  25998. */
  25999. export class SolidParticleSystem implements IDisposable {
  26000. /**
  26001. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  26002. * Example : var p = SPS.particles[i];
  26003. */
  26004. particles: SolidParticle[];
  26005. /**
  26006. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  26007. */
  26008. nbParticles: number;
  26009. /**
  26010. * If the particles must ever face the camera (default false). Useful for planar particles.
  26011. */
  26012. billboard: boolean;
  26013. /**
  26014. * Recompute normals when adding a shape
  26015. */
  26016. recomputeNormals: boolean;
  26017. /**
  26018. * This a counter ofr your own usage. It's not set by any SPS functions.
  26019. */
  26020. counter: number;
  26021. /**
  26022. * The SPS name. This name is also given to the underlying mesh.
  26023. */
  26024. name: string;
  26025. /**
  26026. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  26027. */
  26028. mesh: Mesh;
  26029. /**
  26030. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  26031. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  26032. */
  26033. vars: any;
  26034. /**
  26035. * This array is populated when the SPS is set as 'pickable'.
  26036. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  26037. * Each element of this array is an object `{idx: int, faceId: int}`.
  26038. * `idx` is the picked particle index in the `SPS.particles` array
  26039. * `faceId` is the picked face index counted within this particle.
  26040. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  26041. */
  26042. pickedParticles: {
  26043. idx: number;
  26044. faceId: number;
  26045. }[];
  26046. /**
  26047. * This array is populated when `enableDepthSort` is set to true.
  26048. * Each element of this array is an instance of the class DepthSortedParticle.
  26049. */
  26050. depthSortedParticles: DepthSortedParticle[];
  26051. /**
  26052. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  26053. * @hidden
  26054. */
  26055. _bSphereOnly: boolean;
  26056. /**
  26057. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  26058. * @hidden
  26059. */
  26060. _bSphereRadiusFactor: number;
  26061. private _scene;
  26062. private _positions;
  26063. private _indices;
  26064. private _normals;
  26065. private _colors;
  26066. private _uvs;
  26067. private _indices32;
  26068. private _positions32;
  26069. private _normals32;
  26070. private _fixedNormal32;
  26071. private _colors32;
  26072. private _uvs32;
  26073. private _index;
  26074. private _updatable;
  26075. private _pickable;
  26076. private _isVisibilityBoxLocked;
  26077. private _alwaysVisible;
  26078. private _depthSort;
  26079. private _shapeCounter;
  26080. private _copy;
  26081. private _color;
  26082. private _computeParticleColor;
  26083. private _computeParticleTexture;
  26084. private _computeParticleRotation;
  26085. private _computeParticleVertex;
  26086. private _computeBoundingBox;
  26087. private _depthSortParticles;
  26088. private _camera;
  26089. private _mustUnrotateFixedNormals;
  26090. private _particlesIntersect;
  26091. private _needs32Bits;
  26092. /**
  26093. * Creates a SPS (Solid Particle System) object.
  26094. * @param name (String) is the SPS name, this will be the underlying mesh name.
  26095. * @param scene (Scene) is the scene in which the SPS is added.
  26096. * @param options defines the options of the sps e.g.
  26097. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  26098. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  26099. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  26100. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  26101. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  26102. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  26103. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  26104. */
  26105. constructor(name: string, scene: Scene, options?: {
  26106. updatable?: boolean;
  26107. isPickable?: boolean;
  26108. enableDepthSort?: boolean;
  26109. particleIntersection?: boolean;
  26110. boundingSphereOnly?: boolean;
  26111. bSphereRadiusFactor?: number;
  26112. });
  26113. /**
  26114. * Builds the SPS underlying mesh. Returns a standard Mesh.
  26115. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  26116. * @returns the created mesh
  26117. */
  26118. buildMesh(): Mesh;
  26119. /**
  26120. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  26121. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  26122. * Thus the particles generated from `digest()` have their property `position` set yet.
  26123. * @param mesh ( Mesh ) is the mesh to be digested
  26124. * @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
  26125. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  26126. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  26127. * @returns the current SPS
  26128. */
  26129. digest(mesh: Mesh, options?: {
  26130. facetNb?: number;
  26131. number?: number;
  26132. delta?: number;
  26133. }): SolidParticleSystem;
  26134. private _unrotateFixedNormals;
  26135. private _resetCopy;
  26136. private _meshBuilder;
  26137. private _posToShape;
  26138. private _uvsToShapeUV;
  26139. private _addParticle;
  26140. /**
  26141. * Adds some particles to the SPS from the model shape. Returns the shape id.
  26142. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  26143. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  26144. * @param nb (positive integer) the number of particles to be created from this model
  26145. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  26146. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  26147. * @returns the number of shapes in the system
  26148. */
  26149. addShape(mesh: Mesh, nb: number, options?: {
  26150. positionFunction?: any;
  26151. vertexFunction?: any;
  26152. }): number;
  26153. private _rebuildParticle;
  26154. /**
  26155. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  26156. * @returns the SPS.
  26157. */
  26158. rebuildMesh(): SolidParticleSystem;
  26159. /**
  26160. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  26161. * This method calls `updateParticle()` for each particle of the SPS.
  26162. * For an animated SPS, it is usually called within the render loop.
  26163. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  26164. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  26165. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  26166. * @returns the SPS.
  26167. */
  26168. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  26169. /**
  26170. * Disposes the SPS.
  26171. */
  26172. dispose(): void;
  26173. /**
  26174. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  26175. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26176. * @returns the SPS.
  26177. */
  26178. refreshVisibleSize(): SolidParticleSystem;
  26179. /**
  26180. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  26181. * @param size the size (float) of the visibility box
  26182. * note : this doesn't lock the SPS mesh bounding box.
  26183. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26184. */
  26185. setVisibilityBox(size: number): void;
  26186. /**
  26187. * Gets whether the SPS as always visible or not
  26188. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26189. */
  26190. /**
  26191. * Sets the SPS as always visible or not
  26192. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26193. */
  26194. isAlwaysVisible: boolean;
  26195. /**
  26196. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26197. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26198. */
  26199. /**
  26200. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26201. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26202. */
  26203. isVisibilityBoxLocked: boolean;
  26204. /**
  26205. * Tells to `setParticles()` to compute the particle rotations or not.
  26206. * Default value : true. The SPS is faster when it's set to false.
  26207. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26208. */
  26209. /**
  26210. * Gets if `setParticles()` computes the particle rotations or not.
  26211. * Default value : true. The SPS is faster when it's set to false.
  26212. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26213. */
  26214. computeParticleRotation: boolean;
  26215. /**
  26216. * Tells to `setParticles()` to compute the particle colors or not.
  26217. * Default value : true. The SPS is faster when it's set to false.
  26218. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26219. */
  26220. /**
  26221. * Gets if `setParticles()` computes the particle colors or not.
  26222. * Default value : true. The SPS is faster when it's set to false.
  26223. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26224. */
  26225. computeParticleColor: boolean;
  26226. /**
  26227. * Gets if `setParticles()` computes the particle textures or not.
  26228. * Default value : true. The SPS is faster when it's set to false.
  26229. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  26230. */
  26231. computeParticleTexture: boolean;
  26232. /**
  26233. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  26234. * Default value : false. The SPS is faster when it's set to false.
  26235. * Note : the particle custom vertex positions aren't stored values.
  26236. */
  26237. /**
  26238. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  26239. * Default value : false. The SPS is faster when it's set to false.
  26240. * Note : the particle custom vertex positions aren't stored values.
  26241. */
  26242. computeParticleVertex: boolean;
  26243. /**
  26244. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  26245. */
  26246. /**
  26247. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  26248. */
  26249. computeBoundingBox: boolean;
  26250. /**
  26251. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  26252. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26253. * Default : `true`
  26254. */
  26255. /**
  26256. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  26257. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26258. * Default : `true`
  26259. */
  26260. depthSortParticles: boolean;
  26261. /**
  26262. * This function does nothing. It may be overwritten to set all the particle first values.
  26263. * The SPS doesn't call this function, you may have to call it by your own.
  26264. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26265. */
  26266. initParticles(): void;
  26267. /**
  26268. * This function does nothing. It may be overwritten to recycle a particle.
  26269. * The SPS doesn't call this function, you may have to call it by your own.
  26270. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26271. * @param particle The particle to recycle
  26272. * @returns the recycled particle
  26273. */
  26274. recycleParticle(particle: SolidParticle): SolidParticle;
  26275. /**
  26276. * Updates a particle : this function should be overwritten by the user.
  26277. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  26278. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26279. * @example : just set a particle position or velocity and recycle conditions
  26280. * @param particle The particle to update
  26281. * @returns the updated particle
  26282. */
  26283. updateParticle(particle: SolidParticle): SolidParticle;
  26284. /**
  26285. * Updates a vertex of a particle : it can be overwritten by the user.
  26286. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  26287. * @param particle the current particle
  26288. * @param vertex the current index of the current particle
  26289. * @param pt the index of the current vertex in the particle shape
  26290. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  26291. * @example : just set a vertex particle position
  26292. * @returns the updated vertex
  26293. */
  26294. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  26295. /**
  26296. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  26297. * This does nothing and may be overwritten by the user.
  26298. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26299. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26300. * @param update the boolean update value actually passed to setParticles()
  26301. */
  26302. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26303. /**
  26304. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  26305. * This will be passed three parameters.
  26306. * This does nothing and may be overwritten by the user.
  26307. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26308. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26309. * @param update the boolean update value actually passed to setParticles()
  26310. */
  26311. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26312. }
  26313. }
  26314. declare module "babylonjs/Particles/solidParticle" {
  26315. import { Nullable } from "babylonjs/types";
  26316. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  26317. import { Color4 } from "babylonjs/Maths/math.color";
  26318. import { Mesh } from "babylonjs/Meshes/mesh";
  26319. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26320. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  26321. import { Plane } from "babylonjs/Maths/math.plane";
  26322. /**
  26323. * Represents one particle of a solid particle system.
  26324. */
  26325. export class SolidParticle {
  26326. /**
  26327. * particle global index
  26328. */
  26329. idx: number;
  26330. /**
  26331. * The color of the particle
  26332. */
  26333. color: Nullable<Color4>;
  26334. /**
  26335. * The world space position of the particle.
  26336. */
  26337. position: Vector3;
  26338. /**
  26339. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  26340. */
  26341. rotation: Vector3;
  26342. /**
  26343. * The world space rotation quaternion of the particle.
  26344. */
  26345. rotationQuaternion: Nullable<Quaternion>;
  26346. /**
  26347. * The scaling of the particle.
  26348. */
  26349. scaling: Vector3;
  26350. /**
  26351. * The uvs of the particle.
  26352. */
  26353. uvs: Vector4;
  26354. /**
  26355. * The current speed of the particle.
  26356. */
  26357. velocity: Vector3;
  26358. /**
  26359. * The pivot point in the particle local space.
  26360. */
  26361. pivot: Vector3;
  26362. /**
  26363. * Must the particle be translated from its pivot point in its local space ?
  26364. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  26365. * Default : false
  26366. */
  26367. translateFromPivot: boolean;
  26368. /**
  26369. * Is the particle active or not ?
  26370. */
  26371. alive: boolean;
  26372. /**
  26373. * Is the particle visible or not ?
  26374. */
  26375. isVisible: boolean;
  26376. /**
  26377. * Index of this particle in the global "positions" array (Internal use)
  26378. * @hidden
  26379. */
  26380. _pos: number;
  26381. /**
  26382. * @hidden Index of this particle in the global "indices" array (Internal use)
  26383. */
  26384. _ind: number;
  26385. /**
  26386. * @hidden ModelShape of this particle (Internal use)
  26387. */
  26388. _model: ModelShape;
  26389. /**
  26390. * ModelShape id of this particle
  26391. */
  26392. shapeId: number;
  26393. /**
  26394. * Index of the particle in its shape id
  26395. */
  26396. idxInShape: number;
  26397. /**
  26398. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  26399. */
  26400. _modelBoundingInfo: BoundingInfo;
  26401. /**
  26402. * @hidden Particle BoundingInfo object (Internal use)
  26403. */
  26404. _boundingInfo: BoundingInfo;
  26405. /**
  26406. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  26407. */
  26408. _sps: SolidParticleSystem;
  26409. /**
  26410. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  26411. */
  26412. _stillInvisible: boolean;
  26413. /**
  26414. * @hidden Last computed particle rotation matrix
  26415. */
  26416. _rotationMatrix: number[];
  26417. /**
  26418. * Parent particle Id, if any.
  26419. * Default null.
  26420. */
  26421. parentId: Nullable<number>;
  26422. /**
  26423. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  26424. * The possible values are :
  26425. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26426. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26427. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26428. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26429. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26430. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  26431. * */
  26432. cullingStrategy: number;
  26433. /**
  26434. * @hidden Internal global position in the SPS.
  26435. */
  26436. _globalPosition: Vector3;
  26437. /**
  26438. * Creates a Solid Particle object.
  26439. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  26440. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  26441. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  26442. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  26443. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  26444. * @param shapeId (integer) is the model shape identifier in the SPS.
  26445. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  26446. * @param sps defines the sps it is associated to
  26447. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  26448. */
  26449. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  26450. /**
  26451. * Legacy support, changed scale to scaling
  26452. */
  26453. /**
  26454. * Legacy support, changed scale to scaling
  26455. */
  26456. scale: Vector3;
  26457. /**
  26458. * Legacy support, changed quaternion to rotationQuaternion
  26459. */
  26460. /**
  26461. * Legacy support, changed quaternion to rotationQuaternion
  26462. */
  26463. quaternion: Nullable<Quaternion>;
  26464. /**
  26465. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  26466. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  26467. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  26468. * @returns true if it intersects
  26469. */
  26470. intersectsMesh(target: Mesh | SolidParticle): boolean;
  26471. /**
  26472. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  26473. * A particle is in the frustum if its bounding box intersects the frustum
  26474. * @param frustumPlanes defines the frustum to test
  26475. * @returns true if the particle is in the frustum planes
  26476. */
  26477. isInFrustum(frustumPlanes: Plane[]): boolean;
  26478. /**
  26479. * get the rotation matrix of the particle
  26480. * @hidden
  26481. */
  26482. getRotationMatrix(m: Matrix): void;
  26483. }
  26484. /**
  26485. * Represents the shape of the model used by one particle of a solid particle system.
  26486. * SPS internal tool, don't use it manually.
  26487. */
  26488. export class ModelShape {
  26489. /**
  26490. * The shape id
  26491. * @hidden
  26492. */
  26493. shapeID: number;
  26494. /**
  26495. * flat array of model positions (internal use)
  26496. * @hidden
  26497. */
  26498. _shape: Vector3[];
  26499. /**
  26500. * flat array of model UVs (internal use)
  26501. * @hidden
  26502. */
  26503. _shapeUV: number[];
  26504. /**
  26505. * length of the shape in the model indices array (internal use)
  26506. * @hidden
  26507. */
  26508. _indicesLength: number;
  26509. /**
  26510. * Custom position function (internal use)
  26511. * @hidden
  26512. */
  26513. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  26514. /**
  26515. * Custom vertex function (internal use)
  26516. * @hidden
  26517. */
  26518. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  26519. /**
  26520. * 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.
  26521. * SPS internal tool, don't use it manually.
  26522. * @hidden
  26523. */
  26524. 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>);
  26525. }
  26526. /**
  26527. * Represents a Depth Sorted Particle in the solid particle system.
  26528. */
  26529. export class DepthSortedParticle {
  26530. /**
  26531. * Index of the particle in the "indices" array
  26532. */
  26533. ind: number;
  26534. /**
  26535. * Length of the particle shape in the "indices" array
  26536. */
  26537. indicesLength: number;
  26538. /**
  26539. * Squared distance from the particle to the camera
  26540. */
  26541. sqDistance: number;
  26542. }
  26543. }
  26544. declare module "babylonjs/Collisions/meshCollisionData" {
  26545. import { Collider } from "babylonjs/Collisions/collider";
  26546. import { Vector3 } from "babylonjs/Maths/math.vector";
  26547. import { Nullable } from "babylonjs/types";
  26548. import { Observer } from "babylonjs/Misc/observable";
  26549. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26550. /**
  26551. * @hidden
  26552. */
  26553. export class _MeshCollisionData {
  26554. _checkCollisions: boolean;
  26555. _collisionMask: number;
  26556. _collisionGroup: number;
  26557. _collider: Nullable<Collider>;
  26558. _oldPositionForCollisions: Vector3;
  26559. _diffPositionForCollisions: Vector3;
  26560. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  26561. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  26562. }
  26563. }
  26564. declare module "babylonjs/Meshes/abstractMesh" {
  26565. import { Observable } from "babylonjs/Misc/observable";
  26566. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  26567. import { Camera } from "babylonjs/Cameras/camera";
  26568. import { Scene, IDisposable } from "babylonjs/scene";
  26569. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26570. import { Node } from "babylonjs/node";
  26571. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  26572. import { TransformNode } from "babylonjs/Meshes/transformNode";
  26573. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26574. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  26575. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26576. import { Material } from "babylonjs/Materials/material";
  26577. import { Light } from "babylonjs/Lights/light";
  26578. import { Skeleton } from "babylonjs/Bones/skeleton";
  26579. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  26580. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  26581. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  26582. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  26583. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  26584. import { Plane } from "babylonjs/Maths/math.plane";
  26585. import { Ray } from "babylonjs/Culling/ray";
  26586. import { Collider } from "babylonjs/Collisions/collider";
  26587. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26588. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  26589. /** @hidden */
  26590. class _FacetDataStorage {
  26591. facetPositions: Vector3[];
  26592. facetNormals: Vector3[];
  26593. facetPartitioning: number[][];
  26594. facetNb: number;
  26595. partitioningSubdivisions: number;
  26596. partitioningBBoxRatio: number;
  26597. facetDataEnabled: boolean;
  26598. facetParameters: any;
  26599. bbSize: Vector3;
  26600. subDiv: {
  26601. max: number;
  26602. X: number;
  26603. Y: number;
  26604. Z: number;
  26605. };
  26606. facetDepthSort: boolean;
  26607. facetDepthSortEnabled: boolean;
  26608. depthSortedIndices: IndicesArray;
  26609. depthSortedFacets: {
  26610. ind: number;
  26611. sqDistance: number;
  26612. }[];
  26613. facetDepthSortFunction: (f1: {
  26614. ind: number;
  26615. sqDistance: number;
  26616. }, f2: {
  26617. ind: number;
  26618. sqDistance: number;
  26619. }) => number;
  26620. facetDepthSortFrom: Vector3;
  26621. facetDepthSortOrigin: Vector3;
  26622. invertedMatrix: Matrix;
  26623. }
  26624. /**
  26625. * @hidden
  26626. **/
  26627. class _InternalAbstractMeshDataInfo {
  26628. _hasVertexAlpha: boolean;
  26629. _useVertexColors: boolean;
  26630. _numBoneInfluencers: number;
  26631. _applyFog: boolean;
  26632. _receiveShadows: boolean;
  26633. _facetData: _FacetDataStorage;
  26634. _visibility: number;
  26635. _skeleton: Nullable<Skeleton>;
  26636. _layerMask: number;
  26637. _computeBonesUsingShaders: boolean;
  26638. _isActive: boolean;
  26639. _onlyForInstances: boolean;
  26640. _isActiveIntermediate: boolean;
  26641. _onlyForInstancesIntermediate: boolean;
  26642. }
  26643. /**
  26644. * Class used to store all common mesh properties
  26645. */
  26646. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  26647. /** No occlusion */
  26648. static OCCLUSION_TYPE_NONE: number;
  26649. /** Occlusion set to optimisitic */
  26650. static OCCLUSION_TYPE_OPTIMISTIC: number;
  26651. /** Occlusion set to strict */
  26652. static OCCLUSION_TYPE_STRICT: number;
  26653. /** Use an accurante occlusion algorithm */
  26654. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  26655. /** Use a conservative occlusion algorithm */
  26656. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  26657. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  26658. * Test order :
  26659. * Is the bounding sphere outside the frustum ?
  26660. * If not, are the bounding box vertices outside the frustum ?
  26661. * It not, then the cullable object is in the frustum.
  26662. */
  26663. static readonly CULLINGSTRATEGY_STANDARD: number;
  26664. /** Culling strategy : Bounding Sphere Only.
  26665. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  26666. * It's also less accurate than the standard because some not visible objects can still be selected.
  26667. * Test : is the bounding sphere outside the frustum ?
  26668. * If not, then the cullable object is in the frustum.
  26669. */
  26670. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  26671. /** Culling strategy : Optimistic Inclusion.
  26672. * This in an inclusion test first, then the standard exclusion test.
  26673. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  26674. * 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.
  26675. * Anyway, it's as accurate as the standard strategy.
  26676. * Test :
  26677. * Is the cullable object bounding sphere center in the frustum ?
  26678. * If not, apply the default culling strategy.
  26679. */
  26680. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  26681. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  26682. * This in an inclusion test first, then the bounding sphere only exclusion test.
  26683. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  26684. * 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.
  26685. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  26686. * Test :
  26687. * Is the cullable object bounding sphere center in the frustum ?
  26688. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  26689. */
  26690. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  26691. /**
  26692. * No billboard
  26693. */
  26694. static readonly BILLBOARDMODE_NONE: number;
  26695. /** Billboard on X axis */
  26696. static readonly BILLBOARDMODE_X: number;
  26697. /** Billboard on Y axis */
  26698. static readonly BILLBOARDMODE_Y: number;
  26699. /** Billboard on Z axis */
  26700. static readonly BILLBOARDMODE_Z: number;
  26701. /** Billboard on all axes */
  26702. static readonly BILLBOARDMODE_ALL: number;
  26703. /** Billboard on using position instead of orientation */
  26704. static readonly BILLBOARDMODE_USE_POSITION: number;
  26705. /** @hidden */
  26706. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  26707. /**
  26708. * The culling strategy to use to check whether the mesh must be rendered or not.
  26709. * This value can be changed at any time and will be used on the next render mesh selection.
  26710. * The possible values are :
  26711. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26712. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26713. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26714. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26715. * Please read each static variable documentation to get details about the culling process.
  26716. * */
  26717. cullingStrategy: number;
  26718. /**
  26719. * Gets the number of facets in the mesh
  26720. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26721. */
  26722. readonly facetNb: number;
  26723. /**
  26724. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  26725. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26726. */
  26727. partitioningSubdivisions: number;
  26728. /**
  26729. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  26730. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  26731. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26732. */
  26733. partitioningBBoxRatio: number;
  26734. /**
  26735. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  26736. * Works only for updatable meshes.
  26737. * Doesn't work with multi-materials
  26738. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26739. */
  26740. mustDepthSortFacets: boolean;
  26741. /**
  26742. * The location (Vector3) where the facet depth sort must be computed from.
  26743. * By default, the active camera position.
  26744. * Used only when facet depth sort is enabled
  26745. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26746. */
  26747. facetDepthSortFrom: Vector3;
  26748. /**
  26749. * gets a boolean indicating if facetData is enabled
  26750. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26751. */
  26752. readonly isFacetDataEnabled: boolean;
  26753. /** @hidden */
  26754. _updateNonUniformScalingState(value: boolean): boolean;
  26755. /**
  26756. * An event triggered when this mesh collides with another one
  26757. */
  26758. onCollideObservable: Observable<AbstractMesh>;
  26759. /** Set a function to call when this mesh collides with another one */
  26760. onCollide: () => void;
  26761. /**
  26762. * An event triggered when the collision's position changes
  26763. */
  26764. onCollisionPositionChangeObservable: Observable<Vector3>;
  26765. /** Set a function to call when the collision's position changes */
  26766. onCollisionPositionChange: () => void;
  26767. /**
  26768. * An event triggered when material is changed
  26769. */
  26770. onMaterialChangedObservable: Observable<AbstractMesh>;
  26771. /**
  26772. * Gets or sets the orientation for POV movement & rotation
  26773. */
  26774. definedFacingForward: boolean;
  26775. /** @hidden */
  26776. _occlusionQuery: Nullable<WebGLQuery>;
  26777. /** @hidden */
  26778. _renderingGroup: Nullable<RenderingGroup>;
  26779. /**
  26780. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26781. */
  26782. /**
  26783. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26784. */
  26785. visibility: number;
  26786. /** Gets or sets the alpha index used to sort transparent meshes
  26787. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  26788. */
  26789. alphaIndex: number;
  26790. /**
  26791. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  26792. */
  26793. isVisible: boolean;
  26794. /**
  26795. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  26796. */
  26797. isPickable: boolean;
  26798. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  26799. showSubMeshesBoundingBox: boolean;
  26800. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  26801. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  26802. */
  26803. isBlocker: boolean;
  26804. /**
  26805. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  26806. */
  26807. enablePointerMoveEvents: boolean;
  26808. /**
  26809. * Specifies the rendering group id for this mesh (0 by default)
  26810. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  26811. */
  26812. renderingGroupId: number;
  26813. private _material;
  26814. /** Gets or sets current material */
  26815. material: Nullable<Material>;
  26816. /**
  26817. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  26818. * @see http://doc.babylonjs.com/babylon101/shadows
  26819. */
  26820. receiveShadows: boolean;
  26821. /** Defines color to use when rendering outline */
  26822. outlineColor: Color3;
  26823. /** Define width to use when rendering outline */
  26824. outlineWidth: number;
  26825. /** Defines color to use when rendering overlay */
  26826. overlayColor: Color3;
  26827. /** Defines alpha to use when rendering overlay */
  26828. overlayAlpha: number;
  26829. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  26830. hasVertexAlpha: boolean;
  26831. /** 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) */
  26832. useVertexColors: boolean;
  26833. /**
  26834. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  26835. */
  26836. computeBonesUsingShaders: boolean;
  26837. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  26838. numBoneInfluencers: number;
  26839. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  26840. applyFog: boolean;
  26841. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  26842. useOctreeForRenderingSelection: boolean;
  26843. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  26844. useOctreeForPicking: boolean;
  26845. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  26846. useOctreeForCollisions: boolean;
  26847. /**
  26848. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  26849. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  26850. */
  26851. layerMask: number;
  26852. /**
  26853. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  26854. */
  26855. alwaysSelectAsActiveMesh: boolean;
  26856. /**
  26857. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  26858. */
  26859. doNotSyncBoundingInfo: boolean;
  26860. /**
  26861. * Gets or sets the current action manager
  26862. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26863. */
  26864. actionManager: Nullable<AbstractActionManager>;
  26865. private _meshCollisionData;
  26866. /**
  26867. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  26868. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26869. */
  26870. ellipsoid: Vector3;
  26871. /**
  26872. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  26873. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26874. */
  26875. ellipsoidOffset: Vector3;
  26876. /**
  26877. * Gets or sets a collision mask used to mask collisions (default is -1).
  26878. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26879. */
  26880. collisionMask: number;
  26881. /**
  26882. * Gets or sets the current collision group mask (-1 by default).
  26883. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26884. */
  26885. collisionGroup: number;
  26886. /**
  26887. * Defines edge width used when edgesRenderer is enabled
  26888. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26889. */
  26890. edgesWidth: number;
  26891. /**
  26892. * Defines edge color used when edgesRenderer is enabled
  26893. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26894. */
  26895. edgesColor: Color4;
  26896. /** @hidden */
  26897. _edgesRenderer: Nullable<IEdgesRenderer>;
  26898. /** @hidden */
  26899. _masterMesh: Nullable<AbstractMesh>;
  26900. /** @hidden */
  26901. _boundingInfo: Nullable<BoundingInfo>;
  26902. /** @hidden */
  26903. _renderId: number;
  26904. /**
  26905. * Gets or sets the list of subMeshes
  26906. * @see http://doc.babylonjs.com/how_to/multi_materials
  26907. */
  26908. subMeshes: SubMesh[];
  26909. /** @hidden */
  26910. _intersectionsInProgress: AbstractMesh[];
  26911. /** @hidden */
  26912. _unIndexed: boolean;
  26913. /** @hidden */
  26914. _lightSources: Light[];
  26915. /** Gets the list of lights affecting that mesh */
  26916. readonly lightSources: Light[];
  26917. /** @hidden */
  26918. readonly _positions: Nullable<Vector3[]>;
  26919. /** @hidden */
  26920. _waitingData: {
  26921. lods: Nullable<any>;
  26922. actions: Nullable<any>;
  26923. freezeWorldMatrix: Nullable<boolean>;
  26924. };
  26925. /** @hidden */
  26926. _bonesTransformMatrices: Nullable<Float32Array>;
  26927. /** @hidden */
  26928. _transformMatrixTexture: Nullable<RawTexture>;
  26929. /**
  26930. * Gets or sets a skeleton to apply skining transformations
  26931. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26932. */
  26933. skeleton: Nullable<Skeleton>;
  26934. /**
  26935. * An event triggered when the mesh is rebuilt.
  26936. */
  26937. onRebuildObservable: Observable<AbstractMesh>;
  26938. /**
  26939. * Creates a new AbstractMesh
  26940. * @param name defines the name of the mesh
  26941. * @param scene defines the hosting scene
  26942. */
  26943. constructor(name: string, scene?: Nullable<Scene>);
  26944. /**
  26945. * Returns the string "AbstractMesh"
  26946. * @returns "AbstractMesh"
  26947. */
  26948. getClassName(): string;
  26949. /**
  26950. * Gets a string representation of the current mesh
  26951. * @param fullDetails defines a boolean indicating if full details must be included
  26952. * @returns a string representation of the current mesh
  26953. */
  26954. toString(fullDetails?: boolean): string;
  26955. /**
  26956. * @hidden
  26957. */
  26958. protected _getEffectiveParent(): Nullable<Node>;
  26959. /** @hidden */
  26960. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26961. /** @hidden */
  26962. _rebuild(): void;
  26963. /** @hidden */
  26964. _resyncLightSources(): void;
  26965. /** @hidden */
  26966. _resyncLighSource(light: Light): void;
  26967. /** @hidden */
  26968. _unBindEffect(): void;
  26969. /** @hidden */
  26970. _removeLightSource(light: Light, dispose: boolean): void;
  26971. private _markSubMeshesAsDirty;
  26972. /** @hidden */
  26973. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  26974. /** @hidden */
  26975. _markSubMeshesAsAttributesDirty(): void;
  26976. /** @hidden */
  26977. _markSubMeshesAsMiscDirty(): void;
  26978. /**
  26979. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  26980. */
  26981. scaling: Vector3;
  26982. /**
  26983. * Returns true if the mesh is blocked. Implemented by child classes
  26984. */
  26985. readonly isBlocked: boolean;
  26986. /**
  26987. * Returns the mesh itself by default. Implemented by child classes
  26988. * @param camera defines the camera to use to pick the right LOD level
  26989. * @returns the currentAbstractMesh
  26990. */
  26991. getLOD(camera: Camera): Nullable<AbstractMesh>;
  26992. /**
  26993. * Returns 0 by default. Implemented by child classes
  26994. * @returns an integer
  26995. */
  26996. getTotalVertices(): number;
  26997. /**
  26998. * Returns a positive integer : the total number of indices in this mesh geometry.
  26999. * @returns the numner of indices or zero if the mesh has no geometry.
  27000. */
  27001. getTotalIndices(): number;
  27002. /**
  27003. * Returns null by default. Implemented by child classes
  27004. * @returns null
  27005. */
  27006. getIndices(): Nullable<IndicesArray>;
  27007. /**
  27008. * Returns the array of the requested vertex data kind. Implemented by child classes
  27009. * @param kind defines the vertex data kind to use
  27010. * @returns null
  27011. */
  27012. getVerticesData(kind: string): Nullable<FloatArray>;
  27013. /**
  27014. * Sets the vertex data of the mesh geometry for the requested `kind`.
  27015. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  27016. * Note that a new underlying VertexBuffer object is created each call.
  27017. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  27018. * @param kind defines vertex data kind:
  27019. * * VertexBuffer.PositionKind
  27020. * * VertexBuffer.UVKind
  27021. * * VertexBuffer.UV2Kind
  27022. * * VertexBuffer.UV3Kind
  27023. * * VertexBuffer.UV4Kind
  27024. * * VertexBuffer.UV5Kind
  27025. * * VertexBuffer.UV6Kind
  27026. * * VertexBuffer.ColorKind
  27027. * * VertexBuffer.MatricesIndicesKind
  27028. * * VertexBuffer.MatricesIndicesExtraKind
  27029. * * VertexBuffer.MatricesWeightsKind
  27030. * * VertexBuffer.MatricesWeightsExtraKind
  27031. * @param data defines the data source
  27032. * @param updatable defines if the data must be flagged as updatable (or static)
  27033. * @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
  27034. * @returns the current mesh
  27035. */
  27036. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  27037. /**
  27038. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  27039. * If the mesh has no geometry, it is simply returned as it is.
  27040. * @param kind defines vertex data kind:
  27041. * * VertexBuffer.PositionKind
  27042. * * VertexBuffer.UVKind
  27043. * * VertexBuffer.UV2Kind
  27044. * * VertexBuffer.UV3Kind
  27045. * * VertexBuffer.UV4Kind
  27046. * * VertexBuffer.UV5Kind
  27047. * * VertexBuffer.UV6Kind
  27048. * * VertexBuffer.ColorKind
  27049. * * VertexBuffer.MatricesIndicesKind
  27050. * * VertexBuffer.MatricesIndicesExtraKind
  27051. * * VertexBuffer.MatricesWeightsKind
  27052. * * VertexBuffer.MatricesWeightsExtraKind
  27053. * @param data defines the data source
  27054. * @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
  27055. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  27056. * @returns the current mesh
  27057. */
  27058. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  27059. /**
  27060. * Sets the mesh indices,
  27061. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  27062. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  27063. * @param totalVertices Defines the total number of vertices
  27064. * @returns the current mesh
  27065. */
  27066. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  27067. /**
  27068. * Gets a boolean indicating if specific vertex data is present
  27069. * @param kind defines the vertex data kind to use
  27070. * @returns true is data kind is present
  27071. */
  27072. isVerticesDataPresent(kind: string): boolean;
  27073. /**
  27074. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  27075. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  27076. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  27077. * @returns a BoundingInfo
  27078. */
  27079. getBoundingInfo(): BoundingInfo;
  27080. /**
  27081. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  27082. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  27083. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  27084. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  27085. * @returns the current mesh
  27086. */
  27087. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  27088. /**
  27089. * Overwrite the current bounding info
  27090. * @param boundingInfo defines the new bounding info
  27091. * @returns the current mesh
  27092. */
  27093. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  27094. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  27095. readonly useBones: boolean;
  27096. /** @hidden */
  27097. _preActivate(): void;
  27098. /** @hidden */
  27099. _preActivateForIntermediateRendering(renderId: number): void;
  27100. /** @hidden */
  27101. _activate(renderId: number, intermediateRendering: boolean): boolean;
  27102. /** @hidden */
  27103. _postActivate(): void;
  27104. /** @hidden */
  27105. _freeze(): void;
  27106. /** @hidden */
  27107. _unFreeze(): void;
  27108. /**
  27109. * Gets the current world matrix
  27110. * @returns a Matrix
  27111. */
  27112. getWorldMatrix(): Matrix;
  27113. /** @hidden */
  27114. _getWorldMatrixDeterminant(): number;
  27115. /**
  27116. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  27117. */
  27118. readonly isAnInstance: boolean;
  27119. /**
  27120. * Gets a boolean indicating if this mesh has instances
  27121. */
  27122. readonly hasInstances: boolean;
  27123. /**
  27124. * Perform relative position change from the point of view of behind the front of the mesh.
  27125. * This is performed taking into account the meshes current rotation, so you do not have to care.
  27126. * Supports definition of mesh facing forward or backward
  27127. * @param amountRight defines the distance on the right axis
  27128. * @param amountUp defines the distance on the up axis
  27129. * @param amountForward defines the distance on the forward axis
  27130. * @returns the current mesh
  27131. */
  27132. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  27133. /**
  27134. * Calculate relative position change from the point of view of behind the front of the mesh.
  27135. * This is performed taking into account the meshes current rotation, so you do not have to care.
  27136. * Supports definition of mesh facing forward or backward
  27137. * @param amountRight defines the distance on the right axis
  27138. * @param amountUp defines the distance on the up axis
  27139. * @param amountForward defines the distance on the forward axis
  27140. * @returns the new displacement vector
  27141. */
  27142. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  27143. /**
  27144. * Perform relative rotation change from the point of view of behind the front of the mesh.
  27145. * Supports definition of mesh facing forward or backward
  27146. * @param flipBack defines the flip
  27147. * @param twirlClockwise defines the twirl
  27148. * @param tiltRight defines the tilt
  27149. * @returns the current mesh
  27150. */
  27151. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  27152. /**
  27153. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  27154. * Supports definition of mesh facing forward or backward.
  27155. * @param flipBack defines the flip
  27156. * @param twirlClockwise defines the twirl
  27157. * @param tiltRight defines the tilt
  27158. * @returns the new rotation vector
  27159. */
  27160. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  27161. /**
  27162. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  27163. * This means the mesh underlying bounding box and sphere are recomputed.
  27164. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  27165. * @returns the current mesh
  27166. */
  27167. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  27168. /** @hidden */
  27169. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  27170. /** @hidden */
  27171. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  27172. /** @hidden */
  27173. _updateBoundingInfo(): AbstractMesh;
  27174. /** @hidden */
  27175. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  27176. /** @hidden */
  27177. protected _afterComputeWorldMatrix(): void;
  27178. /** @hidden */
  27179. readonly _effectiveMesh: AbstractMesh;
  27180. /**
  27181. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  27182. * A mesh is in the frustum if its bounding box intersects the frustum
  27183. * @param frustumPlanes defines the frustum to test
  27184. * @returns true if the mesh is in the frustum planes
  27185. */
  27186. isInFrustum(frustumPlanes: Plane[]): boolean;
  27187. /**
  27188. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  27189. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  27190. * @param frustumPlanes defines the frustum to test
  27191. * @returns true if the mesh is completely in the frustum planes
  27192. */
  27193. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  27194. /**
  27195. * True if the mesh intersects another mesh or a SolidParticle object
  27196. * @param mesh defines a target mesh or SolidParticle to test
  27197. * @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)
  27198. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  27199. * @returns true if there is an intersection
  27200. */
  27201. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  27202. /**
  27203. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  27204. * @param point defines the point to test
  27205. * @returns true if there is an intersection
  27206. */
  27207. intersectsPoint(point: Vector3): boolean;
  27208. /**
  27209. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  27210. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27211. */
  27212. checkCollisions: boolean;
  27213. /**
  27214. * Gets Collider object used to compute collisions (not physics)
  27215. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27216. */
  27217. readonly collider: Nullable<Collider>;
  27218. /**
  27219. * Move the mesh using collision engine
  27220. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27221. * @param displacement defines the requested displacement vector
  27222. * @returns the current mesh
  27223. */
  27224. moveWithCollisions(displacement: Vector3): AbstractMesh;
  27225. private _onCollisionPositionChange;
  27226. /** @hidden */
  27227. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  27228. /** @hidden */
  27229. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  27230. /** @hidden */
  27231. _checkCollision(collider: Collider): AbstractMesh;
  27232. /** @hidden */
  27233. _generatePointsArray(): boolean;
  27234. /**
  27235. * Checks if the passed Ray intersects with the mesh
  27236. * @param ray defines the ray to use
  27237. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  27238. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  27239. * @returns the picking info
  27240. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  27241. */
  27242. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  27243. /**
  27244. * Clones the current mesh
  27245. * @param name defines the mesh name
  27246. * @param newParent defines the new mesh parent
  27247. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  27248. * @returns the new mesh
  27249. */
  27250. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  27251. /**
  27252. * Disposes all the submeshes of the current meshnp
  27253. * @returns the current mesh
  27254. */
  27255. releaseSubMeshes(): AbstractMesh;
  27256. /**
  27257. * Releases resources associated with this abstract mesh.
  27258. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27259. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27260. */
  27261. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27262. /**
  27263. * Adds the passed mesh as a child to the current mesh
  27264. * @param mesh defines the child mesh
  27265. * @returns the current mesh
  27266. */
  27267. addChild(mesh: AbstractMesh): AbstractMesh;
  27268. /**
  27269. * Removes the passed mesh from the current mesh children list
  27270. * @param mesh defines the child mesh
  27271. * @returns the current mesh
  27272. */
  27273. removeChild(mesh: AbstractMesh): AbstractMesh;
  27274. /** @hidden */
  27275. private _initFacetData;
  27276. /**
  27277. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  27278. * This method can be called within the render loop.
  27279. * 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
  27280. * @returns the current mesh
  27281. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27282. */
  27283. updateFacetData(): AbstractMesh;
  27284. /**
  27285. * Returns the facetLocalNormals array.
  27286. * The normals are expressed in the mesh local spac
  27287. * @returns an array of Vector3
  27288. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27289. */
  27290. getFacetLocalNormals(): Vector3[];
  27291. /**
  27292. * Returns the facetLocalPositions array.
  27293. * The facet positions are expressed in the mesh local space
  27294. * @returns an array of Vector3
  27295. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27296. */
  27297. getFacetLocalPositions(): Vector3[];
  27298. /**
  27299. * Returns the facetLocalPartioning array
  27300. * @returns an array of array of numbers
  27301. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27302. */
  27303. getFacetLocalPartitioning(): number[][];
  27304. /**
  27305. * Returns the i-th facet position in the world system.
  27306. * This method allocates a new Vector3 per call
  27307. * @param i defines the facet index
  27308. * @returns a new Vector3
  27309. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27310. */
  27311. getFacetPosition(i: number): Vector3;
  27312. /**
  27313. * Sets the reference Vector3 with the i-th facet position in the world system
  27314. * @param i defines the facet index
  27315. * @param ref defines the target vector
  27316. * @returns the current mesh
  27317. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27318. */
  27319. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  27320. /**
  27321. * Returns the i-th facet normal in the world system.
  27322. * This method allocates a new Vector3 per call
  27323. * @param i defines the facet index
  27324. * @returns a new Vector3
  27325. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27326. */
  27327. getFacetNormal(i: number): Vector3;
  27328. /**
  27329. * Sets the reference Vector3 with the i-th facet normal in the world system
  27330. * @param i defines the facet index
  27331. * @param ref defines the target vector
  27332. * @returns the current mesh
  27333. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27334. */
  27335. getFacetNormalToRef(i: number, ref: Vector3): this;
  27336. /**
  27337. * 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)
  27338. * @param x defines x coordinate
  27339. * @param y defines y coordinate
  27340. * @param z defines z coordinate
  27341. * @returns the array of facet indexes
  27342. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27343. */
  27344. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  27345. /**
  27346. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  27347. * @param projected sets as the (x,y,z) world projection on the facet
  27348. * @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
  27349. * @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
  27350. * @param x defines x coordinate
  27351. * @param y defines y coordinate
  27352. * @param z defines z coordinate
  27353. * @returns the face index if found (or null instead)
  27354. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27355. */
  27356. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27357. /**
  27358. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  27359. * @param projected sets as the (x,y,z) local projection on the facet
  27360. * @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
  27361. * @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
  27362. * @param x defines x coordinate
  27363. * @param y defines y coordinate
  27364. * @param z defines z coordinate
  27365. * @returns the face index if found (or null instead)
  27366. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27367. */
  27368. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27369. /**
  27370. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  27371. * @returns the parameters
  27372. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27373. */
  27374. getFacetDataParameters(): any;
  27375. /**
  27376. * Disables the feature FacetData and frees the related memory
  27377. * @returns the current mesh
  27378. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27379. */
  27380. disableFacetData(): AbstractMesh;
  27381. /**
  27382. * Updates the AbstractMesh indices array
  27383. * @param indices defines the data source
  27384. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27385. * @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)
  27386. * @returns the current mesh
  27387. */
  27388. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27389. /**
  27390. * Creates new normals data for the mesh
  27391. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  27392. * @returns the current mesh
  27393. */
  27394. createNormals(updatable: boolean): AbstractMesh;
  27395. /**
  27396. * Align the mesh with a normal
  27397. * @param normal defines the normal to use
  27398. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  27399. * @returns the current mesh
  27400. */
  27401. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  27402. /** @hidden */
  27403. _checkOcclusionQuery(): boolean;
  27404. /**
  27405. * Disables the mesh edge rendering mode
  27406. * @returns the currentAbstractMesh
  27407. */
  27408. disableEdgesRendering(): AbstractMesh;
  27409. /**
  27410. * Enables the edge rendering mode on the mesh.
  27411. * This mode makes the mesh edges visible
  27412. * @param epsilon defines the maximal distance between two angles to detect a face
  27413. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  27414. * @returns the currentAbstractMesh
  27415. * @see https://www.babylonjs-playground.com/#19O9TU#0
  27416. */
  27417. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  27418. }
  27419. }
  27420. declare module "babylonjs/Actions/actionEvent" {
  27421. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27422. import { Nullable } from "babylonjs/types";
  27423. import { Sprite } from "babylonjs/Sprites/sprite";
  27424. import { Scene } from "babylonjs/scene";
  27425. import { Vector2 } from "babylonjs/Maths/math.vector";
  27426. /**
  27427. * Interface used to define ActionEvent
  27428. */
  27429. export interface IActionEvent {
  27430. /** The mesh or sprite that triggered the action */
  27431. source: any;
  27432. /** The X mouse cursor position at the time of the event */
  27433. pointerX: number;
  27434. /** The Y mouse cursor position at the time of the event */
  27435. pointerY: number;
  27436. /** The mesh that is currently pointed at (can be null) */
  27437. meshUnderPointer: Nullable<AbstractMesh>;
  27438. /** the original (browser) event that triggered the ActionEvent */
  27439. sourceEvent?: any;
  27440. /** additional data for the event */
  27441. additionalData?: any;
  27442. }
  27443. /**
  27444. * ActionEvent is the event being sent when an action is triggered.
  27445. */
  27446. export class ActionEvent implements IActionEvent {
  27447. /** The mesh or sprite that triggered the action */
  27448. source: any;
  27449. /** The X mouse cursor position at the time of the event */
  27450. pointerX: number;
  27451. /** The Y mouse cursor position at the time of the event */
  27452. pointerY: number;
  27453. /** The mesh that is currently pointed at (can be null) */
  27454. meshUnderPointer: Nullable<AbstractMesh>;
  27455. /** the original (browser) event that triggered the ActionEvent */
  27456. sourceEvent?: any;
  27457. /** additional data for the event */
  27458. additionalData?: any;
  27459. /**
  27460. * Creates a new ActionEvent
  27461. * @param source The mesh or sprite that triggered the action
  27462. * @param pointerX The X mouse cursor position at the time of the event
  27463. * @param pointerY The Y mouse cursor position at the time of the event
  27464. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  27465. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  27466. * @param additionalData additional data for the event
  27467. */
  27468. constructor(
  27469. /** The mesh or sprite that triggered the action */
  27470. source: any,
  27471. /** The X mouse cursor position at the time of the event */
  27472. pointerX: number,
  27473. /** The Y mouse cursor position at the time of the event */
  27474. pointerY: number,
  27475. /** The mesh that is currently pointed at (can be null) */
  27476. meshUnderPointer: Nullable<AbstractMesh>,
  27477. /** the original (browser) event that triggered the ActionEvent */
  27478. sourceEvent?: any,
  27479. /** additional data for the event */
  27480. additionalData?: any);
  27481. /**
  27482. * Helper function to auto-create an ActionEvent from a source mesh.
  27483. * @param source The source mesh that triggered the event
  27484. * @param evt The original (browser) event
  27485. * @param additionalData additional data for the event
  27486. * @returns the new ActionEvent
  27487. */
  27488. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  27489. /**
  27490. * Helper function to auto-create an ActionEvent from a source sprite
  27491. * @param source The source sprite that triggered the event
  27492. * @param scene Scene associated with the sprite
  27493. * @param evt The original (browser) event
  27494. * @param additionalData additional data for the event
  27495. * @returns the new ActionEvent
  27496. */
  27497. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  27498. /**
  27499. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  27500. * @param scene the scene where the event occurred
  27501. * @param evt The original (browser) event
  27502. * @returns the new ActionEvent
  27503. */
  27504. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  27505. /**
  27506. * Helper function to auto-create an ActionEvent from a primitive
  27507. * @param prim defines the target primitive
  27508. * @param pointerPos defines the pointer position
  27509. * @param evt The original (browser) event
  27510. * @param additionalData additional data for the event
  27511. * @returns the new ActionEvent
  27512. */
  27513. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  27514. }
  27515. }
  27516. declare module "babylonjs/Actions/abstractActionManager" {
  27517. import { IDisposable } from "babylonjs/scene";
  27518. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  27519. import { IAction } from "babylonjs/Actions/action";
  27520. import { Nullable } from "babylonjs/types";
  27521. /**
  27522. * Abstract class used to decouple action Manager from scene and meshes.
  27523. * Do not instantiate.
  27524. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27525. */
  27526. export abstract class AbstractActionManager implements IDisposable {
  27527. /** Gets the list of active triggers */
  27528. static Triggers: {
  27529. [key: string]: number;
  27530. };
  27531. /** Gets the cursor to use when hovering items */
  27532. hoverCursor: string;
  27533. /** Gets the list of actions */
  27534. actions: IAction[];
  27535. /**
  27536. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  27537. */
  27538. isRecursive: boolean;
  27539. /**
  27540. * Releases all associated resources
  27541. */
  27542. abstract dispose(): void;
  27543. /**
  27544. * Does this action manager has pointer triggers
  27545. */
  27546. abstract readonly hasPointerTriggers: boolean;
  27547. /**
  27548. * Does this action manager has pick triggers
  27549. */
  27550. abstract readonly hasPickTriggers: boolean;
  27551. /**
  27552. * Process a specific trigger
  27553. * @param trigger defines the trigger to process
  27554. * @param evt defines the event details to be processed
  27555. */
  27556. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  27557. /**
  27558. * Does this action manager handles actions of any of the given triggers
  27559. * @param triggers defines the triggers to be tested
  27560. * @return a boolean indicating whether one (or more) of the triggers is handled
  27561. */
  27562. abstract hasSpecificTriggers(triggers: number[]): boolean;
  27563. /**
  27564. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  27565. * speed.
  27566. * @param triggerA defines the trigger to be tested
  27567. * @param triggerB defines the trigger to be tested
  27568. * @return a boolean indicating whether one (or more) of the triggers is handled
  27569. */
  27570. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  27571. /**
  27572. * Does this action manager handles actions of a given trigger
  27573. * @param trigger defines the trigger to be tested
  27574. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  27575. * @return whether the trigger is handled
  27576. */
  27577. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  27578. /**
  27579. * Serialize this manager to a JSON object
  27580. * @param name defines the property name to store this manager
  27581. * @returns a JSON representation of this manager
  27582. */
  27583. abstract serialize(name: string): any;
  27584. /**
  27585. * Registers an action to this action manager
  27586. * @param action defines the action to be registered
  27587. * @return the action amended (prepared) after registration
  27588. */
  27589. abstract registerAction(action: IAction): Nullable<IAction>;
  27590. /**
  27591. * Unregisters an action to this action manager
  27592. * @param action defines the action to be unregistered
  27593. * @return a boolean indicating whether the action has been unregistered
  27594. */
  27595. abstract unregisterAction(action: IAction): Boolean;
  27596. /**
  27597. * Does exist one action manager with at least one trigger
  27598. **/
  27599. static readonly HasTriggers: boolean;
  27600. /**
  27601. * Does exist one action manager with at least one pick trigger
  27602. **/
  27603. static readonly HasPickTriggers: boolean;
  27604. /**
  27605. * Does exist one action manager that handles actions of a given trigger
  27606. * @param trigger defines the trigger to be tested
  27607. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  27608. **/
  27609. static HasSpecificTrigger(trigger: number): boolean;
  27610. }
  27611. }
  27612. declare module "babylonjs/node" {
  27613. import { Scene } from "babylonjs/scene";
  27614. import { Nullable } from "babylonjs/types";
  27615. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  27616. import { Engine } from "babylonjs/Engines/engine";
  27617. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  27618. import { Observable } from "babylonjs/Misc/observable";
  27619. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  27620. import { IInspectable } from "babylonjs/Misc/iInspectable";
  27621. import { Animatable } from "babylonjs/Animations/animatable";
  27622. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27623. import { Animation } from "babylonjs/Animations/animation";
  27624. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27625. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27626. /**
  27627. * Defines how a node can be built from a string name.
  27628. */
  27629. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  27630. /**
  27631. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  27632. */
  27633. export class Node implements IBehaviorAware<Node> {
  27634. /** @hidden */
  27635. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  27636. private static _NodeConstructors;
  27637. /**
  27638. * Add a new node constructor
  27639. * @param type defines the type name of the node to construct
  27640. * @param constructorFunc defines the constructor function
  27641. */
  27642. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  27643. /**
  27644. * Returns a node constructor based on type name
  27645. * @param type defines the type name
  27646. * @param name defines the new node name
  27647. * @param scene defines the hosting scene
  27648. * @param options defines optional options to transmit to constructors
  27649. * @returns the new constructor or null
  27650. */
  27651. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  27652. /**
  27653. * Gets or sets the name of the node
  27654. */
  27655. name: string;
  27656. /**
  27657. * Gets or sets the id of the node
  27658. */
  27659. id: string;
  27660. /**
  27661. * Gets or sets the unique id of the node
  27662. */
  27663. uniqueId: number;
  27664. /**
  27665. * Gets or sets a string used to store user defined state for the node
  27666. */
  27667. state: string;
  27668. /**
  27669. * Gets or sets an object used to store user defined information for the node
  27670. */
  27671. metadata: any;
  27672. /**
  27673. * For internal use only. Please do not use.
  27674. */
  27675. reservedDataStore: any;
  27676. /**
  27677. * List of inspectable custom properties (used by the Inspector)
  27678. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  27679. */
  27680. inspectableCustomProperties: IInspectable[];
  27681. private _doNotSerialize;
  27682. /**
  27683. * Gets or sets a boolean used to define if the node must be serialized
  27684. */
  27685. doNotSerialize: boolean;
  27686. /** @hidden */
  27687. _isDisposed: boolean;
  27688. /**
  27689. * Gets a list of Animations associated with the node
  27690. */
  27691. animations: import("babylonjs/Animations/animation").Animation[];
  27692. protected _ranges: {
  27693. [name: string]: Nullable<AnimationRange>;
  27694. };
  27695. /**
  27696. * Callback raised when the node is ready to be used
  27697. */
  27698. onReady: Nullable<(node: Node) => void>;
  27699. private _isEnabled;
  27700. private _isParentEnabled;
  27701. private _isReady;
  27702. /** @hidden */
  27703. _currentRenderId: number;
  27704. private _parentUpdateId;
  27705. /** @hidden */
  27706. _childUpdateId: number;
  27707. /** @hidden */
  27708. _waitingParentId: Nullable<string>;
  27709. /** @hidden */
  27710. _scene: Scene;
  27711. /** @hidden */
  27712. _cache: any;
  27713. private _parentNode;
  27714. private _children;
  27715. /** @hidden */
  27716. _worldMatrix: Matrix;
  27717. /** @hidden */
  27718. _worldMatrixDeterminant: number;
  27719. /** @hidden */
  27720. _worldMatrixDeterminantIsDirty: boolean;
  27721. /** @hidden */
  27722. private _sceneRootNodesIndex;
  27723. /**
  27724. * Gets a boolean indicating if the node has been disposed
  27725. * @returns true if the node was disposed
  27726. */
  27727. isDisposed(): boolean;
  27728. /**
  27729. * Gets or sets the parent of the node (without keeping the current position in the scene)
  27730. * @see https://doc.babylonjs.com/how_to/parenting
  27731. */
  27732. parent: Nullable<Node>;
  27733. private addToSceneRootNodes;
  27734. private removeFromSceneRootNodes;
  27735. private _animationPropertiesOverride;
  27736. /**
  27737. * Gets or sets the animation properties override
  27738. */
  27739. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  27740. /**
  27741. * Gets a string idenfifying the name of the class
  27742. * @returns "Node" string
  27743. */
  27744. getClassName(): string;
  27745. /** @hidden */
  27746. readonly _isNode: boolean;
  27747. /**
  27748. * An event triggered when the mesh is disposed
  27749. */
  27750. onDisposeObservable: Observable<Node>;
  27751. private _onDisposeObserver;
  27752. /**
  27753. * Sets a callback that will be raised when the node will be disposed
  27754. */
  27755. onDispose: () => void;
  27756. /**
  27757. * Creates a new Node
  27758. * @param name the name and id to be given to this node
  27759. * @param scene the scene this node will be added to
  27760. * @param addToRootNodes the node will be added to scene.rootNodes
  27761. */
  27762. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  27763. /**
  27764. * Gets the scene of the node
  27765. * @returns a scene
  27766. */
  27767. getScene(): Scene;
  27768. /**
  27769. * Gets the engine of the node
  27770. * @returns a Engine
  27771. */
  27772. getEngine(): Engine;
  27773. private _behaviors;
  27774. /**
  27775. * Attach a behavior to the node
  27776. * @see http://doc.babylonjs.com/features/behaviour
  27777. * @param behavior defines the behavior to attach
  27778. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  27779. * @returns the current Node
  27780. */
  27781. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  27782. /**
  27783. * Remove an attached behavior
  27784. * @see http://doc.babylonjs.com/features/behaviour
  27785. * @param behavior defines the behavior to attach
  27786. * @returns the current Node
  27787. */
  27788. removeBehavior(behavior: Behavior<Node>): Node;
  27789. /**
  27790. * Gets the list of attached behaviors
  27791. * @see http://doc.babylonjs.com/features/behaviour
  27792. */
  27793. readonly behaviors: Behavior<Node>[];
  27794. /**
  27795. * Gets an attached behavior by name
  27796. * @param name defines the name of the behavior to look for
  27797. * @see http://doc.babylonjs.com/features/behaviour
  27798. * @returns null if behavior was not found else the requested behavior
  27799. */
  27800. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  27801. /**
  27802. * Returns the latest update of the World matrix
  27803. * @returns a Matrix
  27804. */
  27805. getWorldMatrix(): Matrix;
  27806. /** @hidden */
  27807. _getWorldMatrixDeterminant(): number;
  27808. /**
  27809. * Returns directly the latest state of the mesh World matrix.
  27810. * A Matrix is returned.
  27811. */
  27812. readonly worldMatrixFromCache: Matrix;
  27813. /** @hidden */
  27814. _initCache(): void;
  27815. /** @hidden */
  27816. updateCache(force?: boolean): void;
  27817. /** @hidden */
  27818. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27819. /** @hidden */
  27820. _updateCache(ignoreParentClass?: boolean): void;
  27821. /** @hidden */
  27822. _isSynchronized(): boolean;
  27823. /** @hidden */
  27824. _markSyncedWithParent(): void;
  27825. /** @hidden */
  27826. isSynchronizedWithParent(): boolean;
  27827. /** @hidden */
  27828. isSynchronized(): boolean;
  27829. /**
  27830. * Is this node ready to be used/rendered
  27831. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27832. * @return true if the node is ready
  27833. */
  27834. isReady(completeCheck?: boolean): boolean;
  27835. /**
  27836. * Is this node enabled?
  27837. * 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
  27838. * @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
  27839. * @return whether this node (and its parent) is enabled
  27840. */
  27841. isEnabled(checkAncestors?: boolean): boolean;
  27842. /** @hidden */
  27843. protected _syncParentEnabledState(): void;
  27844. /**
  27845. * Set the enabled state of this node
  27846. * @param value defines the new enabled state
  27847. */
  27848. setEnabled(value: boolean): void;
  27849. /**
  27850. * Is this node a descendant of the given node?
  27851. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  27852. * @param ancestor defines the parent node to inspect
  27853. * @returns a boolean indicating if this node is a descendant of the given node
  27854. */
  27855. isDescendantOf(ancestor: Node): boolean;
  27856. /** @hidden */
  27857. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  27858. /**
  27859. * Will return all nodes that have this node as ascendant
  27860. * @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
  27861. * @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
  27862. * @return all children nodes of all types
  27863. */
  27864. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  27865. /**
  27866. * Get all child-meshes of this node
  27867. * @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)
  27868. * @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
  27869. * @returns an array of AbstractMesh
  27870. */
  27871. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  27872. /**
  27873. * Get all direct children of this node
  27874. * @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
  27875. * @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)
  27876. * @returns an array of Node
  27877. */
  27878. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  27879. /** @hidden */
  27880. _setReady(state: boolean): void;
  27881. /**
  27882. * Get an animation by name
  27883. * @param name defines the name of the animation to look for
  27884. * @returns null if not found else the requested animation
  27885. */
  27886. getAnimationByName(name: string): Nullable<Animation>;
  27887. /**
  27888. * Creates an animation range for this node
  27889. * @param name defines the name of the range
  27890. * @param from defines the starting key
  27891. * @param to defines the end key
  27892. */
  27893. createAnimationRange(name: string, from: number, to: number): void;
  27894. /**
  27895. * Delete a specific animation range
  27896. * @param name defines the name of the range to delete
  27897. * @param deleteFrames defines if animation frames from the range must be deleted as well
  27898. */
  27899. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  27900. /**
  27901. * Get an animation range by name
  27902. * @param name defines the name of the animation range to look for
  27903. * @returns null if not found else the requested animation range
  27904. */
  27905. getAnimationRange(name: string): Nullable<AnimationRange>;
  27906. /**
  27907. * Gets the list of all animation ranges defined on this node
  27908. * @returns an array
  27909. */
  27910. getAnimationRanges(): Nullable<AnimationRange>[];
  27911. /**
  27912. * Will start the animation sequence
  27913. * @param name defines the range frames for animation sequence
  27914. * @param loop defines if the animation should loop (false by default)
  27915. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  27916. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  27917. * @returns the object created for this animation. If range does not exist, it will return null
  27918. */
  27919. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  27920. /**
  27921. * Serialize animation ranges into a JSON compatible object
  27922. * @returns serialization object
  27923. */
  27924. serializeAnimationRanges(): any;
  27925. /**
  27926. * Computes the world matrix of the node
  27927. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27928. * @returns the world matrix
  27929. */
  27930. computeWorldMatrix(force?: boolean): Matrix;
  27931. /**
  27932. * Releases resources associated with this node.
  27933. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27934. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27935. */
  27936. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27937. /**
  27938. * Parse animation range data from a serialization object and store them into a given node
  27939. * @param node defines where to store the animation ranges
  27940. * @param parsedNode defines the serialization object to read data from
  27941. * @param scene defines the hosting scene
  27942. */
  27943. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  27944. /**
  27945. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  27946. * @param includeDescendants Include bounding info from descendants as well (true by default)
  27947. * @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
  27948. * @returns the new bounding vectors
  27949. */
  27950. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  27951. min: Vector3;
  27952. max: Vector3;
  27953. };
  27954. }
  27955. }
  27956. declare module "babylonjs/Animations/animation" {
  27957. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  27958. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  27959. import { Color3 } from "babylonjs/Maths/math.color";
  27960. import { Nullable } from "babylonjs/types";
  27961. import { Scene } from "babylonjs/scene";
  27962. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  27963. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27964. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  27965. import { Node } from "babylonjs/node";
  27966. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27967. import { Size } from "babylonjs/Maths/math.size";
  27968. import { Animatable } from "babylonjs/Animations/animatable";
  27969. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  27970. /**
  27971. * @hidden
  27972. */
  27973. export class _IAnimationState {
  27974. key: number;
  27975. repeatCount: number;
  27976. workValue?: any;
  27977. loopMode?: number;
  27978. offsetValue?: any;
  27979. highLimitValue?: any;
  27980. }
  27981. /**
  27982. * Class used to store any kind of animation
  27983. */
  27984. export class Animation {
  27985. /**Name of the animation */
  27986. name: string;
  27987. /**Property to animate */
  27988. targetProperty: string;
  27989. /**The frames per second of the animation */
  27990. framePerSecond: number;
  27991. /**The data type of the animation */
  27992. dataType: number;
  27993. /**The loop mode of the animation */
  27994. loopMode?: number | undefined;
  27995. /**Specifies if blending should be enabled */
  27996. enableBlending?: boolean | undefined;
  27997. /**
  27998. * Use matrix interpolation instead of using direct key value when animating matrices
  27999. */
  28000. static AllowMatricesInterpolation: boolean;
  28001. /**
  28002. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  28003. */
  28004. static AllowMatrixDecomposeForInterpolation: boolean;
  28005. /**
  28006. * Stores the key frames of the animation
  28007. */
  28008. private _keys;
  28009. /**
  28010. * Stores the easing function of the animation
  28011. */
  28012. private _easingFunction;
  28013. /**
  28014. * @hidden Internal use only
  28015. */
  28016. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  28017. /**
  28018. * The set of event that will be linked to this animation
  28019. */
  28020. private _events;
  28021. /**
  28022. * Stores an array of target property paths
  28023. */
  28024. targetPropertyPath: string[];
  28025. /**
  28026. * Stores the blending speed of the animation
  28027. */
  28028. blendingSpeed: number;
  28029. /**
  28030. * Stores the animation ranges for the animation
  28031. */
  28032. private _ranges;
  28033. /**
  28034. * @hidden Internal use
  28035. */
  28036. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  28037. /**
  28038. * Sets up an animation
  28039. * @param property The property to animate
  28040. * @param animationType The animation type to apply
  28041. * @param framePerSecond The frames per second of the animation
  28042. * @param easingFunction The easing function used in the animation
  28043. * @returns The created animation
  28044. */
  28045. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  28046. /**
  28047. * Create and start an animation on a node
  28048. * @param name defines the name of the global animation that will be run on all nodes
  28049. * @param node defines the root node where the animation will take place
  28050. * @param targetProperty defines property to animate
  28051. * @param framePerSecond defines the number of frame per second yo use
  28052. * @param totalFrame defines the number of frames in total
  28053. * @param from defines the initial value
  28054. * @param to defines the final value
  28055. * @param loopMode defines which loop mode you want to use (off by default)
  28056. * @param easingFunction defines the easing function to use (linear by default)
  28057. * @param onAnimationEnd defines the callback to call when animation end
  28058. * @returns the animatable created for this animation
  28059. */
  28060. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  28061. /**
  28062. * Create and start an animation on a node and its descendants
  28063. * @param name defines the name of the global animation that will be run on all nodes
  28064. * @param node defines the root node where the animation will take place
  28065. * @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
  28066. * @param targetProperty defines property to animate
  28067. * @param framePerSecond defines the number of frame per second to use
  28068. * @param totalFrame defines the number of frames in total
  28069. * @param from defines the initial value
  28070. * @param to defines the final value
  28071. * @param loopMode defines which loop mode you want to use (off by default)
  28072. * @param easingFunction defines the easing function to use (linear by default)
  28073. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  28074. * @returns the list of animatables created for all nodes
  28075. * @example https://www.babylonjs-playground.com/#MH0VLI
  28076. */
  28077. 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[]>;
  28078. /**
  28079. * Creates a new animation, merges it with the existing animations and starts it
  28080. * @param name Name of the animation
  28081. * @param node Node which contains the scene that begins the animations
  28082. * @param targetProperty Specifies which property to animate
  28083. * @param framePerSecond The frames per second of the animation
  28084. * @param totalFrame The total number of frames
  28085. * @param from The frame at the beginning of the animation
  28086. * @param to The frame at the end of the animation
  28087. * @param loopMode Specifies the loop mode of the animation
  28088. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  28089. * @param onAnimationEnd Callback to run once the animation is complete
  28090. * @returns Nullable animation
  28091. */
  28092. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  28093. /**
  28094. * Transition property of an host to the target Value
  28095. * @param property The property to transition
  28096. * @param targetValue The target Value of the property
  28097. * @param host The object where the property to animate belongs
  28098. * @param scene Scene used to run the animation
  28099. * @param frameRate Framerate (in frame/s) to use
  28100. * @param transition The transition type we want to use
  28101. * @param duration The duration of the animation, in milliseconds
  28102. * @param onAnimationEnd Callback trigger at the end of the animation
  28103. * @returns Nullable animation
  28104. */
  28105. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  28106. /**
  28107. * Return the array of runtime animations currently using this animation
  28108. */
  28109. readonly runtimeAnimations: RuntimeAnimation[];
  28110. /**
  28111. * Specifies if any of the runtime animations are currently running
  28112. */
  28113. readonly hasRunningRuntimeAnimations: boolean;
  28114. /**
  28115. * Initializes the animation
  28116. * @param name Name of the animation
  28117. * @param targetProperty Property to animate
  28118. * @param framePerSecond The frames per second of the animation
  28119. * @param dataType The data type of the animation
  28120. * @param loopMode The loop mode of the animation
  28121. * @param enableBlending Specifies if blending should be enabled
  28122. */
  28123. constructor(
  28124. /**Name of the animation */
  28125. name: string,
  28126. /**Property to animate */
  28127. targetProperty: string,
  28128. /**The frames per second of the animation */
  28129. framePerSecond: number,
  28130. /**The data type of the animation */
  28131. dataType: number,
  28132. /**The loop mode of the animation */
  28133. loopMode?: number | undefined,
  28134. /**Specifies if blending should be enabled */
  28135. enableBlending?: boolean | undefined);
  28136. /**
  28137. * Converts the animation to a string
  28138. * @param fullDetails support for multiple levels of logging within scene loading
  28139. * @returns String form of the animation
  28140. */
  28141. toString(fullDetails?: boolean): string;
  28142. /**
  28143. * Add an event to this animation
  28144. * @param event Event to add
  28145. */
  28146. addEvent(event: AnimationEvent): void;
  28147. /**
  28148. * Remove all events found at the given frame
  28149. * @param frame The frame to remove events from
  28150. */
  28151. removeEvents(frame: number): void;
  28152. /**
  28153. * Retrieves all the events from the animation
  28154. * @returns Events from the animation
  28155. */
  28156. getEvents(): AnimationEvent[];
  28157. /**
  28158. * Creates an animation range
  28159. * @param name Name of the animation range
  28160. * @param from Starting frame of the animation range
  28161. * @param to Ending frame of the animation
  28162. */
  28163. createRange(name: string, from: number, to: number): void;
  28164. /**
  28165. * Deletes an animation range by name
  28166. * @param name Name of the animation range to delete
  28167. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  28168. */
  28169. deleteRange(name: string, deleteFrames?: boolean): void;
  28170. /**
  28171. * Gets the animation range by name, or null if not defined
  28172. * @param name Name of the animation range
  28173. * @returns Nullable animation range
  28174. */
  28175. getRange(name: string): Nullable<AnimationRange>;
  28176. /**
  28177. * Gets the key frames from the animation
  28178. * @returns The key frames of the animation
  28179. */
  28180. getKeys(): Array<IAnimationKey>;
  28181. /**
  28182. * Gets the highest frame rate of the animation
  28183. * @returns Highest frame rate of the animation
  28184. */
  28185. getHighestFrame(): number;
  28186. /**
  28187. * Gets the easing function of the animation
  28188. * @returns Easing function of the animation
  28189. */
  28190. getEasingFunction(): IEasingFunction;
  28191. /**
  28192. * Sets the easing function of the animation
  28193. * @param easingFunction A custom mathematical formula for animation
  28194. */
  28195. setEasingFunction(easingFunction: EasingFunction): void;
  28196. /**
  28197. * Interpolates a scalar linearly
  28198. * @param startValue Start value of the animation curve
  28199. * @param endValue End value of the animation curve
  28200. * @param gradient Scalar amount to interpolate
  28201. * @returns Interpolated scalar value
  28202. */
  28203. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  28204. /**
  28205. * Interpolates a scalar cubically
  28206. * @param startValue Start value of the animation curve
  28207. * @param outTangent End tangent of the animation
  28208. * @param endValue End value of the animation curve
  28209. * @param inTangent Start tangent of the animation curve
  28210. * @param gradient Scalar amount to interpolate
  28211. * @returns Interpolated scalar value
  28212. */
  28213. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  28214. /**
  28215. * Interpolates a quaternion using a spherical linear interpolation
  28216. * @param startValue Start value of the animation curve
  28217. * @param endValue End value of the animation curve
  28218. * @param gradient Scalar amount to interpolate
  28219. * @returns Interpolated quaternion value
  28220. */
  28221. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  28222. /**
  28223. * Interpolates a quaternion cubically
  28224. * @param startValue Start value of the animation curve
  28225. * @param outTangent End tangent of the animation curve
  28226. * @param endValue End value of the animation curve
  28227. * @param inTangent Start tangent of the animation curve
  28228. * @param gradient Scalar amount to interpolate
  28229. * @returns Interpolated quaternion value
  28230. */
  28231. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  28232. /**
  28233. * Interpolates a Vector3 linearl
  28234. * @param startValue Start value of the animation curve
  28235. * @param endValue End value of the animation curve
  28236. * @param gradient Scalar amount to interpolate
  28237. * @returns Interpolated scalar value
  28238. */
  28239. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  28240. /**
  28241. * Interpolates a Vector3 cubically
  28242. * @param startValue Start value of the animation curve
  28243. * @param outTangent End tangent of the animation
  28244. * @param endValue End value of the animation curve
  28245. * @param inTangent Start tangent of the animation curve
  28246. * @param gradient Scalar amount to interpolate
  28247. * @returns InterpolatedVector3 value
  28248. */
  28249. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  28250. /**
  28251. * Interpolates a Vector2 linearly
  28252. * @param startValue Start value of the animation curve
  28253. * @param endValue End value of the animation curve
  28254. * @param gradient Scalar amount to interpolate
  28255. * @returns Interpolated Vector2 value
  28256. */
  28257. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  28258. /**
  28259. * Interpolates a Vector2 cubically
  28260. * @param startValue Start value of the animation curve
  28261. * @param outTangent End tangent of the animation
  28262. * @param endValue End value of the animation curve
  28263. * @param inTangent Start tangent of the animation curve
  28264. * @param gradient Scalar amount to interpolate
  28265. * @returns Interpolated Vector2 value
  28266. */
  28267. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  28268. /**
  28269. * Interpolates a size linearly
  28270. * @param startValue Start value of the animation curve
  28271. * @param endValue End value of the animation curve
  28272. * @param gradient Scalar amount to interpolate
  28273. * @returns Interpolated Size value
  28274. */
  28275. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  28276. /**
  28277. * Interpolates a Color3 linearly
  28278. * @param startValue Start value of the animation curve
  28279. * @param endValue End value of the animation curve
  28280. * @param gradient Scalar amount to interpolate
  28281. * @returns Interpolated Color3 value
  28282. */
  28283. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  28284. /**
  28285. * @hidden Internal use only
  28286. */
  28287. _getKeyValue(value: any): any;
  28288. /**
  28289. * @hidden Internal use only
  28290. */
  28291. _interpolate(currentFrame: number, state: _IAnimationState): any;
  28292. /**
  28293. * Defines the function to use to interpolate matrices
  28294. * @param startValue defines the start matrix
  28295. * @param endValue defines the end matrix
  28296. * @param gradient defines the gradient between both matrices
  28297. * @param result defines an optional target matrix where to store the interpolation
  28298. * @returns the interpolated matrix
  28299. */
  28300. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  28301. /**
  28302. * Makes a copy of the animation
  28303. * @returns Cloned animation
  28304. */
  28305. clone(): Animation;
  28306. /**
  28307. * Sets the key frames of the animation
  28308. * @param values The animation key frames to set
  28309. */
  28310. setKeys(values: Array<IAnimationKey>): void;
  28311. /**
  28312. * Serializes the animation to an object
  28313. * @returns Serialized object
  28314. */
  28315. serialize(): any;
  28316. /**
  28317. * Float animation type
  28318. */
  28319. private static _ANIMATIONTYPE_FLOAT;
  28320. /**
  28321. * Vector3 animation type
  28322. */
  28323. private static _ANIMATIONTYPE_VECTOR3;
  28324. /**
  28325. * Quaternion animation type
  28326. */
  28327. private static _ANIMATIONTYPE_QUATERNION;
  28328. /**
  28329. * Matrix animation type
  28330. */
  28331. private static _ANIMATIONTYPE_MATRIX;
  28332. /**
  28333. * Color3 animation type
  28334. */
  28335. private static _ANIMATIONTYPE_COLOR3;
  28336. /**
  28337. * Vector2 animation type
  28338. */
  28339. private static _ANIMATIONTYPE_VECTOR2;
  28340. /**
  28341. * Size animation type
  28342. */
  28343. private static _ANIMATIONTYPE_SIZE;
  28344. /**
  28345. * Relative Loop Mode
  28346. */
  28347. private static _ANIMATIONLOOPMODE_RELATIVE;
  28348. /**
  28349. * Cycle Loop Mode
  28350. */
  28351. private static _ANIMATIONLOOPMODE_CYCLE;
  28352. /**
  28353. * Constant Loop Mode
  28354. */
  28355. private static _ANIMATIONLOOPMODE_CONSTANT;
  28356. /**
  28357. * Get the float animation type
  28358. */
  28359. static readonly ANIMATIONTYPE_FLOAT: number;
  28360. /**
  28361. * Get the Vector3 animation type
  28362. */
  28363. static readonly ANIMATIONTYPE_VECTOR3: number;
  28364. /**
  28365. * Get the Vector2 animation type
  28366. */
  28367. static readonly ANIMATIONTYPE_VECTOR2: number;
  28368. /**
  28369. * Get the Size animation type
  28370. */
  28371. static readonly ANIMATIONTYPE_SIZE: number;
  28372. /**
  28373. * Get the Quaternion animation type
  28374. */
  28375. static readonly ANIMATIONTYPE_QUATERNION: number;
  28376. /**
  28377. * Get the Matrix animation type
  28378. */
  28379. static readonly ANIMATIONTYPE_MATRIX: number;
  28380. /**
  28381. * Get the Color3 animation type
  28382. */
  28383. static readonly ANIMATIONTYPE_COLOR3: number;
  28384. /**
  28385. * Get the Relative Loop Mode
  28386. */
  28387. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  28388. /**
  28389. * Get the Cycle Loop Mode
  28390. */
  28391. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  28392. /**
  28393. * Get the Constant Loop Mode
  28394. */
  28395. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  28396. /** @hidden */
  28397. static _UniversalLerp(left: any, right: any, amount: number): any;
  28398. /**
  28399. * Parses an animation object and creates an animation
  28400. * @param parsedAnimation Parsed animation object
  28401. * @returns Animation object
  28402. */
  28403. static Parse(parsedAnimation: any): Animation;
  28404. /**
  28405. * Appends the serialized animations from the source animations
  28406. * @param source Source containing the animations
  28407. * @param destination Target to store the animations
  28408. */
  28409. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28410. }
  28411. }
  28412. declare module "babylonjs/Animations/animatable.interface" {
  28413. import { Nullable } from "babylonjs/types";
  28414. import { Animation } from "babylonjs/Animations/animation";
  28415. /**
  28416. * Interface containing an array of animations
  28417. */
  28418. export interface IAnimatable {
  28419. /**
  28420. * Array of animations
  28421. */
  28422. animations: Nullable<Array<Animation>>;
  28423. }
  28424. }
  28425. declare module "babylonjs/Materials/fresnelParameters" {
  28426. import { Color3 } from "babylonjs/Maths/math.color";
  28427. /**
  28428. * This represents all the required information to add a fresnel effect on a material:
  28429. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28430. */
  28431. export class FresnelParameters {
  28432. private _isEnabled;
  28433. /**
  28434. * Define if the fresnel effect is enable or not.
  28435. */
  28436. isEnabled: boolean;
  28437. /**
  28438. * Define the color used on edges (grazing angle)
  28439. */
  28440. leftColor: Color3;
  28441. /**
  28442. * Define the color used on center
  28443. */
  28444. rightColor: Color3;
  28445. /**
  28446. * Define bias applied to computed fresnel term
  28447. */
  28448. bias: number;
  28449. /**
  28450. * Defined the power exponent applied to fresnel term
  28451. */
  28452. power: number;
  28453. /**
  28454. * Clones the current fresnel and its valuues
  28455. * @returns a clone fresnel configuration
  28456. */
  28457. clone(): FresnelParameters;
  28458. /**
  28459. * Serializes the current fresnel parameters to a JSON representation.
  28460. * @return the JSON serialization
  28461. */
  28462. serialize(): any;
  28463. /**
  28464. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  28465. * @param parsedFresnelParameters Define the JSON representation
  28466. * @returns the parsed parameters
  28467. */
  28468. static Parse(parsedFresnelParameters: any): FresnelParameters;
  28469. }
  28470. }
  28471. declare module "babylonjs/Misc/decorators" {
  28472. import { Nullable } from "babylonjs/types";
  28473. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28474. import { Scene } from "babylonjs/scene";
  28475. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  28476. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28477. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28478. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28479. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28480. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28481. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28482. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28483. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28484. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28485. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28486. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28487. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28488. /**
  28489. * Decorator used to define property that can be serialized as reference to a camera
  28490. * @param sourceName defines the name of the property to decorate
  28491. */
  28492. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28493. /**
  28494. * Class used to help serialization objects
  28495. */
  28496. export class SerializationHelper {
  28497. /** @hidden */
  28498. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  28499. /** @hidden */
  28500. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  28501. /** @hidden */
  28502. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  28503. /** @hidden */
  28504. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  28505. /**
  28506. * Appends the serialized animations from the source animations
  28507. * @param source Source containing the animations
  28508. * @param destination Target to store the animations
  28509. */
  28510. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28511. /**
  28512. * Static function used to serialized a specific entity
  28513. * @param entity defines the entity to serialize
  28514. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  28515. * @returns a JSON compatible object representing the serialization of the entity
  28516. */
  28517. static Serialize<T>(entity: T, serializationObject?: any): any;
  28518. /**
  28519. * Creates a new entity from a serialization data object
  28520. * @param creationFunction defines a function used to instanciated the new entity
  28521. * @param source defines the source serialization data
  28522. * @param scene defines the hosting scene
  28523. * @param rootUrl defines the root url for resources
  28524. * @returns a new entity
  28525. */
  28526. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  28527. /**
  28528. * Clones an object
  28529. * @param creationFunction defines the function used to instanciate the new object
  28530. * @param source defines the source object
  28531. * @returns the cloned object
  28532. */
  28533. static Clone<T>(creationFunction: () => T, source: T): T;
  28534. /**
  28535. * Instanciates a new object based on a source one (some data will be shared between both object)
  28536. * @param creationFunction defines the function used to instanciate the new object
  28537. * @param source defines the source object
  28538. * @returns the new object
  28539. */
  28540. static Instanciate<T>(creationFunction: () => T, source: T): T;
  28541. }
  28542. }
  28543. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  28544. import { Nullable } from "babylonjs/types";
  28545. /**
  28546. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  28547. */
  28548. export interface CubeMapInfo {
  28549. /**
  28550. * The pixel array for the front face.
  28551. * This is stored in format, left to right, up to down format.
  28552. */
  28553. front: Nullable<ArrayBufferView>;
  28554. /**
  28555. * The pixel array for the back face.
  28556. * This is stored in format, left to right, up to down format.
  28557. */
  28558. back: Nullable<ArrayBufferView>;
  28559. /**
  28560. * The pixel array for the left face.
  28561. * This is stored in format, left to right, up to down format.
  28562. */
  28563. left: Nullable<ArrayBufferView>;
  28564. /**
  28565. * The pixel array for the right face.
  28566. * This is stored in format, left to right, up to down format.
  28567. */
  28568. right: Nullable<ArrayBufferView>;
  28569. /**
  28570. * The pixel array for the up face.
  28571. * This is stored in format, left to right, up to down format.
  28572. */
  28573. up: Nullable<ArrayBufferView>;
  28574. /**
  28575. * The pixel array for the down face.
  28576. * This is stored in format, left to right, up to down format.
  28577. */
  28578. down: Nullable<ArrayBufferView>;
  28579. /**
  28580. * The size of the cubemap stored.
  28581. *
  28582. * Each faces will be size * size pixels.
  28583. */
  28584. size: number;
  28585. /**
  28586. * The format of the texture.
  28587. *
  28588. * RGBA, RGB.
  28589. */
  28590. format: number;
  28591. /**
  28592. * The type of the texture data.
  28593. *
  28594. * UNSIGNED_INT, FLOAT.
  28595. */
  28596. type: number;
  28597. /**
  28598. * Specifies whether the texture is in gamma space.
  28599. */
  28600. gammaSpace: boolean;
  28601. }
  28602. /**
  28603. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  28604. */
  28605. export class PanoramaToCubeMapTools {
  28606. private static FACE_FRONT;
  28607. private static FACE_BACK;
  28608. private static FACE_RIGHT;
  28609. private static FACE_LEFT;
  28610. private static FACE_DOWN;
  28611. private static FACE_UP;
  28612. /**
  28613. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  28614. *
  28615. * @param float32Array The source data.
  28616. * @param inputWidth The width of the input panorama.
  28617. * @param inputHeight The height of the input panorama.
  28618. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  28619. * @return The cubemap data
  28620. */
  28621. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  28622. private static CreateCubemapTexture;
  28623. private static CalcProjectionSpherical;
  28624. }
  28625. }
  28626. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  28627. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28628. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28629. import { Nullable } from "babylonjs/types";
  28630. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  28631. /**
  28632. * Helper class dealing with the extraction of spherical polynomial dataArray
  28633. * from a cube map.
  28634. */
  28635. export class CubeMapToSphericalPolynomialTools {
  28636. private static FileFaces;
  28637. /**
  28638. * Converts a texture to the according Spherical Polynomial data.
  28639. * This extracts the first 3 orders only as they are the only one used in the lighting.
  28640. *
  28641. * @param texture The texture to extract the information from.
  28642. * @return The Spherical Polynomial data.
  28643. */
  28644. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  28645. /**
  28646. * Converts a cubemap to the according Spherical Polynomial data.
  28647. * This extracts the first 3 orders only as they are the only one used in the lighting.
  28648. *
  28649. * @param cubeInfo The Cube map to extract the information from.
  28650. * @return The Spherical Polynomial data.
  28651. */
  28652. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  28653. }
  28654. }
  28655. declare module "babylonjs/Misc/guid" {
  28656. /**
  28657. * Class used to manipulate GUIDs
  28658. */
  28659. export class GUID {
  28660. /**
  28661. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  28662. * Be aware Math.random() could cause collisions, but:
  28663. * "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"
  28664. * @returns a pseudo random id
  28665. */
  28666. static RandomId(): string;
  28667. }
  28668. }
  28669. declare module "babylonjs/Materials/Textures/baseTexture" {
  28670. import { Observable } from "babylonjs/Misc/observable";
  28671. import { Nullable } from "babylonjs/types";
  28672. import { Scene } from "babylonjs/scene";
  28673. import { Matrix } from "babylonjs/Maths/math.vector";
  28674. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28675. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28676. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28677. import { ISize } from "babylonjs/Maths/math.size";
  28678. /**
  28679. * Base class of all the textures in babylon.
  28680. * It groups all the common properties the materials, post process, lights... might need
  28681. * in order to make a correct use of the texture.
  28682. */
  28683. export class BaseTexture implements IAnimatable {
  28684. /**
  28685. * Default anisotropic filtering level for the application.
  28686. * It is set to 4 as a good tradeoff between perf and quality.
  28687. */
  28688. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  28689. /**
  28690. * Gets or sets the unique id of the texture
  28691. */
  28692. uniqueId: number;
  28693. /**
  28694. * Define the name of the texture.
  28695. */
  28696. name: string;
  28697. /**
  28698. * Gets or sets an object used to store user defined information.
  28699. */
  28700. metadata: any;
  28701. /**
  28702. * For internal use only. Please do not use.
  28703. */
  28704. reservedDataStore: any;
  28705. private _hasAlpha;
  28706. /**
  28707. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  28708. */
  28709. hasAlpha: boolean;
  28710. /**
  28711. * Defines if the alpha value should be determined via the rgb values.
  28712. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  28713. */
  28714. getAlphaFromRGB: boolean;
  28715. /**
  28716. * Intensity or strength of the texture.
  28717. * It is commonly used by materials to fine tune the intensity of the texture
  28718. */
  28719. level: number;
  28720. /**
  28721. * Define the UV chanel to use starting from 0 and defaulting to 0.
  28722. * This is part of the texture as textures usually maps to one uv set.
  28723. */
  28724. coordinatesIndex: number;
  28725. private _coordinatesMode;
  28726. /**
  28727. * How a texture is mapped.
  28728. *
  28729. * | Value | Type | Description |
  28730. * | ----- | ----------------------------------- | ----------- |
  28731. * | 0 | EXPLICIT_MODE | |
  28732. * | 1 | SPHERICAL_MODE | |
  28733. * | 2 | PLANAR_MODE | |
  28734. * | 3 | CUBIC_MODE | |
  28735. * | 4 | PROJECTION_MODE | |
  28736. * | 5 | SKYBOX_MODE | |
  28737. * | 6 | INVCUBIC_MODE | |
  28738. * | 7 | EQUIRECTANGULAR_MODE | |
  28739. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  28740. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  28741. */
  28742. coordinatesMode: number;
  28743. /**
  28744. * | Value | Type | Description |
  28745. * | ----- | ------------------ | ----------- |
  28746. * | 0 | CLAMP_ADDRESSMODE | |
  28747. * | 1 | WRAP_ADDRESSMODE | |
  28748. * | 2 | MIRROR_ADDRESSMODE | |
  28749. */
  28750. wrapU: number;
  28751. /**
  28752. * | Value | Type | Description |
  28753. * | ----- | ------------------ | ----------- |
  28754. * | 0 | CLAMP_ADDRESSMODE | |
  28755. * | 1 | WRAP_ADDRESSMODE | |
  28756. * | 2 | MIRROR_ADDRESSMODE | |
  28757. */
  28758. wrapV: number;
  28759. /**
  28760. * | Value | Type | Description |
  28761. * | ----- | ------------------ | ----------- |
  28762. * | 0 | CLAMP_ADDRESSMODE | |
  28763. * | 1 | WRAP_ADDRESSMODE | |
  28764. * | 2 | MIRROR_ADDRESSMODE | |
  28765. */
  28766. wrapR: number;
  28767. /**
  28768. * With compliant hardware and browser (supporting anisotropic filtering)
  28769. * this defines the level of anisotropic filtering in the texture.
  28770. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  28771. */
  28772. anisotropicFilteringLevel: number;
  28773. /**
  28774. * Define if the texture is a cube texture or if false a 2d texture.
  28775. */
  28776. isCube: boolean;
  28777. /**
  28778. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  28779. */
  28780. is3D: boolean;
  28781. /**
  28782. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  28783. * HDR texture are usually stored in linear space.
  28784. * This only impacts the PBR and Background materials
  28785. */
  28786. gammaSpace: boolean;
  28787. /**
  28788. * Gets or sets whether or not the texture contains RGBD data.
  28789. */
  28790. isRGBD: boolean;
  28791. /**
  28792. * Is Z inverted in the texture (useful in a cube texture).
  28793. */
  28794. invertZ: boolean;
  28795. /**
  28796. * Are mip maps generated for this texture or not.
  28797. */
  28798. readonly noMipmap: boolean;
  28799. /**
  28800. * @hidden
  28801. */
  28802. lodLevelInAlpha: boolean;
  28803. /**
  28804. * With prefiltered texture, defined the offset used during the prefiltering steps.
  28805. */
  28806. lodGenerationOffset: number;
  28807. /**
  28808. * With prefiltered texture, defined the scale used during the prefiltering steps.
  28809. */
  28810. lodGenerationScale: number;
  28811. /**
  28812. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  28813. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  28814. * average roughness values.
  28815. */
  28816. linearSpecularLOD: boolean;
  28817. /**
  28818. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  28819. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  28820. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  28821. */
  28822. irradianceTexture: Nullable<BaseTexture>;
  28823. /**
  28824. * Define if the texture is a render target.
  28825. */
  28826. isRenderTarget: boolean;
  28827. /**
  28828. * Define the unique id of the texture in the scene.
  28829. */
  28830. readonly uid: string;
  28831. /**
  28832. * Return a string representation of the texture.
  28833. * @returns the texture as a string
  28834. */
  28835. toString(): string;
  28836. /**
  28837. * Get the class name of the texture.
  28838. * @returns "BaseTexture"
  28839. */
  28840. getClassName(): string;
  28841. /**
  28842. * Define the list of animation attached to the texture.
  28843. */
  28844. animations: import("babylonjs/Animations/animation").Animation[];
  28845. /**
  28846. * An event triggered when the texture is disposed.
  28847. */
  28848. onDisposeObservable: Observable<BaseTexture>;
  28849. private _onDisposeObserver;
  28850. /**
  28851. * Callback triggered when the texture has been disposed.
  28852. * Kept for back compatibility, you can use the onDisposeObservable instead.
  28853. */
  28854. onDispose: () => void;
  28855. /**
  28856. * Define the current state of the loading sequence when in delayed load mode.
  28857. */
  28858. delayLoadState: number;
  28859. private _scene;
  28860. /** @hidden */
  28861. _texture: Nullable<InternalTexture>;
  28862. private _uid;
  28863. /**
  28864. * Define if the texture is preventinga material to render or not.
  28865. * If not and the texture is not ready, the engine will use a default black texture instead.
  28866. */
  28867. readonly isBlocking: boolean;
  28868. /**
  28869. * Instantiates a new BaseTexture.
  28870. * Base class of all the textures in babylon.
  28871. * It groups all the common properties the materials, post process, lights... might need
  28872. * in order to make a correct use of the texture.
  28873. * @param scene Define the scene the texture blongs to
  28874. */
  28875. constructor(scene: Nullable<Scene>);
  28876. /**
  28877. * Get the scene the texture belongs to.
  28878. * @returns the scene or null if undefined
  28879. */
  28880. getScene(): Nullable<Scene>;
  28881. /**
  28882. * Get the texture transform matrix used to offset tile the texture for istance.
  28883. * @returns the transformation matrix
  28884. */
  28885. getTextureMatrix(): Matrix;
  28886. /**
  28887. * Get the texture reflection matrix used to rotate/transform the reflection.
  28888. * @returns the reflection matrix
  28889. */
  28890. getReflectionTextureMatrix(): Matrix;
  28891. /**
  28892. * Get the underlying lower level texture from Babylon.
  28893. * @returns the insternal texture
  28894. */
  28895. getInternalTexture(): Nullable<InternalTexture>;
  28896. /**
  28897. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  28898. * @returns true if ready or not blocking
  28899. */
  28900. isReadyOrNotBlocking(): boolean;
  28901. /**
  28902. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  28903. * @returns true if fully ready
  28904. */
  28905. isReady(): boolean;
  28906. private _cachedSize;
  28907. /**
  28908. * Get the size of the texture.
  28909. * @returns the texture size.
  28910. */
  28911. getSize(): ISize;
  28912. /**
  28913. * Get the base size of the texture.
  28914. * It can be different from the size if the texture has been resized for POT for instance
  28915. * @returns the base size
  28916. */
  28917. getBaseSize(): ISize;
  28918. /**
  28919. * Update the sampling mode of the texture.
  28920. * Default is Trilinear mode.
  28921. *
  28922. * | Value | Type | Description |
  28923. * | ----- | ------------------ | ----------- |
  28924. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  28925. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  28926. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  28927. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  28928. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  28929. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  28930. * | 7 | NEAREST_LINEAR | |
  28931. * | 8 | NEAREST_NEAREST | |
  28932. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  28933. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  28934. * | 11 | LINEAR_LINEAR | |
  28935. * | 12 | LINEAR_NEAREST | |
  28936. *
  28937. * > _mag_: magnification filter (close to the viewer)
  28938. * > _min_: minification filter (far from the viewer)
  28939. * > _mip_: filter used between mip map levels
  28940. *@param samplingMode Define the new sampling mode of the texture
  28941. */
  28942. updateSamplingMode(samplingMode: number): void;
  28943. /**
  28944. * Scales the texture if is `canRescale()`
  28945. * @param ratio the resize factor we want to use to rescale
  28946. */
  28947. scale(ratio: number): void;
  28948. /**
  28949. * Get if the texture can rescale.
  28950. */
  28951. readonly canRescale: boolean;
  28952. /** @hidden */
  28953. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  28954. /** @hidden */
  28955. _rebuild(): void;
  28956. /**
  28957. * Triggers the load sequence in delayed load mode.
  28958. */
  28959. delayLoad(): void;
  28960. /**
  28961. * Clones the texture.
  28962. * @returns the cloned texture
  28963. */
  28964. clone(): Nullable<BaseTexture>;
  28965. /**
  28966. * Get the texture underlying type (INT, FLOAT...)
  28967. */
  28968. readonly textureType: number;
  28969. /**
  28970. * Get the texture underlying format (RGB, RGBA...)
  28971. */
  28972. readonly textureFormat: number;
  28973. /**
  28974. * Indicates that textures need to be re-calculated for all materials
  28975. */
  28976. protected _markAllSubMeshesAsTexturesDirty(): void;
  28977. /**
  28978. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  28979. * This will returns an RGBA array buffer containing either in values (0-255) or
  28980. * float values (0-1) depending of the underlying buffer type.
  28981. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  28982. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  28983. * @param buffer defines a user defined buffer to fill with data (can be null)
  28984. * @returns The Array buffer containing the pixels data.
  28985. */
  28986. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  28987. /**
  28988. * Release and destroy the underlying lower level texture aka internalTexture.
  28989. */
  28990. releaseInternalTexture(): void;
  28991. /**
  28992. * Get the polynomial representation of the texture data.
  28993. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  28994. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  28995. */
  28996. sphericalPolynomial: Nullable<SphericalPolynomial>;
  28997. /** @hidden */
  28998. readonly _lodTextureHigh: Nullable<BaseTexture>;
  28999. /** @hidden */
  29000. readonly _lodTextureMid: Nullable<BaseTexture>;
  29001. /** @hidden */
  29002. readonly _lodTextureLow: Nullable<BaseTexture>;
  29003. /**
  29004. * Dispose the texture and release its associated resources.
  29005. */
  29006. dispose(): void;
  29007. /**
  29008. * Serialize the texture into a JSON representation that can be parsed later on.
  29009. * @returns the JSON representation of the texture
  29010. */
  29011. serialize(): any;
  29012. /**
  29013. * Helper function to be called back once a list of texture contains only ready textures.
  29014. * @param textures Define the list of textures to wait for
  29015. * @param callback Define the callback triggered once the entire list will be ready
  29016. */
  29017. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  29018. }
  29019. }
  29020. declare module "babylonjs/Materials/effect" {
  29021. import { Observable } from "babylonjs/Misc/observable";
  29022. import { Nullable } from "babylonjs/types";
  29023. import { IDisposable } from "babylonjs/scene";
  29024. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  29025. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29026. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  29027. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  29028. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  29029. import { Engine } from "babylonjs/Engines/engine";
  29030. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29031. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29032. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29033. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29034. /**
  29035. * Options to be used when creating an effect.
  29036. */
  29037. export class EffectCreationOptions {
  29038. /**
  29039. * Atrributes that will be used in the shader.
  29040. */
  29041. attributes: string[];
  29042. /**
  29043. * Uniform varible names that will be set in the shader.
  29044. */
  29045. uniformsNames: string[];
  29046. /**
  29047. * Uniform buffer varible names that will be set in the shader.
  29048. */
  29049. uniformBuffersNames: string[];
  29050. /**
  29051. * Sampler texture variable names that will be set in the shader.
  29052. */
  29053. samplers: string[];
  29054. /**
  29055. * Define statements that will be set in the shader.
  29056. */
  29057. defines: any;
  29058. /**
  29059. * Possible fallbacks for this effect to improve performance when needed.
  29060. */
  29061. fallbacks: Nullable<IEffectFallbacks>;
  29062. /**
  29063. * Callback that will be called when the shader is compiled.
  29064. */
  29065. onCompiled: Nullable<(effect: Effect) => void>;
  29066. /**
  29067. * Callback that will be called if an error occurs during shader compilation.
  29068. */
  29069. onError: Nullable<(effect: Effect, errors: string) => void>;
  29070. /**
  29071. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29072. */
  29073. indexParameters?: any;
  29074. /**
  29075. * Max number of lights that can be used in the shader.
  29076. */
  29077. maxSimultaneousLights?: number;
  29078. /**
  29079. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29080. */
  29081. transformFeedbackVaryings?: Nullable<string[]>;
  29082. }
  29083. /**
  29084. * Effect containing vertex and fragment shader that can be executed on an object.
  29085. */
  29086. export class Effect implements IDisposable {
  29087. /**
  29088. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29089. */
  29090. static ShadersRepository: string;
  29091. /**
  29092. * Name of the effect.
  29093. */
  29094. name: any;
  29095. /**
  29096. * String container all the define statements that should be set on the shader.
  29097. */
  29098. defines: string;
  29099. /**
  29100. * Callback that will be called when the shader is compiled.
  29101. */
  29102. onCompiled: Nullable<(effect: Effect) => void>;
  29103. /**
  29104. * Callback that will be called if an error occurs during shader compilation.
  29105. */
  29106. onError: Nullable<(effect: Effect, errors: string) => void>;
  29107. /**
  29108. * Callback that will be called when effect is bound.
  29109. */
  29110. onBind: Nullable<(effect: Effect) => void>;
  29111. /**
  29112. * Unique ID of the effect.
  29113. */
  29114. uniqueId: number;
  29115. /**
  29116. * Observable that will be called when the shader is compiled.
  29117. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29118. */
  29119. onCompileObservable: Observable<Effect>;
  29120. /**
  29121. * Observable that will be called if an error occurs during shader compilation.
  29122. */
  29123. onErrorObservable: Observable<Effect>;
  29124. /** @hidden */
  29125. _onBindObservable: Nullable<Observable<Effect>>;
  29126. /**
  29127. * Observable that will be called when effect is bound.
  29128. */
  29129. readonly onBindObservable: Observable<Effect>;
  29130. /** @hidden */
  29131. _bonesComputationForcedToCPU: boolean;
  29132. private static _uniqueIdSeed;
  29133. private _engine;
  29134. private _uniformBuffersNames;
  29135. private _uniformsNames;
  29136. private _samplerList;
  29137. private _samplers;
  29138. private _isReady;
  29139. private _compilationError;
  29140. private _attributesNames;
  29141. private _attributes;
  29142. private _uniforms;
  29143. /**
  29144. * Key for the effect.
  29145. * @hidden
  29146. */
  29147. _key: string;
  29148. private _indexParameters;
  29149. private _fallbacks;
  29150. private _vertexSourceCode;
  29151. private _fragmentSourceCode;
  29152. private _vertexSourceCodeOverride;
  29153. private _fragmentSourceCodeOverride;
  29154. private _transformFeedbackVaryings;
  29155. /**
  29156. * Compiled shader to webGL program.
  29157. * @hidden
  29158. */
  29159. _pipelineContext: Nullable<IPipelineContext>;
  29160. private _valueCache;
  29161. private static _baseCache;
  29162. /**
  29163. * Instantiates an effect.
  29164. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29165. * @param baseName Name of the effect.
  29166. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29167. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29168. * @param samplers List of sampler variables that will be passed to the shader.
  29169. * @param engine Engine to be used to render the effect
  29170. * @param defines Define statements to be added to the shader.
  29171. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29172. * @param onCompiled Callback that will be called when the shader is compiled.
  29173. * @param onError Callback that will be called if an error occurs during shader compilation.
  29174. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29175. */
  29176. 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);
  29177. private _useFinalCode;
  29178. /**
  29179. * Unique key for this effect
  29180. */
  29181. readonly key: string;
  29182. /**
  29183. * If the effect has been compiled and prepared.
  29184. * @returns if the effect is compiled and prepared.
  29185. */
  29186. isReady(): boolean;
  29187. private _isReadyInternal;
  29188. /**
  29189. * The engine the effect was initialized with.
  29190. * @returns the engine.
  29191. */
  29192. getEngine(): Engine;
  29193. /**
  29194. * The pipeline context for this effect
  29195. * @returns the associated pipeline context
  29196. */
  29197. getPipelineContext(): Nullable<IPipelineContext>;
  29198. /**
  29199. * The set of names of attribute variables for the shader.
  29200. * @returns An array of attribute names.
  29201. */
  29202. getAttributesNames(): string[];
  29203. /**
  29204. * Returns the attribute at the given index.
  29205. * @param index The index of the attribute.
  29206. * @returns The location of the attribute.
  29207. */
  29208. getAttributeLocation(index: number): number;
  29209. /**
  29210. * Returns the attribute based on the name of the variable.
  29211. * @param name of the attribute to look up.
  29212. * @returns the attribute location.
  29213. */
  29214. getAttributeLocationByName(name: string): number;
  29215. /**
  29216. * The number of attributes.
  29217. * @returns the numnber of attributes.
  29218. */
  29219. getAttributesCount(): number;
  29220. /**
  29221. * Gets the index of a uniform variable.
  29222. * @param uniformName of the uniform to look up.
  29223. * @returns the index.
  29224. */
  29225. getUniformIndex(uniformName: string): number;
  29226. /**
  29227. * Returns the attribute based on the name of the variable.
  29228. * @param uniformName of the uniform to look up.
  29229. * @returns the location of the uniform.
  29230. */
  29231. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29232. /**
  29233. * Returns an array of sampler variable names
  29234. * @returns The array of sampler variable neames.
  29235. */
  29236. getSamplers(): string[];
  29237. /**
  29238. * The error from the last compilation.
  29239. * @returns the error string.
  29240. */
  29241. getCompilationError(): string;
  29242. /**
  29243. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29244. * @param func The callback to be used.
  29245. */
  29246. executeWhenCompiled(func: (effect: Effect) => void): void;
  29247. private _checkIsReady;
  29248. /** @hidden */
  29249. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29250. /** @hidden */
  29251. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29252. /** @hidden */
  29253. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29254. /**
  29255. * Recompiles the webGL program
  29256. * @param vertexSourceCode The source code for the vertex shader.
  29257. * @param fragmentSourceCode The source code for the fragment shader.
  29258. * @param onCompiled Callback called when completed.
  29259. * @param onError Callback called on error.
  29260. * @hidden
  29261. */
  29262. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29263. /**
  29264. * Prepares the effect
  29265. * @hidden
  29266. */
  29267. _prepareEffect(): void;
  29268. private _processCompilationErrors;
  29269. /**
  29270. * Checks if the effect is supported. (Must be called after compilation)
  29271. */
  29272. readonly isSupported: boolean;
  29273. /**
  29274. * Binds a texture to the engine to be used as output of the shader.
  29275. * @param channel Name of the output variable.
  29276. * @param texture Texture to bind.
  29277. * @hidden
  29278. */
  29279. _bindTexture(channel: string, texture: InternalTexture): void;
  29280. /**
  29281. * Sets a texture on the engine to be used in the shader.
  29282. * @param channel Name of the sampler variable.
  29283. * @param texture Texture to set.
  29284. */
  29285. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29286. /**
  29287. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29288. * @param channel Name of the sampler variable.
  29289. * @param texture Texture to set.
  29290. */
  29291. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29292. /**
  29293. * Sets an array of textures on the engine to be used in the shader.
  29294. * @param channel Name of the variable.
  29295. * @param textures Textures to set.
  29296. */
  29297. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29298. /**
  29299. * 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)
  29300. * @param channel Name of the sampler variable.
  29301. * @param postProcess Post process to get the input texture from.
  29302. */
  29303. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29304. /**
  29305. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29306. * 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)
  29307. * @param channel Name of the sampler variable.
  29308. * @param postProcess Post process to get the output texture from.
  29309. */
  29310. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29311. /** @hidden */
  29312. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  29313. /** @hidden */
  29314. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29315. /** @hidden */
  29316. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29317. /** @hidden */
  29318. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29319. /**
  29320. * Binds a buffer to a uniform.
  29321. * @param buffer Buffer to bind.
  29322. * @param name Name of the uniform variable to bind to.
  29323. */
  29324. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29325. /**
  29326. * Binds block to a uniform.
  29327. * @param blockName Name of the block to bind.
  29328. * @param index Index to bind.
  29329. */
  29330. bindUniformBlock(blockName: string, index: number): void;
  29331. /**
  29332. * Sets an interger value on a uniform variable.
  29333. * @param uniformName Name of the variable.
  29334. * @param value Value to be set.
  29335. * @returns this effect.
  29336. */
  29337. setInt(uniformName: string, value: number): Effect;
  29338. /**
  29339. * Sets an int array on a uniform variable.
  29340. * @param uniformName Name of the variable.
  29341. * @param array array to be set.
  29342. * @returns this effect.
  29343. */
  29344. setIntArray(uniformName: string, array: Int32Array): Effect;
  29345. /**
  29346. * 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)
  29347. * @param uniformName Name of the variable.
  29348. * @param array array to be set.
  29349. * @returns this effect.
  29350. */
  29351. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29352. /**
  29353. * 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)
  29354. * @param uniformName Name of the variable.
  29355. * @param array array to be set.
  29356. * @returns this effect.
  29357. */
  29358. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29359. /**
  29360. * 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)
  29361. * @param uniformName Name of the variable.
  29362. * @param array array to be set.
  29363. * @returns this effect.
  29364. */
  29365. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29366. /**
  29367. * Sets an float array on a uniform variable.
  29368. * @param uniformName Name of the variable.
  29369. * @param array array to be set.
  29370. * @returns this effect.
  29371. */
  29372. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29373. /**
  29374. * 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)
  29375. * @param uniformName Name of the variable.
  29376. * @param array array to be set.
  29377. * @returns this effect.
  29378. */
  29379. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29380. /**
  29381. * 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)
  29382. * @param uniformName Name of the variable.
  29383. * @param array array to be set.
  29384. * @returns this effect.
  29385. */
  29386. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29387. /**
  29388. * 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)
  29389. * @param uniformName Name of the variable.
  29390. * @param array array to be set.
  29391. * @returns this effect.
  29392. */
  29393. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29394. /**
  29395. * Sets an array on a uniform variable.
  29396. * @param uniformName Name of the variable.
  29397. * @param array array to be set.
  29398. * @returns this effect.
  29399. */
  29400. setArray(uniformName: string, array: number[]): Effect;
  29401. /**
  29402. * 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)
  29403. * @param uniformName Name of the variable.
  29404. * @param array array to be set.
  29405. * @returns this effect.
  29406. */
  29407. setArray2(uniformName: string, array: number[]): Effect;
  29408. /**
  29409. * 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)
  29410. * @param uniformName Name of the variable.
  29411. * @param array array to be set.
  29412. * @returns this effect.
  29413. */
  29414. setArray3(uniformName: string, array: number[]): Effect;
  29415. /**
  29416. * 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)
  29417. * @param uniformName Name of the variable.
  29418. * @param array array to be set.
  29419. * @returns this effect.
  29420. */
  29421. setArray4(uniformName: string, array: number[]): Effect;
  29422. /**
  29423. * Sets matrices on a uniform variable.
  29424. * @param uniformName Name of the variable.
  29425. * @param matrices matrices to be set.
  29426. * @returns this effect.
  29427. */
  29428. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29429. /**
  29430. * Sets matrix on a uniform variable.
  29431. * @param uniformName Name of the variable.
  29432. * @param matrix matrix to be set.
  29433. * @returns this effect.
  29434. */
  29435. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  29436. /**
  29437. * 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)
  29438. * @param uniformName Name of the variable.
  29439. * @param matrix matrix to be set.
  29440. * @returns this effect.
  29441. */
  29442. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29443. /**
  29444. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29445. * @param uniformName Name of the variable.
  29446. * @param matrix matrix to be set.
  29447. * @returns this effect.
  29448. */
  29449. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29450. /**
  29451. * Sets a float on a uniform variable.
  29452. * @param uniformName Name of the variable.
  29453. * @param value value to be set.
  29454. * @returns this effect.
  29455. */
  29456. setFloat(uniformName: string, value: number): Effect;
  29457. /**
  29458. * Sets a boolean on a uniform variable.
  29459. * @param uniformName Name of the variable.
  29460. * @param bool value to be set.
  29461. * @returns this effect.
  29462. */
  29463. setBool(uniformName: string, bool: boolean): Effect;
  29464. /**
  29465. * Sets a Vector2 on a uniform variable.
  29466. * @param uniformName Name of the variable.
  29467. * @param vector2 vector2 to be set.
  29468. * @returns this effect.
  29469. */
  29470. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  29471. /**
  29472. * Sets a float2 on a uniform variable.
  29473. * @param uniformName Name of the variable.
  29474. * @param x First float in float2.
  29475. * @param y Second float in float2.
  29476. * @returns this effect.
  29477. */
  29478. setFloat2(uniformName: string, x: number, y: number): Effect;
  29479. /**
  29480. * Sets a Vector3 on a uniform variable.
  29481. * @param uniformName Name of the variable.
  29482. * @param vector3 Value to be set.
  29483. * @returns this effect.
  29484. */
  29485. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  29486. /**
  29487. * Sets a float3 on a uniform variable.
  29488. * @param uniformName Name of the variable.
  29489. * @param x First float in float3.
  29490. * @param y Second float in float3.
  29491. * @param z Third float in float3.
  29492. * @returns this effect.
  29493. */
  29494. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29495. /**
  29496. * Sets a Vector4 on a uniform variable.
  29497. * @param uniformName Name of the variable.
  29498. * @param vector4 Value to be set.
  29499. * @returns this effect.
  29500. */
  29501. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  29502. /**
  29503. * Sets a float4 on a uniform variable.
  29504. * @param uniformName Name of the variable.
  29505. * @param x First float in float4.
  29506. * @param y Second float in float4.
  29507. * @param z Third float in float4.
  29508. * @param w Fourth float in float4.
  29509. * @returns this effect.
  29510. */
  29511. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29512. /**
  29513. * Sets a Color3 on a uniform variable.
  29514. * @param uniformName Name of the variable.
  29515. * @param color3 Value to be set.
  29516. * @returns this effect.
  29517. */
  29518. setColor3(uniformName: string, color3: IColor3Like): Effect;
  29519. /**
  29520. * Sets a Color4 on a uniform variable.
  29521. * @param uniformName Name of the variable.
  29522. * @param color3 Value to be set.
  29523. * @param alpha Alpha value to be set.
  29524. * @returns this effect.
  29525. */
  29526. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  29527. /**
  29528. * Sets a Color4 on a uniform variable
  29529. * @param uniformName defines the name of the variable
  29530. * @param color4 defines the value to be set
  29531. * @returns this effect.
  29532. */
  29533. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  29534. /** Release all associated resources */
  29535. dispose(): void;
  29536. /**
  29537. * This function will add a new shader to the shader store
  29538. * @param name the name of the shader
  29539. * @param pixelShader optional pixel shader content
  29540. * @param vertexShader optional vertex shader content
  29541. */
  29542. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29543. /**
  29544. * Store of each shader (The can be looked up using effect.key)
  29545. */
  29546. static ShadersStore: {
  29547. [key: string]: string;
  29548. };
  29549. /**
  29550. * Store of each included file for a shader (The can be looked up using effect.key)
  29551. */
  29552. static IncludesShadersStore: {
  29553. [key: string]: string;
  29554. };
  29555. /**
  29556. * Resets the cache of effects.
  29557. */
  29558. static ResetCache(): void;
  29559. }
  29560. }
  29561. declare module "babylonjs/Engines/engineCapabilities" {
  29562. import { Nullable } from "babylonjs/types";
  29563. /**
  29564. * Class used to describe the capabilities of the engine relatively to the current browser
  29565. */
  29566. export class EngineCapabilities {
  29567. /** Maximum textures units per fragment shader */
  29568. maxTexturesImageUnits: number;
  29569. /** Maximum texture units per vertex shader */
  29570. maxVertexTextureImageUnits: number;
  29571. /** Maximum textures units in the entire pipeline */
  29572. maxCombinedTexturesImageUnits: number;
  29573. /** Maximum texture size */
  29574. maxTextureSize: number;
  29575. /** Maximum cube texture size */
  29576. maxCubemapTextureSize: number;
  29577. /** Maximum render texture size */
  29578. maxRenderTextureSize: number;
  29579. /** Maximum number of vertex attributes */
  29580. maxVertexAttribs: number;
  29581. /** Maximum number of varyings */
  29582. maxVaryingVectors: number;
  29583. /** Maximum number of uniforms per vertex shader */
  29584. maxVertexUniformVectors: number;
  29585. /** Maximum number of uniforms per fragment shader */
  29586. maxFragmentUniformVectors: number;
  29587. /** Defines if standard derivates (dx/dy) are supported */
  29588. standardDerivatives: boolean;
  29589. /** Defines if s3tc texture compression is supported */
  29590. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  29591. /** Defines if pvrtc texture compression is supported */
  29592. pvrtc: any;
  29593. /** Defines if etc1 texture compression is supported */
  29594. etc1: any;
  29595. /** Defines if etc2 texture compression is supported */
  29596. etc2: any;
  29597. /** Defines if astc texture compression is supported */
  29598. astc: any;
  29599. /** Defines if float textures are supported */
  29600. textureFloat: boolean;
  29601. /** Defines if vertex array objects are supported */
  29602. vertexArrayObject: boolean;
  29603. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  29604. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  29605. /** Gets the maximum level of anisotropy supported */
  29606. maxAnisotropy: number;
  29607. /** Defines if instancing is supported */
  29608. instancedArrays: boolean;
  29609. /** Defines if 32 bits indices are supported */
  29610. uintIndices: boolean;
  29611. /** Defines if high precision shaders are supported */
  29612. highPrecisionShaderSupported: boolean;
  29613. /** Defines if depth reading in the fragment shader is supported */
  29614. fragmentDepthSupported: boolean;
  29615. /** Defines if float texture linear filtering is supported*/
  29616. textureFloatLinearFiltering: boolean;
  29617. /** Defines if rendering to float textures is supported */
  29618. textureFloatRender: boolean;
  29619. /** Defines if half float textures are supported*/
  29620. textureHalfFloat: boolean;
  29621. /** Defines if half float texture linear filtering is supported*/
  29622. textureHalfFloatLinearFiltering: boolean;
  29623. /** Defines if rendering to half float textures is supported */
  29624. textureHalfFloatRender: boolean;
  29625. /** Defines if textureLOD shader command is supported */
  29626. textureLOD: boolean;
  29627. /** Defines if draw buffers extension is supported */
  29628. drawBuffersExtension: boolean;
  29629. /** Defines if depth textures are supported */
  29630. depthTextureExtension: boolean;
  29631. /** Defines if float color buffer are supported */
  29632. colorBufferFloat: boolean;
  29633. /** Gets disjoint timer query extension (null if not supported) */
  29634. timerQuery: EXT_disjoint_timer_query;
  29635. /** Defines if timestamp can be used with timer query */
  29636. canUseTimestampForTimerQuery: boolean;
  29637. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  29638. multiview: any;
  29639. /** Function used to let the system compiles shaders in background */
  29640. parallelShaderCompile: {
  29641. COMPLETION_STATUS_KHR: number;
  29642. };
  29643. /** Max number of texture samples for MSAA */
  29644. maxMSAASamples: number;
  29645. /** Defines if the blend min max extension is supported */
  29646. blendMinMax: boolean;
  29647. }
  29648. }
  29649. declare module "babylonjs/Misc/perfCounter" {
  29650. /**
  29651. * This class is used to track a performance counter which is number based.
  29652. * The user has access to many properties which give statistics of different nature.
  29653. *
  29654. * The implementer can track two kinds of Performance Counter: time and count.
  29655. * 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.
  29656. * 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.
  29657. */
  29658. export class PerfCounter {
  29659. /**
  29660. * Gets or sets a global boolean to turn on and off all the counters
  29661. */
  29662. static Enabled: boolean;
  29663. /**
  29664. * Returns the smallest value ever
  29665. */
  29666. readonly min: number;
  29667. /**
  29668. * Returns the biggest value ever
  29669. */
  29670. readonly max: number;
  29671. /**
  29672. * Returns the average value since the performance counter is running
  29673. */
  29674. readonly average: number;
  29675. /**
  29676. * Returns the average value of the last second the counter was monitored
  29677. */
  29678. readonly lastSecAverage: number;
  29679. /**
  29680. * Returns the current value
  29681. */
  29682. readonly current: number;
  29683. /**
  29684. * Gets the accumulated total
  29685. */
  29686. readonly total: number;
  29687. /**
  29688. * Gets the total value count
  29689. */
  29690. readonly count: number;
  29691. /**
  29692. * Creates a new counter
  29693. */
  29694. constructor();
  29695. /**
  29696. * Call this method to start monitoring a new frame.
  29697. * 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.
  29698. */
  29699. fetchNewFrame(): void;
  29700. /**
  29701. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  29702. * @param newCount the count value to add to the monitored count
  29703. * @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.
  29704. */
  29705. addCount(newCount: number, fetchResult: boolean): void;
  29706. /**
  29707. * Start monitoring this performance counter
  29708. */
  29709. beginMonitoring(): void;
  29710. /**
  29711. * Compute the time lapsed since the previous beginMonitoring() call.
  29712. * @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
  29713. */
  29714. endMonitoring(newFrame?: boolean): void;
  29715. private _fetchResult;
  29716. private _startMonitoringTime;
  29717. private _min;
  29718. private _max;
  29719. private _average;
  29720. private _current;
  29721. private _totalValueCount;
  29722. private _totalAccumulated;
  29723. private _lastSecAverage;
  29724. private _lastSecAccumulated;
  29725. private _lastSecTime;
  29726. private _lastSecValueCount;
  29727. }
  29728. }
  29729. declare module "babylonjs/States/depthCullingState" {
  29730. import { Nullable } from "babylonjs/types";
  29731. /**
  29732. * @hidden
  29733. **/
  29734. export class DepthCullingState {
  29735. private _isDepthTestDirty;
  29736. private _isDepthMaskDirty;
  29737. private _isDepthFuncDirty;
  29738. private _isCullFaceDirty;
  29739. private _isCullDirty;
  29740. private _isZOffsetDirty;
  29741. private _isFrontFaceDirty;
  29742. private _depthTest;
  29743. private _depthMask;
  29744. private _depthFunc;
  29745. private _cull;
  29746. private _cullFace;
  29747. private _zOffset;
  29748. private _frontFace;
  29749. /**
  29750. * Initializes the state.
  29751. */
  29752. constructor();
  29753. readonly isDirty: boolean;
  29754. zOffset: number;
  29755. cullFace: Nullable<number>;
  29756. cull: Nullable<boolean>;
  29757. depthFunc: Nullable<number>;
  29758. depthMask: boolean;
  29759. depthTest: boolean;
  29760. frontFace: Nullable<number>;
  29761. reset(): void;
  29762. apply(gl: WebGLRenderingContext): void;
  29763. }
  29764. }
  29765. declare module "babylonjs/States/stencilState" {
  29766. /**
  29767. * @hidden
  29768. **/
  29769. export class StencilState {
  29770. /** 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 */
  29771. static readonly ALWAYS: number;
  29772. /** Passed to stencilOperation to specify that stencil value must be kept */
  29773. static readonly KEEP: number;
  29774. /** Passed to stencilOperation to specify that stencil value must be replaced */
  29775. static readonly REPLACE: number;
  29776. private _isStencilTestDirty;
  29777. private _isStencilMaskDirty;
  29778. private _isStencilFuncDirty;
  29779. private _isStencilOpDirty;
  29780. private _stencilTest;
  29781. private _stencilMask;
  29782. private _stencilFunc;
  29783. private _stencilFuncRef;
  29784. private _stencilFuncMask;
  29785. private _stencilOpStencilFail;
  29786. private _stencilOpDepthFail;
  29787. private _stencilOpStencilDepthPass;
  29788. readonly isDirty: boolean;
  29789. stencilFunc: number;
  29790. stencilFuncRef: number;
  29791. stencilFuncMask: number;
  29792. stencilOpStencilFail: number;
  29793. stencilOpDepthFail: number;
  29794. stencilOpStencilDepthPass: number;
  29795. stencilMask: number;
  29796. stencilTest: boolean;
  29797. constructor();
  29798. reset(): void;
  29799. apply(gl: WebGLRenderingContext): void;
  29800. }
  29801. }
  29802. declare module "babylonjs/States/alphaCullingState" {
  29803. /**
  29804. * @hidden
  29805. **/
  29806. export class AlphaState {
  29807. private _isAlphaBlendDirty;
  29808. private _isBlendFunctionParametersDirty;
  29809. private _isBlendEquationParametersDirty;
  29810. private _isBlendConstantsDirty;
  29811. private _alphaBlend;
  29812. private _blendFunctionParameters;
  29813. private _blendEquationParameters;
  29814. private _blendConstants;
  29815. /**
  29816. * Initializes the state.
  29817. */
  29818. constructor();
  29819. readonly isDirty: boolean;
  29820. alphaBlend: boolean;
  29821. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  29822. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  29823. setAlphaEquationParameters(rgb: number, alpha: number): void;
  29824. reset(): void;
  29825. apply(gl: WebGLRenderingContext): void;
  29826. }
  29827. }
  29828. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  29829. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  29830. /** @hidden */
  29831. export class WebGL2ShaderProcessor implements IShaderProcessor {
  29832. attributeProcessor(attribute: string): string;
  29833. varyingProcessor(varying: string, isFragment: boolean): string;
  29834. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  29835. }
  29836. }
  29837. declare module "babylonjs/Engines/instancingAttributeInfo" {
  29838. /**
  29839. * Interface for attribute information associated with buffer instanciation
  29840. */
  29841. export class InstancingAttributeInfo {
  29842. /**
  29843. * Index/offset of the attribute in the vertex shader
  29844. */
  29845. index: number;
  29846. /**
  29847. * size of the attribute, 1, 2, 3 or 4
  29848. */
  29849. attributeSize: number;
  29850. /**
  29851. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  29852. * default is FLOAT
  29853. */
  29854. attribyteType: number;
  29855. /**
  29856. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  29857. */
  29858. normalized: boolean;
  29859. /**
  29860. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  29861. */
  29862. offset: number;
  29863. /**
  29864. * Name of the GLSL attribute, for debugging purpose only
  29865. */
  29866. attributeName: string;
  29867. }
  29868. }
  29869. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  29870. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29871. import { Nullable } from "babylonjs/types";
  29872. module "babylonjs/Engines/thinEngine" {
  29873. interface ThinEngine {
  29874. /**
  29875. * Update a video texture
  29876. * @param texture defines the texture to update
  29877. * @param video defines the video element to use
  29878. * @param invertY defines if data must be stored with Y axis inverted
  29879. */
  29880. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29881. }
  29882. }
  29883. }
  29884. declare module "babylonjs/Materials/Textures/videoTexture" {
  29885. import { Observable } from "babylonjs/Misc/observable";
  29886. import { Nullable } from "babylonjs/types";
  29887. import { Scene } from "babylonjs/scene";
  29888. import { Texture } from "babylonjs/Materials/Textures/texture";
  29889. import "babylonjs/Engines/Extensions/engine.videoTexture";
  29890. /**
  29891. * Settings for finer control over video usage
  29892. */
  29893. export interface VideoTextureSettings {
  29894. /**
  29895. * Applies `autoplay` to video, if specified
  29896. */
  29897. autoPlay?: boolean;
  29898. /**
  29899. * Applies `loop` to video, if specified
  29900. */
  29901. loop?: boolean;
  29902. /**
  29903. * Automatically updates internal texture from video at every frame in the render loop
  29904. */
  29905. autoUpdateTexture: boolean;
  29906. /**
  29907. * Image src displayed during the video loading or until the user interacts with the video.
  29908. */
  29909. poster?: string;
  29910. }
  29911. /**
  29912. * If you want to display a video in your scene, this is the special texture for that.
  29913. * This special texture works similar to other textures, with the exception of a few parameters.
  29914. * @see https://doc.babylonjs.com/how_to/video_texture
  29915. */
  29916. export class VideoTexture extends Texture {
  29917. /**
  29918. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  29919. */
  29920. readonly autoUpdateTexture: boolean;
  29921. /**
  29922. * The video instance used by the texture internally
  29923. */
  29924. readonly video: HTMLVideoElement;
  29925. private _onUserActionRequestedObservable;
  29926. /**
  29927. * Event triggerd when a dom action is required by the user to play the video.
  29928. * This happens due to recent changes in browser policies preventing video to auto start.
  29929. */
  29930. readonly onUserActionRequestedObservable: Observable<Texture>;
  29931. private _generateMipMaps;
  29932. private _engine;
  29933. private _stillImageCaptured;
  29934. private _displayingPosterTexture;
  29935. private _settings;
  29936. private _createInternalTextureOnEvent;
  29937. private _frameId;
  29938. /**
  29939. * Creates a video texture.
  29940. * If you want to display a video in your scene, this is the special texture for that.
  29941. * This special texture works similar to other textures, with the exception of a few parameters.
  29942. * @see https://doc.babylonjs.com/how_to/video_texture
  29943. * @param name optional name, will detect from video source, if not defined
  29944. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  29945. * @param scene is obviously the current scene.
  29946. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  29947. * @param invertY is false by default but can be used to invert video on Y axis
  29948. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  29949. * @param settings allows finer control over video usage
  29950. */
  29951. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  29952. private _getName;
  29953. private _getVideo;
  29954. private _createInternalTexture;
  29955. private reset;
  29956. /**
  29957. * @hidden Internal method to initiate `update`.
  29958. */
  29959. _rebuild(): void;
  29960. /**
  29961. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  29962. */
  29963. update(): void;
  29964. /**
  29965. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  29966. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  29967. */
  29968. updateTexture(isVisible: boolean): void;
  29969. protected _updateInternalTexture: () => void;
  29970. /**
  29971. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  29972. * @param url New url.
  29973. */
  29974. updateURL(url: string): void;
  29975. /**
  29976. * Dispose the texture and release its associated resources.
  29977. */
  29978. dispose(): void;
  29979. /**
  29980. * Creates a video texture straight from a stream.
  29981. * @param scene Define the scene the texture should be created in
  29982. * @param stream Define the stream the texture should be created from
  29983. * @returns The created video texture as a promise
  29984. */
  29985. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  29986. /**
  29987. * Creates a video texture straight from your WebCam video feed.
  29988. * @param scene Define the scene the texture should be created in
  29989. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29990. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29991. * @returns The created video texture as a promise
  29992. */
  29993. static CreateFromWebCamAsync(scene: Scene, constraints: {
  29994. minWidth: number;
  29995. maxWidth: number;
  29996. minHeight: number;
  29997. maxHeight: number;
  29998. deviceId: string;
  29999. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  30000. /**
  30001. * Creates a video texture straight from your WebCam video feed.
  30002. * @param scene Define the scene the texture should be created in
  30003. * @param onReady Define a callback to triggered once the texture will be ready
  30004. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30005. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30006. */
  30007. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  30008. minWidth: number;
  30009. maxWidth: number;
  30010. minHeight: number;
  30011. maxHeight: number;
  30012. deviceId: string;
  30013. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  30014. }
  30015. }
  30016. declare module "babylonjs/Engines/thinEngine" {
  30017. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  30018. import { Effect, EffectCreationOptions } from "babylonjs/Materials/effect";
  30019. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  30020. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  30021. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  30022. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  30023. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  30024. import { Observable } from "babylonjs/Misc/observable";
  30025. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  30026. import { StencilState } from "babylonjs/States/stencilState";
  30027. import { AlphaState } from "babylonjs/States/alphaCullingState";
  30028. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30029. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  30030. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30031. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  30032. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30033. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  30034. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  30035. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  30036. import { WebRequest } from "babylonjs/Misc/webRequest";
  30037. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  30038. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30039. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  30040. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  30041. /**
  30042. * Defines the interface used by objects working like Scene
  30043. * @hidden
  30044. */
  30045. interface ISceneLike {
  30046. _addPendingData(data: any): void;
  30047. _removePendingData(data: any): void;
  30048. offlineProvider: IOfflineProvider;
  30049. }
  30050. /** Interface defining initialization parameters for Engine class */
  30051. export interface EngineOptions extends WebGLContextAttributes {
  30052. /**
  30053. * Defines if the engine should no exceed a specified device ratio
  30054. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  30055. */
  30056. limitDeviceRatio?: number;
  30057. /**
  30058. * Defines if webvr should be enabled automatically
  30059. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30060. */
  30061. autoEnableWebVR?: boolean;
  30062. /**
  30063. * Defines if webgl2 should be turned off even if supported
  30064. * @see http://doc.babylonjs.com/features/webgl2
  30065. */
  30066. disableWebGL2Support?: boolean;
  30067. /**
  30068. * Defines if webaudio should be initialized as well
  30069. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30070. */
  30071. audioEngine?: boolean;
  30072. /**
  30073. * Defines if animations should run using a deterministic lock step
  30074. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30075. */
  30076. deterministicLockstep?: boolean;
  30077. /** Defines the maximum steps to use with deterministic lock step mode */
  30078. lockstepMaxSteps?: number;
  30079. /**
  30080. * Defines that engine should ignore context lost events
  30081. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  30082. */
  30083. doNotHandleContextLost?: boolean;
  30084. /**
  30085. * Defines that engine should ignore modifying touch action attribute and style
  30086. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  30087. */
  30088. doNotHandleTouchAction?: boolean;
  30089. /**
  30090. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  30091. */
  30092. useHighPrecisionFloats?: boolean;
  30093. }
  30094. /**
  30095. * The base engine class (root of all engines)
  30096. */
  30097. export class ThinEngine {
  30098. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  30099. static ExceptionList: ({
  30100. key: string;
  30101. capture: string;
  30102. captureConstraint: number;
  30103. targets: string[];
  30104. } | {
  30105. key: string;
  30106. capture: null;
  30107. captureConstraint: null;
  30108. targets: string[];
  30109. })[];
  30110. /** @hidden */
  30111. static _TextureLoaders: IInternalTextureLoader[];
  30112. /**
  30113. * Returns the current npm package of the sdk
  30114. */
  30115. static readonly NpmPackage: string;
  30116. /**
  30117. * Returns the current version of the framework
  30118. */
  30119. static readonly Version: string;
  30120. /**
  30121. * Returns a string describing the current engine
  30122. */
  30123. readonly description: string;
  30124. /**
  30125. * Gets or sets the epsilon value used by collision engine
  30126. */
  30127. static CollisionsEpsilon: number;
  30128. /**
  30129. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30130. */
  30131. static ShadersRepository: string;
  30132. /** @hidden */
  30133. _shaderProcessor: IShaderProcessor;
  30134. /**
  30135. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30136. */
  30137. forcePOTTextures: boolean;
  30138. /**
  30139. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30140. */
  30141. isFullscreen: boolean;
  30142. /**
  30143. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  30144. */
  30145. cullBackFaces: boolean;
  30146. /**
  30147. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  30148. */
  30149. renderEvenInBackground: boolean;
  30150. /**
  30151. * Gets or sets a boolean indicating that cache can be kept between frames
  30152. */
  30153. preventCacheWipeBetweenFrames: boolean;
  30154. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  30155. validateShaderPrograms: boolean;
  30156. /**
  30157. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  30158. */
  30159. disableUniformBuffers: boolean;
  30160. /** @hidden */
  30161. _uniformBuffers: UniformBuffer[];
  30162. /**
  30163. * Gets a boolean indicating that the engine supports uniform buffers
  30164. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30165. */
  30166. readonly supportsUniformBuffers: boolean;
  30167. /** @hidden */
  30168. _gl: WebGLRenderingContext;
  30169. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  30170. protected _windowIsBackground: boolean;
  30171. protected _webGLVersion: number;
  30172. protected _highPrecisionShadersAllowed: boolean;
  30173. /** @hidden */
  30174. readonly _shouldUseHighPrecisionShader: boolean;
  30175. /**
  30176. * Gets a boolean indicating that only power of 2 textures are supported
  30177. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  30178. */
  30179. readonly needPOTTextures: boolean;
  30180. /** @hidden */
  30181. _badOS: boolean;
  30182. /** @hidden */
  30183. _badDesktopOS: boolean;
  30184. private _hardwareScalingLevel;
  30185. /** @hidden */
  30186. _caps: EngineCapabilities;
  30187. private _isStencilEnable;
  30188. protected _colorWrite: boolean;
  30189. /** @hidden */
  30190. _drawCalls: PerfCounter;
  30191. private _glVersion;
  30192. private _glRenderer;
  30193. private _glVendor;
  30194. /** @hidden */
  30195. _videoTextureSupported: boolean;
  30196. protected _renderingQueueLaunched: boolean;
  30197. protected _activeRenderLoops: (() => void)[];
  30198. /**
  30199. * Observable signaled when a context lost event is raised
  30200. */
  30201. onContextLostObservable: Observable<ThinEngine>;
  30202. /**
  30203. * Observable signaled when a context restored event is raised
  30204. */
  30205. onContextRestoredObservable: Observable<ThinEngine>;
  30206. private _onContextLost;
  30207. private _onContextRestored;
  30208. protected _contextWasLost: boolean;
  30209. /** @hidden */
  30210. _doNotHandleContextLost: boolean;
  30211. /**
  30212. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  30213. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  30214. */
  30215. doNotHandleContextLost: boolean;
  30216. /**
  30217. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  30218. */
  30219. disableVertexArrayObjects: boolean;
  30220. /** @hidden */
  30221. protected _depthCullingState: DepthCullingState;
  30222. /** @hidden */
  30223. protected _stencilState: StencilState;
  30224. /** @hidden */
  30225. protected _alphaState: AlphaState;
  30226. /** @hidden */
  30227. _internalTexturesCache: InternalTexture[];
  30228. /** @hidden */
  30229. protected _activeChannel: number;
  30230. private _currentTextureChannel;
  30231. /** @hidden */
  30232. protected _boundTexturesCache: {
  30233. [key: string]: Nullable<InternalTexture>;
  30234. };
  30235. /** @hidden */
  30236. protected _currentEffect: Nullable<Effect>;
  30237. /** @hidden */
  30238. protected _currentProgram: Nullable<WebGLProgram>;
  30239. private _compiledEffects;
  30240. private _vertexAttribArraysEnabled;
  30241. /** @hidden */
  30242. protected _cachedViewport: Nullable<IViewportLike>;
  30243. private _cachedVertexArrayObject;
  30244. /** @hidden */
  30245. protected _cachedVertexBuffers: any;
  30246. /** @hidden */
  30247. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  30248. /** @hidden */
  30249. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  30250. /** @hidden */
  30251. _currentRenderTarget: Nullable<InternalTexture>;
  30252. private _uintIndicesCurrentlySet;
  30253. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  30254. /** @hidden */
  30255. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  30256. private _currentBufferPointers;
  30257. private _currentInstanceLocations;
  30258. private _currentInstanceBuffers;
  30259. private _textureUnits;
  30260. /** @hidden */
  30261. _workingCanvas: Nullable<HTMLCanvasElement>;
  30262. /** @hidden */
  30263. _workingContext: Nullable<CanvasRenderingContext2D>;
  30264. /** @hidden */
  30265. _bindedRenderFunction: any;
  30266. private _vaoRecordInProgress;
  30267. private _mustWipeVertexAttributes;
  30268. private _emptyTexture;
  30269. private _emptyCubeTexture;
  30270. private _emptyTexture3D;
  30271. /** @hidden */
  30272. _frameHandler: number;
  30273. private _nextFreeTextureSlots;
  30274. private _maxSimultaneousTextures;
  30275. private _activeRequests;
  30276. protected _texturesSupported: string[];
  30277. /** @hidden */
  30278. _textureFormatInUse: Nullable<string>;
  30279. protected readonly _supportsHardwareTextureRescaling: boolean;
  30280. /**
  30281. * Gets the list of texture formats supported
  30282. */
  30283. readonly texturesSupported: Array<string>;
  30284. /**
  30285. * Gets the list of texture formats in use
  30286. */
  30287. readonly textureFormatInUse: Nullable<string>;
  30288. /**
  30289. * Gets the current viewport
  30290. */
  30291. readonly currentViewport: Nullable<IViewportLike>;
  30292. /**
  30293. * Gets the default empty texture
  30294. */
  30295. readonly emptyTexture: InternalTexture;
  30296. /**
  30297. * Gets the default empty 3D texture
  30298. */
  30299. readonly emptyTexture3D: InternalTexture;
  30300. /**
  30301. * Gets the default empty cube texture
  30302. */
  30303. readonly emptyCubeTexture: InternalTexture;
  30304. /**
  30305. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  30306. */
  30307. readonly premultipliedAlpha: boolean;
  30308. /**
  30309. * Creates a new engine
  30310. * @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
  30311. * @param antialias defines enable antialiasing (default: false)
  30312. * @param options defines further options to be sent to the getContext() function
  30313. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  30314. */
  30315. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  30316. private _rebuildInternalTextures;
  30317. private _rebuildEffects;
  30318. /**
  30319. * Gets a boolean indicating if all created effects are ready
  30320. * @returns true if all effects are ready
  30321. */
  30322. areAllEffectsReady(): boolean;
  30323. protected _rebuildBuffers(): void;
  30324. private _initGLContext;
  30325. /**
  30326. * Gets version of the current webGL context
  30327. */
  30328. readonly webGLVersion: number;
  30329. /**
  30330. * Gets a string idenfifying the name of the class
  30331. * @returns "Engine" string
  30332. */
  30333. getClassName(): string;
  30334. /**
  30335. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  30336. */
  30337. readonly isStencilEnable: boolean;
  30338. /** @hidden */
  30339. _prepareWorkingCanvas(): void;
  30340. /**
  30341. * Reset the texture cache to empty state
  30342. */
  30343. resetTextureCache(): void;
  30344. /**
  30345. * Gets an object containing information about the current webGL context
  30346. * @returns an object containing the vender, the renderer and the version of the current webGL context
  30347. */
  30348. getGlInfo(): {
  30349. vendor: string;
  30350. renderer: string;
  30351. version: string;
  30352. };
  30353. /**
  30354. * Defines the hardware scaling level.
  30355. * By default the hardware scaling level is computed from the window device ratio.
  30356. * 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.
  30357. * @param level defines the level to use
  30358. */
  30359. setHardwareScalingLevel(level: number): void;
  30360. /**
  30361. * Gets the current hardware scaling level.
  30362. * By default the hardware scaling level is computed from the window device ratio.
  30363. * 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.
  30364. * @returns a number indicating the current hardware scaling level
  30365. */
  30366. getHardwareScalingLevel(): number;
  30367. /**
  30368. * Gets the list of loaded textures
  30369. * @returns an array containing all loaded textures
  30370. */
  30371. getLoadedTexturesCache(): InternalTexture[];
  30372. /**
  30373. * Gets the object containing all engine capabilities
  30374. * @returns the EngineCapabilities object
  30375. */
  30376. getCaps(): EngineCapabilities;
  30377. /**
  30378. * stop executing a render loop function and remove it from the execution array
  30379. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  30380. */
  30381. stopRenderLoop(renderFunction?: () => void): void;
  30382. /** @hidden */
  30383. _renderLoop(): void;
  30384. /**
  30385. * Gets the HTML canvas attached with the current webGL context
  30386. * @returns a HTML canvas
  30387. */
  30388. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  30389. /**
  30390. * Gets host window
  30391. * @returns the host window object
  30392. */
  30393. getHostWindow(): Window;
  30394. /**
  30395. * Gets the current render width
  30396. * @param useScreen defines if screen size must be used (or the current render target if any)
  30397. * @returns a number defining the current render width
  30398. */
  30399. getRenderWidth(useScreen?: boolean): number;
  30400. /**
  30401. * Gets the current render height
  30402. * @param useScreen defines if screen size must be used (or the current render target if any)
  30403. * @returns a number defining the current render height
  30404. */
  30405. getRenderHeight(useScreen?: boolean): number;
  30406. /**
  30407. * Can be used to override the current requestAnimationFrame requester.
  30408. * @hidden
  30409. */
  30410. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  30411. /**
  30412. * Register and execute a render loop. The engine can have more than one render function
  30413. * @param renderFunction defines the function to continuously execute
  30414. */
  30415. runRenderLoop(renderFunction: () => void): void;
  30416. /**
  30417. * Clear the current render buffer or the current render target (if any is set up)
  30418. * @param color defines the color to use
  30419. * @param backBuffer defines if the back buffer must be cleared
  30420. * @param depth defines if the depth buffer must be cleared
  30421. * @param stencil defines if the stencil buffer must be cleared
  30422. */
  30423. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  30424. private _viewportCached;
  30425. /** @hidden */
  30426. _viewport(x: number, y: number, width: number, height: number): void;
  30427. /**
  30428. * Set the WebGL's viewport
  30429. * @param viewport defines the viewport element to be used
  30430. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  30431. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  30432. */
  30433. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  30434. /**
  30435. * Begin a new frame
  30436. */
  30437. beginFrame(): void;
  30438. /**
  30439. * Enf the current frame
  30440. */
  30441. endFrame(): void;
  30442. /**
  30443. * Resize the view according to the canvas' size
  30444. */
  30445. resize(): void;
  30446. /**
  30447. * Force a specific size of the canvas
  30448. * @param width defines the new canvas' width
  30449. * @param height defines the new canvas' height
  30450. */
  30451. setSize(width: number, height: number): void;
  30452. /**
  30453. * Binds the frame buffer to the specified texture.
  30454. * @param texture The texture to render to or null for the default canvas
  30455. * @param faceIndex The face of the texture to render to in case of cube texture
  30456. * @param requiredWidth The width of the target to render to
  30457. * @param requiredHeight The height of the target to render to
  30458. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  30459. * @param depthStencilTexture The depth stencil texture to use to render
  30460. * @param lodLevel defines le lod level to bind to the frame buffer
  30461. */
  30462. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  30463. /** @hidden */
  30464. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  30465. /**
  30466. * Unbind the current render target texture from the webGL context
  30467. * @param texture defines the render target texture to unbind
  30468. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  30469. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  30470. */
  30471. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  30472. /**
  30473. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  30474. */
  30475. flushFramebuffer(): void;
  30476. /**
  30477. * Unbind the current render target and bind the default framebuffer
  30478. */
  30479. restoreDefaultFramebuffer(): void;
  30480. private _resetVertexBufferBinding;
  30481. /**
  30482. * Creates a vertex buffer
  30483. * @param data the data for the vertex buffer
  30484. * @returns the new WebGL static buffer
  30485. */
  30486. createVertexBuffer(data: DataArray): DataBuffer;
  30487. private _createVertexBuffer;
  30488. /**
  30489. * Creates a dynamic vertex buffer
  30490. * @param data the data for the dynamic vertex buffer
  30491. * @returns the new WebGL dynamic buffer
  30492. */
  30493. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  30494. /**
  30495. * Updates a dynamic vertex buffer.
  30496. * @param vertexBuffer the vertex buffer to update
  30497. * @param data the data used to update the vertex buffer
  30498. * @param byteOffset the byte offset of the data
  30499. * @param byteLength the byte length of the data
  30500. */
  30501. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  30502. protected _resetIndexBufferBinding(): void;
  30503. /**
  30504. * Creates a new index buffer
  30505. * @param indices defines the content of the index buffer
  30506. * @param updatable defines if the index buffer must be updatable
  30507. * @returns a new webGL buffer
  30508. */
  30509. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  30510. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  30511. /**
  30512. * Bind a webGL buffer to the webGL context
  30513. * @param buffer defines the buffer to bind
  30514. */
  30515. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  30516. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  30517. private bindBuffer;
  30518. /**
  30519. * update the bound buffer with the given data
  30520. * @param data defines the data to update
  30521. */
  30522. updateArrayBuffer(data: Float32Array): void;
  30523. private _vertexAttribPointer;
  30524. private _bindIndexBufferWithCache;
  30525. private _bindVertexBuffersAttributes;
  30526. /**
  30527. * Records a vertex array object
  30528. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30529. * @param vertexBuffers defines the list of vertex buffers to store
  30530. * @param indexBuffer defines the index buffer to store
  30531. * @param effect defines the effect to store
  30532. * @returns the new vertex array object
  30533. */
  30534. recordVertexArrayObject(vertexBuffers: {
  30535. [key: string]: VertexBuffer;
  30536. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  30537. /**
  30538. * Bind a specific vertex array object
  30539. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30540. * @param vertexArrayObject defines the vertex array object to bind
  30541. * @param indexBuffer defines the index buffer to bind
  30542. */
  30543. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  30544. /**
  30545. * Bind webGl buffers directly to the webGL context
  30546. * @param vertexBuffer defines the vertex buffer to bind
  30547. * @param indexBuffer defines the index buffer to bind
  30548. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  30549. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  30550. * @param effect defines the effect associated with the vertex buffer
  30551. */
  30552. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  30553. private _unbindVertexArrayObject;
  30554. /**
  30555. * Bind a list of vertex buffers to the webGL context
  30556. * @param vertexBuffers defines the list of vertex buffers to bind
  30557. * @param indexBuffer defines the index buffer to bind
  30558. * @param effect defines the effect associated with the vertex buffers
  30559. */
  30560. bindBuffers(vertexBuffers: {
  30561. [key: string]: Nullable<VertexBuffer>;
  30562. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  30563. /**
  30564. * Unbind all instance attributes
  30565. */
  30566. unbindInstanceAttributes(): void;
  30567. /**
  30568. * Release and free the memory of a vertex array object
  30569. * @param vao defines the vertex array object to delete
  30570. */
  30571. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  30572. /** @hidden */
  30573. _releaseBuffer(buffer: DataBuffer): boolean;
  30574. protected _deleteBuffer(buffer: DataBuffer): void;
  30575. /**
  30576. * Creates a webGL buffer to use with instanciation
  30577. * @param capacity defines the size of the buffer
  30578. * @returns the webGL buffer
  30579. */
  30580. createInstancesBuffer(capacity: number): DataBuffer;
  30581. /**
  30582. * Delete a webGL buffer used with instanciation
  30583. * @param buffer defines the webGL buffer to delete
  30584. */
  30585. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  30586. /**
  30587. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  30588. * @param instancesBuffer defines the webGL buffer to update and bind
  30589. * @param data defines the data to store in the buffer
  30590. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  30591. */
  30592. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  30593. /**
  30594. * Apply all cached states (depth, culling, stencil and alpha)
  30595. */
  30596. applyStates(): void;
  30597. /**
  30598. * Send a draw order
  30599. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30600. * @param indexStart defines the starting index
  30601. * @param indexCount defines the number of index to draw
  30602. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30603. */
  30604. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  30605. /**
  30606. * Draw a list of points
  30607. * @param verticesStart defines the index of first vertex to draw
  30608. * @param verticesCount defines the count of vertices to draw
  30609. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30610. */
  30611. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30612. /**
  30613. * Draw a list of unindexed primitives
  30614. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30615. * @param verticesStart defines the index of first vertex to draw
  30616. * @param verticesCount defines the count of vertices to draw
  30617. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30618. */
  30619. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30620. /**
  30621. * Draw a list of indexed primitives
  30622. * @param fillMode defines the primitive to use
  30623. * @param indexStart defines the starting index
  30624. * @param indexCount defines the number of index to draw
  30625. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30626. */
  30627. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  30628. /**
  30629. * Draw a list of unindexed primitives
  30630. * @param fillMode defines the primitive to use
  30631. * @param verticesStart defines the index of first vertex to draw
  30632. * @param verticesCount defines the count of vertices to draw
  30633. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30634. */
  30635. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30636. private _drawMode;
  30637. /** @hidden */
  30638. _releaseEffect(effect: Effect): void;
  30639. /** @hidden */
  30640. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  30641. /**
  30642. * Create a new effect (used to store vertex/fragment shaders)
  30643. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  30644. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  30645. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  30646. * @param samplers defines an array of string used to represent textures
  30647. * @param defines defines the string containing the defines to use to compile the shaders
  30648. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  30649. * @param onCompiled defines a function to call when the effect creation is successful
  30650. * @param onError defines a function to call when the effect creation has failed
  30651. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  30652. * @returns the new Effect
  30653. */
  30654. 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;
  30655. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  30656. private _compileShader;
  30657. private _compileRawShader;
  30658. /**
  30659. * Directly creates a webGL program
  30660. * @param pipelineContext defines the pipeline context to attach to
  30661. * @param vertexCode defines the vertex shader code to use
  30662. * @param fragmentCode defines the fragment shader code to use
  30663. * @param context defines the webGL context to use (if not set, the current one will be used)
  30664. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30665. * @returns the new webGL program
  30666. */
  30667. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30668. /**
  30669. * Creates a webGL program
  30670. * @param pipelineContext defines the pipeline context to attach to
  30671. * @param vertexCode defines the vertex shader code to use
  30672. * @param fragmentCode defines the fragment shader code to use
  30673. * @param defines defines the string containing the defines to use to compile the shaders
  30674. * @param context defines the webGL context to use (if not set, the current one will be used)
  30675. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30676. * @returns the new webGL program
  30677. */
  30678. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30679. /**
  30680. * Creates a new pipeline context
  30681. * @returns the new pipeline
  30682. */
  30683. createPipelineContext(): IPipelineContext;
  30684. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30685. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  30686. /** @hidden */
  30687. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  30688. /** @hidden */
  30689. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  30690. /** @hidden */
  30691. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  30692. /**
  30693. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  30694. * @param pipelineContext defines the pipeline context to use
  30695. * @param uniformsNames defines the list of uniform names
  30696. * @returns an array of webGL uniform locations
  30697. */
  30698. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  30699. /**
  30700. * Gets the lsit of active attributes for a given webGL program
  30701. * @param pipelineContext defines the pipeline context to use
  30702. * @param attributesNames defines the list of attribute names to get
  30703. * @returns an array of indices indicating the offset of each attribute
  30704. */
  30705. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  30706. /**
  30707. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  30708. * @param effect defines the effect to activate
  30709. */
  30710. enableEffect(effect: Nullable<Effect>): void;
  30711. /**
  30712. * Set the value of an uniform to an array of int32
  30713. * @param uniform defines the webGL uniform location where to store the value
  30714. * @param array defines the array of int32 to store
  30715. */
  30716. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30717. /**
  30718. * Set the value of an uniform to an array of int32 (stored as vec2)
  30719. * @param uniform defines the webGL uniform location where to store the value
  30720. * @param array defines the array of int32 to store
  30721. */
  30722. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30723. /**
  30724. * Set the value of an uniform to an array of int32 (stored as vec3)
  30725. * @param uniform defines the webGL uniform location where to store the value
  30726. * @param array defines the array of int32 to store
  30727. */
  30728. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30729. /**
  30730. * Set the value of an uniform to an array of int32 (stored as vec4)
  30731. * @param uniform defines the webGL uniform location where to store the value
  30732. * @param array defines the array of int32 to store
  30733. */
  30734. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30735. /**
  30736. * Set the value of an uniform to an array of float32
  30737. * @param uniform defines the webGL uniform location where to store the value
  30738. * @param array defines the array of float32 to store
  30739. */
  30740. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30741. /**
  30742. * Set the value of an uniform to an array of float32 (stored as vec2)
  30743. * @param uniform defines the webGL uniform location where to store the value
  30744. * @param array defines the array of float32 to store
  30745. */
  30746. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30747. /**
  30748. * Set the value of an uniform to an array of float32 (stored as vec3)
  30749. * @param uniform defines the webGL uniform location where to store the value
  30750. * @param array defines the array of float32 to store
  30751. */
  30752. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30753. /**
  30754. * Set the value of an uniform to an array of float32 (stored as vec4)
  30755. * @param uniform defines the webGL uniform location where to store the value
  30756. * @param array defines the array of float32 to store
  30757. */
  30758. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30759. /**
  30760. * Set the value of an uniform to an array of number
  30761. * @param uniform defines the webGL uniform location where to store the value
  30762. * @param array defines the array of number to store
  30763. */
  30764. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30765. /**
  30766. * Set the value of an uniform to an array of number (stored as vec2)
  30767. * @param uniform defines the webGL uniform location where to store the value
  30768. * @param array defines the array of number to store
  30769. */
  30770. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30771. /**
  30772. * Set the value of an uniform to an array of number (stored as vec3)
  30773. * @param uniform defines the webGL uniform location where to store the value
  30774. * @param array defines the array of number to store
  30775. */
  30776. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30777. /**
  30778. * Set the value of an uniform to an array of number (stored as vec4)
  30779. * @param uniform defines the webGL uniform location where to store the value
  30780. * @param array defines the array of number to store
  30781. */
  30782. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30783. /**
  30784. * Set the value of an uniform to an array of float32 (stored as matrices)
  30785. * @param uniform defines the webGL uniform location where to store the value
  30786. * @param matrices defines the array of float32 to store
  30787. */
  30788. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  30789. /**
  30790. * Set the value of an uniform to a matrix (3x3)
  30791. * @param uniform defines the webGL uniform location where to store the value
  30792. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  30793. */
  30794. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30795. /**
  30796. * Set the value of an uniform to a matrix (2x2)
  30797. * @param uniform defines the webGL uniform location where to store the value
  30798. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  30799. */
  30800. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30801. /**
  30802. * Set the value of an uniform to a number (int)
  30803. * @param uniform defines the webGL uniform location where to store the value
  30804. * @param value defines the int number to store
  30805. */
  30806. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30807. /**
  30808. * Set the value of an uniform to a number (float)
  30809. * @param uniform defines the webGL uniform location where to store the value
  30810. * @param value defines the float number to store
  30811. */
  30812. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30813. /**
  30814. * Set the value of an uniform to a vec2
  30815. * @param uniform defines the webGL uniform location where to store the value
  30816. * @param x defines the 1st component of the value
  30817. * @param y defines the 2nd component of the value
  30818. */
  30819. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  30820. /**
  30821. * Set the value of an uniform to a vec3
  30822. * @param uniform defines the webGL uniform location where to store the value
  30823. * @param x defines the 1st component of the value
  30824. * @param y defines the 2nd component of the value
  30825. * @param z defines the 3rd component of the value
  30826. */
  30827. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  30828. /**
  30829. * Set the value of an uniform to a boolean
  30830. * @param uniform defines the webGL uniform location where to store the value
  30831. * @param bool defines the boolean to store
  30832. */
  30833. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  30834. /**
  30835. * Set the value of an uniform to a vec4
  30836. * @param uniform defines the webGL uniform location where to store the value
  30837. * @param x defines the 1st component of the value
  30838. * @param y defines the 2nd component of the value
  30839. * @param z defines the 3rd component of the value
  30840. * @param w defines the 4th component of the value
  30841. */
  30842. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  30843. /**
  30844. * Sets a Color4 on a uniform variable
  30845. * @param uniform defines the uniform location
  30846. * @param color4 defines the value to be set
  30847. */
  30848. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  30849. /**
  30850. * Gets the depth culling state manager
  30851. */
  30852. readonly depthCullingState: DepthCullingState;
  30853. /**
  30854. * Gets the alpha state manager
  30855. */
  30856. readonly alphaState: AlphaState;
  30857. /**
  30858. * Gets the stencil state manager
  30859. */
  30860. readonly stencilState: StencilState;
  30861. /**
  30862. * Clears the list of texture accessible through engine.
  30863. * This can help preventing texture load conflict due to name collision.
  30864. */
  30865. clearInternalTexturesCache(): void;
  30866. /**
  30867. * Force the entire cache to be cleared
  30868. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  30869. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  30870. */
  30871. wipeCaches(bruteForce?: boolean): void;
  30872. /** @hidden */
  30873. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  30874. min: number;
  30875. mag: number;
  30876. };
  30877. /** @hidden */
  30878. _createTexture(): WebGLTexture;
  30879. /**
  30880. * Usually called from Texture.ts.
  30881. * Passed information to create a WebGLTexture
  30882. * @param urlArg defines a value which contains one of the following:
  30883. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  30884. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  30885. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  30886. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  30887. * @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)
  30888. * @param scene needed for loading to the correct scene
  30889. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  30890. * @param onLoad optional callback to be called upon successful completion
  30891. * @param onError optional callback to be called upon failure
  30892. * @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
  30893. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  30894. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  30895. * @param forcedExtension defines the extension to use to pick the right loader
  30896. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  30897. * @returns a InternalTexture for assignment back into BABYLON.Texture
  30898. */
  30899. 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;
  30900. /**
  30901. * @hidden
  30902. */
  30903. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  30904. /**
  30905. * Creates a raw texture
  30906. * @param data defines the data to store in the texture
  30907. * @param width defines the width of the texture
  30908. * @param height defines the height of the texture
  30909. * @param format defines the format of the data
  30910. * @param generateMipMaps defines if the engine should generate the mip levels
  30911. * @param invertY defines if data must be stored with Y axis inverted
  30912. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  30913. * @param compression defines the compression used (null by default)
  30914. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  30915. * @returns the raw texture inside an InternalTexture
  30916. */
  30917. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  30918. /**
  30919. * Creates a new raw cube texture
  30920. * @param data defines the array of data to use to create each face
  30921. * @param size defines the size of the textures
  30922. * @param format defines the format of the data
  30923. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  30924. * @param generateMipMaps defines if the engine should generate the mip levels
  30925. * @param invertY defines if data must be stored with Y axis inverted
  30926. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  30927. * @param compression defines the compression used (null by default)
  30928. * @returns the cube texture as an InternalTexture
  30929. */
  30930. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  30931. /**
  30932. * Creates a new raw 3D texture
  30933. * @param data defines the data used to create the texture
  30934. * @param width defines the width of the texture
  30935. * @param height defines the height of the texture
  30936. * @param depth defines the depth of the texture
  30937. * @param format defines the format of the texture
  30938. * @param generateMipMaps defines if the engine must generate mip levels
  30939. * @param invertY defines if data must be stored with Y axis inverted
  30940. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  30941. * @param compression defines the compressed used (can be null)
  30942. * @param textureType defines the compressed used (can be null)
  30943. * @returns a new raw 3D texture (stored in an InternalTexture)
  30944. */
  30945. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  30946. private _unpackFlipYCached;
  30947. /**
  30948. * In case you are sharing the context with other applications, it might
  30949. * be interested to not cache the unpack flip y state to ensure a consistent
  30950. * value would be set.
  30951. */
  30952. enableUnpackFlipYCached: boolean;
  30953. /** @hidden */
  30954. _unpackFlipY(value: boolean): void;
  30955. /** @hidden */
  30956. _getUnpackAlignement(): number;
  30957. /**
  30958. * Update the sampling mode of a given texture
  30959. * @param samplingMode defines the required sampling mode
  30960. * @param texture defines the texture to update
  30961. */
  30962. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  30963. /**
  30964. * Updates a depth texture Comparison Mode and Function.
  30965. * If the comparison Function is equal to 0, the mode will be set to none.
  30966. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  30967. * @param texture The texture to set the comparison function for
  30968. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  30969. */
  30970. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  30971. /** @hidden */
  30972. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  30973. width: number;
  30974. height: number;
  30975. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  30976. /**
  30977. * Creates a depth stencil texture.
  30978. * This is only available in WebGL 2 or with the depth texture extension available.
  30979. * @param size The size of face edge in the texture.
  30980. * @param options The options defining the texture.
  30981. * @returns The texture
  30982. */
  30983. createDepthStencilTexture(size: number | {
  30984. width: number;
  30985. height: number;
  30986. }, options: DepthTextureCreationOptions): InternalTexture;
  30987. /**
  30988. * Creates a depth stencil texture.
  30989. * This is only available in WebGL 2 or with the depth texture extension available.
  30990. * @param size The size of face edge in the texture.
  30991. * @param options The options defining the texture.
  30992. * @returns The texture
  30993. */
  30994. private _createDepthStencilTexture;
  30995. /** @hidden */
  30996. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  30997. /** @hidden */
  30998. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  30999. /** @hidden */
  31000. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31001. /** @hidden */
  31002. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  31003. /**
  31004. * @hidden
  31005. */
  31006. _setCubeMapTextureParams(loadMipmap: boolean): void;
  31007. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  31008. private _prepareWebGLTexture;
  31009. /** @hidden */
  31010. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  31011. /** @hidden */
  31012. _releaseFramebufferObjects(texture: InternalTexture): void;
  31013. /** @hidden */
  31014. _releaseTexture(texture: InternalTexture): void;
  31015. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  31016. protected _setProgram(program: WebGLProgram): void;
  31017. protected _boundUniforms: {
  31018. [key: number]: WebGLUniformLocation;
  31019. };
  31020. /**
  31021. * Binds an effect to the webGL context
  31022. * @param effect defines the effect to bind
  31023. */
  31024. bindSamplers(effect: Effect): void;
  31025. private _activateCurrentTexture;
  31026. /** @hidden */
  31027. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  31028. /** @hidden */
  31029. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  31030. /**
  31031. * Unbind all textures from the webGL context
  31032. */
  31033. unbindAllTextures(): void;
  31034. /**
  31035. * Sets a texture to the according uniform.
  31036. * @param channel The texture channel
  31037. * @param uniform The uniform to set
  31038. * @param texture The texture to apply
  31039. */
  31040. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  31041. private _bindSamplerUniformToChannel;
  31042. private _getTextureWrapMode;
  31043. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  31044. /**
  31045. * Sets an array of texture to the webGL context
  31046. * @param channel defines the channel where the texture array must be set
  31047. * @param uniform defines the associated uniform location
  31048. * @param textures defines the array of textures to bind
  31049. */
  31050. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  31051. /** @hidden */
  31052. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  31053. private _setTextureParameterFloat;
  31054. private _setTextureParameterInteger;
  31055. /**
  31056. * Unbind all vertex attributes from the webGL context
  31057. */
  31058. unbindAllAttributes(): void;
  31059. /**
  31060. * 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
  31061. */
  31062. releaseEffects(): void;
  31063. /**
  31064. * Dispose and release all associated resources
  31065. */
  31066. dispose(): void;
  31067. /**
  31068. * Attach a new callback raised when context lost event is fired
  31069. * @param callback defines the callback to call
  31070. */
  31071. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31072. /**
  31073. * Attach a new callback raised when context restored event is fired
  31074. * @param callback defines the callback to call
  31075. */
  31076. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31077. /**
  31078. * Get the current error code of the webGL context
  31079. * @returns the error code
  31080. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  31081. */
  31082. getError(): number;
  31083. private _canRenderToFloatFramebuffer;
  31084. private _canRenderToHalfFloatFramebuffer;
  31085. private _canRenderToFramebuffer;
  31086. /** @hidden */
  31087. _getWebGLTextureType(type: number): number;
  31088. /** @hidden */
  31089. _getInternalFormat(format: number): number;
  31090. /** @hidden */
  31091. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  31092. /** @hidden */
  31093. _getRGBAMultiSampleBufferFormat(type: number): number;
  31094. /** @hidden */
  31095. _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;
  31096. /**
  31097. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  31098. * @returns true if the engine can be created
  31099. * @ignorenaming
  31100. */
  31101. static isSupported(): boolean;
  31102. /**
  31103. * Find the next highest power of two.
  31104. * @param x Number to start search from.
  31105. * @return Next highest power of two.
  31106. */
  31107. static CeilingPOT(x: number): number;
  31108. /**
  31109. * Find the next lowest power of two.
  31110. * @param x Number to start search from.
  31111. * @return Next lowest power of two.
  31112. */
  31113. static FloorPOT(x: number): number;
  31114. /**
  31115. * Find the nearest power of two.
  31116. * @param x Number to start search from.
  31117. * @return Next nearest power of two.
  31118. */
  31119. static NearestPOT(x: number): number;
  31120. /**
  31121. * Get the closest exponent of two
  31122. * @param value defines the value to approximate
  31123. * @param max defines the maximum value to return
  31124. * @param mode defines how to define the closest value
  31125. * @returns closest exponent of two of the given value
  31126. */
  31127. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31128. /**
  31129. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31130. * @param func - the function to be called
  31131. * @param requester - the object that will request the next frame. Falls back to window.
  31132. * @returns frame number
  31133. */
  31134. static QueueNewFrame(func: () => void, requester?: any): number;
  31135. }
  31136. }
  31137. declare module "babylonjs/Materials/Textures/internalTexture" {
  31138. import { Observable } from "babylonjs/Misc/observable";
  31139. import { Nullable, int } from "babylonjs/types";
  31140. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  31141. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  31142. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31143. /**
  31144. * Defines the source of the internal texture
  31145. */
  31146. export enum InternalTextureSource {
  31147. /**
  31148. * The source of the texture data is unknown
  31149. */
  31150. Unknown = 0,
  31151. /**
  31152. * Texture data comes from an URL
  31153. */
  31154. Url = 1,
  31155. /**
  31156. * Texture data is only used for temporary storage
  31157. */
  31158. Temp = 2,
  31159. /**
  31160. * Texture data comes from raw data (ArrayBuffer)
  31161. */
  31162. Raw = 3,
  31163. /**
  31164. * Texture content is dynamic (video or dynamic texture)
  31165. */
  31166. Dynamic = 4,
  31167. /**
  31168. * Texture content is generated by rendering to it
  31169. */
  31170. RenderTarget = 5,
  31171. /**
  31172. * Texture content is part of a multi render target process
  31173. */
  31174. MultiRenderTarget = 6,
  31175. /**
  31176. * Texture data comes from a cube data file
  31177. */
  31178. Cube = 7,
  31179. /**
  31180. * Texture data comes from a raw cube data
  31181. */
  31182. CubeRaw = 8,
  31183. /**
  31184. * Texture data come from a prefiltered cube data file
  31185. */
  31186. CubePrefiltered = 9,
  31187. /**
  31188. * Texture content is raw 3D data
  31189. */
  31190. Raw3D = 10,
  31191. /**
  31192. * Texture content is a depth texture
  31193. */
  31194. Depth = 11,
  31195. /**
  31196. * Texture data comes from a raw cube data encoded with RGBD
  31197. */
  31198. CubeRawRGBD = 12
  31199. }
  31200. /**
  31201. * Class used to store data associated with WebGL texture data for the engine
  31202. * This class should not be used directly
  31203. */
  31204. export class InternalTexture {
  31205. /** @hidden */
  31206. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  31207. /**
  31208. * Defines if the texture is ready
  31209. */
  31210. isReady: boolean;
  31211. /**
  31212. * Defines if the texture is a cube texture
  31213. */
  31214. isCube: boolean;
  31215. /**
  31216. * Defines if the texture contains 3D data
  31217. */
  31218. is3D: boolean;
  31219. /**
  31220. * Defines if the texture contains multiview data
  31221. */
  31222. isMultiview: boolean;
  31223. /**
  31224. * Gets the URL used to load this texture
  31225. */
  31226. url: string;
  31227. /**
  31228. * Gets the sampling mode of the texture
  31229. */
  31230. samplingMode: number;
  31231. /**
  31232. * Gets a boolean indicating if the texture needs mipmaps generation
  31233. */
  31234. generateMipMaps: boolean;
  31235. /**
  31236. * Gets the number of samples used by the texture (WebGL2+ only)
  31237. */
  31238. samples: number;
  31239. /**
  31240. * Gets the type of the texture (int, float...)
  31241. */
  31242. type: number;
  31243. /**
  31244. * Gets the format of the texture (RGB, RGBA...)
  31245. */
  31246. format: number;
  31247. /**
  31248. * Observable called when the texture is loaded
  31249. */
  31250. onLoadedObservable: Observable<InternalTexture>;
  31251. /**
  31252. * Gets the width of the texture
  31253. */
  31254. width: number;
  31255. /**
  31256. * Gets the height of the texture
  31257. */
  31258. height: number;
  31259. /**
  31260. * Gets the depth of the texture
  31261. */
  31262. depth: number;
  31263. /**
  31264. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  31265. */
  31266. baseWidth: number;
  31267. /**
  31268. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  31269. */
  31270. baseHeight: number;
  31271. /**
  31272. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  31273. */
  31274. baseDepth: number;
  31275. /**
  31276. * Gets a boolean indicating if the texture is inverted on Y axis
  31277. */
  31278. invertY: boolean;
  31279. /** @hidden */
  31280. _invertVScale: boolean;
  31281. /** @hidden */
  31282. _associatedChannel: number;
  31283. /** @hidden */
  31284. _source: InternalTextureSource;
  31285. /** @hidden */
  31286. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  31287. /** @hidden */
  31288. _bufferView: Nullable<ArrayBufferView>;
  31289. /** @hidden */
  31290. _bufferViewArray: Nullable<ArrayBufferView[]>;
  31291. /** @hidden */
  31292. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  31293. /** @hidden */
  31294. _size: number;
  31295. /** @hidden */
  31296. _extension: string;
  31297. /** @hidden */
  31298. _files: Nullable<string[]>;
  31299. /** @hidden */
  31300. _workingCanvas: Nullable<HTMLCanvasElement>;
  31301. /** @hidden */
  31302. _workingContext: Nullable<CanvasRenderingContext2D>;
  31303. /** @hidden */
  31304. _framebuffer: Nullable<WebGLFramebuffer>;
  31305. /** @hidden */
  31306. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  31307. /** @hidden */
  31308. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  31309. /** @hidden */
  31310. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  31311. /** @hidden */
  31312. _attachments: Nullable<number[]>;
  31313. /** @hidden */
  31314. _cachedCoordinatesMode: Nullable<number>;
  31315. /** @hidden */
  31316. _cachedWrapU: Nullable<number>;
  31317. /** @hidden */
  31318. _cachedWrapV: Nullable<number>;
  31319. /** @hidden */
  31320. _cachedWrapR: Nullable<number>;
  31321. /** @hidden */
  31322. _cachedAnisotropicFilteringLevel: Nullable<number>;
  31323. /** @hidden */
  31324. _isDisabled: boolean;
  31325. /** @hidden */
  31326. _compression: Nullable<string>;
  31327. /** @hidden */
  31328. _generateStencilBuffer: boolean;
  31329. /** @hidden */
  31330. _generateDepthBuffer: boolean;
  31331. /** @hidden */
  31332. _comparisonFunction: number;
  31333. /** @hidden */
  31334. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  31335. /** @hidden */
  31336. _lodGenerationScale: number;
  31337. /** @hidden */
  31338. _lodGenerationOffset: number;
  31339. /** @hidden */
  31340. _colorTextureArray: Nullable<WebGLTexture>;
  31341. /** @hidden */
  31342. _depthStencilTextureArray: Nullable<WebGLTexture>;
  31343. /** @hidden */
  31344. _lodTextureHigh: Nullable<BaseTexture>;
  31345. /** @hidden */
  31346. _lodTextureMid: Nullable<BaseTexture>;
  31347. /** @hidden */
  31348. _lodTextureLow: Nullable<BaseTexture>;
  31349. /** @hidden */
  31350. _isRGBD: boolean;
  31351. /** @hidden */
  31352. _linearSpecularLOD: boolean;
  31353. /** @hidden */
  31354. _irradianceTexture: Nullable<BaseTexture>;
  31355. /** @hidden */
  31356. _webGLTexture: Nullable<WebGLTexture>;
  31357. /** @hidden */
  31358. _references: number;
  31359. private _engine;
  31360. /**
  31361. * Gets the Engine the texture belongs to.
  31362. * @returns The babylon engine
  31363. */
  31364. getEngine(): ThinEngine;
  31365. /**
  31366. * Gets the data source type of the texture
  31367. */
  31368. readonly source: InternalTextureSource;
  31369. /**
  31370. * Creates a new InternalTexture
  31371. * @param engine defines the engine to use
  31372. * @param source defines the type of data that will be used
  31373. * @param delayAllocation if the texture allocation should be delayed (default: false)
  31374. */
  31375. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  31376. /**
  31377. * Increments the number of references (ie. the number of Texture that point to it)
  31378. */
  31379. incrementReferences(): void;
  31380. /**
  31381. * Change the size of the texture (not the size of the content)
  31382. * @param width defines the new width
  31383. * @param height defines the new height
  31384. * @param depth defines the new depth (1 by default)
  31385. */
  31386. updateSize(width: int, height: int, depth?: int): void;
  31387. /** @hidden */
  31388. _rebuild(): void;
  31389. /** @hidden */
  31390. _swapAndDie(target: InternalTexture): void;
  31391. /**
  31392. * Dispose the current allocated resources
  31393. */
  31394. dispose(): void;
  31395. }
  31396. }
  31397. declare module "babylonjs/Audio/analyser" {
  31398. import { Scene } from "babylonjs/scene";
  31399. /**
  31400. * Class used to work with sound analyzer using fast fourier transform (FFT)
  31401. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31402. */
  31403. export class Analyser {
  31404. /**
  31405. * Gets or sets the smoothing
  31406. * @ignorenaming
  31407. */
  31408. SMOOTHING: number;
  31409. /**
  31410. * Gets or sets the FFT table size
  31411. * @ignorenaming
  31412. */
  31413. FFT_SIZE: number;
  31414. /**
  31415. * Gets or sets the bar graph amplitude
  31416. * @ignorenaming
  31417. */
  31418. BARGRAPHAMPLITUDE: number;
  31419. /**
  31420. * Gets or sets the position of the debug canvas
  31421. * @ignorenaming
  31422. */
  31423. DEBUGCANVASPOS: {
  31424. x: number;
  31425. y: number;
  31426. };
  31427. /**
  31428. * Gets or sets the debug canvas size
  31429. * @ignorenaming
  31430. */
  31431. DEBUGCANVASSIZE: {
  31432. width: number;
  31433. height: number;
  31434. };
  31435. private _byteFreqs;
  31436. private _byteTime;
  31437. private _floatFreqs;
  31438. private _webAudioAnalyser;
  31439. private _debugCanvas;
  31440. private _debugCanvasContext;
  31441. private _scene;
  31442. private _registerFunc;
  31443. private _audioEngine;
  31444. /**
  31445. * Creates a new analyser
  31446. * @param scene defines hosting scene
  31447. */
  31448. constructor(scene: Scene);
  31449. /**
  31450. * Get the number of data values you will have to play with for the visualization
  31451. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  31452. * @returns a number
  31453. */
  31454. getFrequencyBinCount(): number;
  31455. /**
  31456. * Gets the current frequency data as a byte array
  31457. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31458. * @returns a Uint8Array
  31459. */
  31460. getByteFrequencyData(): Uint8Array;
  31461. /**
  31462. * Gets the current waveform as a byte array
  31463. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  31464. * @returns a Uint8Array
  31465. */
  31466. getByteTimeDomainData(): Uint8Array;
  31467. /**
  31468. * Gets the current frequency data as a float array
  31469. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31470. * @returns a Float32Array
  31471. */
  31472. getFloatFrequencyData(): Float32Array;
  31473. /**
  31474. * Renders the debug canvas
  31475. */
  31476. drawDebugCanvas(): void;
  31477. /**
  31478. * Stops rendering the debug canvas and removes it
  31479. */
  31480. stopDebugCanvas(): void;
  31481. /**
  31482. * Connects two audio nodes
  31483. * @param inputAudioNode defines first node to connect
  31484. * @param outputAudioNode defines second node to connect
  31485. */
  31486. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  31487. /**
  31488. * Releases all associated resources
  31489. */
  31490. dispose(): void;
  31491. }
  31492. }
  31493. declare module "babylonjs/Audio/audioEngine" {
  31494. import { IDisposable } from "babylonjs/scene";
  31495. import { Analyser } from "babylonjs/Audio/analyser";
  31496. import { Nullable } from "babylonjs/types";
  31497. import { Observable } from "babylonjs/Misc/observable";
  31498. /**
  31499. * This represents an audio engine and it is responsible
  31500. * to play, synchronize and analyse sounds throughout the application.
  31501. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31502. */
  31503. export interface IAudioEngine extends IDisposable {
  31504. /**
  31505. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  31506. */
  31507. readonly canUseWebAudio: boolean;
  31508. /**
  31509. * Gets the current AudioContext if available.
  31510. */
  31511. readonly audioContext: Nullable<AudioContext>;
  31512. /**
  31513. * The master gain node defines the global audio volume of your audio engine.
  31514. */
  31515. readonly masterGain: GainNode;
  31516. /**
  31517. * Gets whether or not mp3 are supported by your browser.
  31518. */
  31519. readonly isMP3supported: boolean;
  31520. /**
  31521. * Gets whether or not ogg are supported by your browser.
  31522. */
  31523. readonly isOGGsupported: boolean;
  31524. /**
  31525. * Defines if Babylon should emit a warning if WebAudio is not supported.
  31526. * @ignoreNaming
  31527. */
  31528. WarnedWebAudioUnsupported: boolean;
  31529. /**
  31530. * Defines if the audio engine relies on a custom unlocked button.
  31531. * In this case, the embedded button will not be displayed.
  31532. */
  31533. useCustomUnlockedButton: boolean;
  31534. /**
  31535. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  31536. */
  31537. readonly unlocked: boolean;
  31538. /**
  31539. * Event raised when audio has been unlocked on the browser.
  31540. */
  31541. onAudioUnlockedObservable: Observable<AudioEngine>;
  31542. /**
  31543. * Event raised when audio has been locked on the browser.
  31544. */
  31545. onAudioLockedObservable: Observable<AudioEngine>;
  31546. /**
  31547. * Flags the audio engine in Locked state.
  31548. * This happens due to new browser policies preventing audio to autoplay.
  31549. */
  31550. lock(): void;
  31551. /**
  31552. * Unlocks the audio engine once a user action has been done on the dom.
  31553. * This is helpful to resume play once browser policies have been satisfied.
  31554. */
  31555. unlock(): void;
  31556. }
  31557. /**
  31558. * This represents the default audio engine used in babylon.
  31559. * It is responsible to play, synchronize and analyse sounds throughout the application.
  31560. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31561. */
  31562. export class AudioEngine implements IAudioEngine {
  31563. private _audioContext;
  31564. private _audioContextInitialized;
  31565. private _muteButton;
  31566. private _hostElement;
  31567. /**
  31568. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  31569. */
  31570. canUseWebAudio: boolean;
  31571. /**
  31572. * The master gain node defines the global audio volume of your audio engine.
  31573. */
  31574. masterGain: GainNode;
  31575. /**
  31576. * Defines if Babylon should emit a warning if WebAudio is not supported.
  31577. * @ignoreNaming
  31578. */
  31579. WarnedWebAudioUnsupported: boolean;
  31580. /**
  31581. * Gets whether or not mp3 are supported by your browser.
  31582. */
  31583. isMP3supported: boolean;
  31584. /**
  31585. * Gets whether or not ogg are supported by your browser.
  31586. */
  31587. isOGGsupported: boolean;
  31588. /**
  31589. * Gets whether audio has been unlocked on the device.
  31590. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  31591. * a user interaction has happened.
  31592. */
  31593. unlocked: boolean;
  31594. /**
  31595. * Defines if the audio engine relies on a custom unlocked button.
  31596. * In this case, the embedded button will not be displayed.
  31597. */
  31598. useCustomUnlockedButton: boolean;
  31599. /**
  31600. * Event raised when audio has been unlocked on the browser.
  31601. */
  31602. onAudioUnlockedObservable: Observable<AudioEngine>;
  31603. /**
  31604. * Event raised when audio has been locked on the browser.
  31605. */
  31606. onAudioLockedObservable: Observable<AudioEngine>;
  31607. /**
  31608. * Gets the current AudioContext if available.
  31609. */
  31610. readonly audioContext: Nullable<AudioContext>;
  31611. private _connectedAnalyser;
  31612. /**
  31613. * Instantiates a new audio engine.
  31614. *
  31615. * There should be only one per page as some browsers restrict the number
  31616. * of audio contexts you can create.
  31617. * @param hostElement defines the host element where to display the mute icon if necessary
  31618. */
  31619. constructor(hostElement?: Nullable<HTMLElement>);
  31620. /**
  31621. * Flags the audio engine in Locked state.
  31622. * This happens due to new browser policies preventing audio to autoplay.
  31623. */
  31624. lock(): void;
  31625. /**
  31626. * Unlocks the audio engine once a user action has been done on the dom.
  31627. * This is helpful to resume play once browser policies have been satisfied.
  31628. */
  31629. unlock(): void;
  31630. private _resumeAudioContext;
  31631. private _initializeAudioContext;
  31632. private _tryToRun;
  31633. private _triggerRunningState;
  31634. private _triggerSuspendedState;
  31635. private _displayMuteButton;
  31636. private _moveButtonToTopLeft;
  31637. private _onResize;
  31638. private _hideMuteButton;
  31639. /**
  31640. * Destroy and release the resources associated with the audio ccontext.
  31641. */
  31642. dispose(): void;
  31643. /**
  31644. * Gets the global volume sets on the master gain.
  31645. * @returns the global volume if set or -1 otherwise
  31646. */
  31647. getGlobalVolume(): number;
  31648. /**
  31649. * Sets the global volume of your experience (sets on the master gain).
  31650. * @param newVolume Defines the new global volume of the application
  31651. */
  31652. setGlobalVolume(newVolume: number): void;
  31653. /**
  31654. * Connect the audio engine to an audio analyser allowing some amazing
  31655. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  31656. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  31657. * @param analyser The analyser to connect to the engine
  31658. */
  31659. connectToAnalyser(analyser: Analyser): void;
  31660. }
  31661. }
  31662. declare module "babylonjs/Loading/loadingScreen" {
  31663. /**
  31664. * Interface used to present a loading screen while loading a scene
  31665. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31666. */
  31667. export interface ILoadingScreen {
  31668. /**
  31669. * Function called to display the loading screen
  31670. */
  31671. displayLoadingUI: () => void;
  31672. /**
  31673. * Function called to hide the loading screen
  31674. */
  31675. hideLoadingUI: () => void;
  31676. /**
  31677. * Gets or sets the color to use for the background
  31678. */
  31679. loadingUIBackgroundColor: string;
  31680. /**
  31681. * Gets or sets the text to display while loading
  31682. */
  31683. loadingUIText: string;
  31684. }
  31685. /**
  31686. * Class used for the default loading screen
  31687. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31688. */
  31689. export class DefaultLoadingScreen implements ILoadingScreen {
  31690. private _renderingCanvas;
  31691. private _loadingText;
  31692. private _loadingDivBackgroundColor;
  31693. private _loadingDiv;
  31694. private _loadingTextDiv;
  31695. /** Gets or sets the logo url to use for the default loading screen */
  31696. static DefaultLogoUrl: string;
  31697. /** Gets or sets the spinner url to use for the default loading screen */
  31698. static DefaultSpinnerUrl: string;
  31699. /**
  31700. * Creates a new default loading screen
  31701. * @param _renderingCanvas defines the canvas used to render the scene
  31702. * @param _loadingText defines the default text to display
  31703. * @param _loadingDivBackgroundColor defines the default background color
  31704. */
  31705. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  31706. /**
  31707. * Function called to display the loading screen
  31708. */
  31709. displayLoadingUI(): void;
  31710. /**
  31711. * Function called to hide the loading screen
  31712. */
  31713. hideLoadingUI(): void;
  31714. /**
  31715. * Gets or sets the text to display while loading
  31716. */
  31717. loadingUIText: string;
  31718. /**
  31719. * Gets or sets the color to use for the background
  31720. */
  31721. loadingUIBackgroundColor: string;
  31722. private _resizeLoadingUI;
  31723. }
  31724. }
  31725. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  31726. /**
  31727. * Interface for any object that can request an animation frame
  31728. */
  31729. export interface ICustomAnimationFrameRequester {
  31730. /**
  31731. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31732. */
  31733. renderFunction?: Function;
  31734. /**
  31735. * Called to request the next frame to render to
  31736. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31737. */
  31738. requestAnimationFrame: Function;
  31739. /**
  31740. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31741. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31742. */
  31743. requestID?: number;
  31744. }
  31745. }
  31746. declare module "babylonjs/Misc/performanceMonitor" {
  31747. /**
  31748. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  31749. */
  31750. export class PerformanceMonitor {
  31751. private _enabled;
  31752. private _rollingFrameTime;
  31753. private _lastFrameTimeMs;
  31754. /**
  31755. * constructor
  31756. * @param frameSampleSize The number of samples required to saturate the sliding window
  31757. */
  31758. constructor(frameSampleSize?: number);
  31759. /**
  31760. * Samples current frame
  31761. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  31762. */
  31763. sampleFrame(timeMs?: number): void;
  31764. /**
  31765. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  31766. */
  31767. readonly averageFrameTime: number;
  31768. /**
  31769. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  31770. */
  31771. readonly averageFrameTimeVariance: number;
  31772. /**
  31773. * Returns the frame time of the most recent frame
  31774. */
  31775. readonly instantaneousFrameTime: number;
  31776. /**
  31777. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  31778. */
  31779. readonly averageFPS: number;
  31780. /**
  31781. * Returns the average framerate in frames per second using the most recent frame time
  31782. */
  31783. readonly instantaneousFPS: number;
  31784. /**
  31785. * Returns true if enough samples have been taken to completely fill the sliding window
  31786. */
  31787. readonly isSaturated: boolean;
  31788. /**
  31789. * Enables contributions to the sliding window sample set
  31790. */
  31791. enable(): void;
  31792. /**
  31793. * Disables contributions to the sliding window sample set
  31794. * Samples will not be interpolated over the disabled period
  31795. */
  31796. disable(): void;
  31797. /**
  31798. * Returns true if sampling is enabled
  31799. */
  31800. readonly isEnabled: boolean;
  31801. /**
  31802. * Resets performance monitor
  31803. */
  31804. reset(): void;
  31805. }
  31806. /**
  31807. * RollingAverage
  31808. *
  31809. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  31810. */
  31811. export class RollingAverage {
  31812. /**
  31813. * Current average
  31814. */
  31815. average: number;
  31816. /**
  31817. * Current variance
  31818. */
  31819. variance: number;
  31820. protected _samples: Array<number>;
  31821. protected _sampleCount: number;
  31822. protected _pos: number;
  31823. protected _m2: number;
  31824. /**
  31825. * constructor
  31826. * @param length The number of samples required to saturate the sliding window
  31827. */
  31828. constructor(length: number);
  31829. /**
  31830. * Adds a sample to the sample set
  31831. * @param v The sample value
  31832. */
  31833. add(v: number): void;
  31834. /**
  31835. * Returns previously added values or null if outside of history or outside the sliding window domain
  31836. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  31837. * @return Value previously recorded with add() or null if outside of range
  31838. */
  31839. history(i: number): number;
  31840. /**
  31841. * Returns true if enough samples have been taken to completely fill the sliding window
  31842. * @return true if sample-set saturated
  31843. */
  31844. isSaturated(): boolean;
  31845. /**
  31846. * Resets the rolling average (equivalent to 0 samples taken so far)
  31847. */
  31848. reset(): void;
  31849. /**
  31850. * Wraps a value around the sample range boundaries
  31851. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  31852. * @return Wrapped position in sample range
  31853. */
  31854. protected _wrapPosition(i: number): number;
  31855. }
  31856. }
  31857. declare module "babylonjs/Engines/engine" {
  31858. import { Observable } from "babylonjs/Misc/observable";
  31859. import { Nullable, IndicesArray } from "babylonjs/types";
  31860. import { Scene } from "babylonjs/scene";
  31861. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31862. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  31863. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31864. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  31865. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  31866. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  31867. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  31868. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  31869. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  31870. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  31871. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31872. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  31873. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31874. import { Material } from "babylonjs/Materials/material";
  31875. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31876. /**
  31877. * Defines the interface used by display changed events
  31878. */
  31879. export interface IDisplayChangedEventArgs {
  31880. /** Gets the vrDisplay object (if any) */
  31881. vrDisplay: Nullable<any>;
  31882. /** Gets a boolean indicating if webVR is supported */
  31883. vrSupported: boolean;
  31884. }
  31885. /**
  31886. * Defines the interface used by objects containing a viewport (like a camera)
  31887. */
  31888. interface IViewportOwnerLike {
  31889. /**
  31890. * Gets or sets the viewport
  31891. */
  31892. viewport: IViewportLike;
  31893. }
  31894. /**
  31895. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  31896. */
  31897. export class Engine extends ThinEngine {
  31898. /** Defines that alpha blending is disabled */
  31899. static readonly ALPHA_DISABLE: number;
  31900. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  31901. static readonly ALPHA_ADD: number;
  31902. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  31903. static readonly ALPHA_COMBINE: number;
  31904. /** Defines that alpha blending to DEST - SRC * DEST */
  31905. static readonly ALPHA_SUBTRACT: number;
  31906. /** Defines that alpha blending to SRC * DEST */
  31907. static readonly ALPHA_MULTIPLY: number;
  31908. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  31909. static readonly ALPHA_MAXIMIZED: number;
  31910. /** Defines that alpha blending to SRC + DEST */
  31911. static readonly ALPHA_ONEONE: number;
  31912. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  31913. static readonly ALPHA_PREMULTIPLIED: number;
  31914. /**
  31915. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  31916. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  31917. */
  31918. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  31919. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  31920. static readonly ALPHA_INTERPOLATE: number;
  31921. /**
  31922. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  31923. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  31924. */
  31925. static readonly ALPHA_SCREENMODE: number;
  31926. /** Defines that the ressource is not delayed*/
  31927. static readonly DELAYLOADSTATE_NONE: number;
  31928. /** Defines that the ressource was successfully delay loaded */
  31929. static readonly DELAYLOADSTATE_LOADED: number;
  31930. /** Defines that the ressource is currently delay loading */
  31931. static readonly DELAYLOADSTATE_LOADING: number;
  31932. /** Defines that the ressource is delayed and has not started loading */
  31933. static readonly DELAYLOADSTATE_NOTLOADED: number;
  31934. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  31935. static readonly NEVER: number;
  31936. /** 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 */
  31937. static readonly ALWAYS: number;
  31938. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  31939. static readonly LESS: number;
  31940. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  31941. static readonly EQUAL: number;
  31942. /** 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 */
  31943. static readonly LEQUAL: number;
  31944. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  31945. static readonly GREATER: number;
  31946. /** 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 */
  31947. static readonly GEQUAL: number;
  31948. /** 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 */
  31949. static readonly NOTEQUAL: number;
  31950. /** Passed to stencilOperation to specify that stencil value must be kept */
  31951. static readonly KEEP: number;
  31952. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31953. static readonly REPLACE: number;
  31954. /** Passed to stencilOperation to specify that stencil value must be incremented */
  31955. static readonly INCR: number;
  31956. /** Passed to stencilOperation to specify that stencil value must be decremented */
  31957. static readonly DECR: number;
  31958. /** Passed to stencilOperation to specify that stencil value must be inverted */
  31959. static readonly INVERT: number;
  31960. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  31961. static readonly INCR_WRAP: number;
  31962. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  31963. static readonly DECR_WRAP: number;
  31964. /** Texture is not repeating outside of 0..1 UVs */
  31965. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  31966. /** Texture is repeating outside of 0..1 UVs */
  31967. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  31968. /** Texture is repeating and mirrored */
  31969. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  31970. /** ALPHA */
  31971. static readonly TEXTUREFORMAT_ALPHA: number;
  31972. /** LUMINANCE */
  31973. static readonly TEXTUREFORMAT_LUMINANCE: number;
  31974. /** LUMINANCE_ALPHA */
  31975. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  31976. /** RGB */
  31977. static readonly TEXTUREFORMAT_RGB: number;
  31978. /** RGBA */
  31979. static readonly TEXTUREFORMAT_RGBA: number;
  31980. /** RED */
  31981. static readonly TEXTUREFORMAT_RED: number;
  31982. /** RED (2nd reference) */
  31983. static readonly TEXTUREFORMAT_R: number;
  31984. /** RG */
  31985. static readonly TEXTUREFORMAT_RG: number;
  31986. /** RED_INTEGER */
  31987. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  31988. /** RED_INTEGER (2nd reference) */
  31989. static readonly TEXTUREFORMAT_R_INTEGER: number;
  31990. /** RG_INTEGER */
  31991. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  31992. /** RGB_INTEGER */
  31993. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  31994. /** RGBA_INTEGER */
  31995. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  31996. /** UNSIGNED_BYTE */
  31997. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  31998. /** UNSIGNED_BYTE (2nd reference) */
  31999. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  32000. /** FLOAT */
  32001. static readonly TEXTURETYPE_FLOAT: number;
  32002. /** HALF_FLOAT */
  32003. static readonly TEXTURETYPE_HALF_FLOAT: number;
  32004. /** BYTE */
  32005. static readonly TEXTURETYPE_BYTE: number;
  32006. /** SHORT */
  32007. static readonly TEXTURETYPE_SHORT: number;
  32008. /** UNSIGNED_SHORT */
  32009. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  32010. /** INT */
  32011. static readonly TEXTURETYPE_INT: number;
  32012. /** UNSIGNED_INT */
  32013. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  32014. /** UNSIGNED_SHORT_4_4_4_4 */
  32015. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  32016. /** UNSIGNED_SHORT_5_5_5_1 */
  32017. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  32018. /** UNSIGNED_SHORT_5_6_5 */
  32019. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  32020. /** UNSIGNED_INT_2_10_10_10_REV */
  32021. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  32022. /** UNSIGNED_INT_24_8 */
  32023. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  32024. /** UNSIGNED_INT_10F_11F_11F_REV */
  32025. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  32026. /** UNSIGNED_INT_5_9_9_9_REV */
  32027. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  32028. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  32029. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  32030. /** nearest is mag = nearest and min = nearest and mip = linear */
  32031. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  32032. /** Bilinear is mag = linear and min = linear and mip = nearest */
  32033. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  32034. /** Trilinear is mag = linear and min = linear and mip = linear */
  32035. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  32036. /** nearest is mag = nearest and min = nearest and mip = linear */
  32037. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  32038. /** Bilinear is mag = linear and min = linear and mip = nearest */
  32039. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  32040. /** Trilinear is mag = linear and min = linear and mip = linear */
  32041. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  32042. /** mag = nearest and min = nearest and mip = nearest */
  32043. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  32044. /** mag = nearest and min = linear and mip = nearest */
  32045. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  32046. /** mag = nearest and min = linear and mip = linear */
  32047. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  32048. /** mag = nearest and min = linear and mip = none */
  32049. static readonly TEXTURE_NEAREST_LINEAR: number;
  32050. /** mag = nearest and min = nearest and mip = none */
  32051. static readonly TEXTURE_NEAREST_NEAREST: number;
  32052. /** mag = linear and min = nearest and mip = nearest */
  32053. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  32054. /** mag = linear and min = nearest and mip = linear */
  32055. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  32056. /** mag = linear and min = linear and mip = none */
  32057. static readonly TEXTURE_LINEAR_LINEAR: number;
  32058. /** mag = linear and min = nearest and mip = none */
  32059. static readonly TEXTURE_LINEAR_NEAREST: number;
  32060. /** Explicit coordinates mode */
  32061. static readonly TEXTURE_EXPLICIT_MODE: number;
  32062. /** Spherical coordinates mode */
  32063. static readonly TEXTURE_SPHERICAL_MODE: number;
  32064. /** Planar coordinates mode */
  32065. static readonly TEXTURE_PLANAR_MODE: number;
  32066. /** Cubic coordinates mode */
  32067. static readonly TEXTURE_CUBIC_MODE: number;
  32068. /** Projection coordinates mode */
  32069. static readonly TEXTURE_PROJECTION_MODE: number;
  32070. /** Skybox coordinates mode */
  32071. static readonly TEXTURE_SKYBOX_MODE: number;
  32072. /** Inverse Cubic coordinates mode */
  32073. static readonly TEXTURE_INVCUBIC_MODE: number;
  32074. /** Equirectangular coordinates mode */
  32075. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  32076. /** Equirectangular Fixed coordinates mode */
  32077. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  32078. /** Equirectangular Fixed Mirrored coordinates mode */
  32079. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  32080. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  32081. static readonly SCALEMODE_FLOOR: number;
  32082. /** Defines that texture rescaling will look for the nearest power of 2 size */
  32083. static readonly SCALEMODE_NEAREST: number;
  32084. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  32085. static readonly SCALEMODE_CEILING: number;
  32086. /**
  32087. * Returns the current npm package of the sdk
  32088. */
  32089. static readonly NpmPackage: string;
  32090. /**
  32091. * Returns the current version of the framework
  32092. */
  32093. static readonly Version: string;
  32094. /** Gets the list of created engines */
  32095. static readonly Instances: Engine[];
  32096. /**
  32097. * Gets the latest created engine
  32098. */
  32099. static readonly LastCreatedEngine: Nullable<Engine>;
  32100. /**
  32101. * Gets the latest created scene
  32102. */
  32103. static readonly LastCreatedScene: Nullable<Scene>;
  32104. /**
  32105. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  32106. * @param flag defines which part of the materials must be marked as dirty
  32107. * @param predicate defines a predicate used to filter which materials should be affected
  32108. */
  32109. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  32110. /**
  32111. * Method called to create the default loading screen.
  32112. * This can be overriden in your own app.
  32113. * @param canvas The rendering canvas element
  32114. * @returns The loading screen
  32115. */
  32116. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  32117. /**
  32118. * Method called to create the default rescale post process on each engine.
  32119. */
  32120. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  32121. /**
  32122. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  32123. **/
  32124. enableOfflineSupport: boolean;
  32125. /**
  32126. * 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)
  32127. **/
  32128. disableManifestCheck: boolean;
  32129. /**
  32130. * Gets the list of created scenes
  32131. */
  32132. scenes: Scene[];
  32133. /**
  32134. * Event raised when a new scene is created
  32135. */
  32136. onNewSceneAddedObservable: Observable<Scene>;
  32137. /**
  32138. * Gets the list of created postprocesses
  32139. */
  32140. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  32141. /**
  32142. * Gets a boolean indicating if the pointer is currently locked
  32143. */
  32144. isPointerLock: boolean;
  32145. /**
  32146. * Observable event triggered each time the rendering canvas is resized
  32147. */
  32148. onResizeObservable: Observable<Engine>;
  32149. /**
  32150. * Observable event triggered each time the canvas loses focus
  32151. */
  32152. onCanvasBlurObservable: Observable<Engine>;
  32153. /**
  32154. * Observable event triggered each time the canvas gains focus
  32155. */
  32156. onCanvasFocusObservable: Observable<Engine>;
  32157. /**
  32158. * Observable event triggered each time the canvas receives pointerout event
  32159. */
  32160. onCanvasPointerOutObservable: Observable<PointerEvent>;
  32161. /**
  32162. * Observable event triggered before each texture is initialized
  32163. */
  32164. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  32165. /**
  32166. * Observable raised when the engine begins a new frame
  32167. */
  32168. onBeginFrameObservable: Observable<Engine>;
  32169. /**
  32170. * If set, will be used to request the next animation frame for the render loop
  32171. */
  32172. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  32173. /**
  32174. * Observable raised when the engine ends the current frame
  32175. */
  32176. onEndFrameObservable: Observable<Engine>;
  32177. /**
  32178. * Observable raised when the engine is about to compile a shader
  32179. */
  32180. onBeforeShaderCompilationObservable: Observable<Engine>;
  32181. /**
  32182. * Observable raised when the engine has jsut compiled a shader
  32183. */
  32184. onAfterShaderCompilationObservable: Observable<Engine>;
  32185. /**
  32186. * Gets the audio engine
  32187. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32188. * @ignorenaming
  32189. */
  32190. static audioEngine: IAudioEngine;
  32191. /**
  32192. * Default AudioEngine factory responsible of creating the Audio Engine.
  32193. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  32194. */
  32195. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  32196. /**
  32197. * Default offline support factory responsible of creating a tool used to store data locally.
  32198. * By default, this will create a Database object if the workload has been embedded.
  32199. */
  32200. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  32201. private _loadingScreen;
  32202. private _pointerLockRequested;
  32203. private _dummyFramebuffer;
  32204. private _rescalePostProcess;
  32205. /** @hidden */
  32206. protected _alphaMode: number;
  32207. /** @hidden */
  32208. protected _alphaEquation: number;
  32209. private _deterministicLockstep;
  32210. private _lockstepMaxSteps;
  32211. protected readonly _supportsHardwareTextureRescaling: boolean;
  32212. private _fps;
  32213. private _deltaTime;
  32214. /**
  32215. * Turn this value on if you want to pause FPS computation when in background
  32216. */
  32217. disablePerformanceMonitorInBackground: boolean;
  32218. private _performanceMonitor;
  32219. /**
  32220. * Gets the performance monitor attached to this engine
  32221. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  32222. */
  32223. readonly performanceMonitor: PerformanceMonitor;
  32224. private _onFocus;
  32225. private _onBlur;
  32226. private _onCanvasPointerOut;
  32227. private _onCanvasBlur;
  32228. private _onCanvasFocus;
  32229. private _onFullscreenChange;
  32230. private _onPointerLockChange;
  32231. /**
  32232. * Creates a new engine
  32233. * @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
  32234. * @param antialias defines enable antialiasing (default: false)
  32235. * @param options defines further options to be sent to the getContext() function
  32236. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  32237. */
  32238. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  32239. /**
  32240. * Gets current aspect ratio
  32241. * @param viewportOwner defines the camera to use to get the aspect ratio
  32242. * @param useScreen defines if screen size must be used (or the current render target if any)
  32243. * @returns a number defining the aspect ratio
  32244. */
  32245. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  32246. /**
  32247. * Gets current screen aspect ratio
  32248. * @returns a number defining the aspect ratio
  32249. */
  32250. getScreenAspectRatio(): number;
  32251. /**
  32252. * Gets host document
  32253. * @returns the host document object
  32254. */
  32255. getHostDocument(): Document;
  32256. /**
  32257. * Gets the client rect of the HTML canvas attached with the current webGL context
  32258. * @returns a client rectanglee
  32259. */
  32260. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  32261. /**
  32262. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  32263. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32264. * @returns true if engine is in deterministic lock step mode
  32265. */
  32266. isDeterministicLockStep(): boolean;
  32267. /**
  32268. * Gets the max steps when engine is running in deterministic lock step
  32269. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32270. * @returns the max steps
  32271. */
  32272. getLockstepMaxSteps(): number;
  32273. /**
  32274. * Force the mipmap generation for the given render target texture
  32275. * @param texture defines the render target texture to use
  32276. */
  32277. generateMipMapsForCubemap(texture: InternalTexture): void;
  32278. /** States */
  32279. /**
  32280. * Set various states to the webGL context
  32281. * @param culling defines backface culling state
  32282. * @param zOffset defines the value to apply to zOffset (0 by default)
  32283. * @param force defines if states must be applied even if cache is up to date
  32284. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  32285. */
  32286. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  32287. /**
  32288. * Set the z offset to apply to current rendering
  32289. * @param value defines the offset to apply
  32290. */
  32291. setZOffset(value: number): void;
  32292. /**
  32293. * Gets the current value of the zOffset
  32294. * @returns the current zOffset state
  32295. */
  32296. getZOffset(): number;
  32297. /**
  32298. * Enable or disable depth buffering
  32299. * @param enable defines the state to set
  32300. */
  32301. setDepthBuffer(enable: boolean): void;
  32302. /**
  32303. * Gets a boolean indicating if depth writing is enabled
  32304. * @returns the current depth writing state
  32305. */
  32306. getDepthWrite(): boolean;
  32307. /**
  32308. * Enable or disable depth writing
  32309. * @param enable defines the state to set
  32310. */
  32311. setDepthWrite(enable: boolean): void;
  32312. /**
  32313. * Enable or disable color writing
  32314. * @param enable defines the state to set
  32315. */
  32316. setColorWrite(enable: boolean): void;
  32317. /**
  32318. * Gets a boolean indicating if color writing is enabled
  32319. * @returns the current color writing state
  32320. */
  32321. getColorWrite(): boolean;
  32322. /**
  32323. * Sets alpha constants used by some alpha blending modes
  32324. * @param r defines the red component
  32325. * @param g defines the green component
  32326. * @param b defines the blue component
  32327. * @param a defines the alpha component
  32328. */
  32329. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  32330. /**
  32331. * Sets the current alpha mode
  32332. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  32333. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  32334. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32335. */
  32336. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  32337. /**
  32338. * Gets the current alpha mode
  32339. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32340. * @returns the current alpha mode
  32341. */
  32342. getAlphaMode(): number;
  32343. /**
  32344. * Sets the current alpha equation
  32345. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  32346. */
  32347. setAlphaEquation(equation: number): void;
  32348. /**
  32349. * Gets the current alpha equation.
  32350. * @returns the current alpha equation
  32351. */
  32352. getAlphaEquation(): number;
  32353. /**
  32354. * Gets a boolean indicating if stencil buffer is enabled
  32355. * @returns the current stencil buffer state
  32356. */
  32357. getStencilBuffer(): boolean;
  32358. /**
  32359. * Enable or disable the stencil buffer
  32360. * @param enable defines if the stencil buffer must be enabled or disabled
  32361. */
  32362. setStencilBuffer(enable: boolean): void;
  32363. /**
  32364. * Gets the current stencil mask
  32365. * @returns a number defining the new stencil mask to use
  32366. */
  32367. getStencilMask(): number;
  32368. /**
  32369. * Sets the current stencil mask
  32370. * @param mask defines the new stencil mask to use
  32371. */
  32372. setStencilMask(mask: number): void;
  32373. /**
  32374. * Gets the current stencil function
  32375. * @returns a number defining the stencil function to use
  32376. */
  32377. getStencilFunction(): number;
  32378. /**
  32379. * Gets the current stencil reference value
  32380. * @returns a number defining the stencil reference value to use
  32381. */
  32382. getStencilFunctionReference(): number;
  32383. /**
  32384. * Gets the current stencil mask
  32385. * @returns a number defining the stencil mask to use
  32386. */
  32387. getStencilFunctionMask(): number;
  32388. /**
  32389. * Sets the current stencil function
  32390. * @param stencilFunc defines the new stencil function to use
  32391. */
  32392. setStencilFunction(stencilFunc: number): void;
  32393. /**
  32394. * Sets the current stencil reference
  32395. * @param reference defines the new stencil reference to use
  32396. */
  32397. setStencilFunctionReference(reference: number): void;
  32398. /**
  32399. * Sets the current stencil mask
  32400. * @param mask defines the new stencil mask to use
  32401. */
  32402. setStencilFunctionMask(mask: number): void;
  32403. /**
  32404. * Gets the current stencil operation when stencil fails
  32405. * @returns a number defining stencil operation to use when stencil fails
  32406. */
  32407. getStencilOperationFail(): number;
  32408. /**
  32409. * Gets the current stencil operation when depth fails
  32410. * @returns a number defining stencil operation to use when depth fails
  32411. */
  32412. getStencilOperationDepthFail(): number;
  32413. /**
  32414. * Gets the current stencil operation when stencil passes
  32415. * @returns a number defining stencil operation to use when stencil passes
  32416. */
  32417. getStencilOperationPass(): number;
  32418. /**
  32419. * Sets the stencil operation to use when stencil fails
  32420. * @param operation defines the stencil operation to use when stencil fails
  32421. */
  32422. setStencilOperationFail(operation: number): void;
  32423. /**
  32424. * Sets the stencil operation to use when depth fails
  32425. * @param operation defines the stencil operation to use when depth fails
  32426. */
  32427. setStencilOperationDepthFail(operation: number): void;
  32428. /**
  32429. * Sets the stencil operation to use when stencil passes
  32430. * @param operation defines the stencil operation to use when stencil passes
  32431. */
  32432. setStencilOperationPass(operation: number): void;
  32433. /**
  32434. * Sets a boolean indicating if the dithering state is enabled or disabled
  32435. * @param value defines the dithering state
  32436. */
  32437. setDitheringState(value: boolean): void;
  32438. /**
  32439. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  32440. * @param value defines the rasterizer state
  32441. */
  32442. setRasterizerState(value: boolean): void;
  32443. /**
  32444. * Gets the current depth function
  32445. * @returns a number defining the depth function
  32446. */
  32447. getDepthFunction(): Nullable<number>;
  32448. /**
  32449. * Sets the current depth function
  32450. * @param depthFunc defines the function to use
  32451. */
  32452. setDepthFunction(depthFunc: number): void;
  32453. /**
  32454. * Sets the current depth function to GREATER
  32455. */
  32456. setDepthFunctionToGreater(): void;
  32457. /**
  32458. * Sets the current depth function to GEQUAL
  32459. */
  32460. setDepthFunctionToGreaterOrEqual(): void;
  32461. /**
  32462. * Sets the current depth function to LESS
  32463. */
  32464. setDepthFunctionToLess(): void;
  32465. /**
  32466. * Sets the current depth function to LEQUAL
  32467. */
  32468. setDepthFunctionToLessOrEqual(): void;
  32469. private _cachedStencilBuffer;
  32470. private _cachedStencilFunction;
  32471. private _cachedStencilMask;
  32472. private _cachedStencilOperationPass;
  32473. private _cachedStencilOperationFail;
  32474. private _cachedStencilOperationDepthFail;
  32475. private _cachedStencilReference;
  32476. /**
  32477. * Caches the the state of the stencil buffer
  32478. */
  32479. cacheStencilState(): void;
  32480. /**
  32481. * Restores the state of the stencil buffer
  32482. */
  32483. restoreStencilState(): void;
  32484. /**
  32485. * Directly set the WebGL Viewport
  32486. * @param x defines the x coordinate of the viewport (in screen space)
  32487. * @param y defines the y coordinate of the viewport (in screen space)
  32488. * @param width defines the width of the viewport (in screen space)
  32489. * @param height defines the height of the viewport (in screen space)
  32490. * @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
  32491. */
  32492. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  32493. /**
  32494. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  32495. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  32496. * @param y defines the y-coordinate of the corner of the clear rectangle
  32497. * @param width defines the width of the clear rectangle
  32498. * @param height defines the height of the clear rectangle
  32499. * @param clearColor defines the clear color
  32500. */
  32501. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  32502. /**
  32503. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  32504. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  32505. * @param y defines the y-coordinate of the corner of the clear rectangle
  32506. * @param width defines the width of the clear rectangle
  32507. * @param height defines the height of the clear rectangle
  32508. */
  32509. enableScissor(x: number, y: number, width: number, height: number): void;
  32510. /**
  32511. * Disable previously set scissor test rectangle
  32512. */
  32513. disableScissor(): void;
  32514. /**
  32515. * Initializes a webVR display and starts listening to display change events
  32516. * The onVRDisplayChangedObservable will be notified upon these changes
  32517. * @returns The onVRDisplayChangedObservable
  32518. */
  32519. initWebVR(): Observable<IDisplayChangedEventArgs>;
  32520. /** @hidden */
  32521. _prepareVRComponent(): void;
  32522. /** @hidden */
  32523. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  32524. /** @hidden */
  32525. _submitVRFrame(): void;
  32526. /**
  32527. * Call this function to leave webVR mode
  32528. * Will do nothing if webVR is not supported or if there is no webVR device
  32529. * @see http://doc.babylonjs.com/how_to/webvr_camera
  32530. */
  32531. disableVR(): void;
  32532. /**
  32533. * Gets a boolean indicating that the system is in VR mode and is presenting
  32534. * @returns true if VR mode is engaged
  32535. */
  32536. isVRPresenting(): boolean;
  32537. /** @hidden */
  32538. _requestVRFrame(): void;
  32539. /** @hidden */
  32540. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  32541. /**
  32542. * Gets the source code of the vertex shader associated with a specific webGL program
  32543. * @param program defines the program to use
  32544. * @returns a string containing the source code of the vertex shader associated with the program
  32545. */
  32546. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  32547. /**
  32548. * Gets the source code of the fragment shader associated with a specific webGL program
  32549. * @param program defines the program to use
  32550. * @returns a string containing the source code of the fragment shader associated with the program
  32551. */
  32552. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  32553. /**
  32554. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32555. * @param x defines the x coordinate of the rectangle where pixels must be read
  32556. * @param y defines the y coordinate of the rectangle where pixels must be read
  32557. * @param width defines the width of the rectangle where pixels must be read
  32558. * @param height defines the height of the rectangle where pixels must be read
  32559. * @returns a Uint8Array containing RGBA colors
  32560. */
  32561. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  32562. /**
  32563. * Sets a depth stencil texture from a render target to the according uniform.
  32564. * @param channel The texture channel
  32565. * @param uniform The uniform to set
  32566. * @param texture The render target texture containing the depth stencil texture to apply
  32567. */
  32568. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  32569. /**
  32570. * Sets a texture to the webGL context from a postprocess
  32571. * @param channel defines the channel to use
  32572. * @param postProcess defines the source postprocess
  32573. */
  32574. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  32575. /**
  32576. * Binds the output of the passed in post process to the texture channel specified
  32577. * @param channel The channel the texture should be bound to
  32578. * @param postProcess The post process which's output should be bound
  32579. */
  32580. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  32581. /** @hidden */
  32582. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  32583. protected _rebuildBuffers(): void;
  32584. _renderLoop(): void;
  32585. /**
  32586. * Toggle full screen mode
  32587. * @param requestPointerLock defines if a pointer lock should be requested from the user
  32588. */
  32589. switchFullscreen(requestPointerLock: boolean): void;
  32590. /**
  32591. * Enters full screen mode
  32592. * @param requestPointerLock defines if a pointer lock should be requested from the user
  32593. */
  32594. enterFullscreen(requestPointerLock: boolean): void;
  32595. /**
  32596. * Exits full screen mode
  32597. */
  32598. exitFullscreen(): void;
  32599. /**
  32600. * Enters Pointerlock mode
  32601. */
  32602. enterPointerlock(): void;
  32603. /**
  32604. * Exits Pointerlock mode
  32605. */
  32606. exitPointerlock(): void;
  32607. /**
  32608. * Begin a new frame
  32609. */
  32610. beginFrame(): void;
  32611. /**
  32612. * Enf the current frame
  32613. */
  32614. endFrame(): void;
  32615. resize(): void;
  32616. /**
  32617. * Set the compressed texture format to use, based on the formats you have, and the formats
  32618. * supported by the hardware / browser.
  32619. *
  32620. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  32621. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  32622. * to API arguments needed to compressed textures. This puts the burden on the container
  32623. * generator to house the arcane code for determining these for current & future formats.
  32624. *
  32625. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  32626. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  32627. *
  32628. * Note: The result of this call is not taken into account when a texture is base64.
  32629. *
  32630. * @param formatsAvailable defines the list of those format families you have created
  32631. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  32632. *
  32633. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  32634. * @returns The extension selected.
  32635. */
  32636. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  32637. /**
  32638. * Force a specific size of the canvas
  32639. * @param width defines the new canvas' width
  32640. * @param height defines the new canvas' height
  32641. */
  32642. setSize(width: number, height: number): void;
  32643. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  32644. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32645. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32646. _releaseTexture(texture: InternalTexture): void;
  32647. /**
  32648. * @hidden
  32649. * Rescales a texture
  32650. * @param source input texutre
  32651. * @param destination destination texture
  32652. * @param scene scene to use to render the resize
  32653. * @param internalFormat format to use when resizing
  32654. * @param onComplete callback to be called when resize has completed
  32655. */
  32656. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32657. /**
  32658. * Gets the current framerate
  32659. * @returns a number representing the framerate
  32660. */
  32661. getFps(): number;
  32662. /**
  32663. * Gets the time spent between current and previous frame
  32664. * @returns a number representing the delta time in ms
  32665. */
  32666. getDeltaTime(): number;
  32667. private _measureFps;
  32668. /**
  32669. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  32670. * @param renderTarget The render target to set the frame buffer for
  32671. */
  32672. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  32673. /**
  32674. * Update a dynamic index buffer
  32675. * @param indexBuffer defines the target index buffer
  32676. * @param indices defines the data to update
  32677. * @param offset defines the offset in the target index buffer where update should start
  32678. */
  32679. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  32680. /**
  32681. * Creates a new render target texture
  32682. * @param size defines the size of the texture
  32683. * @param options defines the options used to create the texture
  32684. * @returns a new render target texture stored in an InternalTexture
  32685. */
  32686. createRenderTargetTexture(size: number | {
  32687. width: number;
  32688. height: number;
  32689. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  32690. /**
  32691. * Updates the sample count of a render target texture
  32692. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  32693. * @param texture defines the texture to update
  32694. * @param samples defines the sample count to set
  32695. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  32696. */
  32697. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  32698. /** @hidden */
  32699. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  32700. dispose(): void;
  32701. private _disableTouchAction;
  32702. /**
  32703. * Display the loading screen
  32704. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32705. */
  32706. displayLoadingUI(): void;
  32707. /**
  32708. * Hide the loading screen
  32709. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32710. */
  32711. hideLoadingUI(): void;
  32712. /**
  32713. * Gets the current loading screen object
  32714. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32715. */
  32716. /**
  32717. * Sets the current loading screen object
  32718. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32719. */
  32720. loadingScreen: ILoadingScreen;
  32721. /**
  32722. * Sets the current loading screen text
  32723. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32724. */
  32725. loadingUIText: string;
  32726. /**
  32727. * Sets the current loading screen background color
  32728. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32729. */
  32730. loadingUIBackgroundColor: string;
  32731. /** Pointerlock and fullscreen */
  32732. /**
  32733. * Ask the browser to promote the current element to pointerlock mode
  32734. * @param element defines the DOM element to promote
  32735. */
  32736. static _RequestPointerlock(element: HTMLElement): void;
  32737. /**
  32738. * Asks the browser to exit pointerlock mode
  32739. */
  32740. static _ExitPointerlock(): void;
  32741. /**
  32742. * Ask the browser to promote the current element to fullscreen rendering mode
  32743. * @param element defines the DOM element to promote
  32744. */
  32745. static _RequestFullscreen(element: HTMLElement): void;
  32746. /**
  32747. * Asks the browser to exit fullscreen mode
  32748. */
  32749. static _ExitFullscreen(): void;
  32750. }
  32751. }
  32752. declare module "babylonjs/Engines/engineStore" {
  32753. import { Nullable } from "babylonjs/types";
  32754. import { Engine } from "babylonjs/Engines/engine";
  32755. import { Scene } from "babylonjs/scene";
  32756. /**
  32757. * The engine store class is responsible to hold all the instances of Engine and Scene created
  32758. * during the life time of the application.
  32759. */
  32760. export class EngineStore {
  32761. /** Gets the list of created engines */
  32762. static Instances: import("babylonjs/Engines/engine").Engine[];
  32763. /** @hidden */
  32764. static _LastCreatedScene: Nullable<Scene>;
  32765. /**
  32766. * Gets the latest created engine
  32767. */
  32768. static readonly LastCreatedEngine: Nullable<Engine>;
  32769. /**
  32770. * Gets the latest created scene
  32771. */
  32772. static readonly LastCreatedScene: Nullable<Scene>;
  32773. /**
  32774. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32775. * @ignorenaming
  32776. */
  32777. static UseFallbackTexture: boolean;
  32778. /**
  32779. * Texture content used if a texture cannot loaded
  32780. * @ignorenaming
  32781. */
  32782. static FallbackTexture: string;
  32783. }
  32784. }
  32785. declare module "babylonjs/Misc/promise" {
  32786. /**
  32787. * Helper class that provides a small promise polyfill
  32788. */
  32789. export class PromisePolyfill {
  32790. /**
  32791. * Static function used to check if the polyfill is required
  32792. * If this is the case then the function will inject the polyfill to window.Promise
  32793. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  32794. */
  32795. static Apply(force?: boolean): void;
  32796. }
  32797. }
  32798. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  32799. /**
  32800. * Interface for screenshot methods with describe argument called `size` as object with options
  32801. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  32802. */
  32803. export interface IScreenshotSize {
  32804. /**
  32805. * number in pixels for canvas height
  32806. */
  32807. height?: number;
  32808. /**
  32809. * multiplier allowing render at a higher or lower resolution
  32810. * If value is defined then height and width will be ignored and taken from camera
  32811. */
  32812. precision?: number;
  32813. /**
  32814. * number in pixels for canvas width
  32815. */
  32816. width?: number;
  32817. }
  32818. }
  32819. declare module "babylonjs/Misc/tools" {
  32820. import { Nullable, float } from "babylonjs/types";
  32821. import { DomManagement } from "babylonjs/Misc/domManagement";
  32822. import { WebRequest } from "babylonjs/Misc/webRequest";
  32823. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  32824. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32825. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  32826. import { Camera } from "babylonjs/Cameras/camera";
  32827. import { Engine } from "babylonjs/Engines/engine";
  32828. interface IColor4Like {
  32829. r: float;
  32830. g: float;
  32831. b: float;
  32832. a: float;
  32833. }
  32834. /**
  32835. * Class containing a set of static utilities functions
  32836. */
  32837. export class Tools {
  32838. /**
  32839. * Gets or sets the base URL to use to load assets
  32840. */
  32841. static BaseUrl: string;
  32842. /**
  32843. * Enable/Disable Custom HTTP Request Headers globally.
  32844. * default = false
  32845. * @see CustomRequestHeaders
  32846. */
  32847. static UseCustomRequestHeaders: boolean;
  32848. /**
  32849. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  32850. * i.e. when loading files, where the server/service expects an Authorization header
  32851. */
  32852. static CustomRequestHeaders: {
  32853. [key: string]: string;
  32854. };
  32855. /**
  32856. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  32857. */
  32858. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  32859. /**
  32860. * Default behaviour for cors in the application.
  32861. * It can be a string if the expected behavior is identical in the entire app.
  32862. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  32863. */
  32864. static CorsBehavior: string | ((url: string | string[]) => string);
  32865. /**
  32866. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32867. * @ignorenaming
  32868. */
  32869. static UseFallbackTexture: boolean;
  32870. /**
  32871. * Use this object to register external classes like custom textures or material
  32872. * to allow the laoders to instantiate them
  32873. */
  32874. static RegisteredExternalClasses: {
  32875. [key: string]: Object;
  32876. };
  32877. /**
  32878. * Texture content used if a texture cannot loaded
  32879. * @ignorenaming
  32880. */
  32881. static fallbackTexture: string;
  32882. /**
  32883. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  32884. * @param u defines the coordinate on X axis
  32885. * @param v defines the coordinate on Y axis
  32886. * @param width defines the width of the source data
  32887. * @param height defines the height of the source data
  32888. * @param pixels defines the source byte array
  32889. * @param color defines the output color
  32890. */
  32891. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  32892. /**
  32893. * Interpolates between a and b via alpha
  32894. * @param a The lower value (returned when alpha = 0)
  32895. * @param b The upper value (returned when alpha = 1)
  32896. * @param alpha The interpolation-factor
  32897. * @return The mixed value
  32898. */
  32899. static Mix(a: number, b: number, alpha: number): number;
  32900. /**
  32901. * Tries to instantiate a new object from a given class name
  32902. * @param className defines the class name to instantiate
  32903. * @returns the new object or null if the system was not able to do the instantiation
  32904. */
  32905. static Instantiate(className: string): any;
  32906. /**
  32907. * Provides a slice function that will work even on IE
  32908. * @param data defines the array to slice
  32909. * @param start defines the start of the data (optional)
  32910. * @param end defines the end of the data (optional)
  32911. * @returns the new sliced array
  32912. */
  32913. static Slice<T>(data: T, start?: number, end?: number): T;
  32914. /**
  32915. * Polyfill for setImmediate
  32916. * @param action defines the action to execute after the current execution block
  32917. */
  32918. static SetImmediate(action: () => void): void;
  32919. /**
  32920. * Function indicating if a number is an exponent of 2
  32921. * @param value defines the value to test
  32922. * @returns true if the value is an exponent of 2
  32923. */
  32924. static IsExponentOfTwo(value: number): boolean;
  32925. private static _tmpFloatArray;
  32926. /**
  32927. * Returns the nearest 32-bit single precision float representation of a Number
  32928. * @param value A Number. If the parameter is of a different type, it will get converted
  32929. * to a number or to NaN if it cannot be converted
  32930. * @returns number
  32931. */
  32932. static FloatRound(value: number): number;
  32933. /**
  32934. * Extracts the filename from a path
  32935. * @param path defines the path to use
  32936. * @returns the filename
  32937. */
  32938. static GetFilename(path: string): string;
  32939. /**
  32940. * Extracts the "folder" part of a path (everything before the filename).
  32941. * @param uri The URI to extract the info from
  32942. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  32943. * @returns The "folder" part of the path
  32944. */
  32945. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  32946. /**
  32947. * Extracts text content from a DOM element hierarchy
  32948. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  32949. */
  32950. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  32951. /**
  32952. * Convert an angle in radians to degrees
  32953. * @param angle defines the angle to convert
  32954. * @returns the angle in degrees
  32955. */
  32956. static ToDegrees(angle: number): number;
  32957. /**
  32958. * Convert an angle in degrees to radians
  32959. * @param angle defines the angle to convert
  32960. * @returns the angle in radians
  32961. */
  32962. static ToRadians(angle: number): number;
  32963. /**
  32964. * Encode a buffer to a base64 string
  32965. * @param buffer defines the buffer to encode
  32966. * @returns the encoded string
  32967. */
  32968. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  32969. /**
  32970. * Returns an array if obj is not an array
  32971. * @param obj defines the object to evaluate as an array
  32972. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  32973. * @returns either obj directly if obj is an array or a new array containing obj
  32974. */
  32975. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32976. /**
  32977. * Gets the pointer prefix to use
  32978. * @returns "pointer" if touch is enabled. Else returns "mouse"
  32979. */
  32980. static GetPointerPrefix(): string;
  32981. /**
  32982. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  32983. * @param url define the url we are trying
  32984. * @param element define the dom element where to configure the cors policy
  32985. */
  32986. static SetCorsBehavior(url: string | string[], element: {
  32987. crossOrigin: string | null;
  32988. }): void;
  32989. /**
  32990. * Removes unwanted characters from an url
  32991. * @param url defines the url to clean
  32992. * @returns the cleaned url
  32993. */
  32994. static CleanUrl(url: string): string;
  32995. /**
  32996. * Gets or sets a function used to pre-process url before using them to load assets
  32997. */
  32998. static PreprocessUrl: (url: string) => string;
  32999. /**
  33000. * Loads an image as an HTMLImageElement.
  33001. * @param input url string, ArrayBuffer, or Blob to load
  33002. * @param onLoad callback called when the image successfully loads
  33003. * @param onError callback called when the image fails to load
  33004. * @param offlineProvider offline provider for caching
  33005. * @returns the HTMLImageElement of the loaded image
  33006. */
  33007. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  33008. /**
  33009. * Loads a file
  33010. * @param url url string, ArrayBuffer, or Blob to load
  33011. * @param onSuccess callback called when the file successfully loads
  33012. * @param onProgress callback called while file is loading (if the server supports this mode)
  33013. * @param offlineProvider defines the offline provider for caching
  33014. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  33015. * @param onError callback called when the file fails to load
  33016. * @returns a file request object
  33017. */
  33018. 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;
  33019. /**
  33020. * Loads a file from a url
  33021. * @param url the file url to load
  33022. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  33023. */
  33024. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  33025. /**
  33026. * Load a script (identified by an url). When the url returns, the
  33027. * content of this file is added into a new script element, attached to the DOM (body element)
  33028. * @param scriptUrl defines the url of the script to laod
  33029. * @param onSuccess defines the callback called when the script is loaded
  33030. * @param onError defines the callback to call if an error occurs
  33031. * @param scriptId defines the id of the script element
  33032. */
  33033. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  33034. /**
  33035. * Load an asynchronous script (identified by an url). When the url returns, the
  33036. * content of this file is added into a new script element, attached to the DOM (body element)
  33037. * @param scriptUrl defines the url of the script to laod
  33038. * @param scriptId defines the id of the script element
  33039. * @returns a promise request object
  33040. */
  33041. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  33042. /**
  33043. * Loads a file from a blob
  33044. * @param fileToLoad defines the blob to use
  33045. * @param callback defines the callback to call when data is loaded
  33046. * @param progressCallback defines the callback to call during loading process
  33047. * @returns a file request object
  33048. */
  33049. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  33050. /**
  33051. * Loads a file
  33052. * @param fileToLoad defines the file to load
  33053. * @param callback defines the callback to call when data is loaded
  33054. * @param progressCallBack defines the callback to call during loading process
  33055. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  33056. * @returns a file request object
  33057. */
  33058. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  33059. /**
  33060. * Creates a data url from a given string content
  33061. * @param content defines the content to convert
  33062. * @returns the new data url link
  33063. */
  33064. static FileAsURL(content: string): string;
  33065. /**
  33066. * Format the given number to a specific decimal format
  33067. * @param value defines the number to format
  33068. * @param decimals defines the number of decimals to use
  33069. * @returns the formatted string
  33070. */
  33071. static Format(value: number, decimals?: number): string;
  33072. /**
  33073. * Tries to copy an object by duplicating every property
  33074. * @param source defines the source object
  33075. * @param destination defines the target object
  33076. * @param doNotCopyList defines a list of properties to avoid
  33077. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  33078. */
  33079. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  33080. /**
  33081. * Gets a boolean indicating if the given object has no own property
  33082. * @param obj defines the object to test
  33083. * @returns true if object has no own property
  33084. */
  33085. static IsEmpty(obj: any): boolean;
  33086. /**
  33087. * Function used to register events at window level
  33088. * @param windowElement defines the Window object to use
  33089. * @param events defines the events to register
  33090. */
  33091. static RegisterTopRootEvents(windowElement: Window, events: {
  33092. name: string;
  33093. handler: Nullable<(e: FocusEvent) => any>;
  33094. }[]): void;
  33095. /**
  33096. * Function used to unregister events from window level
  33097. * @param windowElement defines the Window object to use
  33098. * @param events defines the events to unregister
  33099. */
  33100. static UnregisterTopRootEvents(windowElement: Window, events: {
  33101. name: string;
  33102. handler: Nullable<(e: FocusEvent) => any>;
  33103. }[]): void;
  33104. /**
  33105. * @ignore
  33106. */
  33107. static _ScreenshotCanvas: HTMLCanvasElement;
  33108. /**
  33109. * Dumps the current bound framebuffer
  33110. * @param width defines the rendering width
  33111. * @param height defines the rendering height
  33112. * @param engine defines the hosting engine
  33113. * @param successCallback defines the callback triggered once the data are available
  33114. * @param mimeType defines the mime type of the result
  33115. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  33116. */
  33117. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33118. /**
  33119. * Converts the canvas data to blob.
  33120. * This acts as a polyfill for browsers not supporting the to blob function.
  33121. * @param canvas Defines the canvas to extract the data from
  33122. * @param successCallback Defines the callback triggered once the data are available
  33123. * @param mimeType Defines the mime type of the result
  33124. */
  33125. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  33126. /**
  33127. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  33128. * @param successCallback defines the callback triggered once the data are available
  33129. * @param mimeType defines the mime type of the result
  33130. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  33131. */
  33132. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33133. /**
  33134. * Downloads a blob in the browser
  33135. * @param blob defines the blob to download
  33136. * @param fileName defines the name of the downloaded file
  33137. */
  33138. static Download(blob: Blob, fileName: string): void;
  33139. /**
  33140. * Captures a screenshot of the current rendering
  33141. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33142. * @param engine defines the rendering engine
  33143. * @param camera defines the source camera
  33144. * @param size This parameter can be set to a single number or to an object with the
  33145. * following (optional) properties: precision, width, height. If a single number is passed,
  33146. * it will be used for both width and height. If an object is passed, the screenshot size
  33147. * will be derived from the parameters. The precision property is a multiplier allowing
  33148. * rendering at a higher or lower resolution
  33149. * @param successCallback defines the callback receives a single parameter which contains the
  33150. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33151. * src parameter of an <img> to display it
  33152. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33153. * Check your browser for supported MIME types
  33154. */
  33155. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  33156. /**
  33157. * Captures a screenshot of the current rendering
  33158. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33159. * @param engine defines the rendering engine
  33160. * @param camera defines the source camera
  33161. * @param size This parameter can be set to a single number or to an object with the
  33162. * following (optional) properties: precision, width, height. If a single number is passed,
  33163. * it will be used for both width and height. If an object is passed, the screenshot size
  33164. * will be derived from the parameters. The precision property is a multiplier allowing
  33165. * rendering at a higher or lower resolution
  33166. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33167. * Check your browser for supported MIME types
  33168. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33169. * to the src parameter of an <img> to display it
  33170. */
  33171. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  33172. /**
  33173. * Generates an image screenshot from the specified camera.
  33174. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33175. * @param engine The engine to use for rendering
  33176. * @param camera The camera to use for rendering
  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 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 The MIME type of the screenshot image (default: image/png).
  33186. * Check your browser for supported MIME types
  33187. * @param samples Texture samples (default: 1)
  33188. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33189. * @param fileName A name for for the downloaded file.
  33190. */
  33191. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  33192. /**
  33193. * Generates an image screenshot from the specified camera.
  33194. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33195. * @param engine The engine to use for rendering
  33196. * @param camera The camera to use for rendering
  33197. * @param size This parameter can be set to a single number or to an object with the
  33198. * following (optional) properties: precision, width, height. If a single number is passed,
  33199. * it will be used for both width and height. If an object is passed, the screenshot size
  33200. * will be derived from the parameters. The precision property is a multiplier allowing
  33201. * rendering at a higher or lower resolution
  33202. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33203. * Check your browser for supported MIME types
  33204. * @param samples Texture samples (default: 1)
  33205. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33206. * @param fileName A name for for the downloaded file.
  33207. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33208. * to the src parameter of an <img> to display it
  33209. */
  33210. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  33211. /**
  33212. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  33213. * Be aware Math.random() could cause collisions, but:
  33214. * "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"
  33215. * @returns a pseudo random id
  33216. */
  33217. static RandomId(): string;
  33218. /**
  33219. * Test if the given uri is a base64 string
  33220. * @param uri The uri to test
  33221. * @return True if the uri is a base64 string or false otherwise
  33222. */
  33223. static IsBase64(uri: string): boolean;
  33224. /**
  33225. * Decode the given base64 uri.
  33226. * @param uri The uri to decode
  33227. * @return The decoded base64 data.
  33228. */
  33229. static DecodeBase64(uri: string): ArrayBuffer;
  33230. /**
  33231. * Gets the absolute url.
  33232. * @param url the input url
  33233. * @return the absolute url
  33234. */
  33235. static GetAbsoluteUrl(url: string): string;
  33236. /**
  33237. * No log
  33238. */
  33239. static readonly NoneLogLevel: number;
  33240. /**
  33241. * Only message logs
  33242. */
  33243. static readonly MessageLogLevel: number;
  33244. /**
  33245. * Only warning logs
  33246. */
  33247. static readonly WarningLogLevel: number;
  33248. /**
  33249. * Only error logs
  33250. */
  33251. static readonly ErrorLogLevel: number;
  33252. /**
  33253. * All logs
  33254. */
  33255. static readonly AllLogLevel: number;
  33256. /**
  33257. * Gets a value indicating the number of loading errors
  33258. * @ignorenaming
  33259. */
  33260. static readonly errorsCount: number;
  33261. /**
  33262. * Callback called when a new log is added
  33263. */
  33264. static OnNewCacheEntry: (entry: string) => void;
  33265. /**
  33266. * Log a message to the console
  33267. * @param message defines the message to log
  33268. */
  33269. static Log(message: string): void;
  33270. /**
  33271. * Write a warning message to the console
  33272. * @param message defines the message to log
  33273. */
  33274. static Warn(message: string): void;
  33275. /**
  33276. * Write an error message to the console
  33277. * @param message defines the message to log
  33278. */
  33279. static Error(message: string): void;
  33280. /**
  33281. * Gets current log cache (list of logs)
  33282. */
  33283. static readonly LogCache: string;
  33284. /**
  33285. * Clears the log cache
  33286. */
  33287. static ClearLogCache(): void;
  33288. /**
  33289. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  33290. */
  33291. static LogLevels: number;
  33292. /**
  33293. * Checks if the window object exists
  33294. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  33295. */
  33296. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  33297. /**
  33298. * No performance log
  33299. */
  33300. static readonly PerformanceNoneLogLevel: number;
  33301. /**
  33302. * Use user marks to log performance
  33303. */
  33304. static readonly PerformanceUserMarkLogLevel: number;
  33305. /**
  33306. * Log performance to the console
  33307. */
  33308. static readonly PerformanceConsoleLogLevel: number;
  33309. private static _performance;
  33310. /**
  33311. * Sets the current performance log level
  33312. */
  33313. static PerformanceLogLevel: number;
  33314. private static _StartPerformanceCounterDisabled;
  33315. private static _EndPerformanceCounterDisabled;
  33316. private static _StartUserMark;
  33317. private static _EndUserMark;
  33318. private static _StartPerformanceConsole;
  33319. private static _EndPerformanceConsole;
  33320. /**
  33321. * Starts a performance counter
  33322. */
  33323. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33324. /**
  33325. * Ends a specific performance coutner
  33326. */
  33327. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33328. /**
  33329. * Gets either window.performance.now() if supported or Date.now() else
  33330. */
  33331. static readonly Now: number;
  33332. /**
  33333. * This method will return the name of the class used to create the instance of the given object.
  33334. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  33335. * @param object the object to get the class name from
  33336. * @param isType defines if the object is actually a type
  33337. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  33338. */
  33339. static GetClassName(object: any, isType?: boolean): string;
  33340. /**
  33341. * Gets the first element of an array satisfying a given predicate
  33342. * @param array defines the array to browse
  33343. * @param predicate defines the predicate to use
  33344. * @returns null if not found or the element
  33345. */
  33346. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  33347. /**
  33348. * This method will return the name of the full name of the class, including its owning module (if any).
  33349. * 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).
  33350. * @param object the object to get the class name from
  33351. * @param isType defines if the object is actually a type
  33352. * @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.
  33353. * @ignorenaming
  33354. */
  33355. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  33356. /**
  33357. * Returns a promise that resolves after the given amount of time.
  33358. * @param delay Number of milliseconds to delay
  33359. * @returns Promise that resolves after the given amount of time
  33360. */
  33361. static DelayAsync(delay: number): Promise<void>;
  33362. }
  33363. /**
  33364. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  33365. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  33366. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  33367. * @param name The name of the class, case should be preserved
  33368. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  33369. */
  33370. export function className(name: string, module?: string): (target: Object) => void;
  33371. /**
  33372. * An implementation of a loop for asynchronous functions.
  33373. */
  33374. export class AsyncLoop {
  33375. /**
  33376. * Defines the number of iterations for the loop
  33377. */
  33378. iterations: number;
  33379. /**
  33380. * Defines the current index of the loop.
  33381. */
  33382. index: number;
  33383. private _done;
  33384. private _fn;
  33385. private _successCallback;
  33386. /**
  33387. * Constructor.
  33388. * @param iterations the number of iterations.
  33389. * @param func the function to run each iteration
  33390. * @param successCallback the callback that will be called upon succesful execution
  33391. * @param offset starting offset.
  33392. */
  33393. constructor(
  33394. /**
  33395. * Defines the number of iterations for the loop
  33396. */
  33397. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  33398. /**
  33399. * Execute the next iteration. Must be called after the last iteration was finished.
  33400. */
  33401. executeNext(): void;
  33402. /**
  33403. * Break the loop and run the success callback.
  33404. */
  33405. breakLoop(): void;
  33406. /**
  33407. * Create and run an async loop.
  33408. * @param iterations the number of iterations.
  33409. * @param fn the function to run each iteration
  33410. * @param successCallback the callback that will be called upon succesful execution
  33411. * @param offset starting offset.
  33412. * @returns the created async loop object
  33413. */
  33414. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  33415. /**
  33416. * A for-loop that will run a given number of iterations synchronous and the rest async.
  33417. * @param iterations total number of iterations
  33418. * @param syncedIterations number of synchronous iterations in each async iteration.
  33419. * @param fn the function to call each iteration.
  33420. * @param callback a success call back that will be called when iterating stops.
  33421. * @param breakFunction a break condition (optional)
  33422. * @param timeout timeout settings for the setTimeout function. default - 0.
  33423. * @returns the created async loop object
  33424. */
  33425. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  33426. }
  33427. }
  33428. declare module "babylonjs/Misc/stringDictionary" {
  33429. import { Nullable } from "babylonjs/types";
  33430. /**
  33431. * This class implement a typical dictionary using a string as key and the generic type T as value.
  33432. * The underlying implementation relies on an associative array to ensure the best performances.
  33433. * The value can be anything including 'null' but except 'undefined'
  33434. */
  33435. export class StringDictionary<T> {
  33436. /**
  33437. * This will clear this dictionary and copy the content from the 'source' one.
  33438. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  33439. * @param source the dictionary to take the content from and copy to this dictionary
  33440. */
  33441. copyFrom(source: StringDictionary<T>): void;
  33442. /**
  33443. * Get a value based from its key
  33444. * @param key the given key to get the matching value from
  33445. * @return the value if found, otherwise undefined is returned
  33446. */
  33447. get(key: string): T | undefined;
  33448. /**
  33449. * Get a value from its key or add it if it doesn't exist.
  33450. * This method will ensure you that a given key/data will be present in the dictionary.
  33451. * @param key the given key to get the matching value from
  33452. * @param factory the factory that will create the value if the key is not present in the dictionary.
  33453. * The factory will only be invoked if there's no data for the given key.
  33454. * @return the value corresponding to the key.
  33455. */
  33456. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  33457. /**
  33458. * Get a value from its key if present in the dictionary otherwise add it
  33459. * @param key the key to get the value from
  33460. * @param val if there's no such key/value pair in the dictionary add it with this value
  33461. * @return the value corresponding to the key
  33462. */
  33463. getOrAdd(key: string, val: T): T;
  33464. /**
  33465. * Check if there's a given key in the dictionary
  33466. * @param key the key to check for
  33467. * @return true if the key is present, false otherwise
  33468. */
  33469. contains(key: string): boolean;
  33470. /**
  33471. * Add a new key and its corresponding value
  33472. * @param key the key to add
  33473. * @param value the value corresponding to the key
  33474. * @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
  33475. */
  33476. add(key: string, value: T): boolean;
  33477. /**
  33478. * Update a specific value associated to a key
  33479. * @param key defines the key to use
  33480. * @param value defines the value to store
  33481. * @returns true if the value was updated (or false if the key was not found)
  33482. */
  33483. set(key: string, value: T): boolean;
  33484. /**
  33485. * Get the element of the given key and remove it from the dictionary
  33486. * @param key defines the key to search
  33487. * @returns the value associated with the key or null if not found
  33488. */
  33489. getAndRemove(key: string): Nullable<T>;
  33490. /**
  33491. * Remove a key/value from the dictionary.
  33492. * @param key the key to remove
  33493. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  33494. */
  33495. remove(key: string): boolean;
  33496. /**
  33497. * Clear the whole content of the dictionary
  33498. */
  33499. clear(): void;
  33500. /**
  33501. * Gets the current count
  33502. */
  33503. readonly count: number;
  33504. /**
  33505. * Execute a callback on each key/val of the dictionary.
  33506. * Note that you can remove any element in this dictionary in the callback implementation
  33507. * @param callback the callback to execute on a given key/value pair
  33508. */
  33509. forEach(callback: (key: string, val: T) => void): void;
  33510. /**
  33511. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  33512. * If the callback returns null or undefined the method will iterate to the next key/value pair
  33513. * Note that you can remove any element in this dictionary in the callback implementation
  33514. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  33515. * @returns the first item
  33516. */
  33517. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  33518. private _count;
  33519. private _data;
  33520. }
  33521. }
  33522. declare module "babylonjs/Collisions/collisionCoordinator" {
  33523. import { Nullable } from "babylonjs/types";
  33524. import { Scene } from "babylonjs/scene";
  33525. import { Vector3 } from "babylonjs/Maths/math.vector";
  33526. import { Collider } from "babylonjs/Collisions/collider";
  33527. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33528. /** @hidden */
  33529. export interface ICollisionCoordinator {
  33530. createCollider(): Collider;
  33531. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33532. init(scene: Scene): void;
  33533. }
  33534. /** @hidden */
  33535. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  33536. private _scene;
  33537. private _scaledPosition;
  33538. private _scaledVelocity;
  33539. private _finalPosition;
  33540. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33541. createCollider(): Collider;
  33542. init(scene: Scene): void;
  33543. private _collideWithWorld;
  33544. }
  33545. }
  33546. declare module "babylonjs/Inputs/scene.inputManager" {
  33547. import { Nullable } from "babylonjs/types";
  33548. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33549. import { Vector2 } from "babylonjs/Maths/math.vector";
  33550. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33551. import { Scene } from "babylonjs/scene";
  33552. /**
  33553. * Class used to manage all inputs for the scene.
  33554. */
  33555. export class InputManager {
  33556. /** The distance in pixel that you have to move to prevent some events */
  33557. static DragMovementThreshold: number;
  33558. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  33559. static LongPressDelay: number;
  33560. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  33561. static DoubleClickDelay: number;
  33562. /** If you need to check double click without raising a single click at first click, enable this flag */
  33563. static ExclusiveDoubleClickMode: boolean;
  33564. private _wheelEventName;
  33565. private _onPointerMove;
  33566. private _onPointerDown;
  33567. private _onPointerUp;
  33568. private _initClickEvent;
  33569. private _initActionManager;
  33570. private _delayedSimpleClick;
  33571. private _delayedSimpleClickTimeout;
  33572. private _previousDelayedSimpleClickTimeout;
  33573. private _meshPickProceed;
  33574. private _previousButtonPressed;
  33575. private _currentPickResult;
  33576. private _previousPickResult;
  33577. private _totalPointersPressed;
  33578. private _doubleClickOccured;
  33579. private _pointerOverMesh;
  33580. private _pickedDownMesh;
  33581. private _pickedUpMesh;
  33582. private _pointerX;
  33583. private _pointerY;
  33584. private _unTranslatedPointerX;
  33585. private _unTranslatedPointerY;
  33586. private _startingPointerPosition;
  33587. private _previousStartingPointerPosition;
  33588. private _startingPointerTime;
  33589. private _previousStartingPointerTime;
  33590. private _pointerCaptures;
  33591. private _onKeyDown;
  33592. private _onKeyUp;
  33593. private _onCanvasFocusObserver;
  33594. private _onCanvasBlurObserver;
  33595. private _scene;
  33596. /**
  33597. * Creates a new InputManager
  33598. * @param scene defines the hosting scene
  33599. */
  33600. constructor(scene: Scene);
  33601. /**
  33602. * Gets the mesh that is currently under the pointer
  33603. */
  33604. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33605. /**
  33606. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  33607. */
  33608. readonly unTranslatedPointer: Vector2;
  33609. /**
  33610. * Gets or sets the current on-screen X position of the pointer
  33611. */
  33612. pointerX: number;
  33613. /**
  33614. * Gets or sets the current on-screen Y position of the pointer
  33615. */
  33616. pointerY: number;
  33617. private _updatePointerPosition;
  33618. private _processPointerMove;
  33619. private _setRayOnPointerInfo;
  33620. private _checkPrePointerObservable;
  33621. /**
  33622. * Use this method to simulate a pointer move on a mesh
  33623. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33624. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33625. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33626. */
  33627. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33628. /**
  33629. * Use this method to simulate a pointer down on a mesh
  33630. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33631. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33632. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33633. */
  33634. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33635. private _processPointerDown;
  33636. /** @hidden */
  33637. _isPointerSwiping(): boolean;
  33638. /**
  33639. * Use this method to simulate a pointer up on a mesh
  33640. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33641. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33642. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33643. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33644. */
  33645. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  33646. private _processPointerUp;
  33647. /**
  33648. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33649. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33650. * @returns true if the pointer was captured
  33651. */
  33652. isPointerCaptured(pointerId?: number): boolean;
  33653. /**
  33654. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33655. * @param attachUp defines if you want to attach events to pointerup
  33656. * @param attachDown defines if you want to attach events to pointerdown
  33657. * @param attachMove defines if you want to attach events to pointermove
  33658. */
  33659. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33660. /**
  33661. * Detaches all event handlers
  33662. */
  33663. detachControl(): void;
  33664. /**
  33665. * Force the value of meshUnderPointer
  33666. * @param mesh defines the mesh to use
  33667. */
  33668. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33669. /**
  33670. * Gets the mesh under the pointer
  33671. * @returns a Mesh or null if no mesh is under the pointer
  33672. */
  33673. getPointerOverMesh(): Nullable<AbstractMesh>;
  33674. }
  33675. }
  33676. declare module "babylonjs/Misc/uniqueIdGenerator" {
  33677. /**
  33678. * Helper class used to generate session unique ID
  33679. */
  33680. export class UniqueIdGenerator {
  33681. private static _UniqueIdCounter;
  33682. /**
  33683. * Gets an unique (relatively to the current scene) Id
  33684. */
  33685. static readonly UniqueId: number;
  33686. }
  33687. }
  33688. declare module "babylonjs/Animations/animationGroup" {
  33689. import { Animatable } from "babylonjs/Animations/animatable";
  33690. import { Animation } from "babylonjs/Animations/animation";
  33691. import { Scene, IDisposable } from "babylonjs/scene";
  33692. import { Observable } from "babylonjs/Misc/observable";
  33693. import { Nullable } from "babylonjs/types";
  33694. import "babylonjs/Animations/animatable";
  33695. /**
  33696. * This class defines the direct association between an animation and a target
  33697. */
  33698. export class TargetedAnimation {
  33699. /**
  33700. * Animation to perform
  33701. */
  33702. animation: Animation;
  33703. /**
  33704. * Target to animate
  33705. */
  33706. target: any;
  33707. /**
  33708. * Serialize the object
  33709. * @returns the JSON object representing the current entity
  33710. */
  33711. serialize(): any;
  33712. }
  33713. /**
  33714. * Use this class to create coordinated animations on multiple targets
  33715. */
  33716. export class AnimationGroup implements IDisposable {
  33717. /** The name of the animation group */
  33718. name: string;
  33719. private _scene;
  33720. private _targetedAnimations;
  33721. private _animatables;
  33722. private _from;
  33723. private _to;
  33724. private _isStarted;
  33725. private _isPaused;
  33726. private _speedRatio;
  33727. private _loopAnimation;
  33728. /**
  33729. * Gets or sets the unique id of the node
  33730. */
  33731. uniqueId: number;
  33732. /**
  33733. * This observable will notify when one animation have ended
  33734. */
  33735. onAnimationEndObservable: Observable<TargetedAnimation>;
  33736. /**
  33737. * Observer raised when one animation loops
  33738. */
  33739. onAnimationLoopObservable: Observable<TargetedAnimation>;
  33740. /**
  33741. * This observable will notify when all animations have ended.
  33742. */
  33743. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  33744. /**
  33745. * This observable will notify when all animations have paused.
  33746. */
  33747. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  33748. /**
  33749. * This observable will notify when all animations are playing.
  33750. */
  33751. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  33752. /**
  33753. * Gets the first frame
  33754. */
  33755. readonly from: number;
  33756. /**
  33757. * Gets the last frame
  33758. */
  33759. readonly to: number;
  33760. /**
  33761. * Define if the animations are started
  33762. */
  33763. readonly isStarted: boolean;
  33764. /**
  33765. * Gets a value indicating that the current group is playing
  33766. */
  33767. readonly isPlaying: boolean;
  33768. /**
  33769. * Gets or sets the speed ratio to use for all animations
  33770. */
  33771. /**
  33772. * Gets or sets the speed ratio to use for all animations
  33773. */
  33774. speedRatio: number;
  33775. /**
  33776. * Gets or sets if all animations should loop or not
  33777. */
  33778. loopAnimation: boolean;
  33779. /**
  33780. * Gets the targeted animations for this animation group
  33781. */
  33782. readonly targetedAnimations: Array<TargetedAnimation>;
  33783. /**
  33784. * returning the list of animatables controlled by this animation group.
  33785. */
  33786. readonly animatables: Array<Animatable>;
  33787. /**
  33788. * Instantiates a new Animation Group.
  33789. * This helps managing several animations at once.
  33790. * @see http://doc.babylonjs.com/how_to/group
  33791. * @param name Defines the name of the group
  33792. * @param scene Defines the scene the group belongs to
  33793. */
  33794. constructor(
  33795. /** The name of the animation group */
  33796. name: string, scene?: Nullable<Scene>);
  33797. /**
  33798. * Add an animation (with its target) in the group
  33799. * @param animation defines the animation we want to add
  33800. * @param target defines the target of the animation
  33801. * @returns the TargetedAnimation object
  33802. */
  33803. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  33804. /**
  33805. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  33806. * It can add constant keys at begin or end
  33807. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  33808. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  33809. * @returns the animation group
  33810. */
  33811. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  33812. /**
  33813. * Start all animations on given targets
  33814. * @param loop defines if animations must loop
  33815. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  33816. * @param from defines the from key (optional)
  33817. * @param to defines the to key (optional)
  33818. * @returns the current animation group
  33819. */
  33820. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  33821. /**
  33822. * Pause all animations
  33823. * @returns the animation group
  33824. */
  33825. pause(): AnimationGroup;
  33826. /**
  33827. * Play all animations to initial state
  33828. * This function will start() the animations if they were not started or will restart() them if they were paused
  33829. * @param loop defines if animations must loop
  33830. * @returns the animation group
  33831. */
  33832. play(loop?: boolean): AnimationGroup;
  33833. /**
  33834. * Reset all animations to initial state
  33835. * @returns the animation group
  33836. */
  33837. reset(): AnimationGroup;
  33838. /**
  33839. * Restart animations from key 0
  33840. * @returns the animation group
  33841. */
  33842. restart(): AnimationGroup;
  33843. /**
  33844. * Stop all animations
  33845. * @returns the animation group
  33846. */
  33847. stop(): AnimationGroup;
  33848. /**
  33849. * Set animation weight for all animatables
  33850. * @param weight defines the weight to use
  33851. * @return the animationGroup
  33852. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33853. */
  33854. setWeightForAllAnimatables(weight: number): AnimationGroup;
  33855. /**
  33856. * Synchronize and normalize all animatables with a source animatable
  33857. * @param root defines the root animatable to synchronize with
  33858. * @return the animationGroup
  33859. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33860. */
  33861. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  33862. /**
  33863. * Goes to a specific frame in this animation group
  33864. * @param frame the frame number to go to
  33865. * @return the animationGroup
  33866. */
  33867. goToFrame(frame: number): AnimationGroup;
  33868. /**
  33869. * Dispose all associated resources
  33870. */
  33871. dispose(): void;
  33872. private _checkAnimationGroupEnded;
  33873. /**
  33874. * Clone the current animation group and returns a copy
  33875. * @param newName defines the name of the new group
  33876. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  33877. * @returns the new aniamtion group
  33878. */
  33879. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  33880. /**
  33881. * Serializes the animationGroup to an object
  33882. * @returns Serialized object
  33883. */
  33884. serialize(): any;
  33885. /**
  33886. * Returns a new AnimationGroup object parsed from the source provided.
  33887. * @param parsedAnimationGroup defines the source
  33888. * @param scene defines the scene that will receive the animationGroup
  33889. * @returns a new AnimationGroup
  33890. */
  33891. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  33892. /**
  33893. * Returns the string "AnimationGroup"
  33894. * @returns "AnimationGroup"
  33895. */
  33896. getClassName(): string;
  33897. /**
  33898. * Creates a detailled string about the object
  33899. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  33900. * @returns a string representing the object
  33901. */
  33902. toString(fullDetails?: boolean): string;
  33903. }
  33904. }
  33905. declare module "babylonjs/scene" {
  33906. import { Nullable } from "babylonjs/types";
  33907. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33908. import { Observable } from "babylonjs/Misc/observable";
  33909. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  33910. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  33911. import { Geometry } from "babylonjs/Meshes/geometry";
  33912. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33913. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33914. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33915. import { Mesh } from "babylonjs/Meshes/mesh";
  33916. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33917. import { Bone } from "babylonjs/Bones/bone";
  33918. import { Skeleton } from "babylonjs/Bones/skeleton";
  33919. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33920. import { Camera } from "babylonjs/Cameras/camera";
  33921. import { AbstractScene } from "babylonjs/abstractScene";
  33922. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33923. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33924. import { Material } from "babylonjs/Materials/material";
  33925. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  33926. import { Effect } from "babylonjs/Materials/effect";
  33927. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  33928. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33929. import { Light } from "babylonjs/Lights/light";
  33930. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33931. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  33932. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  33933. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  33934. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33935. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  33936. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33937. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  33938. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  33939. import { Engine } from "babylonjs/Engines/engine";
  33940. import { Node } from "babylonjs/node";
  33941. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  33942. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33943. import { WebRequest } from "babylonjs/Misc/webRequest";
  33944. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  33945. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  33946. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  33947. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  33948. import { Plane } from "babylonjs/Maths/math.plane";
  33949. import { Ray } from "babylonjs/Culling/ray";
  33950. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  33951. import { Animation } from "babylonjs/Animations/animation";
  33952. import { Animatable } from "babylonjs/Animations/animatable";
  33953. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33954. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  33955. import { Collider } from "babylonjs/Collisions/collider";
  33956. /**
  33957. * Define an interface for all classes that will hold resources
  33958. */
  33959. export interface IDisposable {
  33960. /**
  33961. * Releases all held resources
  33962. */
  33963. dispose(): void;
  33964. }
  33965. /** Interface defining initialization parameters for Scene class */
  33966. export interface SceneOptions {
  33967. /**
  33968. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  33969. * It will improve performance when the number of geometries becomes important.
  33970. */
  33971. useGeometryUniqueIdsMap?: boolean;
  33972. /**
  33973. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  33974. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33975. */
  33976. useMaterialMeshMap?: boolean;
  33977. /**
  33978. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  33979. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33980. */
  33981. useClonedMeshhMap?: boolean;
  33982. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  33983. virtual?: boolean;
  33984. }
  33985. /**
  33986. * Represents a scene to be rendered by the engine.
  33987. * @see http://doc.babylonjs.com/features/scene
  33988. */
  33989. export class Scene extends AbstractScene implements IAnimatable {
  33990. /** The fog is deactivated */
  33991. static readonly FOGMODE_NONE: number;
  33992. /** The fog density is following an exponential function */
  33993. static readonly FOGMODE_EXP: number;
  33994. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  33995. static readonly FOGMODE_EXP2: number;
  33996. /** The fog density is following a linear function. */
  33997. static readonly FOGMODE_LINEAR: number;
  33998. /**
  33999. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  34000. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34001. */
  34002. static MinDeltaTime: number;
  34003. /**
  34004. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  34005. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34006. */
  34007. static MaxDeltaTime: number;
  34008. /**
  34009. * Factory used to create the default material.
  34010. * @param name The name of the material to create
  34011. * @param scene The scene to create the material for
  34012. * @returns The default material
  34013. */
  34014. static DefaultMaterialFactory(scene: Scene): Material;
  34015. /**
  34016. * Factory used to create the a collision coordinator.
  34017. * @returns The collision coordinator
  34018. */
  34019. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  34020. /** @hidden */
  34021. _inputManager: InputManager;
  34022. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  34023. cameraToUseForPointers: Nullable<Camera>;
  34024. /** @hidden */
  34025. readonly _isScene: boolean;
  34026. /**
  34027. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  34028. */
  34029. autoClear: boolean;
  34030. /**
  34031. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  34032. */
  34033. autoClearDepthAndStencil: boolean;
  34034. /**
  34035. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  34036. */
  34037. clearColor: Color4;
  34038. /**
  34039. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  34040. */
  34041. ambientColor: Color3;
  34042. /**
  34043. * This is use to store the default BRDF lookup for PBR materials in your scene.
  34044. * It should only be one of the following (if not the default embedded one):
  34045. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  34046. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  34047. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  34048. * The material properties need to be setup according to the type of texture in use.
  34049. */
  34050. environmentBRDFTexture: BaseTexture;
  34051. /** @hidden */
  34052. protected _environmentTexture: Nullable<BaseTexture>;
  34053. /**
  34054. * Texture used in all pbr material as the reflection texture.
  34055. * As in the majority of the scene they are the same (exception for multi room and so on),
  34056. * this is easier to reference from here than from all the materials.
  34057. */
  34058. /**
  34059. * Texture used in all pbr material as the reflection texture.
  34060. * As in the majority of the scene they are the same (exception for multi room and so on),
  34061. * this is easier to set here than in all the materials.
  34062. */
  34063. environmentTexture: Nullable<BaseTexture>;
  34064. /** @hidden */
  34065. protected _environmentIntensity: number;
  34066. /**
  34067. * Intensity of the environment in all pbr material.
  34068. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34069. * As in the majority of the scene they are the same (exception for multi room and so on),
  34070. * this is easier to reference from here than from all the materials.
  34071. */
  34072. /**
  34073. * Intensity of the environment in all pbr material.
  34074. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34075. * As in the majority of the scene they are the same (exception for multi room and so on),
  34076. * this is easier to set here than in all the materials.
  34077. */
  34078. environmentIntensity: number;
  34079. /** @hidden */
  34080. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  34081. /**
  34082. * Default image processing configuration used either in the rendering
  34083. * Forward main pass or through the imageProcessingPostProcess if present.
  34084. * As in the majority of the scene they are the same (exception for multi camera),
  34085. * this is easier to reference from here than from all the materials and post process.
  34086. *
  34087. * No setter as we it is a shared configuration, you can set the values instead.
  34088. */
  34089. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  34090. private _forceWireframe;
  34091. /**
  34092. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  34093. */
  34094. forceWireframe: boolean;
  34095. private _forcePointsCloud;
  34096. /**
  34097. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  34098. */
  34099. forcePointsCloud: boolean;
  34100. /**
  34101. * Gets or sets the active clipplane 1
  34102. */
  34103. clipPlane: Nullable<Plane>;
  34104. /**
  34105. * Gets or sets the active clipplane 2
  34106. */
  34107. clipPlane2: Nullable<Plane>;
  34108. /**
  34109. * Gets or sets the active clipplane 3
  34110. */
  34111. clipPlane3: Nullable<Plane>;
  34112. /**
  34113. * Gets or sets the active clipplane 4
  34114. */
  34115. clipPlane4: Nullable<Plane>;
  34116. /**
  34117. * Gets or sets a boolean indicating if animations are enabled
  34118. */
  34119. animationsEnabled: boolean;
  34120. private _animationPropertiesOverride;
  34121. /**
  34122. * Gets or sets the animation properties override
  34123. */
  34124. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  34125. /**
  34126. * Gets or sets a boolean indicating if a constant deltatime has to be used
  34127. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  34128. */
  34129. useConstantAnimationDeltaTime: boolean;
  34130. /**
  34131. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  34132. * Please note that it requires to run a ray cast through the scene on every frame
  34133. */
  34134. constantlyUpdateMeshUnderPointer: boolean;
  34135. /**
  34136. * Defines the HTML cursor to use when hovering over interactive elements
  34137. */
  34138. hoverCursor: string;
  34139. /**
  34140. * Defines the HTML default cursor to use (empty by default)
  34141. */
  34142. defaultCursor: string;
  34143. /**
  34144. * This is used to call preventDefault() on pointer down
  34145. * in order to block unwanted artifacts like system double clicks
  34146. */
  34147. preventDefaultOnPointerDown: boolean;
  34148. /**
  34149. * This is used to call preventDefault() on pointer up
  34150. * in order to block unwanted artifacts like system double clicks
  34151. */
  34152. preventDefaultOnPointerUp: boolean;
  34153. /**
  34154. * Gets or sets user defined metadata
  34155. */
  34156. metadata: any;
  34157. /**
  34158. * For internal use only. Please do not use.
  34159. */
  34160. reservedDataStore: any;
  34161. /**
  34162. * Gets the name of the plugin used to load this scene (null by default)
  34163. */
  34164. loadingPluginName: string;
  34165. /**
  34166. * Use this array to add regular expressions used to disable offline support for specific urls
  34167. */
  34168. disableOfflineSupportExceptionRules: RegExp[];
  34169. /**
  34170. * An event triggered when the scene is disposed.
  34171. */
  34172. onDisposeObservable: Observable<Scene>;
  34173. private _onDisposeObserver;
  34174. /** Sets a function to be executed when this scene is disposed. */
  34175. onDispose: () => void;
  34176. /**
  34177. * An event triggered before rendering the scene (right after animations and physics)
  34178. */
  34179. onBeforeRenderObservable: Observable<Scene>;
  34180. private _onBeforeRenderObserver;
  34181. /** Sets a function to be executed before rendering this scene */
  34182. beforeRender: Nullable<() => void>;
  34183. /**
  34184. * An event triggered after rendering the scene
  34185. */
  34186. onAfterRenderObservable: Observable<Scene>;
  34187. /**
  34188. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  34189. */
  34190. onAfterRenderCameraObservable: Observable<Camera>;
  34191. private _onAfterRenderObserver;
  34192. /** Sets a function to be executed after rendering this scene */
  34193. afterRender: Nullable<() => void>;
  34194. /**
  34195. * An event triggered before animating the scene
  34196. */
  34197. onBeforeAnimationsObservable: Observable<Scene>;
  34198. /**
  34199. * An event triggered after animations processing
  34200. */
  34201. onAfterAnimationsObservable: Observable<Scene>;
  34202. /**
  34203. * An event triggered before draw calls are ready to be sent
  34204. */
  34205. onBeforeDrawPhaseObservable: Observable<Scene>;
  34206. /**
  34207. * An event triggered after draw calls have been sent
  34208. */
  34209. onAfterDrawPhaseObservable: Observable<Scene>;
  34210. /**
  34211. * An event triggered when the scene is ready
  34212. */
  34213. onReadyObservable: Observable<Scene>;
  34214. /**
  34215. * An event triggered before rendering a camera
  34216. */
  34217. onBeforeCameraRenderObservable: Observable<Camera>;
  34218. private _onBeforeCameraRenderObserver;
  34219. /** Sets a function to be executed before rendering a camera*/
  34220. beforeCameraRender: () => void;
  34221. /**
  34222. * An event triggered after rendering a camera
  34223. */
  34224. onAfterCameraRenderObservable: Observable<Camera>;
  34225. private _onAfterCameraRenderObserver;
  34226. /** Sets a function to be executed after rendering a camera*/
  34227. afterCameraRender: () => void;
  34228. /**
  34229. * An event triggered when active meshes evaluation is about to start
  34230. */
  34231. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  34232. /**
  34233. * An event triggered when active meshes evaluation is done
  34234. */
  34235. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  34236. /**
  34237. * An event triggered when particles rendering is about to start
  34238. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34239. */
  34240. onBeforeParticlesRenderingObservable: Observable<Scene>;
  34241. /**
  34242. * An event triggered when particles rendering is done
  34243. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34244. */
  34245. onAfterParticlesRenderingObservable: Observable<Scene>;
  34246. /**
  34247. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  34248. */
  34249. onDataLoadedObservable: Observable<Scene>;
  34250. /**
  34251. * An event triggered when a camera is created
  34252. */
  34253. onNewCameraAddedObservable: Observable<Camera>;
  34254. /**
  34255. * An event triggered when a camera is removed
  34256. */
  34257. onCameraRemovedObservable: Observable<Camera>;
  34258. /**
  34259. * An event triggered when a light is created
  34260. */
  34261. onNewLightAddedObservable: Observable<Light>;
  34262. /**
  34263. * An event triggered when a light is removed
  34264. */
  34265. onLightRemovedObservable: Observable<Light>;
  34266. /**
  34267. * An event triggered when a geometry is created
  34268. */
  34269. onNewGeometryAddedObservable: Observable<Geometry>;
  34270. /**
  34271. * An event triggered when a geometry is removed
  34272. */
  34273. onGeometryRemovedObservable: Observable<Geometry>;
  34274. /**
  34275. * An event triggered when a transform node is created
  34276. */
  34277. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  34278. /**
  34279. * An event triggered when a transform node is removed
  34280. */
  34281. onTransformNodeRemovedObservable: Observable<TransformNode>;
  34282. /**
  34283. * An event triggered when a mesh is created
  34284. */
  34285. onNewMeshAddedObservable: Observable<AbstractMesh>;
  34286. /**
  34287. * An event triggered when a mesh is removed
  34288. */
  34289. onMeshRemovedObservable: Observable<AbstractMesh>;
  34290. /**
  34291. * An event triggered when a skeleton is created
  34292. */
  34293. onNewSkeletonAddedObservable: Observable<Skeleton>;
  34294. /**
  34295. * An event triggered when a skeleton is removed
  34296. */
  34297. onSkeletonRemovedObservable: Observable<Skeleton>;
  34298. /**
  34299. * An event triggered when a material is created
  34300. */
  34301. onNewMaterialAddedObservable: Observable<Material>;
  34302. /**
  34303. * An event triggered when a material is removed
  34304. */
  34305. onMaterialRemovedObservable: Observable<Material>;
  34306. /**
  34307. * An event triggered when a texture is created
  34308. */
  34309. onNewTextureAddedObservable: Observable<BaseTexture>;
  34310. /**
  34311. * An event triggered when a texture is removed
  34312. */
  34313. onTextureRemovedObservable: Observable<BaseTexture>;
  34314. /**
  34315. * An event triggered when render targets are about to be rendered
  34316. * Can happen multiple times per frame.
  34317. */
  34318. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  34319. /**
  34320. * An event triggered when render targets were rendered.
  34321. * Can happen multiple times per frame.
  34322. */
  34323. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  34324. /**
  34325. * An event triggered before calculating deterministic simulation step
  34326. */
  34327. onBeforeStepObservable: Observable<Scene>;
  34328. /**
  34329. * An event triggered after calculating deterministic simulation step
  34330. */
  34331. onAfterStepObservable: Observable<Scene>;
  34332. /**
  34333. * An event triggered when the activeCamera property is updated
  34334. */
  34335. onActiveCameraChanged: Observable<Scene>;
  34336. /**
  34337. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  34338. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34339. * 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)
  34340. */
  34341. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34342. /**
  34343. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  34344. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34345. * 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)
  34346. */
  34347. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34348. /**
  34349. * This Observable will when a mesh has been imported into the scene.
  34350. */
  34351. onMeshImportedObservable: Observable<AbstractMesh>;
  34352. /**
  34353. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  34354. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  34355. */
  34356. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  34357. /** @hidden */
  34358. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  34359. /**
  34360. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  34361. */
  34362. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  34363. /**
  34364. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  34365. */
  34366. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  34367. /**
  34368. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  34369. */
  34370. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  34371. /** Callback called when a pointer move is detected */
  34372. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34373. /** Callback called when a pointer down is detected */
  34374. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34375. /** Callback called when a pointer up is detected */
  34376. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  34377. /** Callback called when a pointer pick is detected */
  34378. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  34379. /**
  34380. * 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).
  34381. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  34382. */
  34383. onPrePointerObservable: Observable<PointerInfoPre>;
  34384. /**
  34385. * Observable event triggered each time an input event is received from the rendering canvas
  34386. */
  34387. onPointerObservable: Observable<PointerInfo>;
  34388. /**
  34389. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  34390. */
  34391. readonly unTranslatedPointer: Vector2;
  34392. /**
  34393. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  34394. */
  34395. static DragMovementThreshold: number;
  34396. /**
  34397. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  34398. */
  34399. static LongPressDelay: number;
  34400. /**
  34401. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  34402. */
  34403. static DoubleClickDelay: number;
  34404. /** If you need to check double click without raising a single click at first click, enable this flag */
  34405. static ExclusiveDoubleClickMode: boolean;
  34406. /** @hidden */
  34407. _mirroredCameraPosition: Nullable<Vector3>;
  34408. /**
  34409. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  34410. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  34411. */
  34412. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  34413. /**
  34414. * Observable event triggered each time an keyboard event is received from the hosting window
  34415. */
  34416. onKeyboardObservable: Observable<KeyboardInfo>;
  34417. private _useRightHandedSystem;
  34418. /**
  34419. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  34420. */
  34421. useRightHandedSystem: boolean;
  34422. private _timeAccumulator;
  34423. private _currentStepId;
  34424. private _currentInternalStep;
  34425. /**
  34426. * Sets the step Id used by deterministic lock step
  34427. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34428. * @param newStepId defines the step Id
  34429. */
  34430. setStepId(newStepId: number): void;
  34431. /**
  34432. * Gets the step Id used by deterministic lock step
  34433. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34434. * @returns the step Id
  34435. */
  34436. getStepId(): number;
  34437. /**
  34438. * Gets the internal step used by deterministic lock step
  34439. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34440. * @returns the internal step
  34441. */
  34442. getInternalStep(): number;
  34443. private _fogEnabled;
  34444. /**
  34445. * Gets or sets a boolean indicating if fog is enabled on this scene
  34446. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34447. * (Default is true)
  34448. */
  34449. fogEnabled: boolean;
  34450. private _fogMode;
  34451. /**
  34452. * Gets or sets the fog mode to use
  34453. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34454. * | mode | value |
  34455. * | --- | --- |
  34456. * | FOGMODE_NONE | 0 |
  34457. * | FOGMODE_EXP | 1 |
  34458. * | FOGMODE_EXP2 | 2 |
  34459. * | FOGMODE_LINEAR | 3 |
  34460. */
  34461. fogMode: number;
  34462. /**
  34463. * Gets or sets the fog color to use
  34464. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34465. * (Default is Color3(0.2, 0.2, 0.3))
  34466. */
  34467. fogColor: Color3;
  34468. /**
  34469. * Gets or sets the fog density to use
  34470. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34471. * (Default is 0.1)
  34472. */
  34473. fogDensity: number;
  34474. /**
  34475. * Gets or sets the fog start distance to use
  34476. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34477. * (Default is 0)
  34478. */
  34479. fogStart: number;
  34480. /**
  34481. * Gets or sets the fog end distance to use
  34482. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34483. * (Default is 1000)
  34484. */
  34485. fogEnd: number;
  34486. private _shadowsEnabled;
  34487. /**
  34488. * Gets or sets a boolean indicating if shadows are enabled on this scene
  34489. */
  34490. shadowsEnabled: boolean;
  34491. private _lightsEnabled;
  34492. /**
  34493. * Gets or sets a boolean indicating if lights are enabled on this scene
  34494. */
  34495. lightsEnabled: boolean;
  34496. /** All of the active cameras added to this scene. */
  34497. activeCameras: Camera[];
  34498. /** @hidden */
  34499. _activeCamera: Nullable<Camera>;
  34500. /** Gets or sets the current active camera */
  34501. activeCamera: Nullable<Camera>;
  34502. private _defaultMaterial;
  34503. /** The default material used on meshes when no material is affected */
  34504. /** The default material used on meshes when no material is affected */
  34505. defaultMaterial: Material;
  34506. private _texturesEnabled;
  34507. /**
  34508. * Gets or sets a boolean indicating if textures are enabled on this scene
  34509. */
  34510. texturesEnabled: boolean;
  34511. /**
  34512. * Gets or sets a boolean indicating if particles are enabled on this scene
  34513. */
  34514. particlesEnabled: boolean;
  34515. /**
  34516. * Gets or sets a boolean indicating if sprites are enabled on this scene
  34517. */
  34518. spritesEnabled: boolean;
  34519. private _skeletonsEnabled;
  34520. /**
  34521. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  34522. */
  34523. skeletonsEnabled: boolean;
  34524. /**
  34525. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  34526. */
  34527. lensFlaresEnabled: boolean;
  34528. /**
  34529. * Gets or sets a boolean indicating if collisions are enabled on this scene
  34530. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34531. */
  34532. collisionsEnabled: boolean;
  34533. private _collisionCoordinator;
  34534. /** @hidden */
  34535. readonly collisionCoordinator: ICollisionCoordinator;
  34536. /**
  34537. * Defines the gravity applied to this scene (used only for collisions)
  34538. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34539. */
  34540. gravity: Vector3;
  34541. /**
  34542. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  34543. */
  34544. postProcessesEnabled: boolean;
  34545. /**
  34546. * The list of postprocesses added to the scene
  34547. */
  34548. postProcesses: PostProcess[];
  34549. /**
  34550. * Gets the current postprocess manager
  34551. */
  34552. postProcessManager: PostProcessManager;
  34553. /**
  34554. * Gets or sets a boolean indicating if render targets are enabled on this scene
  34555. */
  34556. renderTargetsEnabled: boolean;
  34557. /**
  34558. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  34559. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  34560. */
  34561. dumpNextRenderTargets: boolean;
  34562. /**
  34563. * The list of user defined render targets added to the scene
  34564. */
  34565. customRenderTargets: RenderTargetTexture[];
  34566. /**
  34567. * Defines if texture loading must be delayed
  34568. * If true, textures will only be loaded when they need to be rendered
  34569. */
  34570. useDelayedTextureLoading: boolean;
  34571. /**
  34572. * Gets the list of meshes imported to the scene through SceneLoader
  34573. */
  34574. importedMeshesFiles: String[];
  34575. /**
  34576. * Gets or sets a boolean indicating if probes are enabled on this scene
  34577. */
  34578. probesEnabled: boolean;
  34579. /**
  34580. * Gets or sets the current offline provider to use to store scene data
  34581. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  34582. */
  34583. offlineProvider: IOfflineProvider;
  34584. /**
  34585. * Gets or sets the action manager associated with the scene
  34586. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34587. */
  34588. actionManager: AbstractActionManager;
  34589. private _meshesForIntersections;
  34590. /**
  34591. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  34592. */
  34593. proceduralTexturesEnabled: boolean;
  34594. private _engine;
  34595. private _totalVertices;
  34596. /** @hidden */
  34597. _activeIndices: PerfCounter;
  34598. /** @hidden */
  34599. _activeParticles: PerfCounter;
  34600. /** @hidden */
  34601. _activeBones: PerfCounter;
  34602. private _animationRatio;
  34603. /** @hidden */
  34604. _animationTimeLast: number;
  34605. /** @hidden */
  34606. _animationTime: number;
  34607. /**
  34608. * Gets or sets a general scale for animation speed
  34609. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  34610. */
  34611. animationTimeScale: number;
  34612. /** @hidden */
  34613. _cachedMaterial: Nullable<Material>;
  34614. /** @hidden */
  34615. _cachedEffect: Nullable<Effect>;
  34616. /** @hidden */
  34617. _cachedVisibility: Nullable<number>;
  34618. private _renderId;
  34619. private _frameId;
  34620. private _executeWhenReadyTimeoutId;
  34621. private _intermediateRendering;
  34622. private _viewUpdateFlag;
  34623. private _projectionUpdateFlag;
  34624. /** @hidden */
  34625. _toBeDisposed: Nullable<IDisposable>[];
  34626. private _activeRequests;
  34627. /** @hidden */
  34628. _pendingData: any[];
  34629. private _isDisposed;
  34630. /**
  34631. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  34632. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  34633. */
  34634. dispatchAllSubMeshesOfActiveMeshes: boolean;
  34635. private _activeMeshes;
  34636. private _processedMaterials;
  34637. private _renderTargets;
  34638. /** @hidden */
  34639. _activeParticleSystems: SmartArray<IParticleSystem>;
  34640. private _activeSkeletons;
  34641. private _softwareSkinnedMeshes;
  34642. private _renderingManager;
  34643. /** @hidden */
  34644. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  34645. private _transformMatrix;
  34646. private _sceneUbo;
  34647. /** @hidden */
  34648. _viewMatrix: Matrix;
  34649. private _projectionMatrix;
  34650. /** @hidden */
  34651. _forcedViewPosition: Nullable<Vector3>;
  34652. /** @hidden */
  34653. _frustumPlanes: Plane[];
  34654. /**
  34655. * Gets the list of frustum planes (built from the active camera)
  34656. */
  34657. readonly frustumPlanes: Plane[];
  34658. /**
  34659. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  34660. * This is useful if there are more lights that the maximum simulteanous authorized
  34661. */
  34662. requireLightSorting: boolean;
  34663. /** @hidden */
  34664. readonly useMaterialMeshMap: boolean;
  34665. /** @hidden */
  34666. readonly useClonedMeshhMap: boolean;
  34667. private _externalData;
  34668. private _uid;
  34669. /**
  34670. * @hidden
  34671. * Backing store of defined scene components.
  34672. */
  34673. _components: ISceneComponent[];
  34674. /**
  34675. * @hidden
  34676. * Backing store of defined scene components.
  34677. */
  34678. _serializableComponents: ISceneSerializableComponent[];
  34679. /**
  34680. * List of components to register on the next registration step.
  34681. */
  34682. private _transientComponents;
  34683. /**
  34684. * Registers the transient components if needed.
  34685. */
  34686. private _registerTransientComponents;
  34687. /**
  34688. * @hidden
  34689. * Add a component to the scene.
  34690. * Note that the ccomponent could be registered on th next frame if this is called after
  34691. * the register component stage.
  34692. * @param component Defines the component to add to the scene
  34693. */
  34694. _addComponent(component: ISceneComponent): void;
  34695. /**
  34696. * @hidden
  34697. * Gets a component from the scene.
  34698. * @param name defines the name of the component to retrieve
  34699. * @returns the component or null if not present
  34700. */
  34701. _getComponent(name: string): Nullable<ISceneComponent>;
  34702. /**
  34703. * @hidden
  34704. * Defines the actions happening before camera updates.
  34705. */
  34706. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  34707. /**
  34708. * @hidden
  34709. * Defines the actions happening before clear the canvas.
  34710. */
  34711. _beforeClearStage: Stage<SimpleStageAction>;
  34712. /**
  34713. * @hidden
  34714. * Defines the actions when collecting render targets for the frame.
  34715. */
  34716. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34717. /**
  34718. * @hidden
  34719. * Defines the actions happening for one camera in the frame.
  34720. */
  34721. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34722. /**
  34723. * @hidden
  34724. * Defines the actions happening during the per mesh ready checks.
  34725. */
  34726. _isReadyForMeshStage: Stage<MeshStageAction>;
  34727. /**
  34728. * @hidden
  34729. * Defines the actions happening before evaluate active mesh checks.
  34730. */
  34731. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  34732. /**
  34733. * @hidden
  34734. * Defines the actions happening during the evaluate sub mesh checks.
  34735. */
  34736. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  34737. /**
  34738. * @hidden
  34739. * Defines the actions happening during the active mesh stage.
  34740. */
  34741. _activeMeshStage: Stage<ActiveMeshStageAction>;
  34742. /**
  34743. * @hidden
  34744. * Defines the actions happening during the per camera render target step.
  34745. */
  34746. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  34747. /**
  34748. * @hidden
  34749. * Defines the actions happening just before the active camera is drawing.
  34750. */
  34751. _beforeCameraDrawStage: Stage<CameraStageAction>;
  34752. /**
  34753. * @hidden
  34754. * Defines the actions happening just before a render target is drawing.
  34755. */
  34756. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34757. /**
  34758. * @hidden
  34759. * Defines the actions happening just before a rendering group is drawing.
  34760. */
  34761. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34762. /**
  34763. * @hidden
  34764. * Defines the actions happening just before a mesh is drawing.
  34765. */
  34766. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34767. /**
  34768. * @hidden
  34769. * Defines the actions happening just after a mesh has been drawn.
  34770. */
  34771. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34772. /**
  34773. * @hidden
  34774. * Defines the actions happening just after a rendering group has been drawn.
  34775. */
  34776. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34777. /**
  34778. * @hidden
  34779. * Defines the actions happening just after the active camera has been drawn.
  34780. */
  34781. _afterCameraDrawStage: Stage<CameraStageAction>;
  34782. /**
  34783. * @hidden
  34784. * Defines the actions happening just after a render target has been drawn.
  34785. */
  34786. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34787. /**
  34788. * @hidden
  34789. * Defines the actions happening just after rendering all cameras and computing intersections.
  34790. */
  34791. _afterRenderStage: Stage<SimpleStageAction>;
  34792. /**
  34793. * @hidden
  34794. * Defines the actions happening when a pointer move event happens.
  34795. */
  34796. _pointerMoveStage: Stage<PointerMoveStageAction>;
  34797. /**
  34798. * @hidden
  34799. * Defines the actions happening when a pointer down event happens.
  34800. */
  34801. _pointerDownStage: Stage<PointerUpDownStageAction>;
  34802. /**
  34803. * @hidden
  34804. * Defines the actions happening when a pointer up event happens.
  34805. */
  34806. _pointerUpStage: Stage<PointerUpDownStageAction>;
  34807. /**
  34808. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  34809. */
  34810. private geometriesByUniqueId;
  34811. /**
  34812. * Creates a new Scene
  34813. * @param engine defines the engine to use to render this scene
  34814. * @param options defines the scene options
  34815. */
  34816. constructor(engine: Engine, options?: SceneOptions);
  34817. /**
  34818. * Gets a string idenfifying the name of the class
  34819. * @returns "Scene" string
  34820. */
  34821. getClassName(): string;
  34822. private _defaultMeshCandidates;
  34823. /**
  34824. * @hidden
  34825. */
  34826. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  34827. private _defaultSubMeshCandidates;
  34828. /**
  34829. * @hidden
  34830. */
  34831. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  34832. /**
  34833. * Sets the default candidate providers for the scene.
  34834. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  34835. * and getCollidingSubMeshCandidates to their default function
  34836. */
  34837. setDefaultCandidateProviders(): void;
  34838. /**
  34839. * Gets the mesh that is currently under the pointer
  34840. */
  34841. readonly meshUnderPointer: Nullable<AbstractMesh>;
  34842. /**
  34843. * Gets or sets the current on-screen X position of the pointer
  34844. */
  34845. pointerX: number;
  34846. /**
  34847. * Gets or sets the current on-screen Y position of the pointer
  34848. */
  34849. pointerY: number;
  34850. /**
  34851. * Gets the cached material (ie. the latest rendered one)
  34852. * @returns the cached material
  34853. */
  34854. getCachedMaterial(): Nullable<Material>;
  34855. /**
  34856. * Gets the cached effect (ie. the latest rendered one)
  34857. * @returns the cached effect
  34858. */
  34859. getCachedEffect(): Nullable<Effect>;
  34860. /**
  34861. * Gets the cached visibility state (ie. the latest rendered one)
  34862. * @returns the cached visibility state
  34863. */
  34864. getCachedVisibility(): Nullable<number>;
  34865. /**
  34866. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  34867. * @param material defines the current material
  34868. * @param effect defines the current effect
  34869. * @param visibility defines the current visibility state
  34870. * @returns true if one parameter is not cached
  34871. */
  34872. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  34873. /**
  34874. * Gets the engine associated with the scene
  34875. * @returns an Engine
  34876. */
  34877. getEngine(): Engine;
  34878. /**
  34879. * Gets the total number of vertices rendered per frame
  34880. * @returns the total number of vertices rendered per frame
  34881. */
  34882. getTotalVertices(): number;
  34883. /**
  34884. * Gets the performance counter for total vertices
  34885. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34886. */
  34887. readonly totalVerticesPerfCounter: PerfCounter;
  34888. /**
  34889. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  34890. * @returns the total number of active indices rendered per frame
  34891. */
  34892. getActiveIndices(): number;
  34893. /**
  34894. * Gets the performance counter for active indices
  34895. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34896. */
  34897. readonly totalActiveIndicesPerfCounter: PerfCounter;
  34898. /**
  34899. * Gets the total number of active particles rendered per frame
  34900. * @returns the total number of active particles rendered per frame
  34901. */
  34902. getActiveParticles(): number;
  34903. /**
  34904. * Gets the performance counter for active particles
  34905. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34906. */
  34907. readonly activeParticlesPerfCounter: PerfCounter;
  34908. /**
  34909. * Gets the total number of active bones rendered per frame
  34910. * @returns the total number of active bones rendered per frame
  34911. */
  34912. getActiveBones(): number;
  34913. /**
  34914. * Gets the performance counter for active bones
  34915. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34916. */
  34917. readonly activeBonesPerfCounter: PerfCounter;
  34918. /**
  34919. * Gets the array of active meshes
  34920. * @returns an array of AbstractMesh
  34921. */
  34922. getActiveMeshes(): SmartArray<AbstractMesh>;
  34923. /**
  34924. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  34925. * @returns a number
  34926. */
  34927. getAnimationRatio(): number;
  34928. /**
  34929. * Gets an unique Id for the current render phase
  34930. * @returns a number
  34931. */
  34932. getRenderId(): number;
  34933. /**
  34934. * Gets an unique Id for the current frame
  34935. * @returns a number
  34936. */
  34937. getFrameId(): number;
  34938. /** Call this function if you want to manually increment the render Id*/
  34939. incrementRenderId(): void;
  34940. private _createUbo;
  34941. /**
  34942. * Use this method to simulate a pointer move on a mesh
  34943. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34944. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34945. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34946. * @returns the current scene
  34947. */
  34948. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34949. /**
  34950. * Use this method to simulate a pointer down on a mesh
  34951. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34952. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34953. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34954. * @returns the current scene
  34955. */
  34956. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34957. /**
  34958. * Use this method to simulate a pointer up on a mesh
  34959. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34960. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34961. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34962. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34963. * @returns the current scene
  34964. */
  34965. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  34966. /**
  34967. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34968. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34969. * @returns true if the pointer was captured
  34970. */
  34971. isPointerCaptured(pointerId?: number): boolean;
  34972. /**
  34973. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34974. * @param attachUp defines if you want to attach events to pointerup
  34975. * @param attachDown defines if you want to attach events to pointerdown
  34976. * @param attachMove defines if you want to attach events to pointermove
  34977. */
  34978. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34979. /** Detaches all event handlers*/
  34980. detachControl(): void;
  34981. /**
  34982. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  34983. * Delay loaded resources are not taking in account
  34984. * @return true if all required resources are ready
  34985. */
  34986. isReady(): boolean;
  34987. /** Resets all cached information relative to material (including effect and visibility) */
  34988. resetCachedMaterial(): void;
  34989. /**
  34990. * Registers a function to be called before every frame render
  34991. * @param func defines the function to register
  34992. */
  34993. registerBeforeRender(func: () => void): void;
  34994. /**
  34995. * Unregisters a function called before every frame render
  34996. * @param func defines the function to unregister
  34997. */
  34998. unregisterBeforeRender(func: () => void): void;
  34999. /**
  35000. * Registers a function to be called after every frame render
  35001. * @param func defines the function to register
  35002. */
  35003. registerAfterRender(func: () => void): void;
  35004. /**
  35005. * Unregisters a function called after every frame render
  35006. * @param func defines the function to unregister
  35007. */
  35008. unregisterAfterRender(func: () => void): void;
  35009. private _executeOnceBeforeRender;
  35010. /**
  35011. * The provided function will run before render once and will be disposed afterwards.
  35012. * A timeout delay can be provided so that the function will be executed in N ms.
  35013. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  35014. * @param func The function to be executed.
  35015. * @param timeout optional delay in ms
  35016. */
  35017. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  35018. /** @hidden */
  35019. _addPendingData(data: any): void;
  35020. /** @hidden */
  35021. _removePendingData(data: any): void;
  35022. /**
  35023. * Returns the number of items waiting to be loaded
  35024. * @returns the number of items waiting to be loaded
  35025. */
  35026. getWaitingItemsCount(): number;
  35027. /**
  35028. * Returns a boolean indicating if the scene is still loading data
  35029. */
  35030. readonly isLoading: boolean;
  35031. /**
  35032. * Registers a function to be executed when the scene is ready
  35033. * @param {Function} func - the function to be executed
  35034. */
  35035. executeWhenReady(func: () => void): void;
  35036. /**
  35037. * Returns a promise that resolves when the scene is ready
  35038. * @returns A promise that resolves when the scene is ready
  35039. */
  35040. whenReadyAsync(): Promise<void>;
  35041. /** @hidden */
  35042. _checkIsReady(): void;
  35043. /**
  35044. * Gets all animatable attached to the scene
  35045. */
  35046. readonly animatables: Animatable[];
  35047. /**
  35048. * Resets the last animation time frame.
  35049. * Useful to override when animations start running when loading a scene for the first time.
  35050. */
  35051. resetLastAnimationTimeFrame(): void;
  35052. /**
  35053. * Gets the current view matrix
  35054. * @returns a Matrix
  35055. */
  35056. getViewMatrix(): Matrix;
  35057. /**
  35058. * Gets the current projection matrix
  35059. * @returns a Matrix
  35060. */
  35061. getProjectionMatrix(): Matrix;
  35062. /**
  35063. * Gets the current transform matrix
  35064. * @returns a Matrix made of View * Projection
  35065. */
  35066. getTransformMatrix(): Matrix;
  35067. /**
  35068. * Sets the current transform matrix
  35069. * @param viewL defines the View matrix to use
  35070. * @param projectionL defines the Projection matrix to use
  35071. * @param viewR defines the right View matrix to use (if provided)
  35072. * @param projectionR defines the right Projection matrix to use (if provided)
  35073. */
  35074. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  35075. /**
  35076. * Gets the uniform buffer used to store scene data
  35077. * @returns a UniformBuffer
  35078. */
  35079. getSceneUniformBuffer(): UniformBuffer;
  35080. /**
  35081. * Gets an unique (relatively to the current scene) Id
  35082. * @returns an unique number for the scene
  35083. */
  35084. getUniqueId(): number;
  35085. /**
  35086. * Add a mesh to the list of scene's meshes
  35087. * @param newMesh defines the mesh to add
  35088. * @param recursive if all child meshes should also be added to the scene
  35089. */
  35090. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  35091. /**
  35092. * Remove a mesh for the list of scene's meshes
  35093. * @param toRemove defines the mesh to remove
  35094. * @param recursive if all child meshes should also be removed from the scene
  35095. * @returns the index where the mesh was in the mesh list
  35096. */
  35097. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  35098. /**
  35099. * Add a transform node to the list of scene's transform nodes
  35100. * @param newTransformNode defines the transform node to add
  35101. */
  35102. addTransformNode(newTransformNode: TransformNode): void;
  35103. /**
  35104. * Remove a transform node for the list of scene's transform nodes
  35105. * @param toRemove defines the transform node to remove
  35106. * @returns the index where the transform node was in the transform node list
  35107. */
  35108. removeTransformNode(toRemove: TransformNode): number;
  35109. /**
  35110. * Remove a skeleton for the list of scene's skeletons
  35111. * @param toRemove defines the skeleton to remove
  35112. * @returns the index where the skeleton was in the skeleton list
  35113. */
  35114. removeSkeleton(toRemove: Skeleton): number;
  35115. /**
  35116. * Remove a morph target for the list of scene's morph targets
  35117. * @param toRemove defines the morph target to remove
  35118. * @returns the index where the morph target was in the morph target list
  35119. */
  35120. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  35121. /**
  35122. * Remove a light for the list of scene's lights
  35123. * @param toRemove defines the light to remove
  35124. * @returns the index where the light was in the light list
  35125. */
  35126. removeLight(toRemove: Light): number;
  35127. /**
  35128. * Remove a camera for the list of scene's cameras
  35129. * @param toRemove defines the camera to remove
  35130. * @returns the index where the camera was in the camera list
  35131. */
  35132. removeCamera(toRemove: Camera): number;
  35133. /**
  35134. * Remove a particle system for the list of scene's particle systems
  35135. * @param toRemove defines the particle system to remove
  35136. * @returns the index where the particle system was in the particle system list
  35137. */
  35138. removeParticleSystem(toRemove: IParticleSystem): number;
  35139. /**
  35140. * Remove a animation for the list of scene's animations
  35141. * @param toRemove defines the animation to remove
  35142. * @returns the index where the animation was in the animation list
  35143. */
  35144. removeAnimation(toRemove: Animation): number;
  35145. /**
  35146. * Will stop the animation of the given target
  35147. * @param target - the target
  35148. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  35149. * @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)
  35150. */
  35151. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  35152. /**
  35153. * Removes the given animation group from this scene.
  35154. * @param toRemove The animation group to remove
  35155. * @returns The index of the removed animation group
  35156. */
  35157. removeAnimationGroup(toRemove: AnimationGroup): number;
  35158. /**
  35159. * Removes the given multi-material from this scene.
  35160. * @param toRemove The multi-material to remove
  35161. * @returns The index of the removed multi-material
  35162. */
  35163. removeMultiMaterial(toRemove: MultiMaterial): number;
  35164. /**
  35165. * Removes the given material from this scene.
  35166. * @param toRemove The material to remove
  35167. * @returns The index of the removed material
  35168. */
  35169. removeMaterial(toRemove: Material): number;
  35170. /**
  35171. * Removes the given action manager from this scene.
  35172. * @param toRemove The action manager to remove
  35173. * @returns The index of the removed action manager
  35174. */
  35175. removeActionManager(toRemove: AbstractActionManager): number;
  35176. /**
  35177. * Removes the given texture from this scene.
  35178. * @param toRemove The texture to remove
  35179. * @returns The index of the removed texture
  35180. */
  35181. removeTexture(toRemove: BaseTexture): number;
  35182. /**
  35183. * Adds the given light to this scene
  35184. * @param newLight The light to add
  35185. */
  35186. addLight(newLight: Light): void;
  35187. /**
  35188. * Sorts the list list based on light priorities
  35189. */
  35190. sortLightsByPriority(): void;
  35191. /**
  35192. * Adds the given camera to this scene
  35193. * @param newCamera The camera to add
  35194. */
  35195. addCamera(newCamera: Camera): void;
  35196. /**
  35197. * Adds the given skeleton to this scene
  35198. * @param newSkeleton The skeleton to add
  35199. */
  35200. addSkeleton(newSkeleton: Skeleton): void;
  35201. /**
  35202. * Adds the given particle system to this scene
  35203. * @param newParticleSystem The particle system to add
  35204. */
  35205. addParticleSystem(newParticleSystem: IParticleSystem): void;
  35206. /**
  35207. * Adds the given animation to this scene
  35208. * @param newAnimation The animation to add
  35209. */
  35210. addAnimation(newAnimation: Animation): void;
  35211. /**
  35212. * Adds the given animation group to this scene.
  35213. * @param newAnimationGroup The animation group to add
  35214. */
  35215. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  35216. /**
  35217. * Adds the given multi-material to this scene
  35218. * @param newMultiMaterial The multi-material to add
  35219. */
  35220. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  35221. /**
  35222. * Adds the given material to this scene
  35223. * @param newMaterial The material to add
  35224. */
  35225. addMaterial(newMaterial: Material): void;
  35226. /**
  35227. * Adds the given morph target to this scene
  35228. * @param newMorphTargetManager The morph target to add
  35229. */
  35230. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  35231. /**
  35232. * Adds the given geometry to this scene
  35233. * @param newGeometry The geometry to add
  35234. */
  35235. addGeometry(newGeometry: Geometry): void;
  35236. /**
  35237. * Adds the given action manager to this scene
  35238. * @param newActionManager The action manager to add
  35239. */
  35240. addActionManager(newActionManager: AbstractActionManager): void;
  35241. /**
  35242. * Adds the given texture to this scene.
  35243. * @param newTexture The texture to add
  35244. */
  35245. addTexture(newTexture: BaseTexture): void;
  35246. /**
  35247. * Switch active camera
  35248. * @param newCamera defines the new active camera
  35249. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  35250. */
  35251. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  35252. /**
  35253. * sets the active camera of the scene using its ID
  35254. * @param id defines the camera's ID
  35255. * @return the new active camera or null if none found.
  35256. */
  35257. setActiveCameraByID(id: string): Nullable<Camera>;
  35258. /**
  35259. * sets the active camera of the scene using its name
  35260. * @param name defines the camera's name
  35261. * @returns the new active camera or null if none found.
  35262. */
  35263. setActiveCameraByName(name: string): Nullable<Camera>;
  35264. /**
  35265. * get an animation group using its name
  35266. * @param name defines the material's name
  35267. * @return the animation group or null if none found.
  35268. */
  35269. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  35270. /**
  35271. * Get a material using its unique id
  35272. * @param uniqueId defines the material's unique id
  35273. * @return the material or null if none found.
  35274. */
  35275. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  35276. /**
  35277. * get a material using its id
  35278. * @param id defines the material's ID
  35279. * @return the material or null if none found.
  35280. */
  35281. getMaterialByID(id: string): Nullable<Material>;
  35282. /**
  35283. * Gets a the last added material using a given id
  35284. * @param id defines the material's ID
  35285. * @return the last material with the given id or null if none found.
  35286. */
  35287. getLastMaterialByID(id: string): Nullable<Material>;
  35288. /**
  35289. * Gets a material using its name
  35290. * @param name defines the material's name
  35291. * @return the material or null if none found.
  35292. */
  35293. getMaterialByName(name: string): Nullable<Material>;
  35294. /**
  35295. * Get a texture using its unique id
  35296. * @param uniqueId defines the texture's unique id
  35297. * @return the texture or null if none found.
  35298. */
  35299. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  35300. /**
  35301. * Gets a camera using its id
  35302. * @param id defines the id to look for
  35303. * @returns the camera or null if not found
  35304. */
  35305. getCameraByID(id: string): Nullable<Camera>;
  35306. /**
  35307. * Gets a camera using its unique id
  35308. * @param uniqueId defines the unique id to look for
  35309. * @returns the camera or null if not found
  35310. */
  35311. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  35312. /**
  35313. * Gets a camera using its name
  35314. * @param name defines the camera's name
  35315. * @return the camera or null if none found.
  35316. */
  35317. getCameraByName(name: string): Nullable<Camera>;
  35318. /**
  35319. * Gets a bone using its id
  35320. * @param id defines the bone's id
  35321. * @return the bone or null if not found
  35322. */
  35323. getBoneByID(id: string): Nullable<Bone>;
  35324. /**
  35325. * Gets a bone using its id
  35326. * @param name defines the bone's name
  35327. * @return the bone or null if not found
  35328. */
  35329. getBoneByName(name: string): Nullable<Bone>;
  35330. /**
  35331. * Gets a light node using its name
  35332. * @param name defines the the light's name
  35333. * @return the light or null if none found.
  35334. */
  35335. getLightByName(name: string): Nullable<Light>;
  35336. /**
  35337. * Gets a light node using its id
  35338. * @param id defines the light's id
  35339. * @return the light or null if none found.
  35340. */
  35341. getLightByID(id: string): Nullable<Light>;
  35342. /**
  35343. * Gets a light node using its scene-generated unique ID
  35344. * @param uniqueId defines the light's unique id
  35345. * @return the light or null if none found.
  35346. */
  35347. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  35348. /**
  35349. * Gets a particle system by id
  35350. * @param id defines the particle system id
  35351. * @return the corresponding system or null if none found
  35352. */
  35353. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  35354. /**
  35355. * Gets a geometry using its ID
  35356. * @param id defines the geometry's id
  35357. * @return the geometry or null if none found.
  35358. */
  35359. getGeometryByID(id: string): Nullable<Geometry>;
  35360. private _getGeometryByUniqueID;
  35361. /**
  35362. * Add a new geometry to this scene
  35363. * @param geometry defines the geometry to be added to the scene.
  35364. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  35365. * @return a boolean defining if the geometry was added or not
  35366. */
  35367. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  35368. /**
  35369. * Removes an existing geometry
  35370. * @param geometry defines the geometry to be removed from the scene
  35371. * @return a boolean defining if the geometry was removed or not
  35372. */
  35373. removeGeometry(geometry: Geometry): boolean;
  35374. /**
  35375. * Gets the list of geometries attached to the scene
  35376. * @returns an array of Geometry
  35377. */
  35378. getGeometries(): Geometry[];
  35379. /**
  35380. * Gets the first added mesh found of a given ID
  35381. * @param id defines the id to search for
  35382. * @return the mesh found or null if not found at all
  35383. */
  35384. getMeshByID(id: string): Nullable<AbstractMesh>;
  35385. /**
  35386. * Gets a list of meshes using their id
  35387. * @param id defines the id to search for
  35388. * @returns a list of meshes
  35389. */
  35390. getMeshesByID(id: string): Array<AbstractMesh>;
  35391. /**
  35392. * Gets the first added transform node found of a given ID
  35393. * @param id defines the id to search for
  35394. * @return the found transform node or null if not found at all.
  35395. */
  35396. getTransformNodeByID(id: string): Nullable<TransformNode>;
  35397. /**
  35398. * Gets a transform node with its auto-generated unique id
  35399. * @param uniqueId efines the unique id to search for
  35400. * @return the found transform node or null if not found at all.
  35401. */
  35402. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  35403. /**
  35404. * Gets a list of transform nodes using their id
  35405. * @param id defines the id to search for
  35406. * @returns a list of transform nodes
  35407. */
  35408. getTransformNodesByID(id: string): Array<TransformNode>;
  35409. /**
  35410. * Gets a mesh with its auto-generated unique id
  35411. * @param uniqueId defines the unique id to search for
  35412. * @return the found mesh or null if not found at all.
  35413. */
  35414. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  35415. /**
  35416. * Gets a the last added mesh using a given id
  35417. * @param id defines the id to search for
  35418. * @return the found mesh or null if not found at all.
  35419. */
  35420. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  35421. /**
  35422. * Gets a the last added node (Mesh, Camera, Light) using a given id
  35423. * @param id defines the id to search for
  35424. * @return the found node or null if not found at all
  35425. */
  35426. getLastEntryByID(id: string): Nullable<Node>;
  35427. /**
  35428. * Gets a node (Mesh, Camera, Light) using a given id
  35429. * @param id defines the id to search for
  35430. * @return the found node or null if not found at all
  35431. */
  35432. getNodeByID(id: string): Nullable<Node>;
  35433. /**
  35434. * Gets a node (Mesh, Camera, Light) using a given name
  35435. * @param name defines the name to search for
  35436. * @return the found node or null if not found at all.
  35437. */
  35438. getNodeByName(name: string): Nullable<Node>;
  35439. /**
  35440. * Gets a mesh using a given name
  35441. * @param name defines the name to search for
  35442. * @return the found mesh or null if not found at all.
  35443. */
  35444. getMeshByName(name: string): Nullable<AbstractMesh>;
  35445. /**
  35446. * Gets a transform node using a given name
  35447. * @param name defines the name to search for
  35448. * @return the found transform node or null if not found at all.
  35449. */
  35450. getTransformNodeByName(name: string): Nullable<TransformNode>;
  35451. /**
  35452. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  35453. * @param id defines the id to search for
  35454. * @return the found skeleton or null if not found at all.
  35455. */
  35456. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  35457. /**
  35458. * Gets a skeleton using a given auto generated unique id
  35459. * @param uniqueId defines the unique id to search for
  35460. * @return the found skeleton or null if not found at all.
  35461. */
  35462. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  35463. /**
  35464. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  35465. * @param id defines the id to search for
  35466. * @return the found skeleton or null if not found at all.
  35467. */
  35468. getSkeletonById(id: string): Nullable<Skeleton>;
  35469. /**
  35470. * Gets a skeleton using a given name
  35471. * @param name defines the name to search for
  35472. * @return the found skeleton or null if not found at all.
  35473. */
  35474. getSkeletonByName(name: string): Nullable<Skeleton>;
  35475. /**
  35476. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  35477. * @param id defines the id to search for
  35478. * @return the found morph target manager or null if not found at all.
  35479. */
  35480. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  35481. /**
  35482. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  35483. * @param id defines the id to search for
  35484. * @return the found morph target or null if not found at all.
  35485. */
  35486. getMorphTargetById(id: string): Nullable<MorphTarget>;
  35487. /**
  35488. * Gets a boolean indicating if the given mesh is active
  35489. * @param mesh defines the mesh to look for
  35490. * @returns true if the mesh is in the active list
  35491. */
  35492. isActiveMesh(mesh: AbstractMesh): boolean;
  35493. /**
  35494. * Return a unique id as a string which can serve as an identifier for the scene
  35495. */
  35496. readonly uid: string;
  35497. /**
  35498. * Add an externaly attached data from its key.
  35499. * This method call will fail and return false, if such key already exists.
  35500. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  35501. * @param key the unique key that identifies the data
  35502. * @param data the data object to associate to the key for this Engine instance
  35503. * @return true if no such key were already present and the data was added successfully, false otherwise
  35504. */
  35505. addExternalData<T>(key: string, data: T): boolean;
  35506. /**
  35507. * Get an externaly attached data from its key
  35508. * @param key the unique key that identifies the data
  35509. * @return the associated data, if present (can be null), or undefined if not present
  35510. */
  35511. getExternalData<T>(key: string): Nullable<T>;
  35512. /**
  35513. * Get an externaly attached data from its key, create it using a factory if it's not already present
  35514. * @param key the unique key that identifies the data
  35515. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  35516. * @return the associated data, can be null if the factory returned null.
  35517. */
  35518. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  35519. /**
  35520. * Remove an externaly attached data from the Engine instance
  35521. * @param key the unique key that identifies the data
  35522. * @return true if the data was successfully removed, false if it doesn't exist
  35523. */
  35524. removeExternalData(key: string): boolean;
  35525. private _evaluateSubMesh;
  35526. /**
  35527. * Clear the processed materials smart array preventing retention point in material dispose.
  35528. */
  35529. freeProcessedMaterials(): void;
  35530. private _preventFreeActiveMeshesAndRenderingGroups;
  35531. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  35532. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  35533. * when disposing several meshes in a row or a hierarchy of meshes.
  35534. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  35535. */
  35536. blockfreeActiveMeshesAndRenderingGroups: boolean;
  35537. /**
  35538. * Clear the active meshes smart array preventing retention point in mesh dispose.
  35539. */
  35540. freeActiveMeshes(): void;
  35541. /**
  35542. * Clear the info related to rendering groups preventing retention points during dispose.
  35543. */
  35544. freeRenderingGroups(): void;
  35545. /** @hidden */
  35546. _isInIntermediateRendering(): boolean;
  35547. /**
  35548. * Lambda returning the list of potentially active meshes.
  35549. */
  35550. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  35551. /**
  35552. * Lambda returning the list of potentially active sub meshes.
  35553. */
  35554. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  35555. /**
  35556. * Lambda returning the list of potentially intersecting sub meshes.
  35557. */
  35558. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  35559. /**
  35560. * Lambda returning the list of potentially colliding sub meshes.
  35561. */
  35562. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  35563. private _activeMeshesFrozen;
  35564. /**
  35565. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  35566. * @returns the current scene
  35567. */
  35568. freezeActiveMeshes(): Scene;
  35569. /**
  35570. * Use this function to restart evaluating active meshes on every frame
  35571. * @returns the current scene
  35572. */
  35573. unfreezeActiveMeshes(): Scene;
  35574. private _evaluateActiveMeshes;
  35575. private _activeMesh;
  35576. /**
  35577. * Update the transform matrix to update from the current active camera
  35578. * @param force defines a boolean used to force the update even if cache is up to date
  35579. */
  35580. updateTransformMatrix(force?: boolean): void;
  35581. private _bindFrameBuffer;
  35582. /** @hidden */
  35583. _allowPostProcessClearColor: boolean;
  35584. /** @hidden */
  35585. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  35586. private _processSubCameras;
  35587. private _checkIntersections;
  35588. /** @hidden */
  35589. _advancePhysicsEngineStep(step: number): void;
  35590. /**
  35591. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  35592. */
  35593. getDeterministicFrameTime: () => number;
  35594. /** @hidden */
  35595. _animate(): void;
  35596. /** Execute all animations (for a frame) */
  35597. animate(): void;
  35598. /**
  35599. * Render the scene
  35600. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  35601. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  35602. */
  35603. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  35604. /**
  35605. * Freeze all materials
  35606. * A frozen material will not be updatable but should be faster to render
  35607. */
  35608. freezeMaterials(): void;
  35609. /**
  35610. * Unfreeze all materials
  35611. * A frozen material will not be updatable but should be faster to render
  35612. */
  35613. unfreezeMaterials(): void;
  35614. /**
  35615. * Releases all held ressources
  35616. */
  35617. dispose(): void;
  35618. /**
  35619. * Gets if the scene is already disposed
  35620. */
  35621. readonly isDisposed: boolean;
  35622. /**
  35623. * Call this function to reduce memory footprint of the scene.
  35624. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  35625. */
  35626. clearCachedVertexData(): void;
  35627. /**
  35628. * This function will remove the local cached buffer data from texture.
  35629. * It will save memory but will prevent the texture from being rebuilt
  35630. */
  35631. cleanCachedTextureBuffer(): void;
  35632. /**
  35633. * Get the world extend vectors with an optional filter
  35634. *
  35635. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  35636. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  35637. */
  35638. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  35639. min: Vector3;
  35640. max: Vector3;
  35641. };
  35642. /**
  35643. * Creates a ray that can be used to pick in the scene
  35644. * @param x defines the x coordinate of the origin (on-screen)
  35645. * @param y defines the y coordinate of the origin (on-screen)
  35646. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35647. * @param camera defines the camera to use for the picking
  35648. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35649. * @returns a Ray
  35650. */
  35651. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  35652. /**
  35653. * Creates a ray that can be used to pick in the scene
  35654. * @param x defines the x coordinate of the origin (on-screen)
  35655. * @param y defines the y coordinate of the origin (on-screen)
  35656. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35657. * @param result defines the ray where to store the picking ray
  35658. * @param camera defines the camera to use for the picking
  35659. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35660. * @returns the current scene
  35661. */
  35662. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  35663. /**
  35664. * Creates a ray that can be used to pick in the scene
  35665. * @param x defines the x coordinate of the origin (on-screen)
  35666. * @param y defines the y coordinate of the origin (on-screen)
  35667. * @param camera defines the camera to use for the picking
  35668. * @returns a Ray
  35669. */
  35670. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  35671. /**
  35672. * Creates a ray that can be used to pick in the scene
  35673. * @param x defines the x coordinate of the origin (on-screen)
  35674. * @param y defines the y coordinate of the origin (on-screen)
  35675. * @param result defines the ray where to store the picking ray
  35676. * @param camera defines the camera to use for the picking
  35677. * @returns the current scene
  35678. */
  35679. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  35680. /** Launch a ray to try to pick a mesh in the scene
  35681. * @param x position on screen
  35682. * @param y position on screen
  35683. * @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
  35684. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  35685. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35686. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35687. * @returns a PickingInfo
  35688. */
  35689. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35690. /** Use the given ray to pick a mesh in the scene
  35691. * @param ray The ray to use to pick meshes
  35692. * @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
  35693. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  35694. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35695. * @returns a PickingInfo
  35696. */
  35697. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35698. /**
  35699. * Launch a ray to try to pick a mesh in the scene
  35700. * @param x X position on screen
  35701. * @param y Y position on screen
  35702. * @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
  35703. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35704. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35705. * @returns an array of PickingInfo
  35706. */
  35707. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35708. /**
  35709. * Launch a ray to try to pick a mesh in the scene
  35710. * @param ray Ray to use
  35711. * @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
  35712. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35713. * @returns an array of PickingInfo
  35714. */
  35715. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35716. /**
  35717. * Force the value of meshUnderPointer
  35718. * @param mesh defines the mesh to use
  35719. */
  35720. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35721. /**
  35722. * Gets the mesh under the pointer
  35723. * @returns a Mesh or null if no mesh is under the pointer
  35724. */
  35725. getPointerOverMesh(): Nullable<AbstractMesh>;
  35726. /** @hidden */
  35727. _rebuildGeometries(): void;
  35728. /** @hidden */
  35729. _rebuildTextures(): void;
  35730. private _getByTags;
  35731. /**
  35732. * Get a list of meshes by tags
  35733. * @param tagsQuery defines the tags query to use
  35734. * @param forEach defines a predicate used to filter results
  35735. * @returns an array of Mesh
  35736. */
  35737. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  35738. /**
  35739. * Get a list of cameras by tags
  35740. * @param tagsQuery defines the tags query to use
  35741. * @param forEach defines a predicate used to filter results
  35742. * @returns an array of Camera
  35743. */
  35744. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  35745. /**
  35746. * Get a list of lights by tags
  35747. * @param tagsQuery defines the tags query to use
  35748. * @param forEach defines a predicate used to filter results
  35749. * @returns an array of Light
  35750. */
  35751. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  35752. /**
  35753. * Get a list of materials by tags
  35754. * @param tagsQuery defines the tags query to use
  35755. * @param forEach defines a predicate used to filter results
  35756. * @returns an array of Material
  35757. */
  35758. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  35759. /**
  35760. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  35761. * This allowed control for front to back rendering or reversly depending of the special needs.
  35762. *
  35763. * @param renderingGroupId The rendering group id corresponding to its index
  35764. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  35765. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  35766. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  35767. */
  35768. 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;
  35769. /**
  35770. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  35771. *
  35772. * @param renderingGroupId The rendering group id corresponding to its index
  35773. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  35774. * @param depth Automatically clears depth between groups if true and autoClear is true.
  35775. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  35776. */
  35777. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  35778. /**
  35779. * Gets the current auto clear configuration for one rendering group of the rendering
  35780. * manager.
  35781. * @param index the rendering group index to get the information for
  35782. * @returns The auto clear setup for the requested rendering group
  35783. */
  35784. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  35785. private _blockMaterialDirtyMechanism;
  35786. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  35787. blockMaterialDirtyMechanism: boolean;
  35788. /**
  35789. * Will flag all materials as dirty to trigger new shader compilation
  35790. * @param flag defines the flag used to specify which material part must be marked as dirty
  35791. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  35792. */
  35793. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  35794. /** @hidden */
  35795. _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;
  35796. /** @hidden */
  35797. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  35798. }
  35799. }
  35800. declare module "babylonjs/assetContainer" {
  35801. import { AbstractScene } from "babylonjs/abstractScene";
  35802. import { Scene } from "babylonjs/scene";
  35803. import { Mesh } from "babylonjs/Meshes/mesh";
  35804. /**
  35805. * Set of assets to keep when moving a scene into an asset container.
  35806. */
  35807. export class KeepAssets extends AbstractScene {
  35808. }
  35809. /**
  35810. * Container with a set of assets that can be added or removed from a scene.
  35811. */
  35812. export class AssetContainer extends AbstractScene {
  35813. /**
  35814. * The scene the AssetContainer belongs to.
  35815. */
  35816. scene: Scene;
  35817. /**
  35818. * Instantiates an AssetContainer.
  35819. * @param scene The scene the AssetContainer belongs to.
  35820. */
  35821. constructor(scene: Scene);
  35822. /**
  35823. * Adds all the assets from the container to the scene.
  35824. */
  35825. addAllToScene(): void;
  35826. /**
  35827. * Removes all the assets in the container from the scene
  35828. */
  35829. removeAllFromScene(): void;
  35830. /**
  35831. * Disposes all the assets in the container
  35832. */
  35833. dispose(): void;
  35834. private _moveAssets;
  35835. /**
  35836. * Removes all the assets contained in the scene and adds them to the container.
  35837. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  35838. */
  35839. moveAllFromScene(keepAssets?: KeepAssets): void;
  35840. /**
  35841. * 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.
  35842. * @returns the root mesh
  35843. */
  35844. createRootMesh(): Mesh;
  35845. }
  35846. }
  35847. declare module "babylonjs/abstractScene" {
  35848. import { Scene } from "babylonjs/scene";
  35849. import { Nullable } from "babylonjs/types";
  35850. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35851. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35852. import { Geometry } from "babylonjs/Meshes/geometry";
  35853. import { Skeleton } from "babylonjs/Bones/skeleton";
  35854. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  35855. import { AssetContainer } from "babylonjs/assetContainer";
  35856. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35857. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35858. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35859. import { Material } from "babylonjs/Materials/material";
  35860. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35861. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  35862. import { Camera } from "babylonjs/Cameras/camera";
  35863. import { Light } from "babylonjs/Lights/light";
  35864. import { Node } from "babylonjs/node";
  35865. import { Animation } from "babylonjs/Animations/animation";
  35866. /**
  35867. * Defines how the parser contract is defined.
  35868. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  35869. */
  35870. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  35871. /**
  35872. * Defines how the individual parser contract is defined.
  35873. * These parser can parse an individual asset
  35874. */
  35875. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  35876. /**
  35877. * Base class of the scene acting as a container for the different elements composing a scene.
  35878. * This class is dynamically extended by the different components of the scene increasing
  35879. * flexibility and reducing coupling
  35880. */
  35881. export abstract class AbstractScene {
  35882. /**
  35883. * Stores the list of available parsers in the application.
  35884. */
  35885. private static _BabylonFileParsers;
  35886. /**
  35887. * Stores the list of available individual parsers in the application.
  35888. */
  35889. private static _IndividualBabylonFileParsers;
  35890. /**
  35891. * Adds a parser in the list of available ones
  35892. * @param name Defines the name of the parser
  35893. * @param parser Defines the parser to add
  35894. */
  35895. static AddParser(name: string, parser: BabylonFileParser): void;
  35896. /**
  35897. * Gets a general parser from the list of avaialble ones
  35898. * @param name Defines the name of the parser
  35899. * @returns the requested parser or null
  35900. */
  35901. static GetParser(name: string): Nullable<BabylonFileParser>;
  35902. /**
  35903. * Adds n individual parser in the list of available ones
  35904. * @param name Defines the name of the parser
  35905. * @param parser Defines the parser to add
  35906. */
  35907. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  35908. /**
  35909. * Gets an individual parser from the list of avaialble ones
  35910. * @param name Defines the name of the parser
  35911. * @returns the requested parser or null
  35912. */
  35913. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  35914. /**
  35915. * Parser json data and populate both a scene and its associated container object
  35916. * @param jsonData Defines the data to parse
  35917. * @param scene Defines the scene to parse the data for
  35918. * @param container Defines the container attached to the parsing sequence
  35919. * @param rootUrl Defines the root url of the data
  35920. */
  35921. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  35922. /**
  35923. * Gets the list of root nodes (ie. nodes with no parent)
  35924. */
  35925. rootNodes: Node[];
  35926. /** All of the cameras added to this scene
  35927. * @see http://doc.babylonjs.com/babylon101/cameras
  35928. */
  35929. cameras: Camera[];
  35930. /**
  35931. * All of the lights added to this scene
  35932. * @see http://doc.babylonjs.com/babylon101/lights
  35933. */
  35934. lights: Light[];
  35935. /**
  35936. * All of the (abstract) meshes added to this scene
  35937. */
  35938. meshes: AbstractMesh[];
  35939. /**
  35940. * The list of skeletons added to the scene
  35941. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35942. */
  35943. skeletons: Skeleton[];
  35944. /**
  35945. * All of the particle systems added to this scene
  35946. * @see http://doc.babylonjs.com/babylon101/particles
  35947. */
  35948. particleSystems: IParticleSystem[];
  35949. /**
  35950. * Gets a list of Animations associated with the scene
  35951. */
  35952. animations: Animation[];
  35953. /**
  35954. * All of the animation groups added to this scene
  35955. * @see http://doc.babylonjs.com/how_to/group
  35956. */
  35957. animationGroups: AnimationGroup[];
  35958. /**
  35959. * All of the multi-materials added to this scene
  35960. * @see http://doc.babylonjs.com/how_to/multi_materials
  35961. */
  35962. multiMaterials: MultiMaterial[];
  35963. /**
  35964. * All of the materials added to this scene
  35965. * In the context of a Scene, it is not supposed to be modified manually.
  35966. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  35967. * Note also that the order of the Material wihin the array is not significant and might change.
  35968. * @see http://doc.babylonjs.com/babylon101/materials
  35969. */
  35970. materials: Material[];
  35971. /**
  35972. * The list of morph target managers added to the scene
  35973. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  35974. */
  35975. morphTargetManagers: MorphTargetManager[];
  35976. /**
  35977. * The list of geometries used in the scene.
  35978. */
  35979. geometries: Geometry[];
  35980. /**
  35981. * All of the tranform nodes added to this scene
  35982. * In the context of a Scene, it is not supposed to be modified manually.
  35983. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  35984. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  35985. * @see http://doc.babylonjs.com/how_to/transformnode
  35986. */
  35987. transformNodes: TransformNode[];
  35988. /**
  35989. * ActionManagers available on the scene.
  35990. */
  35991. actionManagers: AbstractActionManager[];
  35992. /**
  35993. * Textures to keep.
  35994. */
  35995. textures: BaseTexture[];
  35996. /**
  35997. * Environment texture for the scene
  35998. */
  35999. environmentTexture: Nullable<BaseTexture>;
  36000. }
  36001. }
  36002. declare module "babylonjs/Audio/sound" {
  36003. import { Observable } from "babylonjs/Misc/observable";
  36004. import { Vector3 } from "babylonjs/Maths/math.vector";
  36005. import { Nullable } from "babylonjs/types";
  36006. import { Scene } from "babylonjs/scene";
  36007. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36008. /**
  36009. * Interface used to define options for Sound class
  36010. */
  36011. export interface ISoundOptions {
  36012. /**
  36013. * Does the sound autoplay once loaded.
  36014. */
  36015. autoplay?: boolean;
  36016. /**
  36017. * Does the sound loop after it finishes playing once.
  36018. */
  36019. loop?: boolean;
  36020. /**
  36021. * Sound's volume
  36022. */
  36023. volume?: number;
  36024. /**
  36025. * Is it a spatial sound?
  36026. */
  36027. spatialSound?: boolean;
  36028. /**
  36029. * Maximum distance to hear that sound
  36030. */
  36031. maxDistance?: number;
  36032. /**
  36033. * Uses user defined attenuation function
  36034. */
  36035. useCustomAttenuation?: boolean;
  36036. /**
  36037. * Define the roll off factor of spatial sounds.
  36038. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36039. */
  36040. rolloffFactor?: number;
  36041. /**
  36042. * Define the reference distance the sound should be heard perfectly.
  36043. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36044. */
  36045. refDistance?: number;
  36046. /**
  36047. * Define the distance attenuation model the sound will follow.
  36048. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36049. */
  36050. distanceModel?: string;
  36051. /**
  36052. * Defines the playback speed (1 by default)
  36053. */
  36054. playbackRate?: number;
  36055. /**
  36056. * Defines if the sound is from a streaming source
  36057. */
  36058. streaming?: boolean;
  36059. /**
  36060. * Defines an optional length (in seconds) inside the sound file
  36061. */
  36062. length?: number;
  36063. /**
  36064. * Defines an optional offset (in seconds) inside the sound file
  36065. */
  36066. offset?: number;
  36067. /**
  36068. * If true, URLs will not be required to state the audio file codec to use.
  36069. */
  36070. skipCodecCheck?: boolean;
  36071. }
  36072. /**
  36073. * Defines a sound that can be played in the application.
  36074. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  36075. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36076. */
  36077. export class Sound {
  36078. /**
  36079. * The name of the sound in the scene.
  36080. */
  36081. name: string;
  36082. /**
  36083. * Does the sound autoplay once loaded.
  36084. */
  36085. autoplay: boolean;
  36086. /**
  36087. * Does the sound loop after it finishes playing once.
  36088. */
  36089. loop: boolean;
  36090. /**
  36091. * Does the sound use a custom attenuation curve to simulate the falloff
  36092. * happening when the source gets further away from the camera.
  36093. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36094. */
  36095. useCustomAttenuation: boolean;
  36096. /**
  36097. * The sound track id this sound belongs to.
  36098. */
  36099. soundTrackId: number;
  36100. /**
  36101. * Is this sound currently played.
  36102. */
  36103. isPlaying: boolean;
  36104. /**
  36105. * Is this sound currently paused.
  36106. */
  36107. isPaused: boolean;
  36108. /**
  36109. * Does this sound enables spatial sound.
  36110. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36111. */
  36112. spatialSound: boolean;
  36113. /**
  36114. * Define the reference distance the sound should be heard perfectly.
  36115. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36116. */
  36117. refDistance: number;
  36118. /**
  36119. * Define the roll off factor of spatial sounds.
  36120. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36121. */
  36122. rolloffFactor: number;
  36123. /**
  36124. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  36125. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36126. */
  36127. maxDistance: number;
  36128. /**
  36129. * Define the distance attenuation model the sound will follow.
  36130. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36131. */
  36132. distanceModel: string;
  36133. /**
  36134. * @hidden
  36135. * Back Compat
  36136. **/
  36137. onended: () => any;
  36138. /**
  36139. * Observable event when the current playing sound finishes.
  36140. */
  36141. onEndedObservable: Observable<Sound>;
  36142. private _panningModel;
  36143. private _playbackRate;
  36144. private _streaming;
  36145. private _startTime;
  36146. private _startOffset;
  36147. private _position;
  36148. /** @hidden */
  36149. _positionInEmitterSpace: boolean;
  36150. private _localDirection;
  36151. private _volume;
  36152. private _isReadyToPlay;
  36153. private _isDirectional;
  36154. private _readyToPlayCallback;
  36155. private _audioBuffer;
  36156. private _soundSource;
  36157. private _streamingSource;
  36158. private _soundPanner;
  36159. private _soundGain;
  36160. private _inputAudioNode;
  36161. private _outputAudioNode;
  36162. private _coneInnerAngle;
  36163. private _coneOuterAngle;
  36164. private _coneOuterGain;
  36165. private _scene;
  36166. private _connectedTransformNode;
  36167. private _customAttenuationFunction;
  36168. private _registerFunc;
  36169. private _isOutputConnected;
  36170. private _htmlAudioElement;
  36171. private _urlType;
  36172. private _length?;
  36173. private _offset?;
  36174. /** @hidden */
  36175. static _SceneComponentInitialization: (scene: Scene) => void;
  36176. /**
  36177. * Create a sound and attach it to a scene
  36178. * @param name Name of your sound
  36179. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  36180. * @param scene defines the scene the sound belongs to
  36181. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  36182. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  36183. */
  36184. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  36185. /**
  36186. * Release the sound and its associated resources
  36187. */
  36188. dispose(): void;
  36189. /**
  36190. * Gets if the sounds is ready to be played or not.
  36191. * @returns true if ready, otherwise false
  36192. */
  36193. isReady(): boolean;
  36194. private _soundLoaded;
  36195. /**
  36196. * Sets the data of the sound from an audiobuffer
  36197. * @param audioBuffer The audioBuffer containing the data
  36198. */
  36199. setAudioBuffer(audioBuffer: AudioBuffer): void;
  36200. /**
  36201. * Updates the current sounds options such as maxdistance, loop...
  36202. * @param options A JSON object containing values named as the object properties
  36203. */
  36204. updateOptions(options: ISoundOptions): void;
  36205. private _createSpatialParameters;
  36206. private _updateSpatialParameters;
  36207. /**
  36208. * Switch the panning model to HRTF:
  36209. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36210. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36211. */
  36212. switchPanningModelToHRTF(): void;
  36213. /**
  36214. * Switch the panning model to Equal Power:
  36215. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36216. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36217. */
  36218. switchPanningModelToEqualPower(): void;
  36219. private _switchPanningModel;
  36220. /**
  36221. * Connect this sound to a sound track audio node like gain...
  36222. * @param soundTrackAudioNode the sound track audio node to connect to
  36223. */
  36224. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  36225. /**
  36226. * Transform this sound into a directional source
  36227. * @param coneInnerAngle Size of the inner cone in degree
  36228. * @param coneOuterAngle Size of the outer cone in degree
  36229. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  36230. */
  36231. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  36232. /**
  36233. * Gets or sets the inner angle for the directional cone.
  36234. */
  36235. /**
  36236. * Gets or sets the inner angle for the directional cone.
  36237. */
  36238. directionalConeInnerAngle: number;
  36239. /**
  36240. * Gets or sets the outer angle for the directional cone.
  36241. */
  36242. /**
  36243. * Gets or sets the outer angle for the directional cone.
  36244. */
  36245. directionalConeOuterAngle: number;
  36246. /**
  36247. * Sets the position of the emitter if spatial sound is enabled
  36248. * @param newPosition Defines the new posisiton
  36249. */
  36250. setPosition(newPosition: Vector3): void;
  36251. /**
  36252. * Sets the local direction of the emitter if spatial sound is enabled
  36253. * @param newLocalDirection Defines the new local direction
  36254. */
  36255. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  36256. private _updateDirection;
  36257. /** @hidden */
  36258. updateDistanceFromListener(): void;
  36259. /**
  36260. * Sets a new custom attenuation function for the sound.
  36261. * @param callback Defines the function used for the attenuation
  36262. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36263. */
  36264. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  36265. /**
  36266. * Play the sound
  36267. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  36268. * @param offset (optional) Start the sound at a specific time in seconds
  36269. * @param length (optional) Sound duration (in seconds)
  36270. */
  36271. play(time?: number, offset?: number, length?: number): void;
  36272. private _onended;
  36273. /**
  36274. * Stop the sound
  36275. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  36276. */
  36277. stop(time?: number): void;
  36278. /**
  36279. * Put the sound in pause
  36280. */
  36281. pause(): void;
  36282. /**
  36283. * Sets a dedicated volume for this sounds
  36284. * @param newVolume Define the new volume of the sound
  36285. * @param time Define time for gradual change to new volume
  36286. */
  36287. setVolume(newVolume: number, time?: number): void;
  36288. /**
  36289. * Set the sound play back rate
  36290. * @param newPlaybackRate Define the playback rate the sound should be played at
  36291. */
  36292. setPlaybackRate(newPlaybackRate: number): void;
  36293. /**
  36294. * Gets the volume of the sound.
  36295. * @returns the volume of the sound
  36296. */
  36297. getVolume(): number;
  36298. /**
  36299. * Attach the sound to a dedicated mesh
  36300. * @param transformNode The transform node to connect the sound with
  36301. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36302. */
  36303. attachToMesh(transformNode: TransformNode): void;
  36304. /**
  36305. * Detach the sound from the previously attached mesh
  36306. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36307. */
  36308. detachFromMesh(): void;
  36309. private _onRegisterAfterWorldMatrixUpdate;
  36310. /**
  36311. * Clone the current sound in the scene.
  36312. * @returns the new sound clone
  36313. */
  36314. clone(): Nullable<Sound>;
  36315. /**
  36316. * Gets the current underlying audio buffer containing the data
  36317. * @returns the audio buffer
  36318. */
  36319. getAudioBuffer(): Nullable<AudioBuffer>;
  36320. /**
  36321. * Serializes the Sound in a JSON representation
  36322. * @returns the JSON representation of the sound
  36323. */
  36324. serialize(): any;
  36325. /**
  36326. * Parse a JSON representation of a sound to innstantiate in a given scene
  36327. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  36328. * @param scene Define the scene the new parsed sound should be created in
  36329. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  36330. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  36331. * @returns the newly parsed sound
  36332. */
  36333. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  36334. }
  36335. }
  36336. declare module "babylonjs/Actions/directAudioActions" {
  36337. import { Action } from "babylonjs/Actions/action";
  36338. import { Condition } from "babylonjs/Actions/condition";
  36339. import { Sound } from "babylonjs/Audio/sound";
  36340. /**
  36341. * This defines an action helpful to play a defined sound on a triggered action.
  36342. */
  36343. export class PlaySoundAction extends Action {
  36344. private _sound;
  36345. /**
  36346. * Instantiate the action
  36347. * @param triggerOptions defines the trigger options
  36348. * @param sound defines the sound to play
  36349. * @param condition defines the trigger related conditions
  36350. */
  36351. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36352. /** @hidden */
  36353. _prepare(): void;
  36354. /**
  36355. * Execute the action and play the sound.
  36356. */
  36357. execute(): void;
  36358. /**
  36359. * Serializes the actions and its related information.
  36360. * @param parent defines the object to serialize in
  36361. * @returns the serialized object
  36362. */
  36363. serialize(parent: any): any;
  36364. }
  36365. /**
  36366. * This defines an action helpful to stop a defined sound on a triggered action.
  36367. */
  36368. export class StopSoundAction extends Action {
  36369. private _sound;
  36370. /**
  36371. * Instantiate the action
  36372. * @param triggerOptions defines the trigger options
  36373. * @param sound defines the sound to stop
  36374. * @param condition defines the trigger related conditions
  36375. */
  36376. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36377. /** @hidden */
  36378. _prepare(): void;
  36379. /**
  36380. * Execute the action and stop the sound.
  36381. */
  36382. execute(): void;
  36383. /**
  36384. * Serializes the actions and its related information.
  36385. * @param parent defines the object to serialize in
  36386. * @returns the serialized object
  36387. */
  36388. serialize(parent: any): any;
  36389. }
  36390. }
  36391. declare module "babylonjs/Actions/interpolateValueAction" {
  36392. import { Action } from "babylonjs/Actions/action";
  36393. import { Condition } from "babylonjs/Actions/condition";
  36394. import { Observable } from "babylonjs/Misc/observable";
  36395. /**
  36396. * This defines an action responsible to change the value of a property
  36397. * by interpolating between its current value and the newly set one once triggered.
  36398. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36399. */
  36400. export class InterpolateValueAction extends Action {
  36401. /**
  36402. * Defines the path of the property where the value should be interpolated
  36403. */
  36404. propertyPath: string;
  36405. /**
  36406. * Defines the target value at the end of the interpolation.
  36407. */
  36408. value: any;
  36409. /**
  36410. * Defines the time it will take for the property to interpolate to the value.
  36411. */
  36412. duration: number;
  36413. /**
  36414. * Defines if the other scene animations should be stopped when the action has been triggered
  36415. */
  36416. stopOtherAnimations?: boolean;
  36417. /**
  36418. * Defines a callback raised once the interpolation animation has been done.
  36419. */
  36420. onInterpolationDone?: () => void;
  36421. /**
  36422. * Observable triggered once the interpolation animation has been done.
  36423. */
  36424. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  36425. private _target;
  36426. private _effectiveTarget;
  36427. private _property;
  36428. /**
  36429. * Instantiate the action
  36430. * @param triggerOptions defines the trigger options
  36431. * @param target defines the object containing the value to interpolate
  36432. * @param propertyPath defines the path to the property in the target object
  36433. * @param value defines the target value at the end of the interpolation
  36434. * @param duration deines the time it will take for the property to interpolate to the value.
  36435. * @param condition defines the trigger related conditions
  36436. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  36437. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  36438. */
  36439. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  36440. /** @hidden */
  36441. _prepare(): void;
  36442. /**
  36443. * Execute the action starts the value interpolation.
  36444. */
  36445. execute(): void;
  36446. /**
  36447. * Serializes the actions and its related information.
  36448. * @param parent defines the object to serialize in
  36449. * @returns the serialized object
  36450. */
  36451. serialize(parent: any): any;
  36452. }
  36453. }
  36454. declare module "babylonjs/Actions/index" {
  36455. export * from "babylonjs/Actions/abstractActionManager";
  36456. export * from "babylonjs/Actions/action";
  36457. export * from "babylonjs/Actions/actionEvent";
  36458. export * from "babylonjs/Actions/actionManager";
  36459. export * from "babylonjs/Actions/condition";
  36460. export * from "babylonjs/Actions/directActions";
  36461. export * from "babylonjs/Actions/directAudioActions";
  36462. export * from "babylonjs/Actions/interpolateValueAction";
  36463. }
  36464. declare module "babylonjs/Animations/index" {
  36465. export * from "babylonjs/Animations/animatable";
  36466. export * from "babylonjs/Animations/animation";
  36467. export * from "babylonjs/Animations/animationGroup";
  36468. export * from "babylonjs/Animations/animationPropertiesOverride";
  36469. export * from "babylonjs/Animations/easing";
  36470. export * from "babylonjs/Animations/runtimeAnimation";
  36471. export * from "babylonjs/Animations/animationEvent";
  36472. export * from "babylonjs/Animations/animationGroup";
  36473. export * from "babylonjs/Animations/animationKey";
  36474. export * from "babylonjs/Animations/animationRange";
  36475. export * from "babylonjs/Animations/animatable.interface";
  36476. }
  36477. declare module "babylonjs/Audio/soundTrack" {
  36478. import { Sound } from "babylonjs/Audio/sound";
  36479. import { Analyser } from "babylonjs/Audio/analyser";
  36480. import { Scene } from "babylonjs/scene";
  36481. /**
  36482. * Options allowed during the creation of a sound track.
  36483. */
  36484. export interface ISoundTrackOptions {
  36485. /**
  36486. * The volume the sound track should take during creation
  36487. */
  36488. volume?: number;
  36489. /**
  36490. * Define if the sound track is the main sound track of the scene
  36491. */
  36492. mainTrack?: boolean;
  36493. }
  36494. /**
  36495. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  36496. * It will be also used in a future release to apply effects on a specific track.
  36497. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36498. */
  36499. export class SoundTrack {
  36500. /**
  36501. * The unique identifier of the sound track in the scene.
  36502. */
  36503. id: number;
  36504. /**
  36505. * The list of sounds included in the sound track.
  36506. */
  36507. soundCollection: Array<Sound>;
  36508. private _outputAudioNode;
  36509. private _scene;
  36510. private _isMainTrack;
  36511. private _connectedAnalyser;
  36512. private _options;
  36513. private _isInitialized;
  36514. /**
  36515. * Creates a new sound track.
  36516. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36517. * @param scene Define the scene the sound track belongs to
  36518. * @param options
  36519. */
  36520. constructor(scene: Scene, options?: ISoundTrackOptions);
  36521. private _initializeSoundTrackAudioGraph;
  36522. /**
  36523. * Release the sound track and its associated resources
  36524. */
  36525. dispose(): void;
  36526. /**
  36527. * Adds a sound to this sound track
  36528. * @param sound define the cound to add
  36529. * @ignoreNaming
  36530. */
  36531. AddSound(sound: Sound): void;
  36532. /**
  36533. * Removes a sound to this sound track
  36534. * @param sound define the cound to remove
  36535. * @ignoreNaming
  36536. */
  36537. RemoveSound(sound: Sound): void;
  36538. /**
  36539. * Set a global volume for the full sound track.
  36540. * @param newVolume Define the new volume of the sound track
  36541. */
  36542. setVolume(newVolume: number): void;
  36543. /**
  36544. * Switch the panning model to HRTF:
  36545. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36546. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36547. */
  36548. switchPanningModelToHRTF(): void;
  36549. /**
  36550. * Switch the panning model to Equal Power:
  36551. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36552. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36553. */
  36554. switchPanningModelToEqualPower(): void;
  36555. /**
  36556. * Connect the sound track to an audio analyser allowing some amazing
  36557. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36558. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36559. * @param analyser The analyser to connect to the engine
  36560. */
  36561. connectToAnalyser(analyser: Analyser): void;
  36562. }
  36563. }
  36564. declare module "babylonjs/Audio/audioSceneComponent" {
  36565. import { Sound } from "babylonjs/Audio/sound";
  36566. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  36567. import { Nullable } from "babylonjs/types";
  36568. import { Vector3 } from "babylonjs/Maths/math.vector";
  36569. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  36570. import { Scene } from "babylonjs/scene";
  36571. import { AbstractScene } from "babylonjs/abstractScene";
  36572. import "babylonjs/Audio/audioEngine";
  36573. module "babylonjs/abstractScene" {
  36574. interface AbstractScene {
  36575. /**
  36576. * The list of sounds used in the scene.
  36577. */
  36578. sounds: Nullable<Array<Sound>>;
  36579. }
  36580. }
  36581. module "babylonjs/scene" {
  36582. interface Scene {
  36583. /**
  36584. * @hidden
  36585. * Backing field
  36586. */
  36587. _mainSoundTrack: SoundTrack;
  36588. /**
  36589. * The main sound track played by the scene.
  36590. * It cotains your primary collection of sounds.
  36591. */
  36592. mainSoundTrack: SoundTrack;
  36593. /**
  36594. * The list of sound tracks added to the scene
  36595. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36596. */
  36597. soundTracks: Nullable<Array<SoundTrack>>;
  36598. /**
  36599. * Gets a sound using a given name
  36600. * @param name defines the name to search for
  36601. * @return the found sound or null if not found at all.
  36602. */
  36603. getSoundByName(name: string): Nullable<Sound>;
  36604. /**
  36605. * Gets or sets if audio support is enabled
  36606. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36607. */
  36608. audioEnabled: boolean;
  36609. /**
  36610. * Gets or sets if audio will be output to headphones
  36611. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36612. */
  36613. headphone: boolean;
  36614. /**
  36615. * Gets or sets custom audio listener position provider
  36616. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36617. */
  36618. audioListenerPositionProvider: Nullable<() => Vector3>;
  36619. }
  36620. }
  36621. /**
  36622. * Defines the sound scene component responsible to manage any sounds
  36623. * in a given scene.
  36624. */
  36625. export class AudioSceneComponent implements ISceneSerializableComponent {
  36626. /**
  36627. * The component name helpfull to identify the component in the list of scene components.
  36628. */
  36629. readonly name: string;
  36630. /**
  36631. * The scene the component belongs to.
  36632. */
  36633. scene: Scene;
  36634. private _audioEnabled;
  36635. /**
  36636. * Gets whether audio is enabled or not.
  36637. * Please use related enable/disable method to switch state.
  36638. */
  36639. readonly audioEnabled: boolean;
  36640. private _headphone;
  36641. /**
  36642. * Gets whether audio is outputing to headphone or not.
  36643. * Please use the according Switch methods to change output.
  36644. */
  36645. readonly headphone: boolean;
  36646. private _audioListenerPositionProvider;
  36647. /**
  36648. * Gets the current audio listener position provider
  36649. */
  36650. /**
  36651. * Sets a custom listener position for all sounds in the scene
  36652. * By default, this is the position of the first active camera
  36653. */
  36654. audioListenerPositionProvider: Nullable<() => Vector3>;
  36655. /**
  36656. * Creates a new instance of the component for the given scene
  36657. * @param scene Defines the scene to register the component in
  36658. */
  36659. constructor(scene: Scene);
  36660. /**
  36661. * Registers the component in a given scene
  36662. */
  36663. register(): void;
  36664. /**
  36665. * Rebuilds the elements related to this component in case of
  36666. * context lost for instance.
  36667. */
  36668. rebuild(): void;
  36669. /**
  36670. * Serializes the component data to the specified json object
  36671. * @param serializationObject The object to serialize to
  36672. */
  36673. serialize(serializationObject: any): void;
  36674. /**
  36675. * Adds all the elements from the container to the scene
  36676. * @param container the container holding the elements
  36677. */
  36678. addFromContainer(container: AbstractScene): void;
  36679. /**
  36680. * Removes all the elements in the container from the scene
  36681. * @param container contains the elements to remove
  36682. * @param dispose if the removed element should be disposed (default: false)
  36683. */
  36684. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  36685. /**
  36686. * Disposes the component and the associated ressources.
  36687. */
  36688. dispose(): void;
  36689. /**
  36690. * Disables audio in the associated scene.
  36691. */
  36692. disableAudio(): void;
  36693. /**
  36694. * Enables audio in the associated scene.
  36695. */
  36696. enableAudio(): void;
  36697. /**
  36698. * Switch audio to headphone output.
  36699. */
  36700. switchAudioModeForHeadphones(): void;
  36701. /**
  36702. * Switch audio to normal speakers.
  36703. */
  36704. switchAudioModeForNormalSpeakers(): void;
  36705. private _afterRender;
  36706. }
  36707. }
  36708. declare module "babylonjs/Audio/weightedsound" {
  36709. import { Sound } from "babylonjs/Audio/sound";
  36710. /**
  36711. * Wraps one or more Sound objects and selects one with random weight for playback.
  36712. */
  36713. export class WeightedSound {
  36714. /** When true a Sound will be selected and played when the current playing Sound completes. */
  36715. loop: boolean;
  36716. private _coneInnerAngle;
  36717. private _coneOuterAngle;
  36718. private _volume;
  36719. /** A Sound is currently playing. */
  36720. isPlaying: boolean;
  36721. /** A Sound is currently paused. */
  36722. isPaused: boolean;
  36723. private _sounds;
  36724. private _weights;
  36725. private _currentIndex?;
  36726. /**
  36727. * Creates a new WeightedSound from the list of sounds given.
  36728. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  36729. * @param sounds Array of Sounds that will be selected from.
  36730. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  36731. */
  36732. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  36733. /**
  36734. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  36735. */
  36736. /**
  36737. * The size of cone in degress for a directional sound in which there will be no attenuation.
  36738. */
  36739. directionalConeInnerAngle: number;
  36740. /**
  36741. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36742. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36743. */
  36744. /**
  36745. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36746. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36747. */
  36748. directionalConeOuterAngle: number;
  36749. /**
  36750. * Playback volume.
  36751. */
  36752. /**
  36753. * Playback volume.
  36754. */
  36755. volume: number;
  36756. private _onended;
  36757. /**
  36758. * Suspend playback
  36759. */
  36760. pause(): void;
  36761. /**
  36762. * Stop playback
  36763. */
  36764. stop(): void;
  36765. /**
  36766. * Start playback.
  36767. * @param startOffset Position the clip head at a specific time in seconds.
  36768. */
  36769. play(startOffset?: number): void;
  36770. }
  36771. }
  36772. declare module "babylonjs/Audio/index" {
  36773. export * from "babylonjs/Audio/analyser";
  36774. export * from "babylonjs/Audio/audioEngine";
  36775. export * from "babylonjs/Audio/audioSceneComponent";
  36776. export * from "babylonjs/Audio/sound";
  36777. export * from "babylonjs/Audio/soundTrack";
  36778. export * from "babylonjs/Audio/weightedsound";
  36779. }
  36780. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  36781. import { Behavior } from "babylonjs/Behaviors/behavior";
  36782. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36783. import { BackEase } from "babylonjs/Animations/easing";
  36784. /**
  36785. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  36786. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36787. */
  36788. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  36789. /**
  36790. * Gets the name of the behavior.
  36791. */
  36792. readonly name: string;
  36793. /**
  36794. * The easing function used by animations
  36795. */
  36796. static EasingFunction: BackEase;
  36797. /**
  36798. * The easing mode used by animations
  36799. */
  36800. static EasingMode: number;
  36801. /**
  36802. * The duration of the animation, in milliseconds
  36803. */
  36804. transitionDuration: number;
  36805. /**
  36806. * Length of the distance animated by the transition when lower radius is reached
  36807. */
  36808. lowerRadiusTransitionRange: number;
  36809. /**
  36810. * Length of the distance animated by the transition when upper radius is reached
  36811. */
  36812. upperRadiusTransitionRange: number;
  36813. private _autoTransitionRange;
  36814. /**
  36815. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36816. */
  36817. /**
  36818. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36819. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  36820. */
  36821. autoTransitionRange: boolean;
  36822. private _attachedCamera;
  36823. private _onAfterCheckInputsObserver;
  36824. private _onMeshTargetChangedObserver;
  36825. /**
  36826. * Initializes the behavior.
  36827. */
  36828. init(): void;
  36829. /**
  36830. * Attaches the behavior to its arc rotate camera.
  36831. * @param camera Defines the camera to attach the behavior to
  36832. */
  36833. attach(camera: ArcRotateCamera): void;
  36834. /**
  36835. * Detaches the behavior from its current arc rotate camera.
  36836. */
  36837. detach(): void;
  36838. private _radiusIsAnimating;
  36839. private _radiusBounceTransition;
  36840. private _animatables;
  36841. private _cachedWheelPrecision;
  36842. /**
  36843. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  36844. * @param radiusLimit The limit to check against.
  36845. * @return Bool to indicate if at limit.
  36846. */
  36847. private _isRadiusAtLimit;
  36848. /**
  36849. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  36850. * @param radiusDelta The delta by which to animate to. Can be negative.
  36851. */
  36852. private _applyBoundRadiusAnimation;
  36853. /**
  36854. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  36855. */
  36856. protected _clearAnimationLocks(): void;
  36857. /**
  36858. * Stops and removes all animations that have been applied to the camera
  36859. */
  36860. stopAllAnimations(): void;
  36861. }
  36862. }
  36863. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  36864. import { Behavior } from "babylonjs/Behaviors/behavior";
  36865. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36866. import { ExponentialEase } from "babylonjs/Animations/easing";
  36867. import { Nullable } from "babylonjs/types";
  36868. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36869. import { Vector3 } from "babylonjs/Maths/math.vector";
  36870. /**
  36871. * 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.
  36872. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36873. */
  36874. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  36875. /**
  36876. * Gets the name of the behavior.
  36877. */
  36878. readonly name: string;
  36879. private _mode;
  36880. private _radiusScale;
  36881. private _positionScale;
  36882. private _defaultElevation;
  36883. private _elevationReturnTime;
  36884. private _elevationReturnWaitTime;
  36885. private _zoomStopsAnimation;
  36886. private _framingTime;
  36887. /**
  36888. * The easing function used by animations
  36889. */
  36890. static EasingFunction: ExponentialEase;
  36891. /**
  36892. * The easing mode used by animations
  36893. */
  36894. static EasingMode: number;
  36895. /**
  36896. * Sets the current mode used by the behavior
  36897. */
  36898. /**
  36899. * Gets current mode used by the behavior.
  36900. */
  36901. mode: number;
  36902. /**
  36903. * Sets the scale applied to the radius (1 by default)
  36904. */
  36905. /**
  36906. * Gets the scale applied to the radius
  36907. */
  36908. radiusScale: number;
  36909. /**
  36910. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36911. */
  36912. /**
  36913. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36914. */
  36915. positionScale: number;
  36916. /**
  36917. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36918. * behaviour is triggered, in radians.
  36919. */
  36920. /**
  36921. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36922. * behaviour is triggered, in radians.
  36923. */
  36924. defaultElevation: number;
  36925. /**
  36926. * Sets the time (in milliseconds) taken to return to the default beta position.
  36927. * Negative value indicates camera should not return to default.
  36928. */
  36929. /**
  36930. * Gets the time (in milliseconds) taken to return to the default beta position.
  36931. * Negative value indicates camera should not return to default.
  36932. */
  36933. elevationReturnTime: number;
  36934. /**
  36935. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36936. */
  36937. /**
  36938. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36939. */
  36940. elevationReturnWaitTime: number;
  36941. /**
  36942. * Sets the flag that indicates if user zooming should stop animation.
  36943. */
  36944. /**
  36945. * Gets the flag that indicates if user zooming should stop animation.
  36946. */
  36947. zoomStopsAnimation: boolean;
  36948. /**
  36949. * Sets the transition time when framing the mesh, in milliseconds
  36950. */
  36951. /**
  36952. * Gets the transition time when framing the mesh, in milliseconds
  36953. */
  36954. framingTime: number;
  36955. /**
  36956. * Define if the behavior should automatically change the configured
  36957. * camera limits and sensibilities.
  36958. */
  36959. autoCorrectCameraLimitsAndSensibility: boolean;
  36960. private _onPrePointerObservableObserver;
  36961. private _onAfterCheckInputsObserver;
  36962. private _onMeshTargetChangedObserver;
  36963. private _attachedCamera;
  36964. private _isPointerDown;
  36965. private _lastInteractionTime;
  36966. /**
  36967. * Initializes the behavior.
  36968. */
  36969. init(): void;
  36970. /**
  36971. * Attaches the behavior to its arc rotate camera.
  36972. * @param camera Defines the camera to attach the behavior to
  36973. */
  36974. attach(camera: ArcRotateCamera): void;
  36975. /**
  36976. * Detaches the behavior from its current arc rotate camera.
  36977. */
  36978. detach(): void;
  36979. private _animatables;
  36980. private _betaIsAnimating;
  36981. private _betaTransition;
  36982. private _radiusTransition;
  36983. private _vectorTransition;
  36984. /**
  36985. * Targets the given mesh and updates zoom level accordingly.
  36986. * @param mesh The mesh to target.
  36987. * @param radius Optional. If a cached radius position already exists, overrides default.
  36988. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36989. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36990. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36991. */
  36992. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36993. /**
  36994. * Targets the given mesh with its children and updates zoom level accordingly.
  36995. * @param mesh The mesh to target.
  36996. * @param radius Optional. If a cached radius position already exists, overrides default.
  36997. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36998. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36999. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37000. */
  37001. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37002. /**
  37003. * Targets the given meshes with their children and updates zoom level accordingly.
  37004. * @param meshes The mesh to target.
  37005. * @param radius Optional. If a cached radius position already exists, overrides default.
  37006. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37007. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37008. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37009. */
  37010. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37011. /**
  37012. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  37013. * @param minimumWorld Determines the smaller position of the bounding box extend
  37014. * @param maximumWorld Determines the bigger position of the bounding box extend
  37015. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37016. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37017. */
  37018. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37019. /**
  37020. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  37021. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  37022. * frustum width.
  37023. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  37024. * to fully enclose the mesh in the viewing frustum.
  37025. */
  37026. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  37027. /**
  37028. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  37029. * is automatically returned to its default position (expected to be above ground plane).
  37030. */
  37031. private _maintainCameraAboveGround;
  37032. /**
  37033. * Returns the frustum slope based on the canvas ratio and camera FOV
  37034. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  37035. */
  37036. private _getFrustumSlope;
  37037. /**
  37038. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  37039. */
  37040. private _clearAnimationLocks;
  37041. /**
  37042. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37043. */
  37044. private _applyUserInteraction;
  37045. /**
  37046. * Stops and removes all animations that have been applied to the camera
  37047. */
  37048. stopAllAnimations(): void;
  37049. /**
  37050. * Gets a value indicating if the user is moving the camera
  37051. */
  37052. readonly isUserIsMoving: boolean;
  37053. /**
  37054. * The camera can move all the way towards the mesh.
  37055. */
  37056. static IgnoreBoundsSizeMode: number;
  37057. /**
  37058. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  37059. */
  37060. static FitFrustumSidesMode: number;
  37061. }
  37062. }
  37063. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  37064. import { Nullable } from "babylonjs/types";
  37065. import { Camera } from "babylonjs/Cameras/camera";
  37066. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37067. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37068. /**
  37069. * Base class for Camera Pointer Inputs.
  37070. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  37071. * for example usage.
  37072. */
  37073. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  37074. /**
  37075. * Defines the camera the input is attached to.
  37076. */
  37077. abstract camera: Camera;
  37078. /**
  37079. * Whether keyboard modifier keys are pressed at time of last mouse event.
  37080. */
  37081. protected _altKey: boolean;
  37082. protected _ctrlKey: boolean;
  37083. protected _metaKey: boolean;
  37084. protected _shiftKey: boolean;
  37085. /**
  37086. * Which mouse buttons were pressed at time of last mouse event.
  37087. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  37088. */
  37089. protected _buttonsPressed: number;
  37090. /**
  37091. * Defines the buttons associated with the input to handle camera move.
  37092. */
  37093. buttons: number[];
  37094. /**
  37095. * Attach the input controls to a specific dom element to get the input from.
  37096. * @param element Defines the element the controls should be listened from
  37097. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37098. */
  37099. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37100. /**
  37101. * Detach the current controls from the specified dom element.
  37102. * @param element Defines the element to stop listening the inputs from
  37103. */
  37104. detachControl(element: Nullable<HTMLElement>): void;
  37105. /**
  37106. * Gets the class name of the current input.
  37107. * @returns the class name
  37108. */
  37109. getClassName(): string;
  37110. /**
  37111. * Get the friendly name associated with the input class.
  37112. * @returns the input friendly name
  37113. */
  37114. getSimpleName(): string;
  37115. /**
  37116. * Called on pointer POINTERDOUBLETAP event.
  37117. * Override this method to provide functionality on POINTERDOUBLETAP event.
  37118. */
  37119. protected onDoubleTap(type: string): void;
  37120. /**
  37121. * Called on pointer POINTERMOVE event if only a single touch is active.
  37122. * Override this method to provide functionality.
  37123. */
  37124. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37125. /**
  37126. * Called on pointer POINTERMOVE event if multiple touches are active.
  37127. * Override this method to provide functionality.
  37128. */
  37129. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37130. /**
  37131. * Called on JS contextmenu event.
  37132. * Override this method to provide functionality.
  37133. */
  37134. protected onContextMenu(evt: PointerEvent): void;
  37135. /**
  37136. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37137. * press.
  37138. * Override this method to provide functionality.
  37139. */
  37140. protected onButtonDown(evt: PointerEvent): void;
  37141. /**
  37142. * Called each time a new POINTERUP event occurs. Ie, for each button
  37143. * release.
  37144. * Override this method to provide functionality.
  37145. */
  37146. protected onButtonUp(evt: PointerEvent): void;
  37147. /**
  37148. * Called when window becomes inactive.
  37149. * Override this method to provide functionality.
  37150. */
  37151. protected onLostFocus(): void;
  37152. private _pointerInput;
  37153. private _observer;
  37154. private _onLostFocus;
  37155. private pointA;
  37156. private pointB;
  37157. }
  37158. }
  37159. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  37160. import { Nullable } from "babylonjs/types";
  37161. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37162. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  37163. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37164. /**
  37165. * Manage the pointers inputs to control an arc rotate camera.
  37166. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37167. */
  37168. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  37169. /**
  37170. * Defines the camera the input is attached to.
  37171. */
  37172. camera: ArcRotateCamera;
  37173. /**
  37174. * Gets the class name of the current input.
  37175. * @returns the class name
  37176. */
  37177. getClassName(): string;
  37178. /**
  37179. * Defines the buttons associated with the input to handle camera move.
  37180. */
  37181. buttons: number[];
  37182. /**
  37183. * Defines the pointer angular sensibility along the X axis or how fast is
  37184. * the camera rotating.
  37185. */
  37186. angularSensibilityX: number;
  37187. /**
  37188. * Defines the pointer angular sensibility along the Y axis or how fast is
  37189. * the camera rotating.
  37190. */
  37191. angularSensibilityY: number;
  37192. /**
  37193. * Defines the pointer pinch precision or how fast is the camera zooming.
  37194. */
  37195. pinchPrecision: number;
  37196. /**
  37197. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37198. * from 0.
  37199. * It defines the percentage of current camera.radius to use as delta when
  37200. * pinch zoom is used.
  37201. */
  37202. pinchDeltaPercentage: number;
  37203. /**
  37204. * Defines the pointer panning sensibility or how fast is the camera moving.
  37205. */
  37206. panningSensibility: number;
  37207. /**
  37208. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  37209. */
  37210. multiTouchPanning: boolean;
  37211. /**
  37212. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  37213. * zoom (pinch) through multitouch.
  37214. */
  37215. multiTouchPanAndZoom: boolean;
  37216. /**
  37217. * Revers pinch action direction.
  37218. */
  37219. pinchInwards: boolean;
  37220. private _isPanClick;
  37221. private _twoFingerActivityCount;
  37222. private _isPinching;
  37223. /**
  37224. * Called on pointer POINTERMOVE event if only a single touch is active.
  37225. */
  37226. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37227. /**
  37228. * Called on pointer POINTERDOUBLETAP event.
  37229. */
  37230. protected onDoubleTap(type: string): void;
  37231. /**
  37232. * Called on pointer POINTERMOVE event if multiple touches are active.
  37233. */
  37234. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37235. /**
  37236. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37237. * press.
  37238. */
  37239. protected onButtonDown(evt: PointerEvent): void;
  37240. /**
  37241. * Called each time a new POINTERUP event occurs. Ie, for each button
  37242. * release.
  37243. */
  37244. protected onButtonUp(evt: PointerEvent): void;
  37245. /**
  37246. * Called when window becomes inactive.
  37247. */
  37248. protected onLostFocus(): void;
  37249. }
  37250. }
  37251. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  37252. import { Nullable } from "babylonjs/types";
  37253. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37254. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37255. /**
  37256. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  37257. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37258. */
  37259. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  37260. /**
  37261. * Defines the camera the input is attached to.
  37262. */
  37263. camera: ArcRotateCamera;
  37264. /**
  37265. * Defines the list of key codes associated with the up action (increase alpha)
  37266. */
  37267. keysUp: number[];
  37268. /**
  37269. * Defines the list of key codes associated with the down action (decrease alpha)
  37270. */
  37271. keysDown: number[];
  37272. /**
  37273. * Defines the list of key codes associated with the left action (increase beta)
  37274. */
  37275. keysLeft: number[];
  37276. /**
  37277. * Defines the list of key codes associated with the right action (decrease beta)
  37278. */
  37279. keysRight: number[];
  37280. /**
  37281. * Defines the list of key codes associated with the reset action.
  37282. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  37283. */
  37284. keysReset: number[];
  37285. /**
  37286. * Defines the panning sensibility of the inputs.
  37287. * (How fast is the camera paning)
  37288. */
  37289. panningSensibility: number;
  37290. /**
  37291. * Defines the zooming sensibility of the inputs.
  37292. * (How fast is the camera zooming)
  37293. */
  37294. zoomingSensibility: number;
  37295. /**
  37296. * Defines wether maintaining the alt key down switch the movement mode from
  37297. * orientation to zoom.
  37298. */
  37299. useAltToZoom: boolean;
  37300. /**
  37301. * Rotation speed of the camera
  37302. */
  37303. angularSpeed: number;
  37304. private _keys;
  37305. private _ctrlPressed;
  37306. private _altPressed;
  37307. private _onCanvasBlurObserver;
  37308. private _onKeyboardObserver;
  37309. private _engine;
  37310. private _scene;
  37311. /**
  37312. * Attach the input controls to a specific dom element to get the input from.
  37313. * @param element Defines the element the controls should be listened from
  37314. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37315. */
  37316. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37317. /**
  37318. * Detach the current controls from the specified dom element.
  37319. * @param element Defines the element to stop listening the inputs from
  37320. */
  37321. detachControl(element: Nullable<HTMLElement>): void;
  37322. /**
  37323. * Update the current camera state depending on the inputs that have been used this frame.
  37324. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37325. */
  37326. checkInputs(): void;
  37327. /**
  37328. * Gets the class name of the current intput.
  37329. * @returns the class name
  37330. */
  37331. getClassName(): string;
  37332. /**
  37333. * Get the friendly name associated with the input class.
  37334. * @returns the input friendly name
  37335. */
  37336. getSimpleName(): string;
  37337. }
  37338. }
  37339. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  37340. import { Nullable } from "babylonjs/types";
  37341. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37342. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37343. /**
  37344. * Manage the mouse wheel inputs to control an arc rotate camera.
  37345. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37346. */
  37347. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  37348. /**
  37349. * Defines the camera the input is attached to.
  37350. */
  37351. camera: ArcRotateCamera;
  37352. /**
  37353. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37354. */
  37355. wheelPrecision: number;
  37356. /**
  37357. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37358. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37359. */
  37360. wheelDeltaPercentage: number;
  37361. private _wheel;
  37362. private _observer;
  37363. private computeDeltaFromMouseWheelLegacyEvent;
  37364. /**
  37365. * Attach the input controls to a specific dom element to get the input from.
  37366. * @param element Defines the element the controls should be listened from
  37367. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37368. */
  37369. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37370. /**
  37371. * Detach the current controls from the specified dom element.
  37372. * @param element Defines the element to stop listening the inputs from
  37373. */
  37374. detachControl(element: Nullable<HTMLElement>): void;
  37375. /**
  37376. * Gets the class name of the current intput.
  37377. * @returns the class name
  37378. */
  37379. getClassName(): string;
  37380. /**
  37381. * Get the friendly name associated with the input class.
  37382. * @returns the input friendly name
  37383. */
  37384. getSimpleName(): string;
  37385. }
  37386. }
  37387. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37388. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37389. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37390. /**
  37391. * Default Inputs manager for the ArcRotateCamera.
  37392. * It groups all the default supported inputs for ease of use.
  37393. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37394. */
  37395. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  37396. /**
  37397. * Instantiates a new ArcRotateCameraInputsManager.
  37398. * @param camera Defines the camera the inputs belong to
  37399. */
  37400. constructor(camera: ArcRotateCamera);
  37401. /**
  37402. * Add mouse wheel input support to the input manager.
  37403. * @returns the current input manager
  37404. */
  37405. addMouseWheel(): ArcRotateCameraInputsManager;
  37406. /**
  37407. * Add pointers input support to the input manager.
  37408. * @returns the current input manager
  37409. */
  37410. addPointers(): ArcRotateCameraInputsManager;
  37411. /**
  37412. * Add keyboard input support to the input manager.
  37413. * @returns the current input manager
  37414. */
  37415. addKeyboard(): ArcRotateCameraInputsManager;
  37416. }
  37417. }
  37418. declare module "babylonjs/Cameras/arcRotateCamera" {
  37419. import { Observable } from "babylonjs/Misc/observable";
  37420. import { Nullable } from "babylonjs/types";
  37421. import { Scene } from "babylonjs/scene";
  37422. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  37423. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37424. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37425. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37426. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  37427. import { Camera } from "babylonjs/Cameras/camera";
  37428. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37429. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  37430. import { Collider } from "babylonjs/Collisions/collider";
  37431. /**
  37432. * This represents an orbital type of camera.
  37433. *
  37434. * 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.
  37435. * 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.
  37436. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  37437. */
  37438. export class ArcRotateCamera extends TargetCamera {
  37439. /**
  37440. * Defines the rotation angle of the camera along the longitudinal axis.
  37441. */
  37442. alpha: number;
  37443. /**
  37444. * Defines the rotation angle of the camera along the latitudinal axis.
  37445. */
  37446. beta: number;
  37447. /**
  37448. * Defines the radius of the camera from it s target point.
  37449. */
  37450. radius: number;
  37451. protected _target: Vector3;
  37452. protected _targetHost: Nullable<AbstractMesh>;
  37453. /**
  37454. * Defines the target point of the camera.
  37455. * The camera looks towards it form the radius distance.
  37456. */
  37457. target: Vector3;
  37458. /**
  37459. * Define the current local position of the camera in the scene
  37460. */
  37461. position: Vector3;
  37462. protected _upVector: Vector3;
  37463. protected _upToYMatrix: Matrix;
  37464. protected _YToUpMatrix: Matrix;
  37465. /**
  37466. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  37467. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  37468. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  37469. */
  37470. upVector: Vector3;
  37471. /**
  37472. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  37473. */
  37474. setMatUp(): void;
  37475. /**
  37476. * Current inertia value on the longitudinal axis.
  37477. * The bigger this number the longer it will take for the camera to stop.
  37478. */
  37479. inertialAlphaOffset: number;
  37480. /**
  37481. * Current inertia value on the latitudinal axis.
  37482. * The bigger this number the longer it will take for the camera to stop.
  37483. */
  37484. inertialBetaOffset: number;
  37485. /**
  37486. * Current inertia value on the radius axis.
  37487. * The bigger this number the longer it will take for the camera to stop.
  37488. */
  37489. inertialRadiusOffset: number;
  37490. /**
  37491. * Minimum allowed angle on the longitudinal axis.
  37492. * This can help limiting how the Camera is able to move in the scene.
  37493. */
  37494. lowerAlphaLimit: Nullable<number>;
  37495. /**
  37496. * Maximum allowed angle on the longitudinal axis.
  37497. * This can help limiting how the Camera is able to move in the scene.
  37498. */
  37499. upperAlphaLimit: Nullable<number>;
  37500. /**
  37501. * Minimum allowed angle on the latitudinal axis.
  37502. * This can help limiting how the Camera is able to move in the scene.
  37503. */
  37504. lowerBetaLimit: number;
  37505. /**
  37506. * Maximum allowed angle on the latitudinal axis.
  37507. * This can help limiting how the Camera is able to move in the scene.
  37508. */
  37509. upperBetaLimit: number;
  37510. /**
  37511. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  37512. * This can help limiting how the Camera is able to move in the scene.
  37513. */
  37514. lowerRadiusLimit: Nullable<number>;
  37515. /**
  37516. * Maximum allowed distance of the camera to the target (The camera can not get further).
  37517. * This can help limiting how the Camera is able to move in the scene.
  37518. */
  37519. upperRadiusLimit: Nullable<number>;
  37520. /**
  37521. * Defines the current inertia value used during panning of the camera along the X axis.
  37522. */
  37523. inertialPanningX: number;
  37524. /**
  37525. * Defines the current inertia value used during panning of the camera along the Y axis.
  37526. */
  37527. inertialPanningY: number;
  37528. /**
  37529. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  37530. * Basically if your fingers moves away from more than this distance you will be considered
  37531. * in pinch mode.
  37532. */
  37533. pinchToPanMaxDistance: number;
  37534. /**
  37535. * Defines the maximum distance the camera can pan.
  37536. * This could help keeping the cammera always in your scene.
  37537. */
  37538. panningDistanceLimit: Nullable<number>;
  37539. /**
  37540. * Defines the target of the camera before paning.
  37541. */
  37542. panningOriginTarget: Vector3;
  37543. /**
  37544. * Defines the value of the inertia used during panning.
  37545. * 0 would mean stop inertia and one would mean no decelleration at all.
  37546. */
  37547. panningInertia: number;
  37548. /**
  37549. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  37550. */
  37551. angularSensibilityX: number;
  37552. /**
  37553. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  37554. */
  37555. angularSensibilityY: number;
  37556. /**
  37557. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  37558. */
  37559. pinchPrecision: number;
  37560. /**
  37561. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  37562. * It will be used instead of pinchDeltaPrecision if different from 0.
  37563. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37564. */
  37565. pinchDeltaPercentage: number;
  37566. /**
  37567. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  37568. */
  37569. panningSensibility: number;
  37570. /**
  37571. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  37572. */
  37573. keysUp: number[];
  37574. /**
  37575. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  37576. */
  37577. keysDown: number[];
  37578. /**
  37579. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  37580. */
  37581. keysLeft: number[];
  37582. /**
  37583. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  37584. */
  37585. keysRight: number[];
  37586. /**
  37587. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37588. */
  37589. wheelPrecision: number;
  37590. /**
  37591. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  37592. * It will be used instead of pinchDeltaPrecision if different from 0.
  37593. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37594. */
  37595. wheelDeltaPercentage: number;
  37596. /**
  37597. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  37598. */
  37599. zoomOnFactor: number;
  37600. /**
  37601. * Defines a screen offset for the camera position.
  37602. */
  37603. targetScreenOffset: Vector2;
  37604. /**
  37605. * Allows the camera to be completely reversed.
  37606. * If false the camera can not arrive upside down.
  37607. */
  37608. allowUpsideDown: boolean;
  37609. /**
  37610. * Define if double tap/click is used to restore the previously saved state of the camera.
  37611. */
  37612. useInputToRestoreState: boolean;
  37613. /** @hidden */
  37614. _viewMatrix: Matrix;
  37615. /** @hidden */
  37616. _useCtrlForPanning: boolean;
  37617. /** @hidden */
  37618. _panningMouseButton: number;
  37619. /**
  37620. * Defines the input associated to the camera.
  37621. */
  37622. inputs: ArcRotateCameraInputsManager;
  37623. /** @hidden */
  37624. _reset: () => void;
  37625. /**
  37626. * Defines the allowed panning axis.
  37627. */
  37628. panningAxis: Vector3;
  37629. protected _localDirection: Vector3;
  37630. protected _transformedDirection: Vector3;
  37631. private _bouncingBehavior;
  37632. /**
  37633. * Gets the bouncing behavior of the camera if it has been enabled.
  37634. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37635. */
  37636. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  37637. /**
  37638. * Defines if the bouncing behavior of the camera is enabled on the camera.
  37639. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37640. */
  37641. useBouncingBehavior: boolean;
  37642. private _framingBehavior;
  37643. /**
  37644. * Gets the framing behavior of the camera if it has been enabled.
  37645. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37646. */
  37647. readonly framingBehavior: Nullable<FramingBehavior>;
  37648. /**
  37649. * Defines if the framing behavior of the camera is enabled on the camera.
  37650. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37651. */
  37652. useFramingBehavior: boolean;
  37653. private _autoRotationBehavior;
  37654. /**
  37655. * Gets the auto rotation behavior of the camera if it has been enabled.
  37656. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37657. */
  37658. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  37659. /**
  37660. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  37661. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37662. */
  37663. useAutoRotationBehavior: boolean;
  37664. /**
  37665. * Observable triggered when the mesh target has been changed on the camera.
  37666. */
  37667. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  37668. /**
  37669. * Event raised when the camera is colliding with a mesh.
  37670. */
  37671. onCollide: (collidedMesh: AbstractMesh) => void;
  37672. /**
  37673. * Defines whether the camera should check collision with the objects oh the scene.
  37674. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  37675. */
  37676. checkCollisions: boolean;
  37677. /**
  37678. * Defines the collision radius of the camera.
  37679. * This simulates a sphere around the camera.
  37680. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37681. */
  37682. collisionRadius: Vector3;
  37683. protected _collider: Collider;
  37684. protected _previousPosition: Vector3;
  37685. protected _collisionVelocity: Vector3;
  37686. protected _newPosition: Vector3;
  37687. protected _previousAlpha: number;
  37688. protected _previousBeta: number;
  37689. protected _previousRadius: number;
  37690. protected _collisionTriggered: boolean;
  37691. protected _targetBoundingCenter: Nullable<Vector3>;
  37692. private _computationVector;
  37693. /**
  37694. * Instantiates a new ArcRotateCamera in a given scene
  37695. * @param name Defines the name of the camera
  37696. * @param alpha Defines the camera rotation along the logitudinal axis
  37697. * @param beta Defines the camera rotation along the latitudinal axis
  37698. * @param radius Defines the camera distance from its target
  37699. * @param target Defines the camera target
  37700. * @param scene Defines the scene the camera belongs to
  37701. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  37702. */
  37703. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37704. /** @hidden */
  37705. _initCache(): void;
  37706. /** @hidden */
  37707. _updateCache(ignoreParentClass?: boolean): void;
  37708. protected _getTargetPosition(): Vector3;
  37709. private _storedAlpha;
  37710. private _storedBeta;
  37711. private _storedRadius;
  37712. private _storedTarget;
  37713. private _storedTargetScreenOffset;
  37714. /**
  37715. * Stores the current state of the camera (alpha, beta, radius and target)
  37716. * @returns the camera itself
  37717. */
  37718. storeState(): Camera;
  37719. /**
  37720. * @hidden
  37721. * Restored camera state. You must call storeState() first
  37722. */
  37723. _restoreStateValues(): boolean;
  37724. /** @hidden */
  37725. _isSynchronizedViewMatrix(): boolean;
  37726. /**
  37727. * Attached controls to the current camera.
  37728. * @param element Defines the element the controls should be listened from
  37729. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37730. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  37731. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  37732. */
  37733. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  37734. /**
  37735. * Detach the current controls from the camera.
  37736. * The camera will stop reacting to inputs.
  37737. * @param element Defines the element to stop listening the inputs from
  37738. */
  37739. detachControl(element: HTMLElement): void;
  37740. /** @hidden */
  37741. _checkInputs(): void;
  37742. protected _checkLimits(): void;
  37743. /**
  37744. * Rebuilds angles (alpha, beta) and radius from the give position and target
  37745. */
  37746. rebuildAnglesAndRadius(): void;
  37747. /**
  37748. * Use a position to define the current camera related information like alpha, beta and radius
  37749. * @param position Defines the position to set the camera at
  37750. */
  37751. setPosition(position: Vector3): void;
  37752. /**
  37753. * Defines the target the camera should look at.
  37754. * This will automatically adapt alpha beta and radius to fit within the new target.
  37755. * @param target Defines the new target as a Vector or a mesh
  37756. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  37757. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  37758. */
  37759. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  37760. /** @hidden */
  37761. _getViewMatrix(): Matrix;
  37762. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  37763. /**
  37764. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  37765. * @param meshes Defines the mesh to zoom on
  37766. * @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)
  37767. */
  37768. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  37769. /**
  37770. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  37771. * The target will be changed but the radius
  37772. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  37773. * @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)
  37774. */
  37775. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  37776. min: Vector3;
  37777. max: Vector3;
  37778. distance: number;
  37779. }, doNotUpdateMaxZ?: boolean): void;
  37780. /**
  37781. * @override
  37782. * Override Camera.createRigCamera
  37783. */
  37784. createRigCamera(name: string, cameraIndex: number): Camera;
  37785. /**
  37786. * @hidden
  37787. * @override
  37788. * Override Camera._updateRigCameras
  37789. */
  37790. _updateRigCameras(): void;
  37791. /**
  37792. * Destroy the camera and release the current resources hold by it.
  37793. */
  37794. dispose(): void;
  37795. /**
  37796. * Gets the current object class name.
  37797. * @return the class name
  37798. */
  37799. getClassName(): string;
  37800. }
  37801. }
  37802. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  37803. import { Behavior } from "babylonjs/Behaviors/behavior";
  37804. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37805. /**
  37806. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  37807. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37808. */
  37809. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  37810. /**
  37811. * Gets the name of the behavior.
  37812. */
  37813. readonly name: string;
  37814. private _zoomStopsAnimation;
  37815. private _idleRotationSpeed;
  37816. private _idleRotationWaitTime;
  37817. private _idleRotationSpinupTime;
  37818. /**
  37819. * Sets the flag that indicates if user zooming should stop animation.
  37820. */
  37821. /**
  37822. * Gets the flag that indicates if user zooming should stop animation.
  37823. */
  37824. zoomStopsAnimation: boolean;
  37825. /**
  37826. * Sets the default speed at which the camera rotates around the model.
  37827. */
  37828. /**
  37829. * Gets the default speed at which the camera rotates around the model.
  37830. */
  37831. idleRotationSpeed: number;
  37832. /**
  37833. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  37834. */
  37835. /**
  37836. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  37837. */
  37838. idleRotationWaitTime: number;
  37839. /**
  37840. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37841. */
  37842. /**
  37843. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37844. */
  37845. idleRotationSpinupTime: number;
  37846. /**
  37847. * Gets a value indicating if the camera is currently rotating because of this behavior
  37848. */
  37849. readonly rotationInProgress: boolean;
  37850. private _onPrePointerObservableObserver;
  37851. private _onAfterCheckInputsObserver;
  37852. private _attachedCamera;
  37853. private _isPointerDown;
  37854. private _lastFrameTime;
  37855. private _lastInteractionTime;
  37856. private _cameraRotationSpeed;
  37857. /**
  37858. * Initializes the behavior.
  37859. */
  37860. init(): void;
  37861. /**
  37862. * Attaches the behavior to its arc rotate camera.
  37863. * @param camera Defines the camera to attach the behavior to
  37864. */
  37865. attach(camera: ArcRotateCamera): void;
  37866. /**
  37867. * Detaches the behavior from its current arc rotate camera.
  37868. */
  37869. detach(): void;
  37870. /**
  37871. * Returns true if user is scrolling.
  37872. * @return true if user is scrolling.
  37873. */
  37874. private _userIsZooming;
  37875. private _lastFrameRadius;
  37876. private _shouldAnimationStopForInteraction;
  37877. /**
  37878. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37879. */
  37880. private _applyUserInteraction;
  37881. private _userIsMoving;
  37882. }
  37883. }
  37884. declare module "babylonjs/Behaviors/Cameras/index" {
  37885. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37886. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37887. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  37888. }
  37889. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  37890. import { Mesh } from "babylonjs/Meshes/mesh";
  37891. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37892. import { Behavior } from "babylonjs/Behaviors/behavior";
  37893. /**
  37894. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  37895. */
  37896. export class AttachToBoxBehavior implements Behavior<Mesh> {
  37897. private ui;
  37898. /**
  37899. * The name of the behavior
  37900. */
  37901. name: string;
  37902. /**
  37903. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  37904. */
  37905. distanceAwayFromFace: number;
  37906. /**
  37907. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  37908. */
  37909. distanceAwayFromBottomOfFace: number;
  37910. private _faceVectors;
  37911. private _target;
  37912. private _scene;
  37913. private _onRenderObserver;
  37914. private _tmpMatrix;
  37915. private _tmpVector;
  37916. /**
  37917. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  37918. * @param ui The transform node that should be attched to the mesh
  37919. */
  37920. constructor(ui: TransformNode);
  37921. /**
  37922. * Initializes the behavior
  37923. */
  37924. init(): void;
  37925. private _closestFace;
  37926. private _zeroVector;
  37927. private _lookAtTmpMatrix;
  37928. private _lookAtToRef;
  37929. /**
  37930. * Attaches the AttachToBoxBehavior to the passed in mesh
  37931. * @param target The mesh that the specified node will be attached to
  37932. */
  37933. attach(target: Mesh): void;
  37934. /**
  37935. * Detaches the behavior from the mesh
  37936. */
  37937. detach(): void;
  37938. }
  37939. }
  37940. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  37941. import { Behavior } from "babylonjs/Behaviors/behavior";
  37942. import { Mesh } from "babylonjs/Meshes/mesh";
  37943. /**
  37944. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  37945. */
  37946. export class FadeInOutBehavior implements Behavior<Mesh> {
  37947. /**
  37948. * Time in milliseconds to delay before fading in (Default: 0)
  37949. */
  37950. delay: number;
  37951. /**
  37952. * Time in milliseconds for the mesh to fade in (Default: 300)
  37953. */
  37954. fadeInTime: number;
  37955. private _millisecondsPerFrame;
  37956. private _hovered;
  37957. private _hoverValue;
  37958. private _ownerNode;
  37959. /**
  37960. * Instatiates the FadeInOutBehavior
  37961. */
  37962. constructor();
  37963. /**
  37964. * The name of the behavior
  37965. */
  37966. readonly name: string;
  37967. /**
  37968. * Initializes the behavior
  37969. */
  37970. init(): void;
  37971. /**
  37972. * Attaches the fade behavior on the passed in mesh
  37973. * @param ownerNode The mesh that will be faded in/out once attached
  37974. */
  37975. attach(ownerNode: Mesh): void;
  37976. /**
  37977. * Detaches the behavior from the mesh
  37978. */
  37979. detach(): void;
  37980. /**
  37981. * Triggers the mesh to begin fading in or out
  37982. * @param value if the object should fade in or out (true to fade in)
  37983. */
  37984. fadeIn(value: boolean): void;
  37985. private _update;
  37986. private _setAllVisibility;
  37987. }
  37988. }
  37989. declare module "babylonjs/Misc/pivotTools" {
  37990. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37991. /**
  37992. * Class containing a set of static utilities functions for managing Pivots
  37993. * @hidden
  37994. */
  37995. export class PivotTools {
  37996. private static _PivotCached;
  37997. private static _OldPivotPoint;
  37998. private static _PivotTranslation;
  37999. private static _PivotTmpVector;
  38000. /** @hidden */
  38001. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  38002. /** @hidden */
  38003. static _RestorePivotPoint(mesh: AbstractMesh): void;
  38004. }
  38005. }
  38006. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  38007. import { Scene } from "babylonjs/scene";
  38008. import { Vector4 } from "babylonjs/Maths/math.vector";
  38009. import { Mesh } from "babylonjs/Meshes/mesh";
  38010. import { Nullable } from "babylonjs/types";
  38011. import { Plane } from "babylonjs/Maths/math.plane";
  38012. /**
  38013. * Class containing static functions to help procedurally build meshes
  38014. */
  38015. export class PlaneBuilder {
  38016. /**
  38017. * Creates a plane mesh
  38018. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  38019. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  38020. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  38021. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  38022. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  38023. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  38024. * @param name defines the name of the mesh
  38025. * @param options defines the options used to create the mesh
  38026. * @param scene defines the hosting scene
  38027. * @returns the plane mesh
  38028. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  38029. */
  38030. static CreatePlane(name: string, options: {
  38031. size?: number;
  38032. width?: number;
  38033. height?: number;
  38034. sideOrientation?: number;
  38035. frontUVs?: Vector4;
  38036. backUVs?: Vector4;
  38037. updatable?: boolean;
  38038. sourcePlane?: Plane;
  38039. }, scene?: Nullable<Scene>): Mesh;
  38040. }
  38041. }
  38042. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  38043. import { Behavior } from "babylonjs/Behaviors/behavior";
  38044. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38045. import { Observable } from "babylonjs/Misc/observable";
  38046. import { Vector3 } from "babylonjs/Maths/math.vector";
  38047. import { Ray } from "babylonjs/Culling/ray";
  38048. import "babylonjs/Meshes/Builders/planeBuilder";
  38049. /**
  38050. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  38051. */
  38052. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  38053. private static _AnyMouseID;
  38054. /**
  38055. * Abstract mesh the behavior is set on
  38056. */
  38057. attachedNode: AbstractMesh;
  38058. private _dragPlane;
  38059. private _scene;
  38060. private _pointerObserver;
  38061. private _beforeRenderObserver;
  38062. private static _planeScene;
  38063. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  38064. /**
  38065. * 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)
  38066. */
  38067. maxDragAngle: number;
  38068. /**
  38069. * @hidden
  38070. */
  38071. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  38072. /**
  38073. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38074. */
  38075. currentDraggingPointerID: number;
  38076. /**
  38077. * The last position where the pointer hit the drag plane in world space
  38078. */
  38079. lastDragPosition: Vector3;
  38080. /**
  38081. * If the behavior is currently in a dragging state
  38082. */
  38083. dragging: boolean;
  38084. /**
  38085. * 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)
  38086. */
  38087. dragDeltaRatio: number;
  38088. /**
  38089. * If the drag plane orientation should be updated during the dragging (Default: true)
  38090. */
  38091. updateDragPlane: boolean;
  38092. private _debugMode;
  38093. private _moving;
  38094. /**
  38095. * Fires each time the attached mesh is dragged with the pointer
  38096. * * delta between last drag position and current drag position in world space
  38097. * * dragDistance along the drag axis
  38098. * * dragPlaneNormal normal of the current drag plane used during the drag
  38099. * * dragPlanePoint in world space where the drag intersects the drag plane
  38100. */
  38101. onDragObservable: Observable<{
  38102. delta: Vector3;
  38103. dragPlanePoint: Vector3;
  38104. dragPlaneNormal: Vector3;
  38105. dragDistance: number;
  38106. pointerId: number;
  38107. }>;
  38108. /**
  38109. * Fires each time a drag begins (eg. mouse down on mesh)
  38110. */
  38111. onDragStartObservable: Observable<{
  38112. dragPlanePoint: Vector3;
  38113. pointerId: number;
  38114. }>;
  38115. /**
  38116. * Fires each time a drag ends (eg. mouse release after drag)
  38117. */
  38118. onDragEndObservable: Observable<{
  38119. dragPlanePoint: Vector3;
  38120. pointerId: number;
  38121. }>;
  38122. /**
  38123. * If the attached mesh should be moved when dragged
  38124. */
  38125. moveAttached: boolean;
  38126. /**
  38127. * If the drag behavior will react to drag events (Default: true)
  38128. */
  38129. enabled: boolean;
  38130. /**
  38131. * If pointer events should start and release the drag (Default: true)
  38132. */
  38133. startAndReleaseDragOnPointerEvents: boolean;
  38134. /**
  38135. * If camera controls should be detached during the drag
  38136. */
  38137. detachCameraControls: boolean;
  38138. /**
  38139. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  38140. */
  38141. useObjectOrienationForDragging: boolean;
  38142. private _options;
  38143. /**
  38144. * Creates a pointer drag behavior that can be attached to a mesh
  38145. * @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)
  38146. */
  38147. constructor(options?: {
  38148. dragAxis?: Vector3;
  38149. dragPlaneNormal?: Vector3;
  38150. });
  38151. /**
  38152. * Predicate to determine if it is valid to move the object to a new position when it is moved
  38153. */
  38154. validateDrag: (targetPosition: Vector3) => boolean;
  38155. /**
  38156. * The name of the behavior
  38157. */
  38158. readonly name: string;
  38159. /**
  38160. * Initializes the behavior
  38161. */
  38162. init(): void;
  38163. private _tmpVector;
  38164. private _alternatePickedPoint;
  38165. private _worldDragAxis;
  38166. private _targetPosition;
  38167. private _attachedElement;
  38168. /**
  38169. * Attaches the drag behavior the passed in mesh
  38170. * @param ownerNode The mesh that will be dragged around once attached
  38171. * @param predicate Predicate to use for pick filtering
  38172. */
  38173. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  38174. /**
  38175. * Force relase the drag action by code.
  38176. */
  38177. releaseDrag(): void;
  38178. private _startDragRay;
  38179. private _lastPointerRay;
  38180. /**
  38181. * Simulates the start of a pointer drag event on the behavior
  38182. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  38183. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  38184. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  38185. */
  38186. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  38187. private _startDrag;
  38188. private _dragDelta;
  38189. private _moveDrag;
  38190. private _pickWithRayOnDragPlane;
  38191. private _pointA;
  38192. private _pointB;
  38193. private _pointC;
  38194. private _lineA;
  38195. private _lineB;
  38196. private _localAxis;
  38197. private _lookAt;
  38198. private _updateDragPlanePosition;
  38199. /**
  38200. * Detaches the behavior from the mesh
  38201. */
  38202. detach(): void;
  38203. }
  38204. }
  38205. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  38206. import { Mesh } from "babylonjs/Meshes/mesh";
  38207. import { Behavior } from "babylonjs/Behaviors/behavior";
  38208. /**
  38209. * A behavior that when attached to a mesh will allow the mesh to be scaled
  38210. */
  38211. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  38212. private _dragBehaviorA;
  38213. private _dragBehaviorB;
  38214. private _startDistance;
  38215. private _initialScale;
  38216. private _targetScale;
  38217. private _ownerNode;
  38218. private _sceneRenderObserver;
  38219. /**
  38220. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  38221. */
  38222. constructor();
  38223. /**
  38224. * The name of the behavior
  38225. */
  38226. readonly name: string;
  38227. /**
  38228. * Initializes the behavior
  38229. */
  38230. init(): void;
  38231. private _getCurrentDistance;
  38232. /**
  38233. * Attaches the scale behavior the passed in mesh
  38234. * @param ownerNode The mesh that will be scaled around once attached
  38235. */
  38236. attach(ownerNode: Mesh): void;
  38237. /**
  38238. * Detaches the behavior from the mesh
  38239. */
  38240. detach(): void;
  38241. }
  38242. }
  38243. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  38244. import { Behavior } from "babylonjs/Behaviors/behavior";
  38245. import { Mesh } from "babylonjs/Meshes/mesh";
  38246. import { Observable } from "babylonjs/Misc/observable";
  38247. /**
  38248. * 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
  38249. */
  38250. export class SixDofDragBehavior implements Behavior<Mesh> {
  38251. private static _virtualScene;
  38252. private _ownerNode;
  38253. private _sceneRenderObserver;
  38254. private _scene;
  38255. private _targetPosition;
  38256. private _virtualOriginMesh;
  38257. private _virtualDragMesh;
  38258. private _pointerObserver;
  38259. private _moving;
  38260. private _startingOrientation;
  38261. /**
  38262. * 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)
  38263. */
  38264. private zDragFactor;
  38265. /**
  38266. * If the object should rotate to face the drag origin
  38267. */
  38268. rotateDraggedObject: boolean;
  38269. /**
  38270. * If the behavior is currently in a dragging state
  38271. */
  38272. dragging: boolean;
  38273. /**
  38274. * 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)
  38275. */
  38276. dragDeltaRatio: number;
  38277. /**
  38278. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38279. */
  38280. currentDraggingPointerID: number;
  38281. /**
  38282. * If camera controls should be detached during the drag
  38283. */
  38284. detachCameraControls: boolean;
  38285. /**
  38286. * Fires each time a drag starts
  38287. */
  38288. onDragStartObservable: Observable<{}>;
  38289. /**
  38290. * Fires each time a drag ends (eg. mouse release after drag)
  38291. */
  38292. onDragEndObservable: Observable<{}>;
  38293. /**
  38294. * 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
  38295. */
  38296. constructor();
  38297. /**
  38298. * The name of the behavior
  38299. */
  38300. readonly name: string;
  38301. /**
  38302. * Initializes the behavior
  38303. */
  38304. init(): void;
  38305. /**
  38306. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  38307. */
  38308. private readonly _pointerCamera;
  38309. /**
  38310. * Attaches the scale behavior the passed in mesh
  38311. * @param ownerNode The mesh that will be scaled around once attached
  38312. */
  38313. attach(ownerNode: Mesh): void;
  38314. /**
  38315. * Detaches the behavior from the mesh
  38316. */
  38317. detach(): void;
  38318. }
  38319. }
  38320. declare module "babylonjs/Behaviors/Meshes/index" {
  38321. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  38322. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  38323. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  38324. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  38325. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  38326. }
  38327. declare module "babylonjs/Behaviors/index" {
  38328. export * from "babylonjs/Behaviors/behavior";
  38329. export * from "babylonjs/Behaviors/Cameras/index";
  38330. export * from "babylonjs/Behaviors/Meshes/index";
  38331. }
  38332. declare module "babylonjs/Bones/boneIKController" {
  38333. import { Bone } from "babylonjs/Bones/bone";
  38334. import { Vector3 } from "babylonjs/Maths/math.vector";
  38335. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38336. import { Nullable } from "babylonjs/types";
  38337. /**
  38338. * Class used to apply inverse kinematics to bones
  38339. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  38340. */
  38341. export class BoneIKController {
  38342. private static _tmpVecs;
  38343. private static _tmpQuat;
  38344. private static _tmpMats;
  38345. /**
  38346. * Gets or sets the target mesh
  38347. */
  38348. targetMesh: AbstractMesh;
  38349. /** Gets or sets the mesh used as pole */
  38350. poleTargetMesh: AbstractMesh;
  38351. /**
  38352. * Gets or sets the bone used as pole
  38353. */
  38354. poleTargetBone: Nullable<Bone>;
  38355. /**
  38356. * Gets or sets the target position
  38357. */
  38358. targetPosition: Vector3;
  38359. /**
  38360. * Gets or sets the pole target position
  38361. */
  38362. poleTargetPosition: Vector3;
  38363. /**
  38364. * Gets or sets the pole target local offset
  38365. */
  38366. poleTargetLocalOffset: Vector3;
  38367. /**
  38368. * Gets or sets the pole angle
  38369. */
  38370. poleAngle: number;
  38371. /**
  38372. * Gets or sets the mesh associated with the controller
  38373. */
  38374. mesh: AbstractMesh;
  38375. /**
  38376. * 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)
  38377. */
  38378. slerpAmount: number;
  38379. private _bone1Quat;
  38380. private _bone1Mat;
  38381. private _bone2Ang;
  38382. private _bone1;
  38383. private _bone2;
  38384. private _bone1Length;
  38385. private _bone2Length;
  38386. private _maxAngle;
  38387. private _maxReach;
  38388. private _rightHandedSystem;
  38389. private _bendAxis;
  38390. private _slerping;
  38391. private _adjustRoll;
  38392. /**
  38393. * Gets or sets maximum allowed angle
  38394. */
  38395. maxAngle: number;
  38396. /**
  38397. * Creates a new BoneIKController
  38398. * @param mesh defines the mesh to control
  38399. * @param bone defines the bone to control
  38400. * @param options defines options to set up the controller
  38401. */
  38402. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  38403. targetMesh?: AbstractMesh;
  38404. poleTargetMesh?: AbstractMesh;
  38405. poleTargetBone?: Bone;
  38406. poleTargetLocalOffset?: Vector3;
  38407. poleAngle?: number;
  38408. bendAxis?: Vector3;
  38409. maxAngle?: number;
  38410. slerpAmount?: number;
  38411. });
  38412. private _setMaxAngle;
  38413. /**
  38414. * Force the controller to update the bones
  38415. */
  38416. update(): void;
  38417. }
  38418. }
  38419. declare module "babylonjs/Bones/boneLookController" {
  38420. import { Vector3 } from "babylonjs/Maths/math.vector";
  38421. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38422. import { Bone } from "babylonjs/Bones/bone";
  38423. import { Space } from "babylonjs/Maths/math.axis";
  38424. /**
  38425. * Class used to make a bone look toward a point in space
  38426. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  38427. */
  38428. export class BoneLookController {
  38429. private static _tmpVecs;
  38430. private static _tmpQuat;
  38431. private static _tmpMats;
  38432. /**
  38433. * The target Vector3 that the bone will look at
  38434. */
  38435. target: Vector3;
  38436. /**
  38437. * The mesh that the bone is attached to
  38438. */
  38439. mesh: AbstractMesh;
  38440. /**
  38441. * The bone that will be looking to the target
  38442. */
  38443. bone: Bone;
  38444. /**
  38445. * The up axis of the coordinate system that is used when the bone is rotated
  38446. */
  38447. upAxis: Vector3;
  38448. /**
  38449. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  38450. */
  38451. upAxisSpace: Space;
  38452. /**
  38453. * Used to make an adjustment to the yaw of the bone
  38454. */
  38455. adjustYaw: number;
  38456. /**
  38457. * Used to make an adjustment to the pitch of the bone
  38458. */
  38459. adjustPitch: number;
  38460. /**
  38461. * Used to make an adjustment to the roll of the bone
  38462. */
  38463. adjustRoll: number;
  38464. /**
  38465. * 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)
  38466. */
  38467. slerpAmount: number;
  38468. private _minYaw;
  38469. private _maxYaw;
  38470. private _minPitch;
  38471. private _maxPitch;
  38472. private _minYawSin;
  38473. private _minYawCos;
  38474. private _maxYawSin;
  38475. private _maxYawCos;
  38476. private _midYawConstraint;
  38477. private _minPitchTan;
  38478. private _maxPitchTan;
  38479. private _boneQuat;
  38480. private _slerping;
  38481. private _transformYawPitch;
  38482. private _transformYawPitchInv;
  38483. private _firstFrameSkipped;
  38484. private _yawRange;
  38485. private _fowardAxis;
  38486. /**
  38487. * Gets or sets the minimum yaw angle that the bone can look to
  38488. */
  38489. minYaw: number;
  38490. /**
  38491. * Gets or sets the maximum yaw angle that the bone can look to
  38492. */
  38493. maxYaw: number;
  38494. /**
  38495. * Gets or sets the minimum pitch angle that the bone can look to
  38496. */
  38497. minPitch: number;
  38498. /**
  38499. * Gets or sets the maximum pitch angle that the bone can look to
  38500. */
  38501. maxPitch: number;
  38502. /**
  38503. * Create a BoneLookController
  38504. * @param mesh the mesh that the bone belongs to
  38505. * @param bone the bone that will be looking to the target
  38506. * @param target the target Vector3 to look at
  38507. * @param options optional settings:
  38508. * * maxYaw: the maximum angle the bone will yaw to
  38509. * * minYaw: the minimum angle the bone will yaw to
  38510. * * maxPitch: the maximum angle the bone will pitch to
  38511. * * minPitch: the minimum angle the bone will yaw to
  38512. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  38513. * * upAxis: the up axis of the coordinate system
  38514. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  38515. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  38516. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  38517. * * adjustYaw: used to make an adjustment to the yaw of the bone
  38518. * * adjustPitch: used to make an adjustment to the pitch of the bone
  38519. * * adjustRoll: used to make an adjustment to the roll of the bone
  38520. **/
  38521. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  38522. maxYaw?: number;
  38523. minYaw?: number;
  38524. maxPitch?: number;
  38525. minPitch?: number;
  38526. slerpAmount?: number;
  38527. upAxis?: Vector3;
  38528. upAxisSpace?: Space;
  38529. yawAxis?: Vector3;
  38530. pitchAxis?: Vector3;
  38531. adjustYaw?: number;
  38532. adjustPitch?: number;
  38533. adjustRoll?: number;
  38534. });
  38535. /**
  38536. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  38537. */
  38538. update(): void;
  38539. private _getAngleDiff;
  38540. private _getAngleBetween;
  38541. private _isAngleBetween;
  38542. }
  38543. }
  38544. declare module "babylonjs/Bones/index" {
  38545. export * from "babylonjs/Bones/bone";
  38546. export * from "babylonjs/Bones/boneIKController";
  38547. export * from "babylonjs/Bones/boneLookController";
  38548. export * from "babylonjs/Bones/skeleton";
  38549. }
  38550. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  38551. import { Nullable } from "babylonjs/types";
  38552. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38553. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38554. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38555. /**
  38556. * Manage the gamepad inputs to control an arc rotate camera.
  38557. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38558. */
  38559. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  38560. /**
  38561. * Defines the camera the input is attached to.
  38562. */
  38563. camera: ArcRotateCamera;
  38564. /**
  38565. * Defines the gamepad the input is gathering event from.
  38566. */
  38567. gamepad: Nullable<Gamepad>;
  38568. /**
  38569. * Defines the gamepad rotation sensiblity.
  38570. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38571. */
  38572. gamepadRotationSensibility: number;
  38573. /**
  38574. * Defines the gamepad move sensiblity.
  38575. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38576. */
  38577. gamepadMoveSensibility: number;
  38578. private _onGamepadConnectedObserver;
  38579. private _onGamepadDisconnectedObserver;
  38580. /**
  38581. * Attach the input controls to a specific dom element to get the input from.
  38582. * @param element Defines the element the controls should be listened from
  38583. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38584. */
  38585. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38586. /**
  38587. * Detach the current controls from the specified dom element.
  38588. * @param element Defines the element to stop listening the inputs from
  38589. */
  38590. detachControl(element: Nullable<HTMLElement>): void;
  38591. /**
  38592. * Update the current camera state depending on the inputs that have been used this frame.
  38593. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38594. */
  38595. checkInputs(): void;
  38596. /**
  38597. * Gets the class name of the current intput.
  38598. * @returns the class name
  38599. */
  38600. getClassName(): string;
  38601. /**
  38602. * Get the friendly name associated with the input class.
  38603. * @returns the input friendly name
  38604. */
  38605. getSimpleName(): string;
  38606. }
  38607. }
  38608. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  38609. import { Nullable } from "babylonjs/types";
  38610. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38611. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38612. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  38613. interface ArcRotateCameraInputsManager {
  38614. /**
  38615. * Add orientation input support to the input manager.
  38616. * @returns the current input manager
  38617. */
  38618. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  38619. }
  38620. }
  38621. /**
  38622. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  38623. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38624. */
  38625. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  38626. /**
  38627. * Defines the camera the input is attached to.
  38628. */
  38629. camera: ArcRotateCamera;
  38630. /**
  38631. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  38632. */
  38633. alphaCorrection: number;
  38634. /**
  38635. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  38636. */
  38637. gammaCorrection: number;
  38638. private _alpha;
  38639. private _gamma;
  38640. private _dirty;
  38641. private _deviceOrientationHandler;
  38642. /**
  38643. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  38644. */
  38645. constructor();
  38646. /**
  38647. * Attach the input controls to a specific dom element to get the input from.
  38648. * @param element Defines the element the controls should be listened from
  38649. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38650. */
  38651. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38652. /** @hidden */
  38653. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  38654. /**
  38655. * Update the current camera state depending on the inputs that have been used this frame.
  38656. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38657. */
  38658. checkInputs(): void;
  38659. /**
  38660. * Detach the current controls from the specified dom element.
  38661. * @param element Defines the element to stop listening the inputs from
  38662. */
  38663. detachControl(element: Nullable<HTMLElement>): void;
  38664. /**
  38665. * Gets the class name of the current intput.
  38666. * @returns the class name
  38667. */
  38668. getClassName(): string;
  38669. /**
  38670. * Get the friendly name associated with the input class.
  38671. * @returns the input friendly name
  38672. */
  38673. getSimpleName(): string;
  38674. }
  38675. }
  38676. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  38677. import { Nullable } from "babylonjs/types";
  38678. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38679. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38680. /**
  38681. * Listen to mouse events to control the camera.
  38682. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38683. */
  38684. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  38685. /**
  38686. * Defines the camera the input is attached to.
  38687. */
  38688. camera: FlyCamera;
  38689. /**
  38690. * Defines if touch is enabled. (Default is true.)
  38691. */
  38692. touchEnabled: boolean;
  38693. /**
  38694. * Defines the buttons associated with the input to handle camera rotation.
  38695. */
  38696. buttons: number[];
  38697. /**
  38698. * Assign buttons for Yaw control.
  38699. */
  38700. buttonsYaw: number[];
  38701. /**
  38702. * Assign buttons for Pitch control.
  38703. */
  38704. buttonsPitch: number[];
  38705. /**
  38706. * Assign buttons for Roll control.
  38707. */
  38708. buttonsRoll: number[];
  38709. /**
  38710. * Detect if any button is being pressed while mouse is moved.
  38711. * -1 = Mouse locked.
  38712. * 0 = Left button.
  38713. * 1 = Middle Button.
  38714. * 2 = Right Button.
  38715. */
  38716. activeButton: number;
  38717. /**
  38718. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  38719. * Higher values reduce its sensitivity.
  38720. */
  38721. angularSensibility: number;
  38722. private _mousemoveCallback;
  38723. private _observer;
  38724. private _rollObserver;
  38725. private previousPosition;
  38726. private noPreventDefault;
  38727. private element;
  38728. /**
  38729. * Listen to mouse events to control the camera.
  38730. * @param touchEnabled Define if touch is enabled. (Default is true.)
  38731. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38732. */
  38733. constructor(touchEnabled?: boolean);
  38734. /**
  38735. * Attach the mouse control to the HTML DOM element.
  38736. * @param element Defines the element that listens to the input events.
  38737. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  38738. */
  38739. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38740. /**
  38741. * Detach the current controls from the specified dom element.
  38742. * @param element Defines the element to stop listening the inputs from
  38743. */
  38744. detachControl(element: Nullable<HTMLElement>): void;
  38745. /**
  38746. * Gets the class name of the current input.
  38747. * @returns the class name.
  38748. */
  38749. getClassName(): string;
  38750. /**
  38751. * Get the friendly name associated with the input class.
  38752. * @returns the input's friendly name.
  38753. */
  38754. getSimpleName(): string;
  38755. private _pointerInput;
  38756. private _onMouseMove;
  38757. /**
  38758. * Rotate camera by mouse offset.
  38759. */
  38760. private rotateCamera;
  38761. }
  38762. }
  38763. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  38764. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38765. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38766. /**
  38767. * Default Inputs manager for the FlyCamera.
  38768. * It groups all the default supported inputs for ease of use.
  38769. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38770. */
  38771. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  38772. /**
  38773. * Instantiates a new FlyCameraInputsManager.
  38774. * @param camera Defines the camera the inputs belong to.
  38775. */
  38776. constructor(camera: FlyCamera);
  38777. /**
  38778. * Add keyboard input support to the input manager.
  38779. * @returns the new FlyCameraKeyboardMoveInput().
  38780. */
  38781. addKeyboard(): FlyCameraInputsManager;
  38782. /**
  38783. * Add mouse input support to the input manager.
  38784. * @param touchEnabled Enable touch screen support.
  38785. * @returns the new FlyCameraMouseInput().
  38786. */
  38787. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  38788. }
  38789. }
  38790. declare module "babylonjs/Cameras/flyCamera" {
  38791. import { Scene } from "babylonjs/scene";
  38792. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  38793. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38794. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38795. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  38796. /**
  38797. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38798. * such as in a 3D Space Shooter or a Flight Simulator.
  38799. */
  38800. export class FlyCamera extends TargetCamera {
  38801. /**
  38802. * Define the collision ellipsoid of the camera.
  38803. * This is helpful for simulating a camera body, like a player's body.
  38804. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38805. */
  38806. ellipsoid: Vector3;
  38807. /**
  38808. * Define an offset for the position of the ellipsoid around the camera.
  38809. * This can be helpful if the camera is attached away from the player's body center,
  38810. * such as at its head.
  38811. */
  38812. ellipsoidOffset: Vector3;
  38813. /**
  38814. * Enable or disable collisions of the camera with the rest of the scene objects.
  38815. */
  38816. checkCollisions: boolean;
  38817. /**
  38818. * Enable or disable gravity on the camera.
  38819. */
  38820. applyGravity: boolean;
  38821. /**
  38822. * Define the current direction the camera is moving to.
  38823. */
  38824. cameraDirection: Vector3;
  38825. /**
  38826. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  38827. * This overrides and empties cameraRotation.
  38828. */
  38829. rotationQuaternion: Quaternion;
  38830. /**
  38831. * Track Roll to maintain the wanted Rolling when looking around.
  38832. */
  38833. _trackRoll: number;
  38834. /**
  38835. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  38836. */
  38837. rollCorrect: number;
  38838. /**
  38839. * Mimic a banked turn, Rolling the camera when Yawing.
  38840. * It's recommended to use rollCorrect = 10 for faster banking correction.
  38841. */
  38842. bankedTurn: boolean;
  38843. /**
  38844. * Limit in radians for how much Roll banking will add. (Default: 90°)
  38845. */
  38846. bankedTurnLimit: number;
  38847. /**
  38848. * Value of 0 disables the banked Roll.
  38849. * Value of 1 is equal to the Yaw angle in radians.
  38850. */
  38851. bankedTurnMultiplier: number;
  38852. /**
  38853. * The inputs manager loads all the input sources, such as keyboard and mouse.
  38854. */
  38855. inputs: FlyCameraInputsManager;
  38856. /**
  38857. * Gets the input sensibility for mouse input.
  38858. * Higher values reduce sensitivity.
  38859. */
  38860. /**
  38861. * Sets the input sensibility for a mouse input.
  38862. * Higher values reduce sensitivity.
  38863. */
  38864. angularSensibility: number;
  38865. /**
  38866. * Get the keys for camera movement forward.
  38867. */
  38868. /**
  38869. * Set the keys for camera movement forward.
  38870. */
  38871. keysForward: number[];
  38872. /**
  38873. * Get the keys for camera movement backward.
  38874. */
  38875. keysBackward: number[];
  38876. /**
  38877. * Get the keys for camera movement up.
  38878. */
  38879. /**
  38880. * Set the keys for camera movement up.
  38881. */
  38882. keysUp: number[];
  38883. /**
  38884. * Get the keys for camera movement down.
  38885. */
  38886. /**
  38887. * Set the keys for camera movement down.
  38888. */
  38889. keysDown: number[];
  38890. /**
  38891. * Get the keys for camera movement left.
  38892. */
  38893. /**
  38894. * Set the keys for camera movement left.
  38895. */
  38896. keysLeft: number[];
  38897. /**
  38898. * Set the keys for camera movement right.
  38899. */
  38900. /**
  38901. * Set the keys for camera movement right.
  38902. */
  38903. keysRight: number[];
  38904. /**
  38905. * Event raised when the camera collides with a mesh in the scene.
  38906. */
  38907. onCollide: (collidedMesh: AbstractMesh) => void;
  38908. private _collider;
  38909. private _needMoveForGravity;
  38910. private _oldPosition;
  38911. private _diffPosition;
  38912. private _newPosition;
  38913. /** @hidden */
  38914. _localDirection: Vector3;
  38915. /** @hidden */
  38916. _transformedDirection: Vector3;
  38917. /**
  38918. * Instantiates a FlyCamera.
  38919. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38920. * such as in a 3D Space Shooter or a Flight Simulator.
  38921. * @param name Define the name of the camera in the scene.
  38922. * @param position Define the starting position of the camera in the scene.
  38923. * @param scene Define the scene the camera belongs to.
  38924. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  38925. */
  38926. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38927. /**
  38928. * Attach a control to the HTML DOM element.
  38929. * @param element Defines the element that listens to the input events.
  38930. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  38931. */
  38932. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38933. /**
  38934. * Detach a control from the HTML DOM element.
  38935. * The camera will stop reacting to that input.
  38936. * @param element Defines the element that listens to the input events.
  38937. */
  38938. detachControl(element: HTMLElement): void;
  38939. private _collisionMask;
  38940. /**
  38941. * Get the mask that the camera ignores in collision events.
  38942. */
  38943. /**
  38944. * Set the mask that the camera ignores in collision events.
  38945. */
  38946. collisionMask: number;
  38947. /** @hidden */
  38948. _collideWithWorld(displacement: Vector3): void;
  38949. /** @hidden */
  38950. private _onCollisionPositionChange;
  38951. /** @hidden */
  38952. _checkInputs(): void;
  38953. /** @hidden */
  38954. _decideIfNeedsToMove(): boolean;
  38955. /** @hidden */
  38956. _updatePosition(): void;
  38957. /**
  38958. * Restore the Roll to its target value at the rate specified.
  38959. * @param rate - Higher means slower restoring.
  38960. * @hidden
  38961. */
  38962. restoreRoll(rate: number): void;
  38963. /**
  38964. * Destroy the camera and release the current resources held by it.
  38965. */
  38966. dispose(): void;
  38967. /**
  38968. * Get the current object class name.
  38969. * @returns the class name.
  38970. */
  38971. getClassName(): string;
  38972. }
  38973. }
  38974. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  38975. import { Nullable } from "babylonjs/types";
  38976. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38977. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38978. /**
  38979. * Listen to keyboard events to control the camera.
  38980. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38981. */
  38982. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  38983. /**
  38984. * Defines the camera the input is attached to.
  38985. */
  38986. camera: FlyCamera;
  38987. /**
  38988. * The list of keyboard keys used to control the forward move of the camera.
  38989. */
  38990. keysForward: number[];
  38991. /**
  38992. * The list of keyboard keys used to control the backward move of the camera.
  38993. */
  38994. keysBackward: number[];
  38995. /**
  38996. * The list of keyboard keys used to control the forward move of the camera.
  38997. */
  38998. keysUp: number[];
  38999. /**
  39000. * The list of keyboard keys used to control the backward move of the camera.
  39001. */
  39002. keysDown: number[];
  39003. /**
  39004. * The list of keyboard keys used to control the right strafe move of the camera.
  39005. */
  39006. keysRight: number[];
  39007. /**
  39008. * The list of keyboard keys used to control the left strafe move of the camera.
  39009. */
  39010. keysLeft: number[];
  39011. private _keys;
  39012. private _onCanvasBlurObserver;
  39013. private _onKeyboardObserver;
  39014. private _engine;
  39015. private _scene;
  39016. /**
  39017. * Attach the input controls to a specific dom element to get the input from.
  39018. * @param element Defines the element the controls should be listened from
  39019. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39020. */
  39021. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39022. /**
  39023. * Detach the current controls from the specified dom element.
  39024. * @param element Defines the element to stop listening the inputs from
  39025. */
  39026. detachControl(element: Nullable<HTMLElement>): void;
  39027. /**
  39028. * Gets the class name of the current intput.
  39029. * @returns the class name
  39030. */
  39031. getClassName(): string;
  39032. /** @hidden */
  39033. _onLostFocus(e: FocusEvent): void;
  39034. /**
  39035. * Get the friendly name associated with the input class.
  39036. * @returns the input friendly name
  39037. */
  39038. getSimpleName(): string;
  39039. /**
  39040. * Update the current camera state depending on the inputs that have been used this frame.
  39041. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39042. */
  39043. checkInputs(): void;
  39044. }
  39045. }
  39046. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  39047. import { Nullable } from "babylonjs/types";
  39048. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39049. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39050. /**
  39051. * Manage the mouse wheel inputs to control a follow camera.
  39052. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39053. */
  39054. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  39055. /**
  39056. * Defines the camera the input is attached to.
  39057. */
  39058. camera: FollowCamera;
  39059. /**
  39060. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  39061. */
  39062. axisControlRadius: boolean;
  39063. /**
  39064. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  39065. */
  39066. axisControlHeight: boolean;
  39067. /**
  39068. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  39069. */
  39070. axisControlRotation: boolean;
  39071. /**
  39072. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  39073. * relation to mouseWheel events.
  39074. */
  39075. wheelPrecision: number;
  39076. /**
  39077. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39078. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39079. */
  39080. wheelDeltaPercentage: number;
  39081. private _wheel;
  39082. private _observer;
  39083. /**
  39084. * Attach the input controls to a specific dom element to get the input from.
  39085. * @param element Defines the element the controls should be listened from
  39086. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39087. */
  39088. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39089. /**
  39090. * Detach the current controls from the specified dom element.
  39091. * @param element Defines the element to stop listening the inputs from
  39092. */
  39093. detachControl(element: Nullable<HTMLElement>): void;
  39094. /**
  39095. * Gets the class name of the current intput.
  39096. * @returns the class name
  39097. */
  39098. getClassName(): string;
  39099. /**
  39100. * Get the friendly name associated with the input class.
  39101. * @returns the input friendly name
  39102. */
  39103. getSimpleName(): string;
  39104. }
  39105. }
  39106. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  39107. import { Nullable } from "babylonjs/types";
  39108. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39109. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  39110. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39111. /**
  39112. * Manage the pointers inputs to control an follow camera.
  39113. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39114. */
  39115. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  39116. /**
  39117. * Defines the camera the input is attached to.
  39118. */
  39119. camera: FollowCamera;
  39120. /**
  39121. * Gets the class name of the current input.
  39122. * @returns the class name
  39123. */
  39124. getClassName(): string;
  39125. /**
  39126. * Defines the pointer angular sensibility along the X axis or how fast is
  39127. * the camera rotating.
  39128. * A negative number will reverse the axis direction.
  39129. */
  39130. angularSensibilityX: number;
  39131. /**
  39132. * Defines the pointer angular sensibility along the Y axis or how fast is
  39133. * the camera rotating.
  39134. * A negative number will reverse the axis direction.
  39135. */
  39136. angularSensibilityY: number;
  39137. /**
  39138. * Defines the pointer pinch precision or how fast is the camera zooming.
  39139. * A negative number will reverse the axis direction.
  39140. */
  39141. pinchPrecision: number;
  39142. /**
  39143. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39144. * from 0.
  39145. * It defines the percentage of current camera.radius to use as delta when
  39146. * pinch zoom is used.
  39147. */
  39148. pinchDeltaPercentage: number;
  39149. /**
  39150. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  39151. */
  39152. axisXControlRadius: boolean;
  39153. /**
  39154. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  39155. */
  39156. axisXControlHeight: boolean;
  39157. /**
  39158. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  39159. */
  39160. axisXControlRotation: boolean;
  39161. /**
  39162. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  39163. */
  39164. axisYControlRadius: boolean;
  39165. /**
  39166. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  39167. */
  39168. axisYControlHeight: boolean;
  39169. /**
  39170. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  39171. */
  39172. axisYControlRotation: boolean;
  39173. /**
  39174. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  39175. */
  39176. axisPinchControlRadius: boolean;
  39177. /**
  39178. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  39179. */
  39180. axisPinchControlHeight: boolean;
  39181. /**
  39182. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  39183. */
  39184. axisPinchControlRotation: boolean;
  39185. /**
  39186. * Log error messages if basic misconfiguration has occurred.
  39187. */
  39188. warningEnable: boolean;
  39189. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39190. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39191. private _warningCounter;
  39192. private _warning;
  39193. }
  39194. }
  39195. declare module "babylonjs/Cameras/followCameraInputsManager" {
  39196. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39197. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39198. /**
  39199. * Default Inputs manager for the FollowCamera.
  39200. * It groups all the default supported inputs for ease of use.
  39201. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39202. */
  39203. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  39204. /**
  39205. * Instantiates a new FollowCameraInputsManager.
  39206. * @param camera Defines the camera the inputs belong to
  39207. */
  39208. constructor(camera: FollowCamera);
  39209. /**
  39210. * Add keyboard input support to the input manager.
  39211. * @returns the current input manager
  39212. */
  39213. addKeyboard(): FollowCameraInputsManager;
  39214. /**
  39215. * Add mouse wheel input support to the input manager.
  39216. * @returns the current input manager
  39217. */
  39218. addMouseWheel(): FollowCameraInputsManager;
  39219. /**
  39220. * Add pointers input support to the input manager.
  39221. * @returns the current input manager
  39222. */
  39223. addPointers(): FollowCameraInputsManager;
  39224. /**
  39225. * Add orientation input support to the input manager.
  39226. * @returns the current input manager
  39227. */
  39228. addVRDeviceOrientation(): FollowCameraInputsManager;
  39229. }
  39230. }
  39231. declare module "babylonjs/Cameras/followCamera" {
  39232. import { Nullable } from "babylonjs/types";
  39233. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39234. import { Scene } from "babylonjs/scene";
  39235. import { Vector3 } from "babylonjs/Maths/math.vector";
  39236. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39237. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  39238. /**
  39239. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  39240. * an arc rotate version arcFollowCamera are available.
  39241. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39242. */
  39243. export class FollowCamera extends TargetCamera {
  39244. /**
  39245. * Distance the follow camera should follow an object at
  39246. */
  39247. radius: number;
  39248. /**
  39249. * Minimum allowed distance of the camera to the axis of rotation
  39250. * (The camera can not get closer).
  39251. * This can help limiting how the Camera is able to move in the scene.
  39252. */
  39253. lowerRadiusLimit: Nullable<number>;
  39254. /**
  39255. * Maximum allowed distance of the camera to the axis of rotation
  39256. * (The camera can not get further).
  39257. * This can help limiting how the Camera is able to move in the scene.
  39258. */
  39259. upperRadiusLimit: Nullable<number>;
  39260. /**
  39261. * Define a rotation offset between the camera and the object it follows
  39262. */
  39263. rotationOffset: number;
  39264. /**
  39265. * Minimum allowed angle to camera position relative to target object.
  39266. * This can help limiting how the Camera is able to move in the scene.
  39267. */
  39268. lowerRotationOffsetLimit: Nullable<number>;
  39269. /**
  39270. * Maximum allowed angle to camera position relative to target object.
  39271. * This can help limiting how the Camera is able to move in the scene.
  39272. */
  39273. upperRotationOffsetLimit: Nullable<number>;
  39274. /**
  39275. * Define a height offset between the camera and the object it follows.
  39276. * It can help following an object from the top (like a car chaing a plane)
  39277. */
  39278. heightOffset: number;
  39279. /**
  39280. * Minimum allowed height of camera position relative to target object.
  39281. * This can help limiting how the Camera is able to move in the scene.
  39282. */
  39283. lowerHeightOffsetLimit: Nullable<number>;
  39284. /**
  39285. * Maximum allowed height of camera position relative to target object.
  39286. * This can help limiting how the Camera is able to move in the scene.
  39287. */
  39288. upperHeightOffsetLimit: Nullable<number>;
  39289. /**
  39290. * Define how fast the camera can accelerate to follow it s target.
  39291. */
  39292. cameraAcceleration: number;
  39293. /**
  39294. * Define the speed limit of the camera following an object.
  39295. */
  39296. maxCameraSpeed: number;
  39297. /**
  39298. * Define the target of the camera.
  39299. */
  39300. lockedTarget: Nullable<AbstractMesh>;
  39301. /**
  39302. * Defines the input associated with the camera.
  39303. */
  39304. inputs: FollowCameraInputsManager;
  39305. /**
  39306. * Instantiates the follow camera.
  39307. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39308. * @param name Define the name of the camera in the scene
  39309. * @param position Define the position of the camera
  39310. * @param scene Define the scene the camera belong to
  39311. * @param lockedTarget Define the target of the camera
  39312. */
  39313. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  39314. private _follow;
  39315. /**
  39316. * Attached controls to the current camera.
  39317. * @param element Defines the element the controls should be listened from
  39318. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39319. */
  39320. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39321. /**
  39322. * Detach the current controls from the camera.
  39323. * The camera will stop reacting to inputs.
  39324. * @param element Defines the element to stop listening the inputs from
  39325. */
  39326. detachControl(element: HTMLElement): void;
  39327. /** @hidden */
  39328. _checkInputs(): void;
  39329. private _checkLimits;
  39330. /**
  39331. * Gets the camera class name.
  39332. * @returns the class name
  39333. */
  39334. getClassName(): string;
  39335. }
  39336. /**
  39337. * Arc Rotate version of the follow camera.
  39338. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  39339. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39340. */
  39341. export class ArcFollowCamera extends TargetCamera {
  39342. /** The longitudinal angle of the camera */
  39343. alpha: number;
  39344. /** The latitudinal angle of the camera */
  39345. beta: number;
  39346. /** The radius of the camera from its target */
  39347. radius: number;
  39348. /** Define the camera target (the messh it should follow) */
  39349. target: Nullable<AbstractMesh>;
  39350. private _cartesianCoordinates;
  39351. /**
  39352. * Instantiates a new ArcFollowCamera
  39353. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39354. * @param name Define the name of the camera
  39355. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  39356. * @param beta Define the rotation angle of the camera around the elevation axis
  39357. * @param radius Define the radius of the camera from its target point
  39358. * @param target Define the target of the camera
  39359. * @param scene Define the scene the camera belongs to
  39360. */
  39361. constructor(name: string,
  39362. /** The longitudinal angle of the camera */
  39363. alpha: number,
  39364. /** The latitudinal angle of the camera */
  39365. beta: number,
  39366. /** The radius of the camera from its target */
  39367. radius: number,
  39368. /** Define the camera target (the messh it should follow) */
  39369. target: Nullable<AbstractMesh>, scene: Scene);
  39370. private _follow;
  39371. /** @hidden */
  39372. _checkInputs(): void;
  39373. /**
  39374. * Returns the class name of the object.
  39375. * It is mostly used internally for serialization purposes.
  39376. */
  39377. getClassName(): string;
  39378. }
  39379. }
  39380. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  39381. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39382. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39383. import { Nullable } from "babylonjs/types";
  39384. /**
  39385. * Manage the keyboard inputs to control the movement of a follow camera.
  39386. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39387. */
  39388. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  39389. /**
  39390. * Defines the camera the input is attached to.
  39391. */
  39392. camera: FollowCamera;
  39393. /**
  39394. * Defines the list of key codes associated with the up action (increase heightOffset)
  39395. */
  39396. keysHeightOffsetIncr: number[];
  39397. /**
  39398. * Defines the list of key codes associated with the down action (decrease heightOffset)
  39399. */
  39400. keysHeightOffsetDecr: number[];
  39401. /**
  39402. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  39403. */
  39404. keysHeightOffsetModifierAlt: boolean;
  39405. /**
  39406. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  39407. */
  39408. keysHeightOffsetModifierCtrl: boolean;
  39409. /**
  39410. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  39411. */
  39412. keysHeightOffsetModifierShift: boolean;
  39413. /**
  39414. * Defines the list of key codes associated with the left action (increase rotationOffset)
  39415. */
  39416. keysRotationOffsetIncr: number[];
  39417. /**
  39418. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  39419. */
  39420. keysRotationOffsetDecr: number[];
  39421. /**
  39422. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  39423. */
  39424. keysRotationOffsetModifierAlt: boolean;
  39425. /**
  39426. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  39427. */
  39428. keysRotationOffsetModifierCtrl: boolean;
  39429. /**
  39430. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  39431. */
  39432. keysRotationOffsetModifierShift: boolean;
  39433. /**
  39434. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  39435. */
  39436. keysRadiusIncr: number[];
  39437. /**
  39438. * Defines the list of key codes associated with the zoom-out action (increase radius)
  39439. */
  39440. keysRadiusDecr: number[];
  39441. /**
  39442. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  39443. */
  39444. keysRadiusModifierAlt: boolean;
  39445. /**
  39446. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  39447. */
  39448. keysRadiusModifierCtrl: boolean;
  39449. /**
  39450. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  39451. */
  39452. keysRadiusModifierShift: boolean;
  39453. /**
  39454. * Defines the rate of change of heightOffset.
  39455. */
  39456. heightSensibility: number;
  39457. /**
  39458. * Defines the rate of change of rotationOffset.
  39459. */
  39460. rotationSensibility: number;
  39461. /**
  39462. * Defines the rate of change of radius.
  39463. */
  39464. radiusSensibility: number;
  39465. private _keys;
  39466. private _ctrlPressed;
  39467. private _altPressed;
  39468. private _shiftPressed;
  39469. private _onCanvasBlurObserver;
  39470. private _onKeyboardObserver;
  39471. private _engine;
  39472. private _scene;
  39473. /**
  39474. * Attach the input controls to a specific dom element to get the input from.
  39475. * @param element Defines the element the controls should be listened from
  39476. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39477. */
  39478. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39479. /**
  39480. * Detach the current controls from the specified dom element.
  39481. * @param element Defines the element to stop listening the inputs from
  39482. */
  39483. detachControl(element: Nullable<HTMLElement>): void;
  39484. /**
  39485. * Update the current camera state depending on the inputs that have been used this frame.
  39486. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39487. */
  39488. checkInputs(): void;
  39489. /**
  39490. * Gets the class name of the current input.
  39491. * @returns the class name
  39492. */
  39493. getClassName(): string;
  39494. /**
  39495. * Get the friendly name associated with the input class.
  39496. * @returns the input friendly name
  39497. */
  39498. getSimpleName(): string;
  39499. /**
  39500. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39501. * allow modification of the heightOffset value.
  39502. */
  39503. private _modifierHeightOffset;
  39504. /**
  39505. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39506. * allow modification of the rotationOffset value.
  39507. */
  39508. private _modifierRotationOffset;
  39509. /**
  39510. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39511. * allow modification of the radius value.
  39512. */
  39513. private _modifierRadius;
  39514. }
  39515. }
  39516. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  39517. import { Nullable } from "babylonjs/types";
  39518. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39519. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39520. import { Observable } from "babylonjs/Misc/observable";
  39521. module "babylonjs/Cameras/freeCameraInputsManager" {
  39522. interface FreeCameraInputsManager {
  39523. /**
  39524. * @hidden
  39525. */
  39526. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  39527. /**
  39528. * Add orientation input support to the input manager.
  39529. * @returns the current input manager
  39530. */
  39531. addDeviceOrientation(): FreeCameraInputsManager;
  39532. }
  39533. }
  39534. /**
  39535. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  39536. * Screen rotation is taken into account.
  39537. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39538. */
  39539. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  39540. private _camera;
  39541. private _screenOrientationAngle;
  39542. private _constantTranform;
  39543. private _screenQuaternion;
  39544. private _alpha;
  39545. private _beta;
  39546. private _gamma;
  39547. /**
  39548. * Can be used to detect if a device orientation sensor is availible on a device
  39549. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  39550. * @returns a promise that will resolve on orientation change
  39551. */
  39552. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  39553. /**
  39554. * @hidden
  39555. */
  39556. _onDeviceOrientationChangedObservable: Observable<void>;
  39557. /**
  39558. * Instantiates a new input
  39559. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39560. */
  39561. constructor();
  39562. /**
  39563. * Define the camera controlled by the input.
  39564. */
  39565. camera: FreeCamera;
  39566. /**
  39567. * Attach the input controls to a specific dom element to get the input from.
  39568. * @param element Defines the element the controls should be listened from
  39569. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39570. */
  39571. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39572. private _orientationChanged;
  39573. private _deviceOrientation;
  39574. /**
  39575. * Detach the current controls from the specified dom element.
  39576. * @param element Defines the element to stop listening the inputs from
  39577. */
  39578. detachControl(element: Nullable<HTMLElement>): void;
  39579. /**
  39580. * Update the current camera state depending on the inputs that have been used this frame.
  39581. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39582. */
  39583. checkInputs(): void;
  39584. /**
  39585. * Gets the class name of the current intput.
  39586. * @returns the class name
  39587. */
  39588. getClassName(): string;
  39589. /**
  39590. * Get the friendly name associated with the input class.
  39591. * @returns the input friendly name
  39592. */
  39593. getSimpleName(): string;
  39594. }
  39595. }
  39596. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  39597. import { Nullable } from "babylonjs/types";
  39598. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39599. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39600. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39601. /**
  39602. * Manage the gamepad inputs to control a free camera.
  39603. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39604. */
  39605. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  39606. /**
  39607. * Define the camera the input is attached to.
  39608. */
  39609. camera: FreeCamera;
  39610. /**
  39611. * Define the Gamepad controlling the input
  39612. */
  39613. gamepad: Nullable<Gamepad>;
  39614. /**
  39615. * Defines the gamepad rotation sensiblity.
  39616. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39617. */
  39618. gamepadAngularSensibility: number;
  39619. /**
  39620. * Defines the gamepad move sensiblity.
  39621. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39622. */
  39623. gamepadMoveSensibility: number;
  39624. private _onGamepadConnectedObserver;
  39625. private _onGamepadDisconnectedObserver;
  39626. private _cameraTransform;
  39627. private _deltaTransform;
  39628. private _vector3;
  39629. private _vector2;
  39630. /**
  39631. * Attach the input controls to a specific dom element to get the input from.
  39632. * @param element Defines the element the controls should be listened from
  39633. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39634. */
  39635. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39636. /**
  39637. * Detach the current controls from the specified dom element.
  39638. * @param element Defines the element to stop listening the inputs from
  39639. */
  39640. detachControl(element: Nullable<HTMLElement>): void;
  39641. /**
  39642. * Update the current camera state depending on the inputs that have been used this frame.
  39643. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39644. */
  39645. checkInputs(): void;
  39646. /**
  39647. * Gets the class name of the current intput.
  39648. * @returns the class name
  39649. */
  39650. getClassName(): string;
  39651. /**
  39652. * Get the friendly name associated with the input class.
  39653. * @returns the input friendly name
  39654. */
  39655. getSimpleName(): string;
  39656. }
  39657. }
  39658. declare module "babylonjs/Misc/virtualJoystick" {
  39659. import { Nullable } from "babylonjs/types";
  39660. import { Vector3 } from "babylonjs/Maths/math.vector";
  39661. /**
  39662. * Defines the potential axis of a Joystick
  39663. */
  39664. export enum JoystickAxis {
  39665. /** X axis */
  39666. X = 0,
  39667. /** Y axis */
  39668. Y = 1,
  39669. /** Z axis */
  39670. Z = 2
  39671. }
  39672. /**
  39673. * Class used to define virtual joystick (used in touch mode)
  39674. */
  39675. export class VirtualJoystick {
  39676. /**
  39677. * Gets or sets a boolean indicating that left and right values must be inverted
  39678. */
  39679. reverseLeftRight: boolean;
  39680. /**
  39681. * Gets or sets a boolean indicating that up and down values must be inverted
  39682. */
  39683. reverseUpDown: boolean;
  39684. /**
  39685. * Gets the offset value for the position (ie. the change of the position value)
  39686. */
  39687. deltaPosition: Vector3;
  39688. /**
  39689. * Gets a boolean indicating if the virtual joystick was pressed
  39690. */
  39691. pressed: boolean;
  39692. /**
  39693. * Canvas the virtual joystick will render onto, default z-index of this is 5
  39694. */
  39695. static Canvas: Nullable<HTMLCanvasElement>;
  39696. private static _globalJoystickIndex;
  39697. private static vjCanvasContext;
  39698. private static vjCanvasWidth;
  39699. private static vjCanvasHeight;
  39700. private static halfWidth;
  39701. private _action;
  39702. private _axisTargetedByLeftAndRight;
  39703. private _axisTargetedByUpAndDown;
  39704. private _joystickSensibility;
  39705. private _inversedSensibility;
  39706. private _joystickPointerID;
  39707. private _joystickColor;
  39708. private _joystickPointerPos;
  39709. private _joystickPreviousPointerPos;
  39710. private _joystickPointerStartPos;
  39711. private _deltaJoystickVector;
  39712. private _leftJoystick;
  39713. private _touches;
  39714. private _onPointerDownHandlerRef;
  39715. private _onPointerMoveHandlerRef;
  39716. private _onPointerUpHandlerRef;
  39717. private _onResize;
  39718. /**
  39719. * Creates a new virtual joystick
  39720. * @param leftJoystick defines that the joystick is for left hand (false by default)
  39721. */
  39722. constructor(leftJoystick?: boolean);
  39723. /**
  39724. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  39725. * @param newJoystickSensibility defines the new sensibility
  39726. */
  39727. setJoystickSensibility(newJoystickSensibility: number): void;
  39728. private _onPointerDown;
  39729. private _onPointerMove;
  39730. private _onPointerUp;
  39731. /**
  39732. * Change the color of the virtual joystick
  39733. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  39734. */
  39735. setJoystickColor(newColor: string): void;
  39736. /**
  39737. * Defines a callback to call when the joystick is touched
  39738. * @param action defines the callback
  39739. */
  39740. setActionOnTouch(action: () => any): void;
  39741. /**
  39742. * Defines which axis you'd like to control for left & right
  39743. * @param axis defines the axis to use
  39744. */
  39745. setAxisForLeftRight(axis: JoystickAxis): void;
  39746. /**
  39747. * Defines which axis you'd like to control for up & down
  39748. * @param axis defines the axis to use
  39749. */
  39750. setAxisForUpDown(axis: JoystickAxis): void;
  39751. private _drawVirtualJoystick;
  39752. /**
  39753. * Release internal HTML canvas
  39754. */
  39755. releaseCanvas(): void;
  39756. }
  39757. }
  39758. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  39759. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  39760. import { Nullable } from "babylonjs/types";
  39761. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39762. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39763. module "babylonjs/Cameras/freeCameraInputsManager" {
  39764. interface FreeCameraInputsManager {
  39765. /**
  39766. * Add virtual joystick input support to the input manager.
  39767. * @returns the current input manager
  39768. */
  39769. addVirtualJoystick(): FreeCameraInputsManager;
  39770. }
  39771. }
  39772. /**
  39773. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  39774. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39775. */
  39776. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  39777. /**
  39778. * Defines the camera the input is attached to.
  39779. */
  39780. camera: FreeCamera;
  39781. private _leftjoystick;
  39782. private _rightjoystick;
  39783. /**
  39784. * Gets the left stick of the virtual joystick.
  39785. * @returns The virtual Joystick
  39786. */
  39787. getLeftJoystick(): VirtualJoystick;
  39788. /**
  39789. * Gets the right stick of the virtual joystick.
  39790. * @returns The virtual Joystick
  39791. */
  39792. getRightJoystick(): VirtualJoystick;
  39793. /**
  39794. * Update the current camera state depending on the inputs that have been used this frame.
  39795. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39796. */
  39797. checkInputs(): void;
  39798. /**
  39799. * Attach the input controls to a specific dom element to get the input from.
  39800. * @param element Defines the element the controls should be listened from
  39801. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39802. */
  39803. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39804. /**
  39805. * Detach the current controls from the specified dom element.
  39806. * @param element Defines the element to stop listening the inputs from
  39807. */
  39808. detachControl(element: Nullable<HTMLElement>): void;
  39809. /**
  39810. * Gets the class name of the current intput.
  39811. * @returns the class name
  39812. */
  39813. getClassName(): string;
  39814. /**
  39815. * Get the friendly name associated with the input class.
  39816. * @returns the input friendly name
  39817. */
  39818. getSimpleName(): string;
  39819. }
  39820. }
  39821. declare module "babylonjs/Cameras/Inputs/index" {
  39822. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  39823. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  39824. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  39825. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  39826. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  39827. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  39828. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  39829. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  39830. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  39831. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  39832. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39833. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  39834. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  39835. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  39836. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  39837. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  39838. }
  39839. declare module "babylonjs/Cameras/touchCamera" {
  39840. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39841. import { Scene } from "babylonjs/scene";
  39842. import { Vector3 } from "babylonjs/Maths/math.vector";
  39843. /**
  39844. * This represents a FPS type of camera controlled by touch.
  39845. * This is like a universal camera minus the Gamepad controls.
  39846. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39847. */
  39848. export class TouchCamera extends FreeCamera {
  39849. /**
  39850. * Defines the touch sensibility for rotation.
  39851. * The higher the faster.
  39852. */
  39853. touchAngularSensibility: number;
  39854. /**
  39855. * Defines the touch sensibility for move.
  39856. * The higher the faster.
  39857. */
  39858. touchMoveSensibility: number;
  39859. /**
  39860. * Instantiates a new touch camera.
  39861. * This represents a FPS type of camera controlled by touch.
  39862. * This is like a universal camera minus the Gamepad controls.
  39863. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39864. * @param name Define the name of the camera in the scene
  39865. * @param position Define the start position of the camera in the scene
  39866. * @param scene Define the scene the camera belongs to
  39867. */
  39868. constructor(name: string, position: Vector3, scene: Scene);
  39869. /**
  39870. * Gets the current object class name.
  39871. * @return the class name
  39872. */
  39873. getClassName(): string;
  39874. /** @hidden */
  39875. _setupInputs(): void;
  39876. }
  39877. }
  39878. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  39879. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39880. import { Scene } from "babylonjs/scene";
  39881. import { Vector3 } from "babylonjs/Maths/math.vector";
  39882. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39883. import { Axis } from "babylonjs/Maths/math.axis";
  39884. /**
  39885. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  39886. * being tilted forward or back and left or right.
  39887. */
  39888. export class DeviceOrientationCamera extends FreeCamera {
  39889. private _initialQuaternion;
  39890. private _quaternionCache;
  39891. private _tmpDragQuaternion;
  39892. private _disablePointerInputWhenUsingDeviceOrientation;
  39893. /**
  39894. * Creates a new device orientation camera
  39895. * @param name The name of the camera
  39896. * @param position The start position camera
  39897. * @param scene The scene the camera belongs to
  39898. */
  39899. constructor(name: string, position: Vector3, scene: Scene);
  39900. /**
  39901. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  39902. */
  39903. disablePointerInputWhenUsingDeviceOrientation: boolean;
  39904. private _dragFactor;
  39905. /**
  39906. * Enabled turning on the y axis when the orientation sensor is active
  39907. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  39908. */
  39909. enableHorizontalDragging(dragFactor?: number): void;
  39910. /**
  39911. * Gets the current instance class name ("DeviceOrientationCamera").
  39912. * This helps avoiding instanceof at run time.
  39913. * @returns the class name
  39914. */
  39915. getClassName(): string;
  39916. /**
  39917. * @hidden
  39918. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  39919. */
  39920. _checkInputs(): void;
  39921. /**
  39922. * Reset the camera to its default orientation on the specified axis only.
  39923. * @param axis The axis to reset
  39924. */
  39925. resetToCurrentRotation(axis?: Axis): void;
  39926. }
  39927. }
  39928. declare module "babylonjs/Gamepads/xboxGamepad" {
  39929. import { Observable } from "babylonjs/Misc/observable";
  39930. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39931. /**
  39932. * Defines supported buttons for XBox360 compatible gamepads
  39933. */
  39934. export enum Xbox360Button {
  39935. /** A */
  39936. A = 0,
  39937. /** B */
  39938. B = 1,
  39939. /** X */
  39940. X = 2,
  39941. /** Y */
  39942. Y = 3,
  39943. /** Start */
  39944. Start = 4,
  39945. /** Back */
  39946. Back = 5,
  39947. /** Left button */
  39948. LB = 6,
  39949. /** Right button */
  39950. RB = 7,
  39951. /** Left stick */
  39952. LeftStick = 8,
  39953. /** Right stick */
  39954. RightStick = 9
  39955. }
  39956. /** Defines values for XBox360 DPad */
  39957. export enum Xbox360Dpad {
  39958. /** Up */
  39959. Up = 0,
  39960. /** Down */
  39961. Down = 1,
  39962. /** Left */
  39963. Left = 2,
  39964. /** Right */
  39965. Right = 3
  39966. }
  39967. /**
  39968. * Defines a XBox360 gamepad
  39969. */
  39970. export class Xbox360Pad extends Gamepad {
  39971. private _leftTrigger;
  39972. private _rightTrigger;
  39973. private _onlefttriggerchanged;
  39974. private _onrighttriggerchanged;
  39975. private _onbuttondown;
  39976. private _onbuttonup;
  39977. private _ondpaddown;
  39978. private _ondpadup;
  39979. /** Observable raised when a button is pressed */
  39980. onButtonDownObservable: Observable<Xbox360Button>;
  39981. /** Observable raised when a button is released */
  39982. onButtonUpObservable: Observable<Xbox360Button>;
  39983. /** Observable raised when a pad is pressed */
  39984. onPadDownObservable: Observable<Xbox360Dpad>;
  39985. /** Observable raised when a pad is released */
  39986. onPadUpObservable: Observable<Xbox360Dpad>;
  39987. private _buttonA;
  39988. private _buttonB;
  39989. private _buttonX;
  39990. private _buttonY;
  39991. private _buttonBack;
  39992. private _buttonStart;
  39993. private _buttonLB;
  39994. private _buttonRB;
  39995. private _buttonLeftStick;
  39996. private _buttonRightStick;
  39997. private _dPadUp;
  39998. private _dPadDown;
  39999. private _dPadLeft;
  40000. private _dPadRight;
  40001. private _isXboxOnePad;
  40002. /**
  40003. * Creates a new XBox360 gamepad object
  40004. * @param id defines the id of this gamepad
  40005. * @param index defines its index
  40006. * @param gamepad defines the internal HTML gamepad object
  40007. * @param xboxOne defines if it is a XBox One gamepad
  40008. */
  40009. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  40010. /**
  40011. * Defines the callback to call when left trigger is pressed
  40012. * @param callback defines the callback to use
  40013. */
  40014. onlefttriggerchanged(callback: (value: number) => void): void;
  40015. /**
  40016. * Defines the callback to call when right trigger is pressed
  40017. * @param callback defines the callback to use
  40018. */
  40019. onrighttriggerchanged(callback: (value: number) => void): void;
  40020. /**
  40021. * Gets the left trigger value
  40022. */
  40023. /**
  40024. * Sets the left trigger value
  40025. */
  40026. leftTrigger: number;
  40027. /**
  40028. * Gets the right trigger value
  40029. */
  40030. /**
  40031. * Sets the right trigger value
  40032. */
  40033. rightTrigger: number;
  40034. /**
  40035. * Defines the callback to call when a button is pressed
  40036. * @param callback defines the callback to use
  40037. */
  40038. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  40039. /**
  40040. * Defines the callback to call when a button is released
  40041. * @param callback defines the callback to use
  40042. */
  40043. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  40044. /**
  40045. * Defines the callback to call when a pad is pressed
  40046. * @param callback defines the callback to use
  40047. */
  40048. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  40049. /**
  40050. * Defines the callback to call when a pad is released
  40051. * @param callback defines the callback to use
  40052. */
  40053. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  40054. private _setButtonValue;
  40055. private _setDPadValue;
  40056. /**
  40057. * Gets the value of the `A` button
  40058. */
  40059. /**
  40060. * Sets the value of the `A` button
  40061. */
  40062. buttonA: number;
  40063. /**
  40064. * Gets the value of the `B` button
  40065. */
  40066. /**
  40067. * Sets the value of the `B` button
  40068. */
  40069. buttonB: number;
  40070. /**
  40071. * Gets the value of the `X` button
  40072. */
  40073. /**
  40074. * Sets the value of the `X` button
  40075. */
  40076. buttonX: number;
  40077. /**
  40078. * Gets the value of the `Y` button
  40079. */
  40080. /**
  40081. * Sets the value of the `Y` button
  40082. */
  40083. buttonY: number;
  40084. /**
  40085. * Gets the value of the `Start` button
  40086. */
  40087. /**
  40088. * Sets the value of the `Start` button
  40089. */
  40090. buttonStart: number;
  40091. /**
  40092. * Gets the value of the `Back` button
  40093. */
  40094. /**
  40095. * Sets the value of the `Back` button
  40096. */
  40097. buttonBack: number;
  40098. /**
  40099. * Gets the value of the `Left` button
  40100. */
  40101. /**
  40102. * Sets the value of the `Left` button
  40103. */
  40104. buttonLB: number;
  40105. /**
  40106. * Gets the value of the `Right` button
  40107. */
  40108. /**
  40109. * Sets the value of the `Right` button
  40110. */
  40111. buttonRB: number;
  40112. /**
  40113. * Gets the value of the Left joystick
  40114. */
  40115. /**
  40116. * Sets the value of the Left joystick
  40117. */
  40118. buttonLeftStick: number;
  40119. /**
  40120. * Gets the value of the Right joystick
  40121. */
  40122. /**
  40123. * Sets the value of the Right joystick
  40124. */
  40125. buttonRightStick: number;
  40126. /**
  40127. * Gets the value of D-pad up
  40128. */
  40129. /**
  40130. * Sets the value of D-pad up
  40131. */
  40132. dPadUp: number;
  40133. /**
  40134. * Gets the value of D-pad down
  40135. */
  40136. /**
  40137. * Sets the value of D-pad down
  40138. */
  40139. dPadDown: number;
  40140. /**
  40141. * Gets the value of D-pad left
  40142. */
  40143. /**
  40144. * Sets the value of D-pad left
  40145. */
  40146. dPadLeft: number;
  40147. /**
  40148. * Gets the value of D-pad right
  40149. */
  40150. /**
  40151. * Sets the value of D-pad right
  40152. */
  40153. dPadRight: number;
  40154. /**
  40155. * Force the gamepad to synchronize with device values
  40156. */
  40157. update(): void;
  40158. /**
  40159. * Disposes the gamepad
  40160. */
  40161. dispose(): void;
  40162. }
  40163. }
  40164. declare module "babylonjs/Gamepads/dualShockGamepad" {
  40165. import { Observable } from "babylonjs/Misc/observable";
  40166. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40167. /**
  40168. * Defines supported buttons for DualShock compatible gamepads
  40169. */
  40170. export enum DualShockButton {
  40171. /** Cross */
  40172. Cross = 0,
  40173. /** Circle */
  40174. Circle = 1,
  40175. /** Square */
  40176. Square = 2,
  40177. /** Triangle */
  40178. Triangle = 3,
  40179. /** Options */
  40180. Options = 4,
  40181. /** Share */
  40182. Share = 5,
  40183. /** L1 */
  40184. L1 = 6,
  40185. /** R1 */
  40186. R1 = 7,
  40187. /** Left stick */
  40188. LeftStick = 8,
  40189. /** Right stick */
  40190. RightStick = 9
  40191. }
  40192. /** Defines values for DualShock DPad */
  40193. export enum DualShockDpad {
  40194. /** Up */
  40195. Up = 0,
  40196. /** Down */
  40197. Down = 1,
  40198. /** Left */
  40199. Left = 2,
  40200. /** Right */
  40201. Right = 3
  40202. }
  40203. /**
  40204. * Defines a DualShock gamepad
  40205. */
  40206. export class DualShockPad extends Gamepad {
  40207. private _leftTrigger;
  40208. private _rightTrigger;
  40209. private _onlefttriggerchanged;
  40210. private _onrighttriggerchanged;
  40211. private _onbuttondown;
  40212. private _onbuttonup;
  40213. private _ondpaddown;
  40214. private _ondpadup;
  40215. /** Observable raised when a button is pressed */
  40216. onButtonDownObservable: Observable<DualShockButton>;
  40217. /** Observable raised when a button is released */
  40218. onButtonUpObservable: Observable<DualShockButton>;
  40219. /** Observable raised when a pad is pressed */
  40220. onPadDownObservable: Observable<DualShockDpad>;
  40221. /** Observable raised when a pad is released */
  40222. onPadUpObservable: Observable<DualShockDpad>;
  40223. private _buttonCross;
  40224. private _buttonCircle;
  40225. private _buttonSquare;
  40226. private _buttonTriangle;
  40227. private _buttonShare;
  40228. private _buttonOptions;
  40229. private _buttonL1;
  40230. private _buttonR1;
  40231. private _buttonLeftStick;
  40232. private _buttonRightStick;
  40233. private _dPadUp;
  40234. private _dPadDown;
  40235. private _dPadLeft;
  40236. private _dPadRight;
  40237. /**
  40238. * Creates a new DualShock gamepad object
  40239. * @param id defines the id of this gamepad
  40240. * @param index defines its index
  40241. * @param gamepad defines the internal HTML gamepad object
  40242. */
  40243. constructor(id: string, index: number, gamepad: any);
  40244. /**
  40245. * Defines the callback to call when left trigger is pressed
  40246. * @param callback defines the callback to use
  40247. */
  40248. onlefttriggerchanged(callback: (value: number) => void): void;
  40249. /**
  40250. * Defines the callback to call when right trigger is pressed
  40251. * @param callback defines the callback to use
  40252. */
  40253. onrighttriggerchanged(callback: (value: number) => void): void;
  40254. /**
  40255. * Gets the left trigger value
  40256. */
  40257. /**
  40258. * Sets the left trigger value
  40259. */
  40260. leftTrigger: number;
  40261. /**
  40262. * Gets the right trigger value
  40263. */
  40264. /**
  40265. * Sets the right trigger value
  40266. */
  40267. rightTrigger: number;
  40268. /**
  40269. * Defines the callback to call when a button is pressed
  40270. * @param callback defines the callback to use
  40271. */
  40272. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  40273. /**
  40274. * Defines the callback to call when a button is released
  40275. * @param callback defines the callback to use
  40276. */
  40277. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  40278. /**
  40279. * Defines the callback to call when a pad is pressed
  40280. * @param callback defines the callback to use
  40281. */
  40282. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  40283. /**
  40284. * Defines the callback to call when a pad is released
  40285. * @param callback defines the callback to use
  40286. */
  40287. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  40288. private _setButtonValue;
  40289. private _setDPadValue;
  40290. /**
  40291. * Gets the value of the `Cross` button
  40292. */
  40293. /**
  40294. * Sets the value of the `Cross` button
  40295. */
  40296. buttonCross: number;
  40297. /**
  40298. * Gets the value of the `Circle` button
  40299. */
  40300. /**
  40301. * Sets the value of the `Circle` button
  40302. */
  40303. buttonCircle: number;
  40304. /**
  40305. * Gets the value of the `Square` button
  40306. */
  40307. /**
  40308. * Sets the value of the `Square` button
  40309. */
  40310. buttonSquare: number;
  40311. /**
  40312. * Gets the value of the `Triangle` button
  40313. */
  40314. /**
  40315. * Sets the value of the `Triangle` button
  40316. */
  40317. buttonTriangle: number;
  40318. /**
  40319. * Gets the value of the `Options` button
  40320. */
  40321. /**
  40322. * Sets the value of the `Options` button
  40323. */
  40324. buttonOptions: number;
  40325. /**
  40326. * Gets the value of the `Share` button
  40327. */
  40328. /**
  40329. * Sets the value of the `Share` button
  40330. */
  40331. buttonShare: number;
  40332. /**
  40333. * Gets the value of the `L1` button
  40334. */
  40335. /**
  40336. * Sets the value of the `L1` button
  40337. */
  40338. buttonL1: number;
  40339. /**
  40340. * Gets the value of the `R1` button
  40341. */
  40342. /**
  40343. * Sets the value of the `R1` button
  40344. */
  40345. buttonR1: number;
  40346. /**
  40347. * Gets the value of the Left joystick
  40348. */
  40349. /**
  40350. * Sets the value of the Left joystick
  40351. */
  40352. buttonLeftStick: number;
  40353. /**
  40354. * Gets the value of the Right joystick
  40355. */
  40356. /**
  40357. * Sets the value of the Right joystick
  40358. */
  40359. buttonRightStick: number;
  40360. /**
  40361. * Gets the value of D-pad up
  40362. */
  40363. /**
  40364. * Sets the value of D-pad up
  40365. */
  40366. dPadUp: number;
  40367. /**
  40368. * Gets the value of D-pad down
  40369. */
  40370. /**
  40371. * Sets the value of D-pad down
  40372. */
  40373. dPadDown: number;
  40374. /**
  40375. * Gets the value of D-pad left
  40376. */
  40377. /**
  40378. * Sets the value of D-pad left
  40379. */
  40380. dPadLeft: number;
  40381. /**
  40382. * Gets the value of D-pad right
  40383. */
  40384. /**
  40385. * Sets the value of D-pad right
  40386. */
  40387. dPadRight: number;
  40388. /**
  40389. * Force the gamepad to synchronize with device values
  40390. */
  40391. update(): void;
  40392. /**
  40393. * Disposes the gamepad
  40394. */
  40395. dispose(): void;
  40396. }
  40397. }
  40398. declare module "babylonjs/Gamepads/gamepadManager" {
  40399. import { Observable } from "babylonjs/Misc/observable";
  40400. import { Nullable } from "babylonjs/types";
  40401. import { Scene } from "babylonjs/scene";
  40402. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40403. /**
  40404. * Manager for handling gamepads
  40405. */
  40406. export class GamepadManager {
  40407. private _scene?;
  40408. private _babylonGamepads;
  40409. private _oneGamepadConnected;
  40410. /** @hidden */
  40411. _isMonitoring: boolean;
  40412. private _gamepadEventSupported;
  40413. private _gamepadSupport;
  40414. /**
  40415. * observable to be triggered when the gamepad controller has been connected
  40416. */
  40417. onGamepadConnectedObservable: Observable<Gamepad>;
  40418. /**
  40419. * observable to be triggered when the gamepad controller has been disconnected
  40420. */
  40421. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40422. private _onGamepadConnectedEvent;
  40423. private _onGamepadDisconnectedEvent;
  40424. /**
  40425. * Initializes the gamepad manager
  40426. * @param _scene BabylonJS scene
  40427. */
  40428. constructor(_scene?: Scene | undefined);
  40429. /**
  40430. * The gamepads in the game pad manager
  40431. */
  40432. readonly gamepads: Gamepad[];
  40433. /**
  40434. * Get the gamepad controllers based on type
  40435. * @param type The type of gamepad controller
  40436. * @returns Nullable gamepad
  40437. */
  40438. getGamepadByType(type?: number): Nullable<Gamepad>;
  40439. /**
  40440. * Disposes the gamepad manager
  40441. */
  40442. dispose(): void;
  40443. private _addNewGamepad;
  40444. private _startMonitoringGamepads;
  40445. private _stopMonitoringGamepads;
  40446. /** @hidden */
  40447. _checkGamepadsStatus(): void;
  40448. private _updateGamepadObjects;
  40449. }
  40450. }
  40451. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  40452. import { Nullable } from "babylonjs/types";
  40453. import { Scene } from "babylonjs/scene";
  40454. import { ISceneComponent } from "babylonjs/sceneComponent";
  40455. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  40456. module "babylonjs/scene" {
  40457. interface Scene {
  40458. /** @hidden */
  40459. _gamepadManager: Nullable<GamepadManager>;
  40460. /**
  40461. * Gets the gamepad manager associated with the scene
  40462. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40463. */
  40464. gamepadManager: GamepadManager;
  40465. }
  40466. }
  40467. module "babylonjs/Cameras/freeCameraInputsManager" {
  40468. /**
  40469. * Interface representing a free camera inputs manager
  40470. */
  40471. interface FreeCameraInputsManager {
  40472. /**
  40473. * Adds gamepad input support to the FreeCameraInputsManager.
  40474. * @returns the FreeCameraInputsManager
  40475. */
  40476. addGamepad(): FreeCameraInputsManager;
  40477. }
  40478. }
  40479. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40480. /**
  40481. * Interface representing an arc rotate camera inputs manager
  40482. */
  40483. interface ArcRotateCameraInputsManager {
  40484. /**
  40485. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40486. * @returns the camera inputs manager
  40487. */
  40488. addGamepad(): ArcRotateCameraInputsManager;
  40489. }
  40490. }
  40491. /**
  40492. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40493. */
  40494. export class GamepadSystemSceneComponent implements ISceneComponent {
  40495. /**
  40496. * The component name helpfull to identify the component in the list of scene components.
  40497. */
  40498. readonly name: string;
  40499. /**
  40500. * The scene the component belongs to.
  40501. */
  40502. scene: Scene;
  40503. /**
  40504. * Creates a new instance of the component for the given scene
  40505. * @param scene Defines the scene to register the component in
  40506. */
  40507. constructor(scene: Scene);
  40508. /**
  40509. * Registers the component in a given scene
  40510. */
  40511. register(): void;
  40512. /**
  40513. * Rebuilds the elements related to this component in case of
  40514. * context lost for instance.
  40515. */
  40516. rebuild(): void;
  40517. /**
  40518. * Disposes the component and the associated ressources
  40519. */
  40520. dispose(): void;
  40521. private _beforeCameraUpdate;
  40522. }
  40523. }
  40524. declare module "babylonjs/Cameras/universalCamera" {
  40525. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  40526. import { Scene } from "babylonjs/scene";
  40527. import { Vector3 } from "babylonjs/Maths/math.vector";
  40528. import "babylonjs/Gamepads/gamepadSceneComponent";
  40529. /**
  40530. * 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,
  40531. * which still works and will still be found in many Playgrounds.
  40532. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40533. */
  40534. export class UniversalCamera extends TouchCamera {
  40535. /**
  40536. * Defines the gamepad rotation sensiblity.
  40537. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40538. */
  40539. gamepadAngularSensibility: number;
  40540. /**
  40541. * Defines the gamepad move sensiblity.
  40542. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40543. */
  40544. gamepadMoveSensibility: number;
  40545. /**
  40546. * 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,
  40547. * which still works and will still be found in many Playgrounds.
  40548. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40549. * @param name Define the name of the camera in the scene
  40550. * @param position Define the start position of the camera in the scene
  40551. * @param scene Define the scene the camera belongs to
  40552. */
  40553. constructor(name: string, position: Vector3, scene: Scene);
  40554. /**
  40555. * Gets the current object class name.
  40556. * @return the class name
  40557. */
  40558. getClassName(): string;
  40559. }
  40560. }
  40561. declare module "babylonjs/Cameras/gamepadCamera" {
  40562. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40563. import { Scene } from "babylonjs/scene";
  40564. import { Vector3 } from "babylonjs/Maths/math.vector";
  40565. /**
  40566. * This represents a FPS type of camera. This is only here for back compat purpose.
  40567. * Please use the UniversalCamera instead as both are identical.
  40568. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40569. */
  40570. export class GamepadCamera extends UniversalCamera {
  40571. /**
  40572. * Instantiates a new Gamepad Camera
  40573. * This represents a FPS type of camera. This is only here for back compat purpose.
  40574. * Please use the UniversalCamera instead as both are identical.
  40575. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40576. * @param name Define the name of the camera in the scene
  40577. * @param position Define the start position of the camera in the scene
  40578. * @param scene Define the scene the camera belongs to
  40579. */
  40580. constructor(name: string, position: Vector3, scene: Scene);
  40581. /**
  40582. * Gets the current object class name.
  40583. * @return the class name
  40584. */
  40585. getClassName(): string;
  40586. }
  40587. }
  40588. declare module "babylonjs/Shaders/pass.fragment" {
  40589. /** @hidden */
  40590. export var passPixelShader: {
  40591. name: string;
  40592. shader: string;
  40593. };
  40594. }
  40595. declare module "babylonjs/Shaders/passCube.fragment" {
  40596. /** @hidden */
  40597. export var passCubePixelShader: {
  40598. name: string;
  40599. shader: string;
  40600. };
  40601. }
  40602. declare module "babylonjs/PostProcesses/passPostProcess" {
  40603. import { Nullable } from "babylonjs/types";
  40604. import { Camera } from "babylonjs/Cameras/camera";
  40605. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40606. import { Engine } from "babylonjs/Engines/engine";
  40607. import "babylonjs/Shaders/pass.fragment";
  40608. import "babylonjs/Shaders/passCube.fragment";
  40609. /**
  40610. * PassPostProcess which produces an output the same as it's input
  40611. */
  40612. export class PassPostProcess extends PostProcess {
  40613. /**
  40614. * Creates the PassPostProcess
  40615. * @param name The name of the effect.
  40616. * @param options The required width/height ratio to downsize to before computing the render pass.
  40617. * @param camera The camera to apply the render pass to.
  40618. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40619. * @param engine The engine which the post process will be applied. (default: current engine)
  40620. * @param reusable If the post process can be reused on the same frame. (default: false)
  40621. * @param textureType The type of texture to be used when performing the post processing.
  40622. * @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)
  40623. */
  40624. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40625. }
  40626. /**
  40627. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  40628. */
  40629. export class PassCubePostProcess extends PostProcess {
  40630. private _face;
  40631. /**
  40632. * Gets or sets the cube face to display.
  40633. * * 0 is +X
  40634. * * 1 is -X
  40635. * * 2 is +Y
  40636. * * 3 is -Y
  40637. * * 4 is +Z
  40638. * * 5 is -Z
  40639. */
  40640. face: number;
  40641. /**
  40642. * Creates the PassCubePostProcess
  40643. * @param name The name of the effect.
  40644. * @param options The required width/height ratio to downsize to before computing the render pass.
  40645. * @param camera The camera to apply the render pass to.
  40646. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40647. * @param engine The engine which the post process will be applied. (default: current engine)
  40648. * @param reusable If the post process can be reused on the same frame. (default: false)
  40649. * @param textureType The type of texture to be used when performing the post processing.
  40650. * @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)
  40651. */
  40652. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40653. }
  40654. }
  40655. declare module "babylonjs/Shaders/anaglyph.fragment" {
  40656. /** @hidden */
  40657. export var anaglyphPixelShader: {
  40658. name: string;
  40659. shader: string;
  40660. };
  40661. }
  40662. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  40663. import { Engine } from "babylonjs/Engines/engine";
  40664. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40665. import { Camera } from "babylonjs/Cameras/camera";
  40666. import "babylonjs/Shaders/anaglyph.fragment";
  40667. /**
  40668. * Postprocess used to generate anaglyphic rendering
  40669. */
  40670. export class AnaglyphPostProcess extends PostProcess {
  40671. private _passedProcess;
  40672. /**
  40673. * Creates a new AnaglyphPostProcess
  40674. * @param name defines postprocess name
  40675. * @param options defines creation options or target ratio scale
  40676. * @param rigCameras defines cameras using this postprocess
  40677. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  40678. * @param engine defines hosting engine
  40679. * @param reusable defines if the postprocess will be reused multiple times per frame
  40680. */
  40681. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  40682. }
  40683. }
  40684. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  40685. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  40686. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40687. import { Scene } from "babylonjs/scene";
  40688. import { Vector3 } from "babylonjs/Maths/math.vector";
  40689. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40690. /**
  40691. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  40692. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40693. */
  40694. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  40695. /**
  40696. * Creates a new AnaglyphArcRotateCamera
  40697. * @param name defines camera name
  40698. * @param alpha defines alpha angle (in radians)
  40699. * @param beta defines beta angle (in radians)
  40700. * @param radius defines radius
  40701. * @param target defines camera target
  40702. * @param interaxialDistance defines distance between each color axis
  40703. * @param scene defines the hosting scene
  40704. */
  40705. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  40706. /**
  40707. * Gets camera class name
  40708. * @returns AnaglyphArcRotateCamera
  40709. */
  40710. getClassName(): string;
  40711. }
  40712. }
  40713. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  40714. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40715. import { Scene } from "babylonjs/scene";
  40716. import { Vector3 } from "babylonjs/Maths/math.vector";
  40717. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40718. /**
  40719. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  40720. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40721. */
  40722. export class AnaglyphFreeCamera extends FreeCamera {
  40723. /**
  40724. * Creates a new AnaglyphFreeCamera
  40725. * @param name defines camera name
  40726. * @param position defines initial position
  40727. * @param interaxialDistance defines distance between each color axis
  40728. * @param scene defines the hosting scene
  40729. */
  40730. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40731. /**
  40732. * Gets camera class name
  40733. * @returns AnaglyphFreeCamera
  40734. */
  40735. getClassName(): string;
  40736. }
  40737. }
  40738. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  40739. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40740. import { Scene } from "babylonjs/scene";
  40741. import { Vector3 } from "babylonjs/Maths/math.vector";
  40742. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40743. /**
  40744. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  40745. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40746. */
  40747. export class AnaglyphGamepadCamera extends GamepadCamera {
  40748. /**
  40749. * Creates a new AnaglyphGamepadCamera
  40750. * @param name defines camera name
  40751. * @param position defines initial position
  40752. * @param interaxialDistance defines distance between each color axis
  40753. * @param scene defines the hosting scene
  40754. */
  40755. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40756. /**
  40757. * Gets camera class name
  40758. * @returns AnaglyphGamepadCamera
  40759. */
  40760. getClassName(): string;
  40761. }
  40762. }
  40763. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  40764. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40765. import { Scene } from "babylonjs/scene";
  40766. import { Vector3 } from "babylonjs/Maths/math.vector";
  40767. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40768. /**
  40769. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  40770. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40771. */
  40772. export class AnaglyphUniversalCamera extends UniversalCamera {
  40773. /**
  40774. * Creates a new AnaglyphUniversalCamera
  40775. * @param name defines camera name
  40776. * @param position defines initial position
  40777. * @param interaxialDistance defines distance between each color axis
  40778. * @param scene defines the hosting scene
  40779. */
  40780. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40781. /**
  40782. * Gets camera class name
  40783. * @returns AnaglyphUniversalCamera
  40784. */
  40785. getClassName(): string;
  40786. }
  40787. }
  40788. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  40789. /** @hidden */
  40790. export var stereoscopicInterlacePixelShader: {
  40791. name: string;
  40792. shader: string;
  40793. };
  40794. }
  40795. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  40796. import { Camera } from "babylonjs/Cameras/camera";
  40797. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40798. import { Engine } from "babylonjs/Engines/engine";
  40799. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  40800. /**
  40801. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  40802. */
  40803. export class StereoscopicInterlacePostProcess extends PostProcess {
  40804. private _stepSize;
  40805. private _passedProcess;
  40806. /**
  40807. * Initializes a StereoscopicInterlacePostProcess
  40808. * @param name The name of the effect.
  40809. * @param rigCameras The rig cameras to be appled to the post process
  40810. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  40811. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40812. * @param engine The engine which the post process will be applied. (default: current engine)
  40813. * @param reusable If the post process can be reused on the same frame. (default: false)
  40814. */
  40815. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  40816. }
  40817. }
  40818. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  40819. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  40820. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40821. import { Scene } from "babylonjs/scene";
  40822. import { Vector3 } from "babylonjs/Maths/math.vector";
  40823. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40824. /**
  40825. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  40826. * @see http://doc.babylonjs.com/features/cameras
  40827. */
  40828. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  40829. /**
  40830. * Creates a new StereoscopicArcRotateCamera
  40831. * @param name defines camera name
  40832. * @param alpha defines alpha angle (in radians)
  40833. * @param beta defines beta angle (in radians)
  40834. * @param radius defines radius
  40835. * @param target defines camera target
  40836. * @param interaxialDistance defines distance between each color axis
  40837. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40838. * @param scene defines the hosting scene
  40839. */
  40840. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40841. /**
  40842. * Gets camera class name
  40843. * @returns StereoscopicArcRotateCamera
  40844. */
  40845. getClassName(): string;
  40846. }
  40847. }
  40848. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  40849. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40850. import { Scene } from "babylonjs/scene";
  40851. import { Vector3 } from "babylonjs/Maths/math.vector";
  40852. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40853. /**
  40854. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  40855. * @see http://doc.babylonjs.com/features/cameras
  40856. */
  40857. export class StereoscopicFreeCamera extends FreeCamera {
  40858. /**
  40859. * Creates a new StereoscopicFreeCamera
  40860. * @param name defines camera name
  40861. * @param position defines initial position
  40862. * @param interaxialDistance defines distance between each color axis
  40863. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40864. * @param scene defines the hosting scene
  40865. */
  40866. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40867. /**
  40868. * Gets camera class name
  40869. * @returns StereoscopicFreeCamera
  40870. */
  40871. getClassName(): string;
  40872. }
  40873. }
  40874. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  40875. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40876. import { Scene } from "babylonjs/scene";
  40877. import { Vector3 } from "babylonjs/Maths/math.vector";
  40878. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40879. /**
  40880. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  40881. * @see http://doc.babylonjs.com/features/cameras
  40882. */
  40883. export class StereoscopicGamepadCamera extends GamepadCamera {
  40884. /**
  40885. * Creates a new StereoscopicGamepadCamera
  40886. * @param name defines camera name
  40887. * @param position defines initial position
  40888. * @param interaxialDistance defines distance between each color axis
  40889. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40890. * @param scene defines the hosting scene
  40891. */
  40892. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40893. /**
  40894. * Gets camera class name
  40895. * @returns StereoscopicGamepadCamera
  40896. */
  40897. getClassName(): string;
  40898. }
  40899. }
  40900. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  40901. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40902. import { Scene } from "babylonjs/scene";
  40903. import { Vector3 } from "babylonjs/Maths/math.vector";
  40904. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40905. /**
  40906. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  40907. * @see http://doc.babylonjs.com/features/cameras
  40908. */
  40909. export class StereoscopicUniversalCamera extends UniversalCamera {
  40910. /**
  40911. * Creates a new StereoscopicUniversalCamera
  40912. * @param name defines camera name
  40913. * @param position defines initial position
  40914. * @param interaxialDistance defines distance between each color axis
  40915. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40916. * @param scene defines the hosting scene
  40917. */
  40918. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40919. /**
  40920. * Gets camera class name
  40921. * @returns StereoscopicUniversalCamera
  40922. */
  40923. getClassName(): string;
  40924. }
  40925. }
  40926. declare module "babylonjs/Cameras/Stereoscopic/index" {
  40927. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  40928. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  40929. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  40930. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  40931. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  40932. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  40933. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  40934. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  40935. }
  40936. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  40937. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40938. import { Scene } from "babylonjs/scene";
  40939. import { Vector3 } from "babylonjs/Maths/math.vector";
  40940. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  40941. /**
  40942. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  40943. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40944. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40945. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40946. */
  40947. export class VirtualJoysticksCamera extends FreeCamera {
  40948. /**
  40949. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  40950. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40951. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40952. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40953. * @param name Define the name of the camera in the scene
  40954. * @param position Define the start position of the camera in the scene
  40955. * @param scene Define the scene the camera belongs to
  40956. */
  40957. constructor(name: string, position: Vector3, scene: Scene);
  40958. /**
  40959. * Gets the current object class name.
  40960. * @return the class name
  40961. */
  40962. getClassName(): string;
  40963. }
  40964. }
  40965. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  40966. import { Matrix } from "babylonjs/Maths/math.vector";
  40967. /**
  40968. * This represents all the required metrics to create a VR camera.
  40969. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  40970. */
  40971. export class VRCameraMetrics {
  40972. /**
  40973. * Define the horizontal resolution off the screen.
  40974. */
  40975. hResolution: number;
  40976. /**
  40977. * Define the vertical resolution off the screen.
  40978. */
  40979. vResolution: number;
  40980. /**
  40981. * Define the horizontal screen size.
  40982. */
  40983. hScreenSize: number;
  40984. /**
  40985. * Define the vertical screen size.
  40986. */
  40987. vScreenSize: number;
  40988. /**
  40989. * Define the vertical screen center position.
  40990. */
  40991. vScreenCenter: number;
  40992. /**
  40993. * Define the distance of the eyes to the screen.
  40994. */
  40995. eyeToScreenDistance: number;
  40996. /**
  40997. * Define the distance between both lenses
  40998. */
  40999. lensSeparationDistance: number;
  41000. /**
  41001. * Define the distance between both viewer's eyes.
  41002. */
  41003. interpupillaryDistance: number;
  41004. /**
  41005. * Define the distortion factor of the VR postprocess.
  41006. * Please, touch with care.
  41007. */
  41008. distortionK: number[];
  41009. /**
  41010. * Define the chromatic aberration correction factors for the VR post process.
  41011. */
  41012. chromaAbCorrection: number[];
  41013. /**
  41014. * Define the scale factor of the post process.
  41015. * The smaller the better but the slower.
  41016. */
  41017. postProcessScaleFactor: number;
  41018. /**
  41019. * Define an offset for the lens center.
  41020. */
  41021. lensCenterOffset: number;
  41022. /**
  41023. * Define if the current vr camera should compensate the distortion of the lense or not.
  41024. */
  41025. compensateDistortion: boolean;
  41026. /**
  41027. * Defines if multiview should be enabled when rendering (Default: false)
  41028. */
  41029. multiviewEnabled: boolean;
  41030. /**
  41031. * Gets the rendering aspect ratio based on the provided resolutions.
  41032. */
  41033. readonly aspectRatio: number;
  41034. /**
  41035. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  41036. */
  41037. readonly aspectRatioFov: number;
  41038. /**
  41039. * @hidden
  41040. */
  41041. readonly leftHMatrix: Matrix;
  41042. /**
  41043. * @hidden
  41044. */
  41045. readonly rightHMatrix: Matrix;
  41046. /**
  41047. * @hidden
  41048. */
  41049. readonly leftPreViewMatrix: Matrix;
  41050. /**
  41051. * @hidden
  41052. */
  41053. readonly rightPreViewMatrix: Matrix;
  41054. /**
  41055. * Get the default VRMetrics based on the most generic setup.
  41056. * @returns the default vr metrics
  41057. */
  41058. static GetDefault(): VRCameraMetrics;
  41059. }
  41060. }
  41061. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  41062. /** @hidden */
  41063. export var vrDistortionCorrectionPixelShader: {
  41064. name: string;
  41065. shader: string;
  41066. };
  41067. }
  41068. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  41069. import { Camera } from "babylonjs/Cameras/camera";
  41070. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41071. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  41072. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  41073. /**
  41074. * VRDistortionCorrectionPostProcess used for mobile VR
  41075. */
  41076. export class VRDistortionCorrectionPostProcess extends PostProcess {
  41077. private _isRightEye;
  41078. private _distortionFactors;
  41079. private _postProcessScaleFactor;
  41080. private _lensCenterOffset;
  41081. private _scaleIn;
  41082. private _scaleFactor;
  41083. private _lensCenter;
  41084. /**
  41085. * Initializes the VRDistortionCorrectionPostProcess
  41086. * @param name The name of the effect.
  41087. * @param camera The camera to apply the render pass to.
  41088. * @param isRightEye If this is for the right eye distortion
  41089. * @param vrMetrics All the required metrics for the VR camera
  41090. */
  41091. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  41092. }
  41093. }
  41094. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  41095. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  41096. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41097. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41098. import { Scene } from "babylonjs/scene";
  41099. import { Vector3 } from "babylonjs/Maths/math.vector";
  41100. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  41101. import "babylonjs/Cameras/RigModes/vrRigMode";
  41102. /**
  41103. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  41104. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41105. */
  41106. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  41107. /**
  41108. * Creates a new VRDeviceOrientationArcRotateCamera
  41109. * @param name defines camera name
  41110. * @param alpha defines the camera rotation along the logitudinal axis
  41111. * @param beta defines the camera rotation along the latitudinal axis
  41112. * @param radius defines the camera distance from its target
  41113. * @param target defines the camera target
  41114. * @param scene defines the scene the camera belongs to
  41115. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41116. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41117. */
  41118. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41119. /**
  41120. * Gets camera class name
  41121. * @returns VRDeviceOrientationArcRotateCamera
  41122. */
  41123. getClassName(): string;
  41124. }
  41125. }
  41126. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  41127. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  41128. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41129. import { Scene } from "babylonjs/scene";
  41130. import { Vector3 } from "babylonjs/Maths/math.vector";
  41131. import "babylonjs/Cameras/RigModes/vrRigMode";
  41132. /**
  41133. * Camera used to simulate VR rendering (based on FreeCamera)
  41134. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41135. */
  41136. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  41137. /**
  41138. * Creates a new VRDeviceOrientationFreeCamera
  41139. * @param name defines camera name
  41140. * @param position defines the start position of the camera
  41141. * @param scene defines the scene the camera belongs to
  41142. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41143. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41144. */
  41145. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41146. /**
  41147. * Gets camera class name
  41148. * @returns VRDeviceOrientationFreeCamera
  41149. */
  41150. getClassName(): string;
  41151. }
  41152. }
  41153. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  41154. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41155. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41156. import { Scene } from "babylonjs/scene";
  41157. import { Vector3 } from "babylonjs/Maths/math.vector";
  41158. import "babylonjs/Gamepads/gamepadSceneComponent";
  41159. /**
  41160. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  41161. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41162. */
  41163. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  41164. /**
  41165. * Creates a new VRDeviceOrientationGamepadCamera
  41166. * @param name defines camera name
  41167. * @param position defines the start position of the camera
  41168. * @param scene defines the scene the camera belongs to
  41169. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41170. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41171. */
  41172. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41173. /**
  41174. * Gets camera class name
  41175. * @returns VRDeviceOrientationGamepadCamera
  41176. */
  41177. getClassName(): string;
  41178. }
  41179. }
  41180. declare module "babylonjs/Materials/pushMaterial" {
  41181. import { Nullable } from "babylonjs/types";
  41182. import { Scene } from "babylonjs/scene";
  41183. import { Matrix } from "babylonjs/Maths/math.vector";
  41184. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41185. import { Mesh } from "babylonjs/Meshes/mesh";
  41186. import { Material } from "babylonjs/Materials/material";
  41187. import { Effect } from "babylonjs/Materials/effect";
  41188. /**
  41189. * Base class of materials working in push mode in babylon JS
  41190. * @hidden
  41191. */
  41192. export class PushMaterial extends Material {
  41193. protected _activeEffect: Effect;
  41194. protected _normalMatrix: Matrix;
  41195. /**
  41196. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  41197. * This means that the material can keep using a previous shader while a new one is being compiled.
  41198. * This is mostly used when shader parallel compilation is supported (true by default)
  41199. */
  41200. allowShaderHotSwapping: boolean;
  41201. constructor(name: string, scene: Scene);
  41202. getEffect(): Effect;
  41203. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  41204. /**
  41205. * Binds the given world matrix to the active effect
  41206. *
  41207. * @param world the matrix to bind
  41208. */
  41209. bindOnlyWorldMatrix(world: Matrix): void;
  41210. /**
  41211. * Binds the given normal matrix to the active effect
  41212. *
  41213. * @param normalMatrix the matrix to bind
  41214. */
  41215. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  41216. bind(world: Matrix, mesh?: Mesh): void;
  41217. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  41218. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  41219. }
  41220. }
  41221. declare module "babylonjs/Materials/materialFlags" {
  41222. /**
  41223. * This groups all the flags used to control the materials channel.
  41224. */
  41225. export class MaterialFlags {
  41226. private static _DiffuseTextureEnabled;
  41227. /**
  41228. * Are diffuse textures enabled in the application.
  41229. */
  41230. static DiffuseTextureEnabled: boolean;
  41231. private static _AmbientTextureEnabled;
  41232. /**
  41233. * Are ambient textures enabled in the application.
  41234. */
  41235. static AmbientTextureEnabled: boolean;
  41236. private static _OpacityTextureEnabled;
  41237. /**
  41238. * Are opacity textures enabled in the application.
  41239. */
  41240. static OpacityTextureEnabled: boolean;
  41241. private static _ReflectionTextureEnabled;
  41242. /**
  41243. * Are reflection textures enabled in the application.
  41244. */
  41245. static ReflectionTextureEnabled: boolean;
  41246. private static _EmissiveTextureEnabled;
  41247. /**
  41248. * Are emissive textures enabled in the application.
  41249. */
  41250. static EmissiveTextureEnabled: boolean;
  41251. private static _SpecularTextureEnabled;
  41252. /**
  41253. * Are specular textures enabled in the application.
  41254. */
  41255. static SpecularTextureEnabled: boolean;
  41256. private static _BumpTextureEnabled;
  41257. /**
  41258. * Are bump textures enabled in the application.
  41259. */
  41260. static BumpTextureEnabled: boolean;
  41261. private static _LightmapTextureEnabled;
  41262. /**
  41263. * Are lightmap textures enabled in the application.
  41264. */
  41265. static LightmapTextureEnabled: boolean;
  41266. private static _RefractionTextureEnabled;
  41267. /**
  41268. * Are refraction textures enabled in the application.
  41269. */
  41270. static RefractionTextureEnabled: boolean;
  41271. private static _ColorGradingTextureEnabled;
  41272. /**
  41273. * Are color grading textures enabled in the application.
  41274. */
  41275. static ColorGradingTextureEnabled: boolean;
  41276. private static _FresnelEnabled;
  41277. /**
  41278. * Are fresnels enabled in the application.
  41279. */
  41280. static FresnelEnabled: boolean;
  41281. private static _ClearCoatTextureEnabled;
  41282. /**
  41283. * Are clear coat textures enabled in the application.
  41284. */
  41285. static ClearCoatTextureEnabled: boolean;
  41286. private static _ClearCoatBumpTextureEnabled;
  41287. /**
  41288. * Are clear coat bump textures enabled in the application.
  41289. */
  41290. static ClearCoatBumpTextureEnabled: boolean;
  41291. private static _ClearCoatTintTextureEnabled;
  41292. /**
  41293. * Are clear coat tint textures enabled in the application.
  41294. */
  41295. static ClearCoatTintTextureEnabled: boolean;
  41296. private static _SheenTextureEnabled;
  41297. /**
  41298. * Are sheen textures enabled in the application.
  41299. */
  41300. static SheenTextureEnabled: boolean;
  41301. private static _AnisotropicTextureEnabled;
  41302. /**
  41303. * Are anisotropic textures enabled in the application.
  41304. */
  41305. static AnisotropicTextureEnabled: boolean;
  41306. private static _ThicknessTextureEnabled;
  41307. /**
  41308. * Are thickness textures enabled in the application.
  41309. */
  41310. static ThicknessTextureEnabled: boolean;
  41311. }
  41312. }
  41313. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  41314. /** @hidden */
  41315. export var defaultFragmentDeclaration: {
  41316. name: string;
  41317. shader: string;
  41318. };
  41319. }
  41320. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  41321. /** @hidden */
  41322. export var defaultUboDeclaration: {
  41323. name: string;
  41324. shader: string;
  41325. };
  41326. }
  41327. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  41328. /** @hidden */
  41329. export var lightFragmentDeclaration: {
  41330. name: string;
  41331. shader: string;
  41332. };
  41333. }
  41334. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  41335. /** @hidden */
  41336. export var lightUboDeclaration: {
  41337. name: string;
  41338. shader: string;
  41339. };
  41340. }
  41341. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  41342. /** @hidden */
  41343. export var lightsFragmentFunctions: {
  41344. name: string;
  41345. shader: string;
  41346. };
  41347. }
  41348. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  41349. /** @hidden */
  41350. export var shadowsFragmentFunctions: {
  41351. name: string;
  41352. shader: string;
  41353. };
  41354. }
  41355. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  41356. /** @hidden */
  41357. export var fresnelFunction: {
  41358. name: string;
  41359. shader: string;
  41360. };
  41361. }
  41362. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  41363. /** @hidden */
  41364. export var reflectionFunction: {
  41365. name: string;
  41366. shader: string;
  41367. };
  41368. }
  41369. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  41370. /** @hidden */
  41371. export var bumpFragmentFunctions: {
  41372. name: string;
  41373. shader: string;
  41374. };
  41375. }
  41376. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  41377. /** @hidden */
  41378. export var logDepthDeclaration: {
  41379. name: string;
  41380. shader: string;
  41381. };
  41382. }
  41383. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  41384. /** @hidden */
  41385. export var bumpFragment: {
  41386. name: string;
  41387. shader: string;
  41388. };
  41389. }
  41390. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  41391. /** @hidden */
  41392. export var depthPrePass: {
  41393. name: string;
  41394. shader: string;
  41395. };
  41396. }
  41397. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  41398. /** @hidden */
  41399. export var lightFragment: {
  41400. name: string;
  41401. shader: string;
  41402. };
  41403. }
  41404. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  41405. /** @hidden */
  41406. export var logDepthFragment: {
  41407. name: string;
  41408. shader: string;
  41409. };
  41410. }
  41411. declare module "babylonjs/Shaders/default.fragment" {
  41412. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  41413. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41414. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41415. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41416. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41417. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  41418. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  41419. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  41420. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  41421. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41422. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41423. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  41424. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  41425. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41426. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  41427. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  41428. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  41429. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  41430. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  41431. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  41432. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  41433. /** @hidden */
  41434. export var defaultPixelShader: {
  41435. name: string;
  41436. shader: string;
  41437. };
  41438. }
  41439. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  41440. /** @hidden */
  41441. export var defaultVertexDeclaration: {
  41442. name: string;
  41443. shader: string;
  41444. };
  41445. }
  41446. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  41447. /** @hidden */
  41448. export var bumpVertexDeclaration: {
  41449. name: string;
  41450. shader: string;
  41451. };
  41452. }
  41453. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  41454. /** @hidden */
  41455. export var bumpVertex: {
  41456. name: string;
  41457. shader: string;
  41458. };
  41459. }
  41460. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  41461. /** @hidden */
  41462. export var fogVertex: {
  41463. name: string;
  41464. shader: string;
  41465. };
  41466. }
  41467. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  41468. /** @hidden */
  41469. export var shadowsVertex: {
  41470. name: string;
  41471. shader: string;
  41472. };
  41473. }
  41474. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  41475. /** @hidden */
  41476. export var pointCloudVertex: {
  41477. name: string;
  41478. shader: string;
  41479. };
  41480. }
  41481. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  41482. /** @hidden */
  41483. export var logDepthVertex: {
  41484. name: string;
  41485. shader: string;
  41486. };
  41487. }
  41488. declare module "babylonjs/Shaders/default.vertex" {
  41489. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  41490. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41491. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41492. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  41493. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  41494. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  41495. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  41496. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  41497. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41498. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41499. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  41500. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  41501. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41502. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  41503. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  41504. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  41505. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  41506. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  41507. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  41508. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  41509. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  41510. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  41511. /** @hidden */
  41512. export var defaultVertexShader: {
  41513. name: string;
  41514. shader: string;
  41515. };
  41516. }
  41517. declare module "babylonjs/Materials/standardMaterial" {
  41518. import { SmartArray } from "babylonjs/Misc/smartArray";
  41519. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  41520. import { Nullable } from "babylonjs/types";
  41521. import { Scene } from "babylonjs/scene";
  41522. import { Matrix } from "babylonjs/Maths/math.vector";
  41523. import { Color3 } from "babylonjs/Maths/math.color";
  41524. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41525. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41526. import { Mesh } from "babylonjs/Meshes/mesh";
  41527. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  41528. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41529. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  41530. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  41531. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  41532. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41533. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41534. import "babylonjs/Shaders/default.fragment";
  41535. import "babylonjs/Shaders/default.vertex";
  41536. /** @hidden */
  41537. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  41538. MAINUV1: boolean;
  41539. MAINUV2: boolean;
  41540. DIFFUSE: boolean;
  41541. DIFFUSEDIRECTUV: number;
  41542. AMBIENT: boolean;
  41543. AMBIENTDIRECTUV: number;
  41544. OPACITY: boolean;
  41545. OPACITYDIRECTUV: number;
  41546. OPACITYRGB: boolean;
  41547. REFLECTION: boolean;
  41548. EMISSIVE: boolean;
  41549. EMISSIVEDIRECTUV: number;
  41550. SPECULAR: boolean;
  41551. SPECULARDIRECTUV: number;
  41552. BUMP: boolean;
  41553. BUMPDIRECTUV: number;
  41554. PARALLAX: boolean;
  41555. PARALLAXOCCLUSION: boolean;
  41556. SPECULAROVERALPHA: boolean;
  41557. CLIPPLANE: boolean;
  41558. CLIPPLANE2: boolean;
  41559. CLIPPLANE3: boolean;
  41560. CLIPPLANE4: boolean;
  41561. ALPHATEST: boolean;
  41562. DEPTHPREPASS: boolean;
  41563. ALPHAFROMDIFFUSE: boolean;
  41564. POINTSIZE: boolean;
  41565. FOG: boolean;
  41566. SPECULARTERM: boolean;
  41567. DIFFUSEFRESNEL: boolean;
  41568. OPACITYFRESNEL: boolean;
  41569. REFLECTIONFRESNEL: boolean;
  41570. REFRACTIONFRESNEL: boolean;
  41571. EMISSIVEFRESNEL: boolean;
  41572. FRESNEL: boolean;
  41573. NORMAL: boolean;
  41574. UV1: boolean;
  41575. UV2: boolean;
  41576. VERTEXCOLOR: boolean;
  41577. VERTEXALPHA: boolean;
  41578. NUM_BONE_INFLUENCERS: number;
  41579. BonesPerMesh: number;
  41580. BONETEXTURE: boolean;
  41581. INSTANCES: boolean;
  41582. GLOSSINESS: boolean;
  41583. ROUGHNESS: boolean;
  41584. EMISSIVEASILLUMINATION: boolean;
  41585. LINKEMISSIVEWITHDIFFUSE: boolean;
  41586. REFLECTIONFRESNELFROMSPECULAR: boolean;
  41587. LIGHTMAP: boolean;
  41588. LIGHTMAPDIRECTUV: number;
  41589. OBJECTSPACE_NORMALMAP: boolean;
  41590. USELIGHTMAPASSHADOWMAP: boolean;
  41591. REFLECTIONMAP_3D: boolean;
  41592. REFLECTIONMAP_SPHERICAL: boolean;
  41593. REFLECTIONMAP_PLANAR: boolean;
  41594. REFLECTIONMAP_CUBIC: boolean;
  41595. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  41596. REFLECTIONMAP_PROJECTION: boolean;
  41597. REFLECTIONMAP_SKYBOX: boolean;
  41598. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  41599. REFLECTIONMAP_EXPLICIT: boolean;
  41600. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  41601. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  41602. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  41603. INVERTCUBICMAP: boolean;
  41604. LOGARITHMICDEPTH: boolean;
  41605. REFRACTION: boolean;
  41606. REFRACTIONMAP_3D: boolean;
  41607. REFLECTIONOVERALPHA: boolean;
  41608. TWOSIDEDLIGHTING: boolean;
  41609. SHADOWFLOAT: boolean;
  41610. MORPHTARGETS: boolean;
  41611. MORPHTARGETS_NORMAL: boolean;
  41612. MORPHTARGETS_TANGENT: boolean;
  41613. MORPHTARGETS_UV: boolean;
  41614. NUM_MORPH_INFLUENCERS: number;
  41615. NONUNIFORMSCALING: boolean;
  41616. PREMULTIPLYALPHA: boolean;
  41617. IMAGEPROCESSING: boolean;
  41618. VIGNETTE: boolean;
  41619. VIGNETTEBLENDMODEMULTIPLY: boolean;
  41620. VIGNETTEBLENDMODEOPAQUE: boolean;
  41621. TONEMAPPING: boolean;
  41622. TONEMAPPING_ACES: boolean;
  41623. CONTRAST: boolean;
  41624. COLORCURVES: boolean;
  41625. COLORGRADING: boolean;
  41626. COLORGRADING3D: boolean;
  41627. SAMPLER3DGREENDEPTH: boolean;
  41628. SAMPLER3DBGRMAP: boolean;
  41629. IMAGEPROCESSINGPOSTPROCESS: boolean;
  41630. MULTIVIEW: boolean;
  41631. /**
  41632. * If the reflection texture on this material is in linear color space
  41633. * @hidden
  41634. */
  41635. IS_REFLECTION_LINEAR: boolean;
  41636. /**
  41637. * If the refraction texture on this material is in linear color space
  41638. * @hidden
  41639. */
  41640. IS_REFRACTION_LINEAR: boolean;
  41641. EXPOSURE: boolean;
  41642. constructor();
  41643. setReflectionMode(modeToEnable: string): void;
  41644. }
  41645. /**
  41646. * This is the default material used in Babylon. It is the best trade off between quality
  41647. * and performances.
  41648. * @see http://doc.babylonjs.com/babylon101/materials
  41649. */
  41650. export class StandardMaterial extends PushMaterial {
  41651. private _diffuseTexture;
  41652. /**
  41653. * The basic texture of the material as viewed under a light.
  41654. */
  41655. diffuseTexture: Nullable<BaseTexture>;
  41656. private _ambientTexture;
  41657. /**
  41658. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  41659. */
  41660. ambientTexture: Nullable<BaseTexture>;
  41661. private _opacityTexture;
  41662. /**
  41663. * Define the transparency of the material from a texture.
  41664. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  41665. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  41666. */
  41667. opacityTexture: Nullable<BaseTexture>;
  41668. private _reflectionTexture;
  41669. /**
  41670. * Define the texture used to display the reflection.
  41671. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41672. */
  41673. reflectionTexture: Nullable<BaseTexture>;
  41674. private _emissiveTexture;
  41675. /**
  41676. * Define texture of the material as if self lit.
  41677. * This will be mixed in the final result even in the absence of light.
  41678. */
  41679. emissiveTexture: Nullable<BaseTexture>;
  41680. private _specularTexture;
  41681. /**
  41682. * Define how the color and intensity of the highlight given by the light in the material.
  41683. */
  41684. specularTexture: Nullable<BaseTexture>;
  41685. private _bumpTexture;
  41686. /**
  41687. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  41688. * 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.
  41689. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  41690. */
  41691. bumpTexture: Nullable<BaseTexture>;
  41692. private _lightmapTexture;
  41693. /**
  41694. * Complex lighting can be computationally expensive to compute at runtime.
  41695. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  41696. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  41697. */
  41698. lightmapTexture: Nullable<BaseTexture>;
  41699. private _refractionTexture;
  41700. /**
  41701. * Define the texture used to display the refraction.
  41702. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41703. */
  41704. refractionTexture: Nullable<BaseTexture>;
  41705. /**
  41706. * The color of the material lit by the environmental background lighting.
  41707. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  41708. */
  41709. ambientColor: Color3;
  41710. /**
  41711. * The basic color of the material as viewed under a light.
  41712. */
  41713. diffuseColor: Color3;
  41714. /**
  41715. * Define how the color and intensity of the highlight given by the light in the material.
  41716. */
  41717. specularColor: Color3;
  41718. /**
  41719. * Define the color of the material as if self lit.
  41720. * This will be mixed in the final result even in the absence of light.
  41721. */
  41722. emissiveColor: Color3;
  41723. /**
  41724. * Defines how sharp are the highlights in the material.
  41725. * The bigger the value the sharper giving a more glossy feeling to the result.
  41726. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  41727. */
  41728. specularPower: number;
  41729. private _useAlphaFromDiffuseTexture;
  41730. /**
  41731. * Does the transparency come from the diffuse texture alpha channel.
  41732. */
  41733. useAlphaFromDiffuseTexture: boolean;
  41734. private _useEmissiveAsIllumination;
  41735. /**
  41736. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  41737. */
  41738. useEmissiveAsIllumination: boolean;
  41739. private _linkEmissiveWithDiffuse;
  41740. /**
  41741. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  41742. * the emissive level when the final color is close to one.
  41743. */
  41744. linkEmissiveWithDiffuse: boolean;
  41745. private _useSpecularOverAlpha;
  41746. /**
  41747. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  41748. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  41749. */
  41750. useSpecularOverAlpha: boolean;
  41751. private _useReflectionOverAlpha;
  41752. /**
  41753. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  41754. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  41755. */
  41756. useReflectionOverAlpha: boolean;
  41757. private _disableLighting;
  41758. /**
  41759. * Does lights from the scene impacts this material.
  41760. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  41761. */
  41762. disableLighting: boolean;
  41763. private _useObjectSpaceNormalMap;
  41764. /**
  41765. * Allows using an object space normal map (instead of tangent space).
  41766. */
  41767. useObjectSpaceNormalMap: boolean;
  41768. private _useParallax;
  41769. /**
  41770. * Is parallax enabled or not.
  41771. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41772. */
  41773. useParallax: boolean;
  41774. private _useParallaxOcclusion;
  41775. /**
  41776. * Is parallax occlusion enabled or not.
  41777. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  41778. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41779. */
  41780. useParallaxOcclusion: boolean;
  41781. /**
  41782. * 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.
  41783. */
  41784. parallaxScaleBias: number;
  41785. private _roughness;
  41786. /**
  41787. * Helps to define how blurry the reflections should appears in the material.
  41788. */
  41789. roughness: number;
  41790. /**
  41791. * In case of refraction, define the value of the index of refraction.
  41792. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41793. */
  41794. indexOfRefraction: number;
  41795. /**
  41796. * Invert the refraction texture alongside the y axis.
  41797. * It can be useful with procedural textures or probe for instance.
  41798. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41799. */
  41800. invertRefractionY: boolean;
  41801. /**
  41802. * Defines the alpha limits in alpha test mode.
  41803. */
  41804. alphaCutOff: number;
  41805. private _useLightmapAsShadowmap;
  41806. /**
  41807. * In case of light mapping, define whether the map contains light or shadow informations.
  41808. */
  41809. useLightmapAsShadowmap: boolean;
  41810. private _diffuseFresnelParameters;
  41811. /**
  41812. * Define the diffuse fresnel parameters of the material.
  41813. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41814. */
  41815. diffuseFresnelParameters: FresnelParameters;
  41816. private _opacityFresnelParameters;
  41817. /**
  41818. * Define the opacity fresnel parameters of the material.
  41819. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41820. */
  41821. opacityFresnelParameters: FresnelParameters;
  41822. private _reflectionFresnelParameters;
  41823. /**
  41824. * Define the reflection fresnel parameters of the material.
  41825. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41826. */
  41827. reflectionFresnelParameters: FresnelParameters;
  41828. private _refractionFresnelParameters;
  41829. /**
  41830. * Define the refraction fresnel parameters of the material.
  41831. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41832. */
  41833. refractionFresnelParameters: FresnelParameters;
  41834. private _emissiveFresnelParameters;
  41835. /**
  41836. * Define the emissive fresnel parameters of the material.
  41837. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41838. */
  41839. emissiveFresnelParameters: FresnelParameters;
  41840. private _useReflectionFresnelFromSpecular;
  41841. /**
  41842. * If true automatically deducts the fresnels values from the material specularity.
  41843. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41844. */
  41845. useReflectionFresnelFromSpecular: boolean;
  41846. private _useGlossinessFromSpecularMapAlpha;
  41847. /**
  41848. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  41849. */
  41850. useGlossinessFromSpecularMapAlpha: boolean;
  41851. private _maxSimultaneousLights;
  41852. /**
  41853. * Defines the maximum number of lights that can be used in the material
  41854. */
  41855. maxSimultaneousLights: number;
  41856. private _invertNormalMapX;
  41857. /**
  41858. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  41859. */
  41860. invertNormalMapX: boolean;
  41861. private _invertNormalMapY;
  41862. /**
  41863. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  41864. */
  41865. invertNormalMapY: boolean;
  41866. private _twoSidedLighting;
  41867. /**
  41868. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  41869. */
  41870. twoSidedLighting: boolean;
  41871. /**
  41872. * Default configuration related to image processing available in the standard Material.
  41873. */
  41874. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41875. /**
  41876. * Gets the image processing configuration used either in this material.
  41877. */
  41878. /**
  41879. * Sets the Default image processing configuration used either in the this material.
  41880. *
  41881. * If sets to null, the scene one is in use.
  41882. */
  41883. imageProcessingConfiguration: ImageProcessingConfiguration;
  41884. /**
  41885. * Keep track of the image processing observer to allow dispose and replace.
  41886. */
  41887. private _imageProcessingObserver;
  41888. /**
  41889. * Attaches a new image processing configuration to the Standard Material.
  41890. * @param configuration
  41891. */
  41892. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  41893. /**
  41894. * Gets wether the color curves effect is enabled.
  41895. */
  41896. /**
  41897. * Sets wether the color curves effect is enabled.
  41898. */
  41899. cameraColorCurvesEnabled: boolean;
  41900. /**
  41901. * Gets wether the color grading effect is enabled.
  41902. */
  41903. /**
  41904. * Gets wether the color grading effect is enabled.
  41905. */
  41906. cameraColorGradingEnabled: boolean;
  41907. /**
  41908. * Gets wether tonemapping is enabled or not.
  41909. */
  41910. /**
  41911. * Sets wether tonemapping is enabled or not
  41912. */
  41913. cameraToneMappingEnabled: boolean;
  41914. /**
  41915. * The camera exposure used on this material.
  41916. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41917. * This corresponds to a photographic exposure.
  41918. */
  41919. /**
  41920. * The camera exposure used on this material.
  41921. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41922. * This corresponds to a photographic exposure.
  41923. */
  41924. cameraExposure: number;
  41925. /**
  41926. * Gets The camera contrast used on this material.
  41927. */
  41928. /**
  41929. * Sets The camera contrast used on this material.
  41930. */
  41931. cameraContrast: number;
  41932. /**
  41933. * Gets the Color Grading 2D Lookup Texture.
  41934. */
  41935. /**
  41936. * Sets the Color Grading 2D Lookup Texture.
  41937. */
  41938. cameraColorGradingTexture: Nullable<BaseTexture>;
  41939. /**
  41940. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41941. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41942. * 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;
  41943. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41944. */
  41945. /**
  41946. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41947. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41948. * 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;
  41949. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41950. */
  41951. cameraColorCurves: Nullable<ColorCurves>;
  41952. /**
  41953. * Custom callback helping to override the default shader used in the material.
  41954. */
  41955. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  41956. protected _renderTargets: SmartArray<RenderTargetTexture>;
  41957. protected _worldViewProjectionMatrix: Matrix;
  41958. protected _globalAmbientColor: Color3;
  41959. protected _useLogarithmicDepth: boolean;
  41960. protected _rebuildInParallel: boolean;
  41961. /**
  41962. * Instantiates a new standard material.
  41963. * This is the default material used in Babylon. It is the best trade off between quality
  41964. * and performances.
  41965. * @see http://doc.babylonjs.com/babylon101/materials
  41966. * @param name Define the name of the material in the scene
  41967. * @param scene Define the scene the material belong to
  41968. */
  41969. constructor(name: string, scene: Scene);
  41970. /**
  41971. * Gets a boolean indicating that current material needs to register RTT
  41972. */
  41973. readonly hasRenderTargetTextures: boolean;
  41974. /**
  41975. * Gets the current class name of the material e.g. "StandardMaterial"
  41976. * Mainly use in serialization.
  41977. * @returns the class name
  41978. */
  41979. getClassName(): string;
  41980. /**
  41981. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  41982. * You can try switching to logarithmic depth.
  41983. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  41984. */
  41985. useLogarithmicDepth: boolean;
  41986. /**
  41987. * Specifies if the material will require alpha blending
  41988. * @returns a boolean specifying if alpha blending is needed
  41989. */
  41990. needAlphaBlending(): boolean;
  41991. /**
  41992. * Specifies if this material should be rendered in alpha test mode
  41993. * @returns a boolean specifying if an alpha test is needed.
  41994. */
  41995. needAlphaTesting(): boolean;
  41996. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  41997. /**
  41998. * Get the texture used for alpha test purpose.
  41999. * @returns the diffuse texture in case of the standard material.
  42000. */
  42001. getAlphaTestTexture(): Nullable<BaseTexture>;
  42002. /**
  42003. * Get if the submesh is ready to be used and all its information available.
  42004. * Child classes can use it to update shaders
  42005. * @param mesh defines the mesh to check
  42006. * @param subMesh defines which submesh to check
  42007. * @param useInstances specifies that instances should be used
  42008. * @returns a boolean indicating that the submesh is ready or not
  42009. */
  42010. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  42011. /**
  42012. * Builds the material UBO layouts.
  42013. * Used internally during the effect preparation.
  42014. */
  42015. buildUniformLayout(): void;
  42016. /**
  42017. * Unbinds the material from the mesh
  42018. */
  42019. unbind(): void;
  42020. /**
  42021. * Binds the submesh to this material by preparing the effect and shader to draw
  42022. * @param world defines the world transformation matrix
  42023. * @param mesh defines the mesh containing the submesh
  42024. * @param subMesh defines the submesh to bind the material to
  42025. */
  42026. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  42027. /**
  42028. * Get the list of animatables in the material.
  42029. * @returns the list of animatables object used in the material
  42030. */
  42031. getAnimatables(): IAnimatable[];
  42032. /**
  42033. * Gets the active textures from the material
  42034. * @returns an array of textures
  42035. */
  42036. getActiveTextures(): BaseTexture[];
  42037. /**
  42038. * Specifies if the material uses a texture
  42039. * @param texture defines the texture to check against the material
  42040. * @returns a boolean specifying if the material uses the texture
  42041. */
  42042. hasTexture(texture: BaseTexture): boolean;
  42043. /**
  42044. * Disposes the material
  42045. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  42046. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  42047. */
  42048. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  42049. /**
  42050. * Makes a duplicate of the material, and gives it a new name
  42051. * @param name defines the new name for the duplicated material
  42052. * @returns the cloned material
  42053. */
  42054. clone(name: string): StandardMaterial;
  42055. /**
  42056. * Serializes this material in a JSON representation
  42057. * @returns the serialized material object
  42058. */
  42059. serialize(): any;
  42060. /**
  42061. * Creates a standard material from parsed material data
  42062. * @param source defines the JSON representation of the material
  42063. * @param scene defines the hosting scene
  42064. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  42065. * @returns a new standard material
  42066. */
  42067. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  42068. /**
  42069. * Are diffuse textures enabled in the application.
  42070. */
  42071. static DiffuseTextureEnabled: boolean;
  42072. /**
  42073. * Are ambient textures enabled in the application.
  42074. */
  42075. static AmbientTextureEnabled: boolean;
  42076. /**
  42077. * Are opacity textures enabled in the application.
  42078. */
  42079. static OpacityTextureEnabled: boolean;
  42080. /**
  42081. * Are reflection textures enabled in the application.
  42082. */
  42083. static ReflectionTextureEnabled: boolean;
  42084. /**
  42085. * Are emissive textures enabled in the application.
  42086. */
  42087. static EmissiveTextureEnabled: boolean;
  42088. /**
  42089. * Are specular textures enabled in the application.
  42090. */
  42091. static SpecularTextureEnabled: boolean;
  42092. /**
  42093. * Are bump textures enabled in the application.
  42094. */
  42095. static BumpTextureEnabled: boolean;
  42096. /**
  42097. * Are lightmap textures enabled in the application.
  42098. */
  42099. static LightmapTextureEnabled: boolean;
  42100. /**
  42101. * Are refraction textures enabled in the application.
  42102. */
  42103. static RefractionTextureEnabled: boolean;
  42104. /**
  42105. * Are color grading textures enabled in the application.
  42106. */
  42107. static ColorGradingTextureEnabled: boolean;
  42108. /**
  42109. * Are fresnels enabled in the application.
  42110. */
  42111. static FresnelEnabled: boolean;
  42112. }
  42113. }
  42114. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  42115. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  42116. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  42117. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  42118. /** @hidden */
  42119. export var imageProcessingPixelShader: {
  42120. name: string;
  42121. shader: string;
  42122. };
  42123. }
  42124. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  42125. import { Nullable } from "babylonjs/types";
  42126. import { Color4 } from "babylonjs/Maths/math.color";
  42127. import { Camera } from "babylonjs/Cameras/camera";
  42128. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  42129. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  42130. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  42131. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42132. import { Engine } from "babylonjs/Engines/engine";
  42133. import "babylonjs/Shaders/imageProcessing.fragment";
  42134. import "babylonjs/Shaders/postprocess.vertex";
  42135. /**
  42136. * ImageProcessingPostProcess
  42137. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42138. */
  42139. export class ImageProcessingPostProcess extends PostProcess {
  42140. /**
  42141. * Default configuration related to image processing available in the PBR Material.
  42142. */
  42143. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42144. /**
  42145. * Gets the image processing configuration used either in this material.
  42146. */
  42147. /**
  42148. * Sets the Default image processing configuration used either in the this material.
  42149. *
  42150. * If sets to null, the scene one is in use.
  42151. */
  42152. imageProcessingConfiguration: ImageProcessingConfiguration;
  42153. /**
  42154. * Keep track of the image processing observer to allow dispose and replace.
  42155. */
  42156. private _imageProcessingObserver;
  42157. /**
  42158. * Attaches a new image processing configuration to the PBR Material.
  42159. * @param configuration
  42160. */
  42161. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42162. /**
  42163. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42164. */
  42165. /**
  42166. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42167. */
  42168. colorCurves: Nullable<ColorCurves>;
  42169. /**
  42170. * Gets wether the color curves effect is enabled.
  42171. */
  42172. /**
  42173. * Sets wether the color curves effect is enabled.
  42174. */
  42175. colorCurvesEnabled: boolean;
  42176. /**
  42177. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42178. */
  42179. /**
  42180. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42181. */
  42182. colorGradingTexture: Nullable<BaseTexture>;
  42183. /**
  42184. * Gets wether the color grading effect is enabled.
  42185. */
  42186. /**
  42187. * Gets wether the color grading effect is enabled.
  42188. */
  42189. colorGradingEnabled: boolean;
  42190. /**
  42191. * Gets exposure used in the effect.
  42192. */
  42193. /**
  42194. * Sets exposure used in the effect.
  42195. */
  42196. exposure: number;
  42197. /**
  42198. * Gets wether tonemapping is enabled or not.
  42199. */
  42200. /**
  42201. * Sets wether tonemapping is enabled or not
  42202. */
  42203. toneMappingEnabled: boolean;
  42204. /**
  42205. * Gets the type of tone mapping effect.
  42206. */
  42207. /**
  42208. * Sets the type of tone mapping effect.
  42209. */
  42210. toneMappingType: number;
  42211. /**
  42212. * Gets contrast used in the effect.
  42213. */
  42214. /**
  42215. * Sets contrast used in the effect.
  42216. */
  42217. contrast: number;
  42218. /**
  42219. * Gets Vignette stretch size.
  42220. */
  42221. /**
  42222. * Sets Vignette stretch size.
  42223. */
  42224. vignetteStretch: number;
  42225. /**
  42226. * Gets Vignette centre X Offset.
  42227. */
  42228. /**
  42229. * Sets Vignette centre X Offset.
  42230. */
  42231. vignetteCentreX: number;
  42232. /**
  42233. * Gets Vignette centre Y Offset.
  42234. */
  42235. /**
  42236. * Sets Vignette centre Y Offset.
  42237. */
  42238. vignetteCentreY: number;
  42239. /**
  42240. * Gets Vignette weight or intensity of the vignette effect.
  42241. */
  42242. /**
  42243. * Sets Vignette weight or intensity of the vignette effect.
  42244. */
  42245. vignetteWeight: number;
  42246. /**
  42247. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42248. * if vignetteEnabled is set to true.
  42249. */
  42250. /**
  42251. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42252. * if vignetteEnabled is set to true.
  42253. */
  42254. vignetteColor: Color4;
  42255. /**
  42256. * Gets Camera field of view used by the Vignette effect.
  42257. */
  42258. /**
  42259. * Sets Camera field of view used by the Vignette effect.
  42260. */
  42261. vignetteCameraFov: number;
  42262. /**
  42263. * Gets the vignette blend mode allowing different kind of effect.
  42264. */
  42265. /**
  42266. * Sets the vignette blend mode allowing different kind of effect.
  42267. */
  42268. vignetteBlendMode: number;
  42269. /**
  42270. * Gets wether the vignette effect is enabled.
  42271. */
  42272. /**
  42273. * Sets wether the vignette effect is enabled.
  42274. */
  42275. vignetteEnabled: boolean;
  42276. private _fromLinearSpace;
  42277. /**
  42278. * Gets wether the input of the processing is in Gamma or Linear Space.
  42279. */
  42280. /**
  42281. * Sets wether the input of the processing is in Gamma or Linear Space.
  42282. */
  42283. fromLinearSpace: boolean;
  42284. /**
  42285. * Defines cache preventing GC.
  42286. */
  42287. private _defines;
  42288. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42289. /**
  42290. * "ImageProcessingPostProcess"
  42291. * @returns "ImageProcessingPostProcess"
  42292. */
  42293. getClassName(): string;
  42294. protected _updateParameters(): void;
  42295. dispose(camera?: Camera): void;
  42296. }
  42297. }
  42298. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  42299. import { Scene } from "babylonjs/scene";
  42300. import { Color3 } from "babylonjs/Maths/math.color";
  42301. import { Mesh } from "babylonjs/Meshes/mesh";
  42302. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  42303. import { Nullable } from "babylonjs/types";
  42304. /**
  42305. * Class containing static functions to help procedurally build meshes
  42306. */
  42307. export class GroundBuilder {
  42308. /**
  42309. * Creates a ground mesh
  42310. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42311. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42312. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42313. * @param name defines the name of the mesh
  42314. * @param options defines the options used to create the mesh
  42315. * @param scene defines the hosting scene
  42316. * @returns the ground mesh
  42317. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42318. */
  42319. static CreateGround(name: string, options: {
  42320. width?: number;
  42321. height?: number;
  42322. subdivisions?: number;
  42323. subdivisionsX?: number;
  42324. subdivisionsY?: number;
  42325. updatable?: boolean;
  42326. }, scene: any): Mesh;
  42327. /**
  42328. * Creates a tiled ground mesh
  42329. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42330. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42331. * * 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
  42332. * * 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
  42333. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42334. * @param name defines the name of the mesh
  42335. * @param options defines the options used to create the mesh
  42336. * @param scene defines the hosting scene
  42337. * @returns the tiled ground mesh
  42338. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42339. */
  42340. static CreateTiledGround(name: string, options: {
  42341. xmin: number;
  42342. zmin: number;
  42343. xmax: number;
  42344. zmax: number;
  42345. subdivisions?: {
  42346. w: number;
  42347. h: number;
  42348. };
  42349. precision?: {
  42350. w: number;
  42351. h: number;
  42352. };
  42353. updatable?: boolean;
  42354. }, scene?: Nullable<Scene>): Mesh;
  42355. /**
  42356. * Creates a ground mesh from a height map
  42357. * * The parameter `url` sets the URL of the height map image resource.
  42358. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42359. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42360. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42361. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42362. * * 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.
  42363. * * 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).
  42364. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42365. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42366. * @param name defines the name of the mesh
  42367. * @param url defines the url to the height map
  42368. * @param options defines the options used to create the mesh
  42369. * @param scene defines the hosting scene
  42370. * @returns the ground mesh
  42371. * @see https://doc.babylonjs.com/babylon101/height_map
  42372. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42373. */
  42374. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42375. width?: number;
  42376. height?: number;
  42377. subdivisions?: number;
  42378. minHeight?: number;
  42379. maxHeight?: number;
  42380. colorFilter?: Color3;
  42381. alphaFilter?: number;
  42382. updatable?: boolean;
  42383. onReady?: (mesh: GroundMesh) => void;
  42384. }, scene?: Nullable<Scene>): GroundMesh;
  42385. }
  42386. }
  42387. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  42388. import { Vector4 } from "babylonjs/Maths/math.vector";
  42389. import { Mesh } from "babylonjs/Meshes/mesh";
  42390. /**
  42391. * Class containing static functions to help procedurally build meshes
  42392. */
  42393. export class TorusBuilder {
  42394. /**
  42395. * Creates a torus mesh
  42396. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42397. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42398. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42399. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42400. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42401. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42402. * @param name defines the name of the mesh
  42403. * @param options defines the options used to create the mesh
  42404. * @param scene defines the hosting scene
  42405. * @returns the torus mesh
  42406. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42407. */
  42408. static CreateTorus(name: string, options: {
  42409. diameter?: number;
  42410. thickness?: number;
  42411. tessellation?: number;
  42412. updatable?: boolean;
  42413. sideOrientation?: number;
  42414. frontUVs?: Vector4;
  42415. backUVs?: Vector4;
  42416. }, scene: any): Mesh;
  42417. }
  42418. }
  42419. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  42420. import { Vector4 } from "babylonjs/Maths/math.vector";
  42421. import { Color4 } from "babylonjs/Maths/math.color";
  42422. import { Mesh } from "babylonjs/Meshes/mesh";
  42423. /**
  42424. * Class containing static functions to help procedurally build meshes
  42425. */
  42426. export class CylinderBuilder {
  42427. /**
  42428. * Creates a cylinder or a cone mesh
  42429. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42430. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42431. * * 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.
  42432. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42433. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42434. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42435. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42436. * * 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).
  42437. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42438. * * 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).
  42439. * * 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
  42440. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42441. * * 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
  42442. * * 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.
  42443. * * If `enclose` is false, a ring surface is one element.
  42444. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42445. * * 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
  42446. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42447. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42448. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42449. * @param name defines the name of the mesh
  42450. * @param options defines the options used to create the mesh
  42451. * @param scene defines the hosting scene
  42452. * @returns the cylinder mesh
  42453. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42454. */
  42455. static CreateCylinder(name: string, options: {
  42456. height?: number;
  42457. diameterTop?: number;
  42458. diameterBottom?: number;
  42459. diameter?: number;
  42460. tessellation?: number;
  42461. subdivisions?: number;
  42462. arc?: number;
  42463. faceColors?: Color4[];
  42464. faceUV?: Vector4[];
  42465. updatable?: boolean;
  42466. hasRings?: boolean;
  42467. enclose?: boolean;
  42468. cap?: number;
  42469. sideOrientation?: number;
  42470. frontUVs?: Vector4;
  42471. backUVs?: Vector4;
  42472. }, scene: any): Mesh;
  42473. }
  42474. }
  42475. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  42476. import { Observable } from "babylonjs/Misc/observable";
  42477. import { Nullable } from "babylonjs/types";
  42478. import { Camera } from "babylonjs/Cameras/camera";
  42479. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  42480. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42481. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  42482. import { Scene } from "babylonjs/scene";
  42483. import { Vector3 } from "babylonjs/Maths/math.vector";
  42484. import { Color3 } from "babylonjs/Maths/math.color";
  42485. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42486. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42487. import { Mesh } from "babylonjs/Meshes/mesh";
  42488. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  42489. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42490. import "babylonjs/Meshes/Builders/groundBuilder";
  42491. import "babylonjs/Meshes/Builders/torusBuilder";
  42492. import "babylonjs/Meshes/Builders/cylinderBuilder";
  42493. import "babylonjs/Gamepads/gamepadSceneComponent";
  42494. import "babylonjs/Animations/animatable";
  42495. /**
  42496. * Options to modify the vr teleportation behavior.
  42497. */
  42498. export interface VRTeleportationOptions {
  42499. /**
  42500. * The name of the mesh which should be used as the teleportation floor. (default: null)
  42501. */
  42502. floorMeshName?: string;
  42503. /**
  42504. * A list of meshes to be used as the teleportation floor. (default: empty)
  42505. */
  42506. floorMeshes?: Mesh[];
  42507. }
  42508. /**
  42509. * Options to modify the vr experience helper's behavior.
  42510. */
  42511. export interface VRExperienceHelperOptions extends WebVROptions {
  42512. /**
  42513. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  42514. */
  42515. createDeviceOrientationCamera?: boolean;
  42516. /**
  42517. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  42518. */
  42519. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  42520. /**
  42521. * Uses the main button on the controller to toggle the laser casted. (default: true)
  42522. */
  42523. laserToggle?: boolean;
  42524. /**
  42525. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  42526. */
  42527. floorMeshes?: Mesh[];
  42528. /**
  42529. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  42530. */
  42531. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  42532. }
  42533. /**
  42534. * Event containing information after VR has been entered
  42535. */
  42536. export class OnAfterEnteringVRObservableEvent {
  42537. /**
  42538. * If entering vr was successful
  42539. */
  42540. success: boolean;
  42541. }
  42542. /**
  42543. * Helps to quickly add VR support to an existing scene.
  42544. * See http://doc.babylonjs.com/how_to/webvr_helper
  42545. */
  42546. export class VRExperienceHelper {
  42547. /** Options to modify the vr experience helper's behavior. */
  42548. webVROptions: VRExperienceHelperOptions;
  42549. private _scene;
  42550. private _position;
  42551. private _btnVR;
  42552. private _btnVRDisplayed;
  42553. private _webVRsupported;
  42554. private _webVRready;
  42555. private _webVRrequesting;
  42556. private _webVRpresenting;
  42557. private _hasEnteredVR;
  42558. private _fullscreenVRpresenting;
  42559. private _canvas;
  42560. private _webVRCamera;
  42561. private _vrDeviceOrientationCamera;
  42562. private _deviceOrientationCamera;
  42563. private _existingCamera;
  42564. private _onKeyDown;
  42565. private _onVrDisplayPresentChange;
  42566. private _onVRDisplayChanged;
  42567. private _onVRRequestPresentStart;
  42568. private _onVRRequestPresentComplete;
  42569. /**
  42570. * 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)
  42571. */
  42572. enableGazeEvenWhenNoPointerLock: boolean;
  42573. /**
  42574. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  42575. */
  42576. exitVROnDoubleTap: boolean;
  42577. /**
  42578. * Observable raised right before entering VR.
  42579. */
  42580. onEnteringVRObservable: Observable<VRExperienceHelper>;
  42581. /**
  42582. * Observable raised when entering VR has completed.
  42583. */
  42584. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  42585. /**
  42586. * Observable raised when exiting VR.
  42587. */
  42588. onExitingVRObservable: Observable<VRExperienceHelper>;
  42589. /**
  42590. * Observable raised when controller mesh is loaded.
  42591. */
  42592. onControllerMeshLoadedObservable: Observable<WebVRController>;
  42593. /** Return this.onEnteringVRObservable
  42594. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  42595. */
  42596. readonly onEnteringVR: Observable<VRExperienceHelper>;
  42597. /** Return this.onExitingVRObservable
  42598. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  42599. */
  42600. readonly onExitingVR: Observable<VRExperienceHelper>;
  42601. /** Return this.onControllerMeshLoadedObservable
  42602. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  42603. */
  42604. readonly onControllerMeshLoaded: Observable<WebVRController>;
  42605. private _rayLength;
  42606. private _useCustomVRButton;
  42607. private _teleportationRequested;
  42608. private _teleportActive;
  42609. private _floorMeshName;
  42610. private _floorMeshesCollection;
  42611. private _rotationAllowed;
  42612. private _teleportBackwardsVector;
  42613. private _teleportationTarget;
  42614. private _isDefaultTeleportationTarget;
  42615. private _postProcessMove;
  42616. private _teleportationFillColor;
  42617. private _teleportationBorderColor;
  42618. private _rotationAngle;
  42619. private _haloCenter;
  42620. private _cameraGazer;
  42621. private _padSensibilityUp;
  42622. private _padSensibilityDown;
  42623. private _leftController;
  42624. private _rightController;
  42625. /**
  42626. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  42627. */
  42628. onNewMeshSelected: Observable<AbstractMesh>;
  42629. /**
  42630. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  42631. * This observable will provide the mesh and the controller used to select the mesh
  42632. */
  42633. onMeshSelectedWithController: Observable<{
  42634. mesh: AbstractMesh;
  42635. controller: WebVRController;
  42636. }>;
  42637. /**
  42638. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  42639. */
  42640. onNewMeshPicked: Observable<PickingInfo>;
  42641. private _circleEase;
  42642. /**
  42643. * Observable raised before camera teleportation
  42644. */
  42645. onBeforeCameraTeleport: Observable<Vector3>;
  42646. /**
  42647. * Observable raised after camera teleportation
  42648. */
  42649. onAfterCameraTeleport: Observable<Vector3>;
  42650. /**
  42651. * Observable raised when current selected mesh gets unselected
  42652. */
  42653. onSelectedMeshUnselected: Observable<AbstractMesh>;
  42654. private _raySelectionPredicate;
  42655. /**
  42656. * To be optionaly changed by user to define custom ray selection
  42657. */
  42658. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  42659. /**
  42660. * To be optionaly changed by user to define custom selection logic (after ray selection)
  42661. */
  42662. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  42663. /**
  42664. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  42665. */
  42666. teleportationEnabled: boolean;
  42667. private _defaultHeight;
  42668. private _teleportationInitialized;
  42669. private _interactionsEnabled;
  42670. private _interactionsRequested;
  42671. private _displayGaze;
  42672. private _displayLaserPointer;
  42673. /**
  42674. * The mesh used to display where the user is going to teleport.
  42675. */
  42676. /**
  42677. * Sets the mesh to be used to display where the user is going to teleport.
  42678. */
  42679. teleportationTarget: Mesh;
  42680. /**
  42681. * 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
  42682. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  42683. * See http://doc.babylonjs.com/resources/baking_transformations
  42684. */
  42685. gazeTrackerMesh: Mesh;
  42686. /**
  42687. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  42688. */
  42689. updateGazeTrackerScale: boolean;
  42690. /**
  42691. * If the gaze trackers color should be updated when selecting meshes
  42692. */
  42693. updateGazeTrackerColor: boolean;
  42694. /**
  42695. * If the controller laser color should be updated when selecting meshes
  42696. */
  42697. updateControllerLaserColor: boolean;
  42698. /**
  42699. * The gaze tracking mesh corresponding to the left controller
  42700. */
  42701. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  42702. /**
  42703. * The gaze tracking mesh corresponding to the right controller
  42704. */
  42705. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  42706. /**
  42707. * If the ray of the gaze should be displayed.
  42708. */
  42709. /**
  42710. * Sets if the ray of the gaze should be displayed.
  42711. */
  42712. displayGaze: boolean;
  42713. /**
  42714. * If the ray of the LaserPointer should be displayed.
  42715. */
  42716. /**
  42717. * Sets if the ray of the LaserPointer should be displayed.
  42718. */
  42719. displayLaserPointer: boolean;
  42720. /**
  42721. * The deviceOrientationCamera used as the camera when not in VR.
  42722. */
  42723. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  42724. /**
  42725. * Based on the current WebVR support, returns the current VR camera used.
  42726. */
  42727. readonly currentVRCamera: Nullable<Camera>;
  42728. /**
  42729. * The webVRCamera which is used when in VR.
  42730. */
  42731. readonly webVRCamera: WebVRFreeCamera;
  42732. /**
  42733. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  42734. */
  42735. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  42736. /**
  42737. * The html button that is used to trigger entering into VR.
  42738. */
  42739. readonly vrButton: Nullable<HTMLButtonElement>;
  42740. private readonly _teleportationRequestInitiated;
  42741. /**
  42742. * Defines wether or not Pointer lock should be requested when switching to
  42743. * full screen.
  42744. */
  42745. requestPointerLockOnFullScreen: boolean;
  42746. /**
  42747. * Instantiates a VRExperienceHelper.
  42748. * Helps to quickly add VR support to an existing scene.
  42749. * @param scene The scene the VRExperienceHelper belongs to.
  42750. * @param webVROptions Options to modify the vr experience helper's behavior.
  42751. */
  42752. constructor(scene: Scene,
  42753. /** Options to modify the vr experience helper's behavior. */
  42754. webVROptions?: VRExperienceHelperOptions);
  42755. private _onDefaultMeshLoaded;
  42756. private _onResize;
  42757. private _onFullscreenChange;
  42758. /**
  42759. * Gets a value indicating if we are currently in VR mode.
  42760. */
  42761. readonly isInVRMode: boolean;
  42762. private onVrDisplayPresentChange;
  42763. private onVRDisplayChanged;
  42764. private moveButtonToBottomRight;
  42765. private displayVRButton;
  42766. private updateButtonVisibility;
  42767. private _cachedAngularSensibility;
  42768. /**
  42769. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  42770. * Otherwise, will use the fullscreen API.
  42771. */
  42772. enterVR(): void;
  42773. /**
  42774. * Attempt to exit VR, or fullscreen.
  42775. */
  42776. exitVR(): void;
  42777. /**
  42778. * The position of the vr experience helper.
  42779. */
  42780. /**
  42781. * Sets the position of the vr experience helper.
  42782. */
  42783. position: Vector3;
  42784. /**
  42785. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  42786. */
  42787. enableInteractions(): void;
  42788. private readonly _noControllerIsActive;
  42789. private beforeRender;
  42790. private _isTeleportationFloor;
  42791. /**
  42792. * Adds a floor mesh to be used for teleportation.
  42793. * @param floorMesh the mesh to be used for teleportation.
  42794. */
  42795. addFloorMesh(floorMesh: Mesh): void;
  42796. /**
  42797. * Removes a floor mesh from being used for teleportation.
  42798. * @param floorMesh the mesh to be removed.
  42799. */
  42800. removeFloorMesh(floorMesh: Mesh): void;
  42801. /**
  42802. * Enables interactions and teleportation using the VR controllers and gaze.
  42803. * @param vrTeleportationOptions options to modify teleportation behavior.
  42804. */
  42805. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  42806. private _onNewGamepadConnected;
  42807. private _tryEnableInteractionOnController;
  42808. private _onNewGamepadDisconnected;
  42809. private _enableInteractionOnController;
  42810. private _checkTeleportWithRay;
  42811. private _checkRotate;
  42812. private _checkTeleportBackwards;
  42813. private _enableTeleportationOnController;
  42814. private _createTeleportationCircles;
  42815. private _displayTeleportationTarget;
  42816. private _hideTeleportationTarget;
  42817. private _rotateCamera;
  42818. private _moveTeleportationSelectorTo;
  42819. private _workingVector;
  42820. private _workingQuaternion;
  42821. private _workingMatrix;
  42822. /**
  42823. * Teleports the users feet to the desired location
  42824. * @param location The location where the user's feet should be placed
  42825. */
  42826. teleportCamera(location: Vector3): void;
  42827. private _convertNormalToDirectionOfRay;
  42828. private _castRayAndSelectObject;
  42829. private _notifySelectedMeshUnselected;
  42830. /**
  42831. * Sets the color of the laser ray from the vr controllers.
  42832. * @param color new color for the ray.
  42833. */
  42834. changeLaserColor(color: Color3): void;
  42835. /**
  42836. * Sets the color of the ray from the vr headsets gaze.
  42837. * @param color new color for the ray.
  42838. */
  42839. changeGazeColor(color: Color3): void;
  42840. /**
  42841. * Exits VR and disposes of the vr experience helper
  42842. */
  42843. dispose(): void;
  42844. /**
  42845. * Gets the name of the VRExperienceHelper class
  42846. * @returns "VRExperienceHelper"
  42847. */
  42848. getClassName(): string;
  42849. }
  42850. }
  42851. declare module "babylonjs/Cameras/VR/index" {
  42852. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  42853. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  42854. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42855. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  42856. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  42857. export * from "babylonjs/Cameras/VR/webVRCamera";
  42858. }
  42859. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  42860. import { Observable } from "babylonjs/Misc/observable";
  42861. import { Nullable } from "babylonjs/types";
  42862. import { IDisposable, Scene } from "babylonjs/scene";
  42863. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  42864. /**
  42865. * Manages an XRSession to work with Babylon's engine
  42866. * @see https://doc.babylonjs.com/how_to/webxr
  42867. */
  42868. export class WebXRSessionManager implements IDisposable {
  42869. private scene;
  42870. /**
  42871. * Fires every time a new xrFrame arrives which can be used to update the camera
  42872. */
  42873. onXRFrameObservable: Observable<any>;
  42874. /**
  42875. * Fires when the xr session is ended either by the device or manually done
  42876. */
  42877. onXRSessionEnded: Observable<any>;
  42878. /**
  42879. * Underlying xr session
  42880. */
  42881. session: XRSession;
  42882. /**
  42883. * Type of reference space used when creating the session
  42884. */
  42885. referenceSpace: XRReferenceSpace;
  42886. /** @hidden */
  42887. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  42888. /**
  42889. * Current XR frame
  42890. */
  42891. currentFrame: Nullable<XRFrame>;
  42892. private _xrNavigator;
  42893. private baseLayer;
  42894. /**
  42895. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  42896. * @param scene The scene which the session should be created for
  42897. */
  42898. constructor(scene: Scene);
  42899. /**
  42900. * Initializes the manager
  42901. * After initialization enterXR can be called to start an XR session
  42902. * @returns Promise which resolves after it is initialized
  42903. */
  42904. initializeAsync(): Promise<void>;
  42905. /**
  42906. * Initializes an xr session
  42907. * @param xrSessionMode mode to initialize
  42908. * @returns a promise which will resolve once the session has been initialized
  42909. */
  42910. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  42911. /**
  42912. * Sets the reference space on the xr session
  42913. * @param referenceSpace space to set
  42914. * @returns a promise that will resolve once the reference space has been set
  42915. */
  42916. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  42917. /**
  42918. * Updates the render state of the session
  42919. * @param state state to set
  42920. * @returns a promise that resolves once the render state has been updated
  42921. */
  42922. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  42923. /**
  42924. * Starts rendering to the xr layer
  42925. * @returns a promise that will resolve once rendering has started
  42926. */
  42927. startRenderingToXRAsync(): Promise<void>;
  42928. /**
  42929. * Stops the xrSession and restores the renderloop
  42930. * @returns Promise which resolves after it exits XR
  42931. */
  42932. exitXRAsync(): Promise<unknown>;
  42933. /**
  42934. * Checks if a session would be supported for the creation options specified
  42935. * @param sessionMode session mode to check if supported eg. immersive-vr
  42936. * @returns true if supported
  42937. */
  42938. supportsSessionAsync(sessionMode: XRSessionMode): any;
  42939. /**
  42940. * @hidden
  42941. * Converts the render layer of xrSession to a render target
  42942. * @param session session to create render target for
  42943. * @param scene scene the new render target should be created for
  42944. */
  42945. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  42946. /**
  42947. * Disposes of the session manager
  42948. */
  42949. dispose(): void;
  42950. }
  42951. }
  42952. declare module "babylonjs/Cameras/XR/webXRCamera" {
  42953. import { Scene } from "babylonjs/scene";
  42954. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42955. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42956. /**
  42957. * WebXR Camera which holds the views for the xrSession
  42958. * @see https://doc.babylonjs.com/how_to/webxr
  42959. */
  42960. export class WebXRCamera extends FreeCamera {
  42961. private static _TmpMatrix;
  42962. /**
  42963. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42964. * @param name the name of the camera
  42965. * @param scene the scene to add the camera to
  42966. */
  42967. constructor(name: string, scene: Scene);
  42968. private _updateNumberOfRigCameras;
  42969. /** @hidden */
  42970. _updateForDualEyeDebugging(pupilDistance?: number): void;
  42971. /**
  42972. * Updates the cameras position from the current pose information of the XR session
  42973. * @param xrSessionManager the session containing pose information
  42974. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  42975. */
  42976. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  42977. }
  42978. }
  42979. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  42980. import { Nullable } from "babylonjs/types";
  42981. import { IDisposable } from "babylonjs/scene";
  42982. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42983. /**
  42984. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42985. */
  42986. export class WebXRManagedOutputCanvas implements IDisposable {
  42987. private helper;
  42988. private _canvas;
  42989. /**
  42990. * xrpresent context of the canvas which can be used to display/mirror xr content
  42991. */
  42992. canvasContext: WebGLRenderingContext;
  42993. /**
  42994. * xr layer for the canvas
  42995. */
  42996. xrLayer: Nullable<XRWebGLLayer>;
  42997. /**
  42998. * Initializes the xr layer for the session
  42999. * @param xrSession xr session
  43000. * @returns a promise that will resolve once the XR Layer has been created
  43001. */
  43002. initializeXRLayerAsync(xrSession: any): any;
  43003. /**
  43004. * Initializes the canvas to be added/removed upon entering/exiting xr
  43005. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  43006. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  43007. */
  43008. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  43009. /**
  43010. * Disposes of the object
  43011. */
  43012. dispose(): void;
  43013. private _setManagedOutputCanvas;
  43014. private _addCanvas;
  43015. private _removeCanvas;
  43016. }
  43017. }
  43018. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  43019. import { Observable } from "babylonjs/Misc/observable";
  43020. import { IDisposable, Scene } from "babylonjs/scene";
  43021. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  43022. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43023. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43024. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  43025. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43026. /**
  43027. * States of the webXR experience
  43028. */
  43029. export enum WebXRState {
  43030. /**
  43031. * Transitioning to being in XR mode
  43032. */
  43033. ENTERING_XR = 0,
  43034. /**
  43035. * Transitioning to non XR mode
  43036. */
  43037. EXITING_XR = 1,
  43038. /**
  43039. * In XR mode and presenting
  43040. */
  43041. IN_XR = 2,
  43042. /**
  43043. * Not entered XR mode
  43044. */
  43045. NOT_IN_XR = 3
  43046. }
  43047. /**
  43048. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  43049. * @see https://doc.babylonjs.com/how_to/webxr
  43050. */
  43051. export class WebXRExperienceHelper implements IDisposable {
  43052. private scene;
  43053. /**
  43054. * 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
  43055. */
  43056. container: AbstractMesh;
  43057. /**
  43058. * Camera used to render xr content
  43059. */
  43060. camera: WebXRCamera;
  43061. /**
  43062. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  43063. */
  43064. state: WebXRState;
  43065. private _setState;
  43066. private static _TmpVector;
  43067. /**
  43068. * Fires when the state of the experience helper has changed
  43069. */
  43070. onStateChangedObservable: Observable<WebXRState>;
  43071. /** Session manager used to keep track of xr session */
  43072. sessionManager: WebXRSessionManager;
  43073. private _nonVRCamera;
  43074. private _originalSceneAutoClear;
  43075. private _supported;
  43076. /**
  43077. * Creates the experience helper
  43078. * @param scene the scene to attach the experience helper to
  43079. * @returns a promise for the experience helper
  43080. */
  43081. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  43082. /**
  43083. * Creates a WebXRExperienceHelper
  43084. * @param scene The scene the helper should be created in
  43085. */
  43086. private constructor();
  43087. /**
  43088. * Exits XR mode and returns the scene to its original state
  43089. * @returns promise that resolves after xr mode has exited
  43090. */
  43091. exitXRAsync(): Promise<unknown>;
  43092. /**
  43093. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43094. * @param sessionCreationOptions options for the XR session
  43095. * @param referenceSpaceType frame of reference of the XR session
  43096. * @param outputCanvas the output canvas that will be used to enter XR mode
  43097. * @returns promise that resolves after xr mode has entered
  43098. */
  43099. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  43100. /**
  43101. * Updates the global position of the camera by moving the camera's container
  43102. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  43103. * @param position The desired global position of the camera
  43104. */
  43105. setPositionOfCameraUsingContainer(position: Vector3): void;
  43106. /**
  43107. * Rotates the xr camera by rotating the camera's container around the camera's position
  43108. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  43109. * @param rotation the desired quaternion rotation to apply to the camera
  43110. */
  43111. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  43112. /**
  43113. * Disposes of the experience helper
  43114. */
  43115. dispose(): void;
  43116. }
  43117. }
  43118. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  43119. import { Nullable } from "babylonjs/types";
  43120. import { Observable } from "babylonjs/Misc/observable";
  43121. import { IDisposable, Scene } from "babylonjs/scene";
  43122. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43123. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43124. /**
  43125. * Button which can be used to enter a different mode of XR
  43126. */
  43127. export class WebXREnterExitUIButton {
  43128. /** button element */
  43129. element: HTMLElement;
  43130. /** XR initialization options for the button */
  43131. sessionMode: XRSessionMode;
  43132. /** Reference space type */
  43133. referenceSpaceType: XRReferenceSpaceType;
  43134. /**
  43135. * Creates a WebXREnterExitUIButton
  43136. * @param element button element
  43137. * @param sessionMode XR initialization session mode
  43138. * @param referenceSpaceType the type of reference space to be used
  43139. */
  43140. constructor(
  43141. /** button element */
  43142. element: HTMLElement,
  43143. /** XR initialization options for the button */
  43144. sessionMode: XRSessionMode,
  43145. /** Reference space type */
  43146. referenceSpaceType: XRReferenceSpaceType);
  43147. /**
  43148. * Overwritable function which can be used to update the button's visuals when the state changes
  43149. * @param activeButton the current active button in the UI
  43150. */
  43151. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  43152. }
  43153. /**
  43154. * Options to create the webXR UI
  43155. */
  43156. export class WebXREnterExitUIOptions {
  43157. /**
  43158. * Context to enter xr with
  43159. */
  43160. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  43161. /**
  43162. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  43163. */
  43164. customButtons?: Array<WebXREnterExitUIButton>;
  43165. }
  43166. /**
  43167. * UI to allow the user to enter/exit XR mode
  43168. */
  43169. export class WebXREnterExitUI implements IDisposable {
  43170. private scene;
  43171. private _overlay;
  43172. private _buttons;
  43173. private _activeButton;
  43174. /**
  43175. * Fired every time the active button is changed.
  43176. *
  43177. * When xr is entered via a button that launches xr that button will be the callback parameter
  43178. *
  43179. * When exiting xr the callback parameter will be null)
  43180. */
  43181. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  43182. /**
  43183. * Creates UI to allow the user to enter/exit XR mode
  43184. * @param scene the scene to add the ui to
  43185. * @param helper the xr experience helper to enter/exit xr with
  43186. * @param options options to configure the UI
  43187. * @returns the created ui
  43188. */
  43189. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  43190. private constructor();
  43191. private _updateButtons;
  43192. /**
  43193. * Disposes of the object
  43194. */
  43195. dispose(): void;
  43196. }
  43197. }
  43198. declare module "babylonjs/Cameras/XR/webXRController" {
  43199. import { Nullable } from "babylonjs/types";
  43200. import { Observable } from "babylonjs/Misc/observable";
  43201. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43202. import { Ray } from "babylonjs/Culling/ray";
  43203. import { Scene } from "babylonjs/scene";
  43204. /**
  43205. * Represents an XR input
  43206. */
  43207. export class WebXRController {
  43208. private scene;
  43209. /** The underlying input source for the controller */
  43210. inputSource: XRInputSource;
  43211. private parentContainer;
  43212. /**
  43213. * 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
  43214. */
  43215. grip?: AbstractMesh;
  43216. /**
  43217. * Pointer which can be used to select objects or attach a visible laser to
  43218. */
  43219. pointer: AbstractMesh;
  43220. /**
  43221. * Event that fires when the controller is removed/disposed
  43222. */
  43223. onDisposeObservable: Observable<{}>;
  43224. private _tmpMatrix;
  43225. private _tmpQuaternion;
  43226. private _tmpVector;
  43227. /**
  43228. * Creates the controller
  43229. * @see https://doc.babylonjs.com/how_to/webxr
  43230. * @param scene the scene which the controller should be associated to
  43231. * @param inputSource the underlying input source for the controller
  43232. * @param parentContainer parent that the controller meshes should be children of
  43233. */
  43234. constructor(scene: Scene,
  43235. /** The underlying input source for the controller */
  43236. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  43237. /**
  43238. * Updates the controller pose based on the given XRFrame
  43239. * @param xrFrame xr frame to update the pose with
  43240. * @param referenceSpace reference space to use
  43241. */
  43242. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  43243. /**
  43244. * Gets a world space ray coming from the controller
  43245. * @param result the resulting ray
  43246. */
  43247. getWorldPointerRayToRef(result: Ray): void;
  43248. /**
  43249. * Disposes of the object
  43250. */
  43251. dispose(): void;
  43252. }
  43253. }
  43254. declare module "babylonjs/Cameras/XR/webXRInput" {
  43255. import { Observable } from "babylonjs/Misc/observable";
  43256. import { IDisposable } from "babylonjs/scene";
  43257. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43258. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  43259. /**
  43260. * XR input used to track XR inputs such as controllers/rays
  43261. */
  43262. export class WebXRInput implements IDisposable {
  43263. /**
  43264. * Base experience the input listens to
  43265. */
  43266. baseExperience: WebXRExperienceHelper;
  43267. /**
  43268. * XR controllers being tracked
  43269. */
  43270. controllers: Array<WebXRController>;
  43271. private _frameObserver;
  43272. private _stateObserver;
  43273. /**
  43274. * Event when a controller has been connected/added
  43275. */
  43276. onControllerAddedObservable: Observable<WebXRController>;
  43277. /**
  43278. * Event when a controller has been removed/disconnected
  43279. */
  43280. onControllerRemovedObservable: Observable<WebXRController>;
  43281. /**
  43282. * Initializes the WebXRInput
  43283. * @param baseExperience experience helper which the input should be created for
  43284. */
  43285. constructor(
  43286. /**
  43287. * Base experience the input listens to
  43288. */
  43289. baseExperience: WebXRExperienceHelper);
  43290. private _onInputSourcesChange;
  43291. private _addAndRemoveControllers;
  43292. /**
  43293. * Disposes of the object
  43294. */
  43295. dispose(): void;
  43296. }
  43297. }
  43298. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  43299. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43300. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43301. /**
  43302. * Enables teleportation
  43303. */
  43304. export class WebXRControllerTeleportation {
  43305. private _teleportationFillColor;
  43306. private _teleportationBorderColor;
  43307. private _tmpRay;
  43308. private _tmpVector;
  43309. /**
  43310. * Creates a WebXRControllerTeleportation
  43311. * @param input input manager to add teleportation to
  43312. * @param floorMeshes floormeshes which can be teleported to
  43313. */
  43314. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  43315. }
  43316. }
  43317. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  43318. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43319. /**
  43320. * Handles pointer input automatically for the pointer of XR controllers
  43321. */
  43322. export class WebXRControllerPointerSelection {
  43323. private static _idCounter;
  43324. private _tmpRay;
  43325. /**
  43326. * Creates a WebXRControllerPointerSelection
  43327. * @param input input manager to setup pointer selection
  43328. */
  43329. constructor(input: WebXRInput);
  43330. private _convertNormalToDirectionOfRay;
  43331. private _updatePointerDistance;
  43332. }
  43333. }
  43334. declare module "babylonjs/Loading/sceneLoader" {
  43335. import { Observable } from "babylonjs/Misc/observable";
  43336. import { Nullable } from "babylonjs/types";
  43337. import { Scene } from "babylonjs/scene";
  43338. import { Engine } from "babylonjs/Engines/engine";
  43339. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43340. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43341. import { AssetContainer } from "babylonjs/assetContainer";
  43342. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43343. import { Skeleton } from "babylonjs/Bones/skeleton";
  43344. /**
  43345. * Class used to represent data loading progression
  43346. */
  43347. export class SceneLoaderProgressEvent {
  43348. /** defines if data length to load can be evaluated */
  43349. readonly lengthComputable: boolean;
  43350. /** defines the loaded data length */
  43351. readonly loaded: number;
  43352. /** defines the data length to load */
  43353. readonly total: number;
  43354. /**
  43355. * Create a new progress event
  43356. * @param lengthComputable defines if data length to load can be evaluated
  43357. * @param loaded defines the loaded data length
  43358. * @param total defines the data length to load
  43359. */
  43360. constructor(
  43361. /** defines if data length to load can be evaluated */
  43362. lengthComputable: boolean,
  43363. /** defines the loaded data length */
  43364. loaded: number,
  43365. /** defines the data length to load */
  43366. total: number);
  43367. /**
  43368. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43369. * @param event defines the source event
  43370. * @returns a new SceneLoaderProgressEvent
  43371. */
  43372. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43373. }
  43374. /**
  43375. * Interface used by SceneLoader plugins to define supported file extensions
  43376. */
  43377. export interface ISceneLoaderPluginExtensions {
  43378. /**
  43379. * Defines the list of supported extensions
  43380. */
  43381. [extension: string]: {
  43382. isBinary: boolean;
  43383. };
  43384. }
  43385. /**
  43386. * Interface used by SceneLoader plugin factory
  43387. */
  43388. export interface ISceneLoaderPluginFactory {
  43389. /**
  43390. * Defines the name of the factory
  43391. */
  43392. name: string;
  43393. /**
  43394. * Function called to create a new plugin
  43395. * @return the new plugin
  43396. */
  43397. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43398. /**
  43399. * Boolean indicating if the plugin can direct load specific data
  43400. */
  43401. canDirectLoad?: (data: string) => boolean;
  43402. }
  43403. /**
  43404. * Interface used to define a SceneLoader plugin
  43405. */
  43406. export interface ISceneLoaderPlugin {
  43407. /**
  43408. * The friendly name of this plugin.
  43409. */
  43410. name: string;
  43411. /**
  43412. * The file extensions supported by this plugin.
  43413. */
  43414. extensions: string | ISceneLoaderPluginExtensions;
  43415. /**
  43416. * Import meshes into a scene.
  43417. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43418. * @param scene The scene to import into
  43419. * @param data The data to import
  43420. * @param rootUrl The root url for scene and resources
  43421. * @param meshes The meshes array to import into
  43422. * @param particleSystems The particle systems array to import into
  43423. * @param skeletons The skeletons array to import into
  43424. * @param onError The callback when import fails
  43425. * @returns True if successful or false otherwise
  43426. */
  43427. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43428. /**
  43429. * Load into a scene.
  43430. * @param scene The scene to load into
  43431. * @param data The data to import
  43432. * @param rootUrl The root url for scene and resources
  43433. * @param onError The callback when import fails
  43434. * @returns true if successful or false otherwise
  43435. */
  43436. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43437. /**
  43438. * The callback that returns true if the data can be directly loaded.
  43439. */
  43440. canDirectLoad?: (data: string) => boolean;
  43441. /**
  43442. * The callback that allows custom handling of the root url based on the response url.
  43443. */
  43444. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43445. /**
  43446. * Load into an asset container.
  43447. * @param scene The scene to load into
  43448. * @param data The data to import
  43449. * @param rootUrl The root url for scene and resources
  43450. * @param onError The callback when import fails
  43451. * @returns The loaded asset container
  43452. */
  43453. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43454. }
  43455. /**
  43456. * Interface used to define an async SceneLoader plugin
  43457. */
  43458. export interface ISceneLoaderPluginAsync {
  43459. /**
  43460. * The friendly name of this plugin.
  43461. */
  43462. name: string;
  43463. /**
  43464. * The file extensions supported by this plugin.
  43465. */
  43466. extensions: string | ISceneLoaderPluginExtensions;
  43467. /**
  43468. * Import meshes into a scene.
  43469. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43470. * @param scene The scene to import into
  43471. * @param data The data to import
  43472. * @param rootUrl The root url for scene and resources
  43473. * @param onProgress The callback when the load progresses
  43474. * @param fileName Defines the name of the file to load
  43475. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43476. */
  43477. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43478. meshes: AbstractMesh[];
  43479. particleSystems: IParticleSystem[];
  43480. skeletons: Skeleton[];
  43481. animationGroups: AnimationGroup[];
  43482. }>;
  43483. /**
  43484. * Load into a scene.
  43485. * @param scene The scene to load into
  43486. * @param data The data to import
  43487. * @param rootUrl The root url for scene and resources
  43488. * @param onProgress The callback when the load progresses
  43489. * @param fileName Defines the name of the file to load
  43490. * @returns Nothing
  43491. */
  43492. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43493. /**
  43494. * The callback that returns true if the data can be directly loaded.
  43495. */
  43496. canDirectLoad?: (data: string) => boolean;
  43497. /**
  43498. * The callback that allows custom handling of the root url based on the response url.
  43499. */
  43500. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43501. /**
  43502. * Load into an asset container.
  43503. * @param scene The scene to load 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 asset container
  43509. */
  43510. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43511. }
  43512. /**
  43513. * Class used to load scene from various file formats using registered plugins
  43514. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43515. */
  43516. export class SceneLoader {
  43517. /**
  43518. * No logging while loading
  43519. */
  43520. static readonly NO_LOGGING: number;
  43521. /**
  43522. * Minimal logging while loading
  43523. */
  43524. static readonly MINIMAL_LOGGING: number;
  43525. /**
  43526. * Summary logging while loading
  43527. */
  43528. static readonly SUMMARY_LOGGING: number;
  43529. /**
  43530. * Detailled logging while loading
  43531. */
  43532. static readonly DETAILED_LOGGING: number;
  43533. /**
  43534. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43535. */
  43536. static ForceFullSceneLoadingForIncremental: boolean;
  43537. /**
  43538. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43539. */
  43540. static ShowLoadingScreen: boolean;
  43541. /**
  43542. * Defines the current logging level (while loading the scene)
  43543. * @ignorenaming
  43544. */
  43545. static loggingLevel: number;
  43546. /**
  43547. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43548. */
  43549. static CleanBoneMatrixWeights: boolean;
  43550. /**
  43551. * Event raised when a plugin is used to load a scene
  43552. */
  43553. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43554. private static _registeredPlugins;
  43555. private static _getDefaultPlugin;
  43556. private static _getPluginForExtension;
  43557. private static _getPluginForDirectLoad;
  43558. private static _getPluginForFilename;
  43559. private static _getDirectLoad;
  43560. private static _loadData;
  43561. private static _getFileInfo;
  43562. /**
  43563. * Gets a plugin that can load the given extension
  43564. * @param extension defines the extension to load
  43565. * @returns a plugin or null if none works
  43566. */
  43567. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43568. /**
  43569. * Gets a boolean indicating that the given extension can be loaded
  43570. * @param extension defines the extension to load
  43571. * @returns true if the extension is supported
  43572. */
  43573. static IsPluginForExtensionAvailable(extension: string): boolean;
  43574. /**
  43575. * Adds a new plugin to the list of registered plugins
  43576. * @param plugin defines the plugin to add
  43577. */
  43578. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43579. /**
  43580. * Import meshes into a scene
  43581. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43582. * @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)
  43583. * @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)
  43584. * @param scene the instance of BABYLON.Scene to append to
  43585. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43586. * @param onProgress a callback with a progress event for each file being loaded
  43587. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43588. * @param pluginExtension the extension used to determine the plugin
  43589. * @returns The loaded plugin
  43590. */
  43591. 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>;
  43592. /**
  43593. * Import meshes into a scene
  43594. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43595. * @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)
  43596. * @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)
  43597. * @param scene the instance of BABYLON.Scene to append to
  43598. * @param onProgress a callback with a progress event for each file being loaded
  43599. * @param pluginExtension the extension used to determine the plugin
  43600. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43601. */
  43602. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43603. meshes: AbstractMesh[];
  43604. particleSystems: IParticleSystem[];
  43605. skeletons: Skeleton[];
  43606. animationGroups: AnimationGroup[];
  43607. }>;
  43608. /**
  43609. * Load a scene
  43610. * @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)
  43611. * @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)
  43612. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43613. * @param onSuccess a callback with the scene when import succeeds
  43614. * @param onProgress a callback with a progress event for each file being loaded
  43615. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43616. * @param pluginExtension the extension used to determine the plugin
  43617. * @returns The loaded plugin
  43618. */
  43619. 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>;
  43620. /**
  43621. * Load a scene
  43622. * @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)
  43623. * @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)
  43624. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43625. * @param onProgress a callback with a progress event for each file being loaded
  43626. * @param pluginExtension the extension used to determine the plugin
  43627. * @returns The loaded scene
  43628. */
  43629. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43630. /**
  43631. * Append a scene
  43632. * @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)
  43633. * @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)
  43634. * @param scene is the instance of BABYLON.Scene to append to
  43635. * @param onSuccess a callback with the scene when import succeeds
  43636. * @param onProgress a callback with a progress event for each file being loaded
  43637. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43638. * @param pluginExtension the extension used to determine the plugin
  43639. * @returns The loaded plugin
  43640. */
  43641. 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>;
  43642. /**
  43643. * Append a scene
  43644. * @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)
  43645. * @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)
  43646. * @param scene is the instance of BABYLON.Scene to append to
  43647. * @param onProgress a callback with a progress event for each file being loaded
  43648. * @param pluginExtension the extension used to determine the plugin
  43649. * @returns The given scene
  43650. */
  43651. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43652. /**
  43653. * Load a scene into an asset container
  43654. * @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)
  43655. * @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)
  43656. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43657. * @param onSuccess a callback with the scene when import succeeds
  43658. * @param onProgress a callback with a progress event for each file being loaded
  43659. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43660. * @param pluginExtension the extension used to determine the plugin
  43661. * @returns The loaded plugin
  43662. */
  43663. 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>;
  43664. /**
  43665. * Load a scene into an asset container
  43666. * @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)
  43667. * @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)
  43668. * @param scene is the instance of Scene to append to
  43669. * @param onProgress a callback with a progress event for each file being loaded
  43670. * @param pluginExtension the extension used to determine the plugin
  43671. * @returns The loaded asset container
  43672. */
  43673. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43674. }
  43675. }
  43676. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43677. import { Scene } from "babylonjs/scene";
  43678. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43679. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43680. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43681. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43682. /**
  43683. * Generic Controller
  43684. */
  43685. export class GenericController extends WebVRController {
  43686. /**
  43687. * Base Url for the controller model.
  43688. */
  43689. static readonly MODEL_BASE_URL: string;
  43690. /**
  43691. * File name for the controller model.
  43692. */
  43693. static readonly MODEL_FILENAME: string;
  43694. /**
  43695. * Creates a new GenericController from a gamepad
  43696. * @param vrGamepad the gamepad that the controller should be created from
  43697. */
  43698. constructor(vrGamepad: any);
  43699. /**
  43700. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43701. * @param scene scene in which to add meshes
  43702. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43703. */
  43704. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43705. /**
  43706. * Called once for each button that changed state since the last frame
  43707. * @param buttonIdx Which button index changed
  43708. * @param state New state of the button
  43709. * @param changes Which properties on the state changed since last frame
  43710. */
  43711. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43712. }
  43713. }
  43714. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43715. import { Observable } from "babylonjs/Misc/observable";
  43716. import { Scene } from "babylonjs/scene";
  43717. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43718. import { Ray } from "babylonjs/Culling/ray";
  43719. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43720. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43721. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43722. /**
  43723. * Defines the WindowsMotionController object that the state of the windows motion controller
  43724. */
  43725. export class WindowsMotionController extends WebVRController {
  43726. /**
  43727. * The base url used to load the left and right controller models
  43728. */
  43729. static MODEL_BASE_URL: string;
  43730. /**
  43731. * The name of the left controller model file
  43732. */
  43733. static MODEL_LEFT_FILENAME: string;
  43734. /**
  43735. * The name of the right controller model file
  43736. */
  43737. static MODEL_RIGHT_FILENAME: string;
  43738. /**
  43739. * The controller name prefix for this controller type
  43740. */
  43741. static readonly GAMEPAD_ID_PREFIX: string;
  43742. /**
  43743. * The controller id pattern for this controller type
  43744. */
  43745. private static readonly GAMEPAD_ID_PATTERN;
  43746. private _loadedMeshInfo;
  43747. private readonly _mapping;
  43748. /**
  43749. * Fired when the trackpad on this controller is clicked
  43750. */
  43751. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43752. /**
  43753. * Fired when the trackpad on this controller is modified
  43754. */
  43755. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43756. /**
  43757. * The current x and y values of this controller's trackpad
  43758. */
  43759. trackpad: StickValues;
  43760. /**
  43761. * Creates a new WindowsMotionController from a gamepad
  43762. * @param vrGamepad the gamepad that the controller should be created from
  43763. */
  43764. constructor(vrGamepad: any);
  43765. /**
  43766. * Fired when the trigger on this controller is modified
  43767. */
  43768. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43769. /**
  43770. * Fired when the menu button on this controller is modified
  43771. */
  43772. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43773. /**
  43774. * Fired when the grip button on this controller is modified
  43775. */
  43776. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43777. /**
  43778. * Fired when the thumbstick button on this controller is modified
  43779. */
  43780. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43781. /**
  43782. * Fired when the touchpad button on this controller is modified
  43783. */
  43784. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43785. /**
  43786. * Fired when the touchpad values on this controller are modified
  43787. */
  43788. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43789. private _updateTrackpad;
  43790. /**
  43791. * Called once per frame by the engine.
  43792. */
  43793. update(): void;
  43794. /**
  43795. * Called once for each button that changed state since the last frame
  43796. * @param buttonIdx Which button index changed
  43797. * @param state New state of the button
  43798. * @param changes Which properties on the state changed since last frame
  43799. */
  43800. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43801. /**
  43802. * Moves the buttons on the controller mesh based on their current state
  43803. * @param buttonName the name of the button to move
  43804. * @param buttonValue the value of the button which determines the buttons new position
  43805. */
  43806. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43807. /**
  43808. * Moves the axis on the controller mesh based on its current state
  43809. * @param axis the index of the axis
  43810. * @param axisValue the value of the axis which determines the meshes new position
  43811. * @hidden
  43812. */
  43813. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43814. /**
  43815. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43816. * @param scene scene in which to add meshes
  43817. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43818. */
  43819. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43820. /**
  43821. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43822. * can be transformed by button presses and axes values, based on this._mapping.
  43823. *
  43824. * @param scene scene in which the meshes exist
  43825. * @param meshes list of meshes that make up the controller model to process
  43826. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43827. */
  43828. private processModel;
  43829. private createMeshInfo;
  43830. /**
  43831. * Gets the ray of the controller in the direction the controller is pointing
  43832. * @param length the length the resulting ray should be
  43833. * @returns a ray in the direction the controller is pointing
  43834. */
  43835. getForwardRay(length?: number): Ray;
  43836. /**
  43837. * Disposes of the controller
  43838. */
  43839. dispose(): void;
  43840. }
  43841. }
  43842. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  43843. import { Observable } from "babylonjs/Misc/observable";
  43844. import { Scene } from "babylonjs/scene";
  43845. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43846. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43847. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43848. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43849. /**
  43850. * Oculus Touch Controller
  43851. */
  43852. export class OculusTouchController extends WebVRController {
  43853. /**
  43854. * Base Url for the controller model.
  43855. */
  43856. static MODEL_BASE_URL: string;
  43857. /**
  43858. * File name for the left controller model.
  43859. */
  43860. static MODEL_LEFT_FILENAME: string;
  43861. /**
  43862. * File name for the right controller model.
  43863. */
  43864. static MODEL_RIGHT_FILENAME: string;
  43865. /**
  43866. * Base Url for the Quest controller model.
  43867. */
  43868. static QUEST_MODEL_BASE_URL: string;
  43869. /**
  43870. * @hidden
  43871. * If the controllers are running on a device that needs the updated Quest controller models
  43872. */
  43873. static _IsQuest: boolean;
  43874. /**
  43875. * Fired when the secondary trigger on this controller is modified
  43876. */
  43877. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43878. /**
  43879. * Fired when the thumb rest on this controller is modified
  43880. */
  43881. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43882. /**
  43883. * Creates a new OculusTouchController from a gamepad
  43884. * @param vrGamepad the gamepad that the controller should be created from
  43885. */
  43886. constructor(vrGamepad: any);
  43887. /**
  43888. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43889. * @param scene scene in which to add meshes
  43890. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43891. */
  43892. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43893. /**
  43894. * Fired when the A button on this controller is modified
  43895. */
  43896. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43897. /**
  43898. * Fired when the B button on this controller is modified
  43899. */
  43900. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43901. /**
  43902. * Fired when the X button on this controller is modified
  43903. */
  43904. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43905. /**
  43906. * Fired when the Y button on this controller is modified
  43907. */
  43908. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43909. /**
  43910. * Called once for each button that changed state since the last frame
  43911. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43912. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43913. * 2) secondary trigger (same)
  43914. * 3) A (right) X (left), touch, pressed = value
  43915. * 4) B / Y
  43916. * 5) thumb rest
  43917. * @param buttonIdx Which button index changed
  43918. * @param state New state of the button
  43919. * @param changes Which properties on the state changed since last frame
  43920. */
  43921. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43922. }
  43923. }
  43924. declare module "babylonjs/Gamepads/Controllers/viveController" {
  43925. import { Scene } from "babylonjs/scene";
  43926. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43927. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43928. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43929. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43930. import { Observable } from "babylonjs/Misc/observable";
  43931. /**
  43932. * Vive Controller
  43933. */
  43934. export class ViveController extends WebVRController {
  43935. /**
  43936. * Base Url for the controller model.
  43937. */
  43938. static MODEL_BASE_URL: string;
  43939. /**
  43940. * File name for the controller model.
  43941. */
  43942. static MODEL_FILENAME: string;
  43943. /**
  43944. * Creates a new ViveController from a gamepad
  43945. * @param vrGamepad the gamepad that the controller should be created from
  43946. */
  43947. constructor(vrGamepad: any);
  43948. /**
  43949. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43950. * @param scene scene in which to add meshes
  43951. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43952. */
  43953. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43954. /**
  43955. * Fired when the left button on this controller is modified
  43956. */
  43957. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43958. /**
  43959. * Fired when the right button on this controller is modified
  43960. */
  43961. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43962. /**
  43963. * Fired when the menu button on this controller is modified
  43964. */
  43965. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43966. /**
  43967. * Called once for each button that changed state since the last frame
  43968. * Vive mapping:
  43969. * 0: touchpad
  43970. * 1: trigger
  43971. * 2: left AND right buttons
  43972. * 3: menu button
  43973. * @param buttonIdx Which button index changed
  43974. * @param state New state of the button
  43975. * @param changes Which properties on the state changed since last frame
  43976. */
  43977. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43978. }
  43979. }
  43980. declare module "babylonjs/Cameras/XR/webXRControllerModelLoader" {
  43981. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43982. /**
  43983. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  43984. */
  43985. export class WebXRControllerModelLoader {
  43986. /**
  43987. * Creates the WebXRControllerModelLoader
  43988. * @param input xr input that creates the controllers
  43989. */
  43990. constructor(input: WebXRInput);
  43991. }
  43992. }
  43993. declare module "babylonjs/Cameras/XR/index" {
  43994. export * from "babylonjs/Cameras/XR/webXRCamera";
  43995. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  43996. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43997. export * from "babylonjs/Cameras/XR/webXRInput";
  43998. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  43999. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  44000. export * from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  44001. export * from "babylonjs/Cameras/XR/webXRController";
  44002. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  44003. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  44004. }
  44005. declare module "babylonjs/Cameras/RigModes/index" {
  44006. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  44007. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  44008. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  44009. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  44010. }
  44011. declare module "babylonjs/Cameras/index" {
  44012. export * from "babylonjs/Cameras/Inputs/index";
  44013. export * from "babylonjs/Cameras/cameraInputsManager";
  44014. export * from "babylonjs/Cameras/camera";
  44015. export * from "babylonjs/Cameras/targetCamera";
  44016. export * from "babylonjs/Cameras/freeCamera";
  44017. export * from "babylonjs/Cameras/freeCameraInputsManager";
  44018. export * from "babylonjs/Cameras/touchCamera";
  44019. export * from "babylonjs/Cameras/arcRotateCamera";
  44020. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  44021. export * from "babylonjs/Cameras/deviceOrientationCamera";
  44022. export * from "babylonjs/Cameras/flyCamera";
  44023. export * from "babylonjs/Cameras/flyCameraInputsManager";
  44024. export * from "babylonjs/Cameras/followCamera";
  44025. export * from "babylonjs/Cameras/followCameraInputsManager";
  44026. export * from "babylonjs/Cameras/gamepadCamera";
  44027. export * from "babylonjs/Cameras/Stereoscopic/index";
  44028. export * from "babylonjs/Cameras/universalCamera";
  44029. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  44030. export * from "babylonjs/Cameras/VR/index";
  44031. export * from "babylonjs/Cameras/XR/index";
  44032. export * from "babylonjs/Cameras/RigModes/index";
  44033. }
  44034. declare module "babylonjs/Collisions/index" {
  44035. export * from "babylonjs/Collisions/collider";
  44036. export * from "babylonjs/Collisions/collisionCoordinator";
  44037. export * from "babylonjs/Collisions/pickingInfo";
  44038. export * from "babylonjs/Collisions/intersectionInfo";
  44039. export * from "babylonjs/Collisions/meshCollisionData";
  44040. }
  44041. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  44042. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  44043. import { Vector3 } from "babylonjs/Maths/math.vector";
  44044. import { Ray } from "babylonjs/Culling/ray";
  44045. import { Plane } from "babylonjs/Maths/math.plane";
  44046. /**
  44047. * Contains an array of blocks representing the octree
  44048. */
  44049. export interface IOctreeContainer<T> {
  44050. /**
  44051. * Blocks within the octree
  44052. */
  44053. blocks: Array<OctreeBlock<T>>;
  44054. }
  44055. /**
  44056. * Class used to store a cell in an octree
  44057. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44058. */
  44059. export class OctreeBlock<T> {
  44060. /**
  44061. * Gets the content of the current block
  44062. */
  44063. entries: T[];
  44064. /**
  44065. * Gets the list of block children
  44066. */
  44067. blocks: Array<OctreeBlock<T>>;
  44068. private _depth;
  44069. private _maxDepth;
  44070. private _capacity;
  44071. private _minPoint;
  44072. private _maxPoint;
  44073. private _boundingVectors;
  44074. private _creationFunc;
  44075. /**
  44076. * Creates a new block
  44077. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  44078. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  44079. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44080. * @param depth defines the current depth of this block in the octree
  44081. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  44082. * @param creationFunc defines a callback to call when an element is added to the block
  44083. */
  44084. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  44085. /**
  44086. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44087. */
  44088. readonly capacity: number;
  44089. /**
  44090. * Gets the minimum vector (in world space) of the block's bounding box
  44091. */
  44092. readonly minPoint: Vector3;
  44093. /**
  44094. * Gets the maximum vector (in world space) of the block's bounding box
  44095. */
  44096. readonly maxPoint: Vector3;
  44097. /**
  44098. * Add a new element to this block
  44099. * @param entry defines the element to add
  44100. */
  44101. addEntry(entry: T): void;
  44102. /**
  44103. * Remove an element from this block
  44104. * @param entry defines the element to remove
  44105. */
  44106. removeEntry(entry: T): void;
  44107. /**
  44108. * Add an array of elements to this block
  44109. * @param entries defines the array of elements to add
  44110. */
  44111. addEntries(entries: T[]): void;
  44112. /**
  44113. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  44114. * @param frustumPlanes defines the frustum planes to test
  44115. * @param selection defines the array to store current content if selection is positive
  44116. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44117. */
  44118. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44119. /**
  44120. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  44121. * @param sphereCenter defines the bounding sphere center
  44122. * @param sphereRadius defines the bounding sphere radius
  44123. * @param selection defines the array to store current content if selection is positive
  44124. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44125. */
  44126. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44127. /**
  44128. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  44129. * @param ray defines the ray to test with
  44130. * @param selection defines the array to store current content if selection is positive
  44131. */
  44132. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  44133. /**
  44134. * Subdivide the content into child blocks (this block will then be empty)
  44135. */
  44136. createInnerBlocks(): void;
  44137. /**
  44138. * @hidden
  44139. */
  44140. 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;
  44141. }
  44142. }
  44143. declare module "babylonjs/Culling/Octrees/octree" {
  44144. import { SmartArray } from "babylonjs/Misc/smartArray";
  44145. import { Vector3 } from "babylonjs/Maths/math.vector";
  44146. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44147. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44148. import { Ray } from "babylonjs/Culling/ray";
  44149. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  44150. import { Plane } from "babylonjs/Maths/math.plane";
  44151. /**
  44152. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  44153. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44154. */
  44155. export class Octree<T> {
  44156. /** 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.) */
  44157. maxDepth: number;
  44158. /**
  44159. * Blocks within the octree containing objects
  44160. */
  44161. blocks: Array<OctreeBlock<T>>;
  44162. /**
  44163. * Content stored in the octree
  44164. */
  44165. dynamicContent: T[];
  44166. private _maxBlockCapacity;
  44167. private _selectionContent;
  44168. private _creationFunc;
  44169. /**
  44170. * Creates a octree
  44171. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44172. * @param creationFunc function to be used to instatiate the octree
  44173. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  44174. * @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.)
  44175. */
  44176. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  44177. /** 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.) */
  44178. maxDepth?: number);
  44179. /**
  44180. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  44181. * @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);
  44182. * @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);
  44183. * @param entries meshes to be added to the octree blocks
  44184. */
  44185. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  44186. /**
  44187. * Adds a mesh to the octree
  44188. * @param entry Mesh to add to the octree
  44189. */
  44190. addMesh(entry: T): void;
  44191. /**
  44192. * Remove an element from the octree
  44193. * @param entry defines the element to remove
  44194. */
  44195. removeMesh(entry: T): void;
  44196. /**
  44197. * Selects an array of meshes within the frustum
  44198. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  44199. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  44200. * @returns array of meshes within the frustum
  44201. */
  44202. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  44203. /**
  44204. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  44205. * @param sphereCenter defines the bounding sphere center
  44206. * @param sphereRadius defines the bounding sphere radius
  44207. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44208. * @returns an array of objects that intersect the sphere
  44209. */
  44210. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  44211. /**
  44212. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  44213. * @param ray defines the ray to test with
  44214. * @returns array of intersected objects
  44215. */
  44216. intersectsRay(ray: Ray): SmartArray<T>;
  44217. /**
  44218. * Adds a mesh into the octree block if it intersects the block
  44219. */
  44220. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  44221. /**
  44222. * Adds a submesh into the octree block if it intersects the block
  44223. */
  44224. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  44225. }
  44226. }
  44227. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  44228. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  44229. import { Scene } from "babylonjs/scene";
  44230. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44231. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44232. import { Ray } from "babylonjs/Culling/ray";
  44233. import { Octree } from "babylonjs/Culling/Octrees/octree";
  44234. import { Collider } from "babylonjs/Collisions/collider";
  44235. module "babylonjs/scene" {
  44236. interface Scene {
  44237. /**
  44238. * @hidden
  44239. * Backing Filed
  44240. */
  44241. _selectionOctree: Octree<AbstractMesh>;
  44242. /**
  44243. * Gets the octree used to boost mesh selection (picking)
  44244. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44245. */
  44246. selectionOctree: Octree<AbstractMesh>;
  44247. /**
  44248. * Creates or updates the octree used to boost selection (picking)
  44249. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44250. * @param maxCapacity defines the maximum capacity per leaf
  44251. * @param maxDepth defines the maximum depth of the octree
  44252. * @returns an octree of AbstractMesh
  44253. */
  44254. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  44255. }
  44256. }
  44257. module "babylonjs/Meshes/abstractMesh" {
  44258. interface AbstractMesh {
  44259. /**
  44260. * @hidden
  44261. * Backing Field
  44262. */
  44263. _submeshesOctree: Octree<SubMesh>;
  44264. /**
  44265. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  44266. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  44267. * @param maxCapacity defines the maximum size of each block (64 by default)
  44268. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  44269. * @returns the new octree
  44270. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  44271. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44272. */
  44273. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  44274. }
  44275. }
  44276. /**
  44277. * Defines the octree scene component responsible to manage any octrees
  44278. * in a given scene.
  44279. */
  44280. export class OctreeSceneComponent {
  44281. /**
  44282. * The component name help to identify the component in the list of scene components.
  44283. */
  44284. readonly name: string;
  44285. /**
  44286. * The scene the component belongs to.
  44287. */
  44288. scene: Scene;
  44289. /**
  44290. * Indicates if the meshes have been checked to make sure they are isEnabled()
  44291. */
  44292. readonly checksIsEnabled: boolean;
  44293. /**
  44294. * Creates a new instance of the component for the given scene
  44295. * @param scene Defines the scene to register the component in
  44296. */
  44297. constructor(scene: Scene);
  44298. /**
  44299. * Registers the component in a given scene
  44300. */
  44301. register(): void;
  44302. /**
  44303. * Return the list of active meshes
  44304. * @returns the list of active meshes
  44305. */
  44306. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  44307. /**
  44308. * Return the list of active sub meshes
  44309. * @param mesh The mesh to get the candidates sub meshes from
  44310. * @returns the list of active sub meshes
  44311. */
  44312. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  44313. private _tempRay;
  44314. /**
  44315. * Return the list of sub meshes intersecting with a given local ray
  44316. * @param mesh defines the mesh to find the submesh for
  44317. * @param localRay defines the ray in local space
  44318. * @returns the list of intersecting sub meshes
  44319. */
  44320. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  44321. /**
  44322. * Return the list of sub meshes colliding with a collider
  44323. * @param mesh defines the mesh to find the submesh for
  44324. * @param collider defines the collider to evaluate the collision against
  44325. * @returns the list of colliding sub meshes
  44326. */
  44327. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  44328. /**
  44329. * Rebuilds the elements related to this component in case of
  44330. * context lost for instance.
  44331. */
  44332. rebuild(): void;
  44333. /**
  44334. * Disposes the component and the associated ressources.
  44335. */
  44336. dispose(): void;
  44337. }
  44338. }
  44339. declare module "babylonjs/Culling/Octrees/index" {
  44340. export * from "babylonjs/Culling/Octrees/octree";
  44341. export * from "babylonjs/Culling/Octrees/octreeBlock";
  44342. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  44343. }
  44344. declare module "babylonjs/Culling/index" {
  44345. export * from "babylonjs/Culling/boundingBox";
  44346. export * from "babylonjs/Culling/boundingInfo";
  44347. export * from "babylonjs/Culling/boundingSphere";
  44348. export * from "babylonjs/Culling/Octrees/index";
  44349. export * from "babylonjs/Culling/ray";
  44350. }
  44351. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  44352. import { IDisposable, Scene } from "babylonjs/scene";
  44353. import { Nullable } from "babylonjs/types";
  44354. import { Observable } from "babylonjs/Misc/observable";
  44355. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44356. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  44357. import { Camera } from "babylonjs/Cameras/camera";
  44358. /**
  44359. * Renders a layer on top of an existing scene
  44360. */
  44361. export class UtilityLayerRenderer implements IDisposable {
  44362. /** the original scene that will be rendered on top of */
  44363. originalScene: Scene;
  44364. private _pointerCaptures;
  44365. private _lastPointerEvents;
  44366. private static _DefaultUtilityLayer;
  44367. private static _DefaultKeepDepthUtilityLayer;
  44368. private _sharedGizmoLight;
  44369. private _renderCamera;
  44370. /**
  44371. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44372. * @returns the camera that is used when rendering the utility layer
  44373. */
  44374. getRenderCamera(): Nullable<Camera>;
  44375. /**
  44376. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44377. * @param cam the camera that should be used when rendering the utility layer
  44378. */
  44379. setRenderCamera(cam: Nullable<Camera>): void;
  44380. /**
  44381. * @hidden
  44382. * Light which used by gizmos to get light shading
  44383. */
  44384. _getSharedGizmoLight(): HemisphericLight;
  44385. /**
  44386. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44387. */
  44388. pickUtilitySceneFirst: boolean;
  44389. /**
  44390. * 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)
  44391. */
  44392. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  44393. /**
  44394. * 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)
  44395. */
  44396. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  44397. /**
  44398. * The scene that is rendered on top of the original scene
  44399. */
  44400. utilityLayerScene: Scene;
  44401. /**
  44402. * If the utility layer should automatically be rendered on top of existing scene
  44403. */
  44404. shouldRender: boolean;
  44405. /**
  44406. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44407. */
  44408. onlyCheckPointerDownEvents: boolean;
  44409. /**
  44410. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44411. */
  44412. processAllEvents: boolean;
  44413. /**
  44414. * Observable raised when the pointer move from the utility layer scene to the main scene
  44415. */
  44416. onPointerOutObservable: Observable<number>;
  44417. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44418. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44419. private _afterRenderObserver;
  44420. private _sceneDisposeObserver;
  44421. private _originalPointerObserver;
  44422. /**
  44423. * Instantiates a UtilityLayerRenderer
  44424. * @param originalScene the original scene that will be rendered on top of
  44425. * @param handleEvents boolean indicating if the utility layer should handle events
  44426. */
  44427. constructor(
  44428. /** the original scene that will be rendered on top of */
  44429. originalScene: Scene, handleEvents?: boolean);
  44430. private _notifyObservers;
  44431. /**
  44432. * Renders the utility layers scene on top of the original scene
  44433. */
  44434. render(): void;
  44435. /**
  44436. * Disposes of the renderer
  44437. */
  44438. dispose(): void;
  44439. private _updateCamera;
  44440. }
  44441. }
  44442. declare module "babylonjs/Gizmos/gizmo" {
  44443. import { Nullable } from "babylonjs/types";
  44444. import { IDisposable } from "babylonjs/scene";
  44445. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44446. import { Mesh } from "babylonjs/Meshes/mesh";
  44447. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44448. /**
  44449. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  44450. */
  44451. export class Gizmo implements IDisposable {
  44452. /** The utility layer the gizmo will be added to */
  44453. gizmoLayer: UtilityLayerRenderer;
  44454. /**
  44455. * The root mesh of the gizmo
  44456. */
  44457. _rootMesh: Mesh;
  44458. private _attachedMesh;
  44459. /**
  44460. * Ratio for the scale of the gizmo (Default: 1)
  44461. */
  44462. scaleRatio: number;
  44463. /**
  44464. * If a custom mesh has been set (Default: false)
  44465. */
  44466. protected _customMeshSet: boolean;
  44467. /**
  44468. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  44469. * * When set, interactions will be enabled
  44470. */
  44471. attachedMesh: Nullable<AbstractMesh>;
  44472. /**
  44473. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44474. * @param mesh The mesh to replace the default mesh of the gizmo
  44475. */
  44476. setCustomMesh(mesh: Mesh): void;
  44477. /**
  44478. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  44479. */
  44480. updateGizmoRotationToMatchAttachedMesh: boolean;
  44481. /**
  44482. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  44483. */
  44484. updateGizmoPositionToMatchAttachedMesh: boolean;
  44485. /**
  44486. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  44487. */
  44488. updateScale: boolean;
  44489. protected _interactionsEnabled: boolean;
  44490. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44491. private _beforeRenderObserver;
  44492. private _tempVector;
  44493. /**
  44494. * Creates a gizmo
  44495. * @param gizmoLayer The utility layer the gizmo will be added to
  44496. */
  44497. constructor(
  44498. /** The utility layer the gizmo will be added to */
  44499. gizmoLayer?: UtilityLayerRenderer);
  44500. /**
  44501. * Updates the gizmo to match the attached mesh's position/rotation
  44502. */
  44503. protected _update(): void;
  44504. /**
  44505. * Disposes of the gizmo
  44506. */
  44507. dispose(): void;
  44508. }
  44509. }
  44510. declare module "babylonjs/Gizmos/planeDragGizmo" {
  44511. import { Observable } from "babylonjs/Misc/observable";
  44512. import { Nullable } from "babylonjs/types";
  44513. import { Vector3 } from "babylonjs/Maths/math.vector";
  44514. import { Color3 } from "babylonjs/Maths/math.color";
  44515. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44516. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44517. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44518. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44519. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44520. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44521. import { Scene } from "babylonjs/scene";
  44522. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44523. /**
  44524. * Single plane drag gizmo
  44525. */
  44526. export class PlaneDragGizmo extends Gizmo {
  44527. /**
  44528. * Drag behavior responsible for the gizmos dragging interactions
  44529. */
  44530. dragBehavior: PointerDragBehavior;
  44531. private _pointerObserver;
  44532. /**
  44533. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44534. */
  44535. snapDistance: number;
  44536. /**
  44537. * Event that fires each time the gizmo snaps to a new location.
  44538. * * snapDistance is the the change in distance
  44539. */
  44540. onSnapObservable: Observable<{
  44541. snapDistance: number;
  44542. }>;
  44543. private _plane;
  44544. private _coloredMaterial;
  44545. private _hoverMaterial;
  44546. private _isEnabled;
  44547. private _parent;
  44548. /** @hidden */
  44549. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  44550. /** @hidden */
  44551. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44552. /**
  44553. * Creates a PlaneDragGizmo
  44554. * @param gizmoLayer The utility layer the gizmo will be added to
  44555. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  44556. * @param color The color of the gizmo
  44557. */
  44558. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44559. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44560. /**
  44561. * If the gizmo is enabled
  44562. */
  44563. isEnabled: boolean;
  44564. /**
  44565. * Disposes of the gizmo
  44566. */
  44567. dispose(): void;
  44568. }
  44569. }
  44570. declare module "babylonjs/Gizmos/positionGizmo" {
  44571. import { Observable } from "babylonjs/Misc/observable";
  44572. import { Nullable } from "babylonjs/types";
  44573. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44574. import { Mesh } from "babylonjs/Meshes/mesh";
  44575. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44576. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  44577. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  44578. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44579. /**
  44580. * Gizmo that enables dragging a mesh along 3 axis
  44581. */
  44582. export class PositionGizmo extends Gizmo {
  44583. /**
  44584. * Internal gizmo used for interactions on the x axis
  44585. */
  44586. xGizmo: AxisDragGizmo;
  44587. /**
  44588. * Internal gizmo used for interactions on the y axis
  44589. */
  44590. yGizmo: AxisDragGizmo;
  44591. /**
  44592. * Internal gizmo used for interactions on the z axis
  44593. */
  44594. zGizmo: AxisDragGizmo;
  44595. /**
  44596. * Internal gizmo used for interactions on the yz plane
  44597. */
  44598. xPlaneGizmo: PlaneDragGizmo;
  44599. /**
  44600. * Internal gizmo used for interactions on the xz plane
  44601. */
  44602. yPlaneGizmo: PlaneDragGizmo;
  44603. /**
  44604. * Internal gizmo used for interactions on the xy plane
  44605. */
  44606. zPlaneGizmo: PlaneDragGizmo;
  44607. /**
  44608. * private variables
  44609. */
  44610. private _meshAttached;
  44611. private _updateGizmoRotationToMatchAttachedMesh;
  44612. private _snapDistance;
  44613. private _scaleRatio;
  44614. /** Fires an event when any of it's sub gizmos are dragged */
  44615. onDragStartObservable: Observable<unknown>;
  44616. /** Fires an event when any of it's sub gizmos are released from dragging */
  44617. onDragEndObservable: Observable<unknown>;
  44618. /**
  44619. * If set to true, planar drag is enabled
  44620. */
  44621. private _planarGizmoEnabled;
  44622. attachedMesh: Nullable<AbstractMesh>;
  44623. /**
  44624. * Creates a PositionGizmo
  44625. * @param gizmoLayer The utility layer the gizmo will be added to
  44626. */
  44627. constructor(gizmoLayer?: UtilityLayerRenderer);
  44628. /**
  44629. * If the planar drag gizmo is enabled
  44630. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  44631. */
  44632. planarGizmoEnabled: boolean;
  44633. updateGizmoRotationToMatchAttachedMesh: boolean;
  44634. /**
  44635. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44636. */
  44637. snapDistance: number;
  44638. /**
  44639. * Ratio for the scale of the gizmo (Default: 1)
  44640. */
  44641. scaleRatio: number;
  44642. /**
  44643. * Disposes of the gizmo
  44644. */
  44645. dispose(): void;
  44646. /**
  44647. * CustomMeshes are not supported by this gizmo
  44648. * @param mesh The mesh to replace the default mesh of the gizmo
  44649. */
  44650. setCustomMesh(mesh: Mesh): void;
  44651. }
  44652. }
  44653. declare module "babylonjs/Gizmos/axisDragGizmo" {
  44654. import { Observable } from "babylonjs/Misc/observable";
  44655. import { Nullable } from "babylonjs/types";
  44656. import { Vector3 } from "babylonjs/Maths/math.vector";
  44657. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44658. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44659. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44660. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44661. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44662. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44663. import { Scene } from "babylonjs/scene";
  44664. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44665. import { Color3 } from "babylonjs/Maths/math.color";
  44666. /**
  44667. * Single axis drag gizmo
  44668. */
  44669. export class AxisDragGizmo extends Gizmo {
  44670. /**
  44671. * Drag behavior responsible for the gizmos dragging interactions
  44672. */
  44673. dragBehavior: PointerDragBehavior;
  44674. private _pointerObserver;
  44675. /**
  44676. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44677. */
  44678. snapDistance: number;
  44679. /**
  44680. * Event that fires each time the gizmo snaps to a new location.
  44681. * * snapDistance is the the change in distance
  44682. */
  44683. onSnapObservable: Observable<{
  44684. snapDistance: number;
  44685. }>;
  44686. private _isEnabled;
  44687. private _parent;
  44688. private _arrow;
  44689. private _coloredMaterial;
  44690. private _hoverMaterial;
  44691. /** @hidden */
  44692. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  44693. /** @hidden */
  44694. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44695. /**
  44696. * Creates an AxisDragGizmo
  44697. * @param gizmoLayer The utility layer the gizmo will be added to
  44698. * @param dragAxis The axis which the gizmo will be able to drag on
  44699. * @param color The color of the gizmo
  44700. */
  44701. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44702. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44703. /**
  44704. * If the gizmo is enabled
  44705. */
  44706. isEnabled: boolean;
  44707. /**
  44708. * Disposes of the gizmo
  44709. */
  44710. dispose(): void;
  44711. }
  44712. }
  44713. declare module "babylonjs/Debug/axesViewer" {
  44714. import { Vector3 } from "babylonjs/Maths/math.vector";
  44715. import { Nullable } from "babylonjs/types";
  44716. import { Scene } from "babylonjs/scene";
  44717. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44718. /**
  44719. * The Axes viewer will show 3 axes in a specific point in space
  44720. */
  44721. export class AxesViewer {
  44722. private _xAxis;
  44723. private _yAxis;
  44724. private _zAxis;
  44725. private _scaleLinesFactor;
  44726. private _instanced;
  44727. /**
  44728. * Gets the hosting scene
  44729. */
  44730. scene: Scene;
  44731. /**
  44732. * Gets or sets a number used to scale line length
  44733. */
  44734. scaleLines: number;
  44735. /** Gets the node hierarchy used to render x-axis */
  44736. readonly xAxis: TransformNode;
  44737. /** Gets the node hierarchy used to render y-axis */
  44738. readonly yAxis: TransformNode;
  44739. /** Gets the node hierarchy used to render z-axis */
  44740. readonly zAxis: TransformNode;
  44741. /**
  44742. * Creates a new AxesViewer
  44743. * @param scene defines the hosting scene
  44744. * @param scaleLines defines a number used to scale line length (1 by default)
  44745. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  44746. * @param xAxis defines the node hierarchy used to render the x-axis
  44747. * @param yAxis defines the node hierarchy used to render the y-axis
  44748. * @param zAxis defines the node hierarchy used to render the z-axis
  44749. */
  44750. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  44751. /**
  44752. * Force the viewer to update
  44753. * @param position defines the position of the viewer
  44754. * @param xaxis defines the x axis of the viewer
  44755. * @param yaxis defines the y axis of the viewer
  44756. * @param zaxis defines the z axis of the viewer
  44757. */
  44758. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  44759. /**
  44760. * Creates an instance of this axes viewer.
  44761. * @returns a new axes viewer with instanced meshes
  44762. */
  44763. createInstance(): AxesViewer;
  44764. /** Releases resources */
  44765. dispose(): void;
  44766. private static _SetRenderingGroupId;
  44767. }
  44768. }
  44769. declare module "babylonjs/Debug/boneAxesViewer" {
  44770. import { Nullable } from "babylonjs/types";
  44771. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  44772. import { Vector3 } from "babylonjs/Maths/math.vector";
  44773. import { Mesh } from "babylonjs/Meshes/mesh";
  44774. import { Bone } from "babylonjs/Bones/bone";
  44775. import { Scene } from "babylonjs/scene";
  44776. /**
  44777. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  44778. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  44779. */
  44780. export class BoneAxesViewer extends AxesViewer {
  44781. /**
  44782. * Gets or sets the target mesh where to display the axes viewer
  44783. */
  44784. mesh: Nullable<Mesh>;
  44785. /**
  44786. * Gets or sets the target bone where to display the axes viewer
  44787. */
  44788. bone: Nullable<Bone>;
  44789. /** Gets current position */
  44790. pos: Vector3;
  44791. /** Gets direction of X axis */
  44792. xaxis: Vector3;
  44793. /** Gets direction of Y axis */
  44794. yaxis: Vector3;
  44795. /** Gets direction of Z axis */
  44796. zaxis: Vector3;
  44797. /**
  44798. * Creates a new BoneAxesViewer
  44799. * @param scene defines the hosting scene
  44800. * @param bone defines the target bone
  44801. * @param mesh defines the target mesh
  44802. * @param scaleLines defines a scaling factor for line length (1 by default)
  44803. */
  44804. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  44805. /**
  44806. * Force the viewer to update
  44807. */
  44808. update(): void;
  44809. /** Releases resources */
  44810. dispose(): void;
  44811. }
  44812. }
  44813. declare module "babylonjs/Debug/debugLayer" {
  44814. import { Scene } from "babylonjs/scene";
  44815. /**
  44816. * Interface used to define scene explorer extensibility option
  44817. */
  44818. export interface IExplorerExtensibilityOption {
  44819. /**
  44820. * Define the option label
  44821. */
  44822. label: string;
  44823. /**
  44824. * Defines the action to execute on click
  44825. */
  44826. action: (entity: any) => void;
  44827. }
  44828. /**
  44829. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  44830. */
  44831. export interface IExplorerExtensibilityGroup {
  44832. /**
  44833. * Defines a predicate to test if a given type mut be extended
  44834. */
  44835. predicate: (entity: any) => boolean;
  44836. /**
  44837. * Gets the list of options added to a type
  44838. */
  44839. entries: IExplorerExtensibilityOption[];
  44840. }
  44841. /**
  44842. * Interface used to define the options to use to create the Inspector
  44843. */
  44844. export interface IInspectorOptions {
  44845. /**
  44846. * Display in overlay mode (default: false)
  44847. */
  44848. overlay?: boolean;
  44849. /**
  44850. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  44851. */
  44852. globalRoot?: HTMLElement;
  44853. /**
  44854. * Display the Scene explorer
  44855. */
  44856. showExplorer?: boolean;
  44857. /**
  44858. * Display the property inspector
  44859. */
  44860. showInspector?: boolean;
  44861. /**
  44862. * Display in embed mode (both panes on the right)
  44863. */
  44864. embedMode?: boolean;
  44865. /**
  44866. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  44867. */
  44868. handleResize?: boolean;
  44869. /**
  44870. * Allow the panes to popup (default: true)
  44871. */
  44872. enablePopup?: boolean;
  44873. /**
  44874. * Allow the panes to be closed by users (default: true)
  44875. */
  44876. enableClose?: boolean;
  44877. /**
  44878. * Optional list of extensibility entries
  44879. */
  44880. explorerExtensibility?: IExplorerExtensibilityGroup[];
  44881. /**
  44882. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  44883. */
  44884. inspectorURL?: string;
  44885. }
  44886. module "babylonjs/scene" {
  44887. interface Scene {
  44888. /**
  44889. * @hidden
  44890. * Backing field
  44891. */
  44892. _debugLayer: DebugLayer;
  44893. /**
  44894. * Gets the debug layer (aka Inspector) associated with the scene
  44895. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44896. */
  44897. debugLayer: DebugLayer;
  44898. }
  44899. }
  44900. /**
  44901. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44902. * what is happening in your scene
  44903. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44904. */
  44905. export class DebugLayer {
  44906. /**
  44907. * Define the url to get the inspector script from.
  44908. * By default it uses the babylonjs CDN.
  44909. * @ignoreNaming
  44910. */
  44911. static InspectorURL: string;
  44912. private _scene;
  44913. private BJSINSPECTOR;
  44914. private _onPropertyChangedObservable?;
  44915. /**
  44916. * Observable triggered when a property is changed through the inspector.
  44917. */
  44918. readonly onPropertyChangedObservable: any;
  44919. /**
  44920. * Instantiates a new debug layer.
  44921. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44922. * what is happening in your scene
  44923. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44924. * @param scene Defines the scene to inspect
  44925. */
  44926. constructor(scene: Scene);
  44927. /** Creates the inspector window. */
  44928. private _createInspector;
  44929. /**
  44930. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  44931. * @param entity defines the entity to select
  44932. * @param lineContainerTitle defines the specific block to highlight
  44933. */
  44934. select(entity: any, lineContainerTitle?: string): void;
  44935. /** Get the inspector from bundle or global */
  44936. private _getGlobalInspector;
  44937. /**
  44938. * Get if the inspector is visible or not.
  44939. * @returns true if visible otherwise, false
  44940. */
  44941. isVisible(): boolean;
  44942. /**
  44943. * Hide the inspector and close its window.
  44944. */
  44945. hide(): void;
  44946. /**
  44947. * Launch the debugLayer.
  44948. * @param config Define the configuration of the inspector
  44949. * @return a promise fulfilled when the debug layer is visible
  44950. */
  44951. show(config?: IInspectorOptions): Promise<DebugLayer>;
  44952. }
  44953. }
  44954. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  44955. import { Nullable } from "babylonjs/types";
  44956. import { Scene } from "babylonjs/scene";
  44957. import { Vector4 } from "babylonjs/Maths/math.vector";
  44958. import { Color4 } from "babylonjs/Maths/math.color";
  44959. import { Mesh } from "babylonjs/Meshes/mesh";
  44960. /**
  44961. * Class containing static functions to help procedurally build meshes
  44962. */
  44963. export class BoxBuilder {
  44964. /**
  44965. * Creates a box mesh
  44966. * * The parameter `size` sets the size (float) of each box side (default 1)
  44967. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  44968. * * 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)
  44969. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  44970. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44971. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44972. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44973. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  44974. * @param name defines the name of the mesh
  44975. * @param options defines the options used to create the mesh
  44976. * @param scene defines the hosting scene
  44977. * @returns the box mesh
  44978. */
  44979. static CreateBox(name: string, options: {
  44980. size?: number;
  44981. width?: number;
  44982. height?: number;
  44983. depth?: number;
  44984. faceUV?: Vector4[];
  44985. faceColors?: Color4[];
  44986. sideOrientation?: number;
  44987. frontUVs?: Vector4;
  44988. backUVs?: Vector4;
  44989. wrap?: boolean;
  44990. topBaseAt?: number;
  44991. bottomBaseAt?: number;
  44992. updatable?: boolean;
  44993. }, scene?: Nullable<Scene>): Mesh;
  44994. }
  44995. }
  44996. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  44997. import { Vector4 } from "babylonjs/Maths/math.vector";
  44998. import { Mesh } from "babylonjs/Meshes/mesh";
  44999. import { Scene } from "babylonjs/scene";
  45000. import { Nullable } from "babylonjs/types";
  45001. /**
  45002. * Class containing static functions to help procedurally build meshes
  45003. */
  45004. export class SphereBuilder {
  45005. /**
  45006. * Creates a sphere mesh
  45007. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  45008. * * 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`)
  45009. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  45010. * * 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
  45011. * * 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)
  45012. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45013. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45014. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45015. * @param name defines the name of the mesh
  45016. * @param options defines the options used to create the mesh
  45017. * @param scene defines the hosting scene
  45018. * @returns the sphere mesh
  45019. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  45020. */
  45021. static CreateSphere(name: string, options: {
  45022. segments?: number;
  45023. diameter?: number;
  45024. diameterX?: number;
  45025. diameterY?: number;
  45026. diameterZ?: number;
  45027. arc?: number;
  45028. slice?: number;
  45029. sideOrientation?: number;
  45030. frontUVs?: Vector4;
  45031. backUVs?: Vector4;
  45032. updatable?: boolean;
  45033. }, scene?: Nullable<Scene>): Mesh;
  45034. }
  45035. }
  45036. declare module "babylonjs/Debug/physicsViewer" {
  45037. import { Nullable } from "babylonjs/types";
  45038. import { Scene } from "babylonjs/scene";
  45039. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45040. import { Mesh } from "babylonjs/Meshes/mesh";
  45041. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  45042. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  45043. /**
  45044. * Used to show the physics impostor around the specific mesh
  45045. */
  45046. export class PhysicsViewer {
  45047. /** @hidden */
  45048. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  45049. /** @hidden */
  45050. protected _meshes: Array<Nullable<AbstractMesh>>;
  45051. /** @hidden */
  45052. protected _scene: Nullable<Scene>;
  45053. /** @hidden */
  45054. protected _numMeshes: number;
  45055. /** @hidden */
  45056. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  45057. private _renderFunction;
  45058. private _utilityLayer;
  45059. private _debugBoxMesh;
  45060. private _debugSphereMesh;
  45061. private _debugCylinderMesh;
  45062. private _debugMaterial;
  45063. private _debugMeshMeshes;
  45064. /**
  45065. * Creates a new PhysicsViewer
  45066. * @param scene defines the hosting scene
  45067. */
  45068. constructor(scene: Scene);
  45069. /** @hidden */
  45070. protected _updateDebugMeshes(): void;
  45071. /**
  45072. * Renders a specified physic impostor
  45073. * @param impostor defines the impostor to render
  45074. * @param targetMesh defines the mesh represented by the impostor
  45075. * @returns the new debug mesh used to render the impostor
  45076. */
  45077. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  45078. /**
  45079. * Hides a specified physic impostor
  45080. * @param impostor defines the impostor to hide
  45081. */
  45082. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  45083. private _getDebugMaterial;
  45084. private _getDebugBoxMesh;
  45085. private _getDebugSphereMesh;
  45086. private _getDebugCylinderMesh;
  45087. private _getDebugMeshMesh;
  45088. private _getDebugMesh;
  45089. /** Releases all resources */
  45090. dispose(): void;
  45091. }
  45092. }
  45093. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  45094. import { Vector3 } from "babylonjs/Maths/math.vector";
  45095. import { Color4 } from "babylonjs/Maths/math.color";
  45096. import { Nullable } from "babylonjs/types";
  45097. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  45098. import { Scene } from "babylonjs/scene";
  45099. /**
  45100. * Class containing static functions to help procedurally build meshes
  45101. */
  45102. export class LinesBuilder {
  45103. /**
  45104. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  45105. * * 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
  45106. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  45107. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  45108. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  45109. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  45110. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45111. * * 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
  45112. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  45113. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45114. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  45115. * @param name defines the name of the new line system
  45116. * @param options defines the options used to create the line system
  45117. * @param scene defines the hosting scene
  45118. * @returns a new line system mesh
  45119. */
  45120. static CreateLineSystem(name: string, options: {
  45121. lines: Vector3[][];
  45122. updatable?: boolean;
  45123. instance?: Nullable<LinesMesh>;
  45124. colors?: Nullable<Color4[][]>;
  45125. useVertexAlpha?: boolean;
  45126. }, scene: Nullable<Scene>): LinesMesh;
  45127. /**
  45128. * Creates a line mesh
  45129. * 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
  45130. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45131. * * The parameter `points` is an array successive Vector3
  45132. * * 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
  45133. * * The optional parameter `colors` is an array of successive Color4, one per line point
  45134. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  45135. * * When updating an instance, remember that only point positions can change, not the number of points
  45136. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45137. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  45138. * @param name defines the name of the new line system
  45139. * @param options defines the options used to create the line system
  45140. * @param scene defines the hosting scene
  45141. * @returns a new line mesh
  45142. */
  45143. static CreateLines(name: string, options: {
  45144. points: Vector3[];
  45145. updatable?: boolean;
  45146. instance?: Nullable<LinesMesh>;
  45147. colors?: Color4[];
  45148. useVertexAlpha?: boolean;
  45149. }, scene?: Nullable<Scene>): LinesMesh;
  45150. /**
  45151. * Creates a dashed line mesh
  45152. * * 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
  45153. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45154. * * The parameter `points` is an array successive Vector3
  45155. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  45156. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  45157. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  45158. * * 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
  45159. * * When updating an instance, remember that only point positions can change, not the number of points
  45160. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45161. * @param name defines the name of the mesh
  45162. * @param options defines the options used to create the mesh
  45163. * @param scene defines the hosting scene
  45164. * @returns the dashed line mesh
  45165. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  45166. */
  45167. static CreateDashedLines(name: string, options: {
  45168. points: Vector3[];
  45169. dashSize?: number;
  45170. gapSize?: number;
  45171. dashNb?: number;
  45172. updatable?: boolean;
  45173. instance?: LinesMesh;
  45174. }, scene?: Nullable<Scene>): LinesMesh;
  45175. }
  45176. }
  45177. declare module "babylonjs/Debug/rayHelper" {
  45178. import { Nullable } from "babylonjs/types";
  45179. import { Ray } from "babylonjs/Culling/ray";
  45180. import { Vector3 } from "babylonjs/Maths/math.vector";
  45181. import { Color3 } from "babylonjs/Maths/math.color";
  45182. import { Scene } from "babylonjs/scene";
  45183. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45184. import "babylonjs/Meshes/Builders/linesBuilder";
  45185. /**
  45186. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45187. * in order to better appreciate the issue one might have.
  45188. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45189. */
  45190. export class RayHelper {
  45191. /**
  45192. * Defines the ray we are currently tryin to visualize.
  45193. */
  45194. ray: Nullable<Ray>;
  45195. private _renderPoints;
  45196. private _renderLine;
  45197. private _renderFunction;
  45198. private _scene;
  45199. private _updateToMeshFunction;
  45200. private _attachedToMesh;
  45201. private _meshSpaceDirection;
  45202. private _meshSpaceOrigin;
  45203. /**
  45204. * Helper function to create a colored helper in a scene in one line.
  45205. * @param ray Defines the ray we are currently tryin to visualize
  45206. * @param scene Defines the scene the ray is used in
  45207. * @param color Defines the color we want to see the ray in
  45208. * @returns The newly created ray helper.
  45209. */
  45210. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  45211. /**
  45212. * Instantiate a new ray helper.
  45213. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45214. * in order to better appreciate the issue one might have.
  45215. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45216. * @param ray Defines the ray we are currently tryin to visualize
  45217. */
  45218. constructor(ray: Ray);
  45219. /**
  45220. * Shows the ray we are willing to debug.
  45221. * @param scene Defines the scene the ray needs to be rendered in
  45222. * @param color Defines the color the ray needs to be rendered in
  45223. */
  45224. show(scene: Scene, color?: Color3): void;
  45225. /**
  45226. * Hides the ray we are debugging.
  45227. */
  45228. hide(): void;
  45229. private _render;
  45230. /**
  45231. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  45232. * @param mesh Defines the mesh we want the helper attached to
  45233. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  45234. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  45235. * @param length Defines the length of the ray
  45236. */
  45237. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  45238. /**
  45239. * Detach the ray helper from the mesh it has previously been attached to.
  45240. */
  45241. detachFromMesh(): void;
  45242. private _updateToMesh;
  45243. /**
  45244. * Dispose the helper and release its associated resources.
  45245. */
  45246. dispose(): void;
  45247. }
  45248. }
  45249. declare module "babylonjs/Debug/skeletonViewer" {
  45250. import { Color3 } from "babylonjs/Maths/math.color";
  45251. import { Scene } from "babylonjs/scene";
  45252. import { Nullable } from "babylonjs/types";
  45253. import { Skeleton } from "babylonjs/Bones/skeleton";
  45254. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45255. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  45256. /**
  45257. * Class used to render a debug view of a given skeleton
  45258. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  45259. */
  45260. export class SkeletonViewer {
  45261. /** defines the skeleton to render */
  45262. skeleton: Skeleton;
  45263. /** defines the mesh attached to the skeleton */
  45264. mesh: AbstractMesh;
  45265. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45266. autoUpdateBonesMatrices: boolean;
  45267. /** defines the rendering group id to use with the viewer */
  45268. renderingGroupId: number;
  45269. /** Gets or sets the color used to render the skeleton */
  45270. color: Color3;
  45271. private _scene;
  45272. private _debugLines;
  45273. private _debugMesh;
  45274. private _isEnabled;
  45275. private _renderFunction;
  45276. private _utilityLayer;
  45277. /**
  45278. * Returns the mesh used to render the bones
  45279. */
  45280. readonly debugMesh: Nullable<LinesMesh>;
  45281. /**
  45282. * Creates a new SkeletonViewer
  45283. * @param skeleton defines the skeleton to render
  45284. * @param mesh defines the mesh attached to the skeleton
  45285. * @param scene defines the hosting scene
  45286. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  45287. * @param renderingGroupId defines the rendering group id to use with the viewer
  45288. */
  45289. constructor(
  45290. /** defines the skeleton to render */
  45291. skeleton: Skeleton,
  45292. /** defines the mesh attached to the skeleton */
  45293. mesh: AbstractMesh, scene: Scene,
  45294. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45295. autoUpdateBonesMatrices?: boolean,
  45296. /** defines the rendering group id to use with the viewer */
  45297. renderingGroupId?: number);
  45298. /** Gets or sets a boolean indicating if the viewer is enabled */
  45299. isEnabled: boolean;
  45300. private _getBonePosition;
  45301. private _getLinesForBonesWithLength;
  45302. private _getLinesForBonesNoLength;
  45303. /** Update the viewer to sync with current skeleton state */
  45304. update(): void;
  45305. /** Release associated resources */
  45306. dispose(): void;
  45307. }
  45308. }
  45309. declare module "babylonjs/Debug/index" {
  45310. export * from "babylonjs/Debug/axesViewer";
  45311. export * from "babylonjs/Debug/boneAxesViewer";
  45312. export * from "babylonjs/Debug/debugLayer";
  45313. export * from "babylonjs/Debug/physicsViewer";
  45314. export * from "babylonjs/Debug/rayHelper";
  45315. export * from "babylonjs/Debug/skeletonViewer";
  45316. }
  45317. declare module "babylonjs/Engines/nullEngine" {
  45318. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  45319. import { Scene } from "babylonjs/scene";
  45320. import { Engine } from "babylonjs/Engines/engine";
  45321. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  45322. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  45323. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45324. import { Effect } from "babylonjs/Materials/effect";
  45325. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  45326. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45327. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  45328. /**
  45329. * Options to create the null engine
  45330. */
  45331. export class NullEngineOptions {
  45332. /**
  45333. * Render width (Default: 512)
  45334. */
  45335. renderWidth: number;
  45336. /**
  45337. * Render height (Default: 256)
  45338. */
  45339. renderHeight: number;
  45340. /**
  45341. * Texture size (Default: 512)
  45342. */
  45343. textureSize: number;
  45344. /**
  45345. * If delta time between frames should be constant
  45346. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45347. */
  45348. deterministicLockstep: boolean;
  45349. /**
  45350. * Maximum about of steps between frames (Default: 4)
  45351. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45352. */
  45353. lockstepMaxSteps: number;
  45354. }
  45355. /**
  45356. * The null engine class provides support for headless version of babylon.js.
  45357. * This can be used in server side scenario or for testing purposes
  45358. */
  45359. export class NullEngine extends Engine {
  45360. private _options;
  45361. /**
  45362. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  45363. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45364. * @returns true if engine is in deterministic lock step mode
  45365. */
  45366. isDeterministicLockStep(): boolean;
  45367. /**
  45368. * Gets the max steps when engine is running in deterministic lock step
  45369. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45370. * @returns the max steps
  45371. */
  45372. getLockstepMaxSteps(): number;
  45373. /**
  45374. * Gets the current hardware scaling level.
  45375. * By default the hardware scaling level is computed from the window device ratio.
  45376. * 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.
  45377. * @returns a number indicating the current hardware scaling level
  45378. */
  45379. getHardwareScalingLevel(): number;
  45380. constructor(options?: NullEngineOptions);
  45381. /**
  45382. * Creates a vertex buffer
  45383. * @param vertices the data for the vertex buffer
  45384. * @returns the new WebGL static buffer
  45385. */
  45386. createVertexBuffer(vertices: FloatArray): DataBuffer;
  45387. /**
  45388. * Creates a new index buffer
  45389. * @param indices defines the content of the index buffer
  45390. * @param updatable defines if the index buffer must be updatable
  45391. * @returns a new webGL buffer
  45392. */
  45393. createIndexBuffer(indices: IndicesArray): DataBuffer;
  45394. /**
  45395. * Clear the current render buffer or the current render target (if any is set up)
  45396. * @param color defines the color to use
  45397. * @param backBuffer defines if the back buffer must be cleared
  45398. * @param depth defines if the depth buffer must be cleared
  45399. * @param stencil defines if the stencil buffer must be cleared
  45400. */
  45401. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45402. /**
  45403. * Gets the current render width
  45404. * @param useScreen defines if screen size must be used (or the current render target if any)
  45405. * @returns a number defining the current render width
  45406. */
  45407. getRenderWidth(useScreen?: boolean): number;
  45408. /**
  45409. * Gets the current render height
  45410. * @param useScreen defines if screen size must be used (or the current render target if any)
  45411. * @returns a number defining the current render height
  45412. */
  45413. getRenderHeight(useScreen?: boolean): number;
  45414. /**
  45415. * Set the WebGL's viewport
  45416. * @param viewport defines the viewport element to be used
  45417. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  45418. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  45419. */
  45420. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  45421. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  45422. /**
  45423. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  45424. * @param pipelineContext defines the pipeline context to use
  45425. * @param uniformsNames defines the list of uniform names
  45426. * @returns an array of webGL uniform locations
  45427. */
  45428. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  45429. /**
  45430. * Gets the lsit of active attributes for a given webGL program
  45431. * @param pipelineContext defines the pipeline context to use
  45432. * @param attributesNames defines the list of attribute names to get
  45433. * @returns an array of indices indicating the offset of each attribute
  45434. */
  45435. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45436. /**
  45437. * Binds an effect to the webGL context
  45438. * @param effect defines the effect to bind
  45439. */
  45440. bindSamplers(effect: Effect): void;
  45441. /**
  45442. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  45443. * @param effect defines the effect to activate
  45444. */
  45445. enableEffect(effect: Effect): void;
  45446. /**
  45447. * Set various states to the webGL context
  45448. * @param culling defines backface culling state
  45449. * @param zOffset defines the value to apply to zOffset (0 by default)
  45450. * @param force defines if states must be applied even if cache is up to date
  45451. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  45452. */
  45453. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45454. /**
  45455. * Set the value of an uniform to an array of int32
  45456. * @param uniform defines the webGL uniform location where to store the value
  45457. * @param array defines the array of int32 to store
  45458. */
  45459. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  45460. /**
  45461. * Set the value of an uniform to an array of int32 (stored as vec2)
  45462. * @param uniform defines the webGL uniform location where to store the value
  45463. * @param array defines the array of int32 to store
  45464. */
  45465. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  45466. /**
  45467. * Set the value of an uniform to an array of int32 (stored as vec3)
  45468. * @param uniform defines the webGL uniform location where to store the value
  45469. * @param array defines the array of int32 to store
  45470. */
  45471. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  45472. /**
  45473. * Set the value of an uniform to an array of int32 (stored as vec4)
  45474. * @param uniform defines the webGL uniform location where to store the value
  45475. * @param array defines the array of int32 to store
  45476. */
  45477. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  45478. /**
  45479. * Set the value of an uniform to an array of float32
  45480. * @param uniform defines the webGL uniform location where to store the value
  45481. * @param array defines the array of float32 to store
  45482. */
  45483. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  45484. /**
  45485. * Set the value of an uniform to an array of float32 (stored as vec2)
  45486. * @param uniform defines the webGL uniform location where to store the value
  45487. * @param array defines the array of float32 to store
  45488. */
  45489. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  45490. /**
  45491. * Set the value of an uniform to an array of float32 (stored as vec3)
  45492. * @param uniform defines the webGL uniform location where to store the value
  45493. * @param array defines the array of float32 to store
  45494. */
  45495. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  45496. /**
  45497. * Set the value of an uniform to an array of float32 (stored as vec4)
  45498. * @param uniform defines the webGL uniform location where to store the value
  45499. * @param array defines the array of float32 to store
  45500. */
  45501. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  45502. /**
  45503. * Set the value of an uniform to an array of number
  45504. * @param uniform defines the webGL uniform location where to store the value
  45505. * @param array defines the array of number to store
  45506. */
  45507. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  45508. /**
  45509. * Set the value of an uniform to an array of number (stored as vec2)
  45510. * @param uniform defines the webGL uniform location where to store the value
  45511. * @param array defines the array of number to store
  45512. */
  45513. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  45514. /**
  45515. * Set the value of an uniform to an array of number (stored as vec3)
  45516. * @param uniform defines the webGL uniform location where to store the value
  45517. * @param array defines the array of number to store
  45518. */
  45519. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  45520. /**
  45521. * Set the value of an uniform to an array of number (stored as vec4)
  45522. * @param uniform defines the webGL uniform location where to store the value
  45523. * @param array defines the array of number to store
  45524. */
  45525. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  45526. /**
  45527. * Set the value of an uniform to an array of float32 (stored as matrices)
  45528. * @param uniform defines the webGL uniform location where to store the value
  45529. * @param matrices defines the array of float32 to store
  45530. */
  45531. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  45532. /**
  45533. * Set the value of an uniform to a matrix (3x3)
  45534. * @param uniform defines the webGL uniform location where to store the value
  45535. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  45536. */
  45537. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45538. /**
  45539. * Set the value of an uniform to a matrix (2x2)
  45540. * @param uniform defines the webGL uniform location where to store the value
  45541. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  45542. */
  45543. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45544. /**
  45545. * Set the value of an uniform to a number (float)
  45546. * @param uniform defines the webGL uniform location where to store the value
  45547. * @param value defines the float number to store
  45548. */
  45549. setFloat(uniform: WebGLUniformLocation, value: number): void;
  45550. /**
  45551. * Set the value of an uniform to a vec2
  45552. * @param uniform defines the webGL uniform location where to store the value
  45553. * @param x defines the 1st component of the value
  45554. * @param y defines the 2nd component of the value
  45555. */
  45556. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  45557. /**
  45558. * Set the value of an uniform to a vec3
  45559. * @param uniform defines the webGL uniform location where to store the value
  45560. * @param x defines the 1st component of the value
  45561. * @param y defines the 2nd component of the value
  45562. * @param z defines the 3rd component of the value
  45563. */
  45564. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  45565. /**
  45566. * Set the value of an uniform to a boolean
  45567. * @param uniform defines the webGL uniform location where to store the value
  45568. * @param bool defines the boolean to store
  45569. */
  45570. setBool(uniform: WebGLUniformLocation, bool: number): void;
  45571. /**
  45572. * Set the value of an uniform to a vec4
  45573. * @param uniform defines the webGL uniform location where to store the value
  45574. * @param x defines the 1st component of the value
  45575. * @param y defines the 2nd component of the value
  45576. * @param z defines the 3rd component of the value
  45577. * @param w defines the 4th component of the value
  45578. */
  45579. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  45580. /**
  45581. * Sets the current alpha mode
  45582. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  45583. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  45584. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45585. */
  45586. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45587. /**
  45588. * Bind webGl buffers directly to the webGL context
  45589. * @param vertexBuffers defines the vertex buffer to bind
  45590. * @param indexBuffer defines the index buffer to bind
  45591. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  45592. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  45593. * @param effect defines the effect associated with the vertex buffer
  45594. */
  45595. bindBuffers(vertexBuffers: {
  45596. [key: string]: VertexBuffer;
  45597. }, indexBuffer: DataBuffer, effect: Effect): void;
  45598. /**
  45599. * Force the entire cache to be cleared
  45600. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  45601. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  45602. */
  45603. wipeCaches(bruteForce?: boolean): void;
  45604. /**
  45605. * Send a draw order
  45606. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  45607. * @param indexStart defines the starting index
  45608. * @param indexCount defines the number of index to draw
  45609. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45610. */
  45611. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  45612. /**
  45613. * Draw a list of indexed primitives
  45614. * @param fillMode defines the primitive to use
  45615. * @param indexStart defines the starting index
  45616. * @param indexCount defines the number of index to draw
  45617. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45618. */
  45619. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  45620. /**
  45621. * Draw a list of unindexed primitives
  45622. * @param fillMode defines the primitive to use
  45623. * @param verticesStart defines the index of first vertex to draw
  45624. * @param verticesCount defines the count of vertices to draw
  45625. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45626. */
  45627. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  45628. /** @hidden */
  45629. _createTexture(): WebGLTexture;
  45630. /** @hidden */
  45631. _releaseTexture(texture: InternalTexture): void;
  45632. /**
  45633. * Usually called from Texture.ts.
  45634. * Passed information to create a WebGLTexture
  45635. * @param urlArg defines a value which contains one of the following:
  45636. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  45637. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  45638. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  45639. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  45640. * @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)
  45641. * @param scene needed for loading to the correct scene
  45642. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  45643. * @param onLoad optional callback to be called upon successful completion
  45644. * @param onError optional callback to be called upon failure
  45645. * @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
  45646. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  45647. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  45648. * @param forcedExtension defines the extension to use to pick the right loader
  45649. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  45650. * @returns a InternalTexture for assignment back into BABYLON.Texture
  45651. */
  45652. 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;
  45653. /**
  45654. * Creates a new render target texture
  45655. * @param size defines the size of the texture
  45656. * @param options defines the options used to create the texture
  45657. * @returns a new render target texture stored in an InternalTexture
  45658. */
  45659. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  45660. /**
  45661. * Update the sampling mode of a given texture
  45662. * @param samplingMode defines the required sampling mode
  45663. * @param texture defines the texture to update
  45664. */
  45665. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  45666. /**
  45667. * Binds the frame buffer to the specified texture.
  45668. * @param texture The texture to render to or null for the default canvas
  45669. * @param faceIndex The face of the texture to render to in case of cube texture
  45670. * @param requiredWidth The width of the target to render to
  45671. * @param requiredHeight The height of the target to render to
  45672. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  45673. * @param depthStencilTexture The depth stencil texture to use to render
  45674. * @param lodLevel defines le lod level to bind to the frame buffer
  45675. */
  45676. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  45677. /**
  45678. * Unbind the current render target texture from the webGL context
  45679. * @param texture defines the render target texture to unbind
  45680. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45681. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45682. */
  45683. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45684. /**
  45685. * Creates a dynamic vertex buffer
  45686. * @param vertices the data for the dynamic vertex buffer
  45687. * @returns the new WebGL dynamic buffer
  45688. */
  45689. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  45690. /**
  45691. * Update the content of a dynamic texture
  45692. * @param texture defines the texture to update
  45693. * @param canvas defines the canvas containing the source
  45694. * @param invertY defines if data must be stored with Y axis inverted
  45695. * @param premulAlpha defines if alpha is stored as premultiplied
  45696. * @param format defines the format of the data
  45697. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  45698. */
  45699. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  45700. /**
  45701. * Gets a boolean indicating if all created effects are ready
  45702. * @returns true if all effects are ready
  45703. */
  45704. areAllEffectsReady(): boolean;
  45705. /**
  45706. * @hidden
  45707. * Get the current error code of the webGL context
  45708. * @returns the error code
  45709. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  45710. */
  45711. getError(): number;
  45712. /** @hidden */
  45713. _getUnpackAlignement(): number;
  45714. /** @hidden */
  45715. _unpackFlipY(value: boolean): void;
  45716. /**
  45717. * Update a dynamic index buffer
  45718. * @param indexBuffer defines the target index buffer
  45719. * @param indices defines the data to update
  45720. * @param offset defines the offset in the target index buffer where update should start
  45721. */
  45722. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  45723. /**
  45724. * Updates a dynamic vertex buffer.
  45725. * @param vertexBuffer the vertex buffer to update
  45726. * @param vertices the data used to update the vertex buffer
  45727. * @param byteOffset the byte offset of the data (optional)
  45728. * @param byteLength the byte length of the data (optional)
  45729. */
  45730. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  45731. /** @hidden */
  45732. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  45733. /** @hidden */
  45734. _bindTexture(channel: number, texture: InternalTexture): void;
  45735. protected _deleteBuffer(buffer: WebGLBuffer): void;
  45736. /**
  45737. * 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
  45738. */
  45739. releaseEffects(): void;
  45740. displayLoadingUI(): void;
  45741. hideLoadingUI(): void;
  45742. /** @hidden */
  45743. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45744. /** @hidden */
  45745. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45746. /** @hidden */
  45747. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45748. /** @hidden */
  45749. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  45750. }
  45751. }
  45752. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  45753. import { Nullable, int } from "babylonjs/types";
  45754. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  45755. /** @hidden */
  45756. export class _OcclusionDataStorage {
  45757. /** @hidden */
  45758. occlusionInternalRetryCounter: number;
  45759. /** @hidden */
  45760. isOcclusionQueryInProgress: boolean;
  45761. /** @hidden */
  45762. isOccluded: boolean;
  45763. /** @hidden */
  45764. occlusionRetryCount: number;
  45765. /** @hidden */
  45766. occlusionType: number;
  45767. /** @hidden */
  45768. occlusionQueryAlgorithmType: number;
  45769. }
  45770. module "babylonjs/Engines/engine" {
  45771. interface Engine {
  45772. /**
  45773. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  45774. * @return the new query
  45775. */
  45776. createQuery(): WebGLQuery;
  45777. /**
  45778. * Delete and release a webGL query
  45779. * @param query defines the query to delete
  45780. * @return the current engine
  45781. */
  45782. deleteQuery(query: WebGLQuery): Engine;
  45783. /**
  45784. * Check if a given query has resolved and got its value
  45785. * @param query defines the query to check
  45786. * @returns true if the query got its value
  45787. */
  45788. isQueryResultAvailable(query: WebGLQuery): boolean;
  45789. /**
  45790. * Gets the value of a given query
  45791. * @param query defines the query to check
  45792. * @returns the value of the query
  45793. */
  45794. getQueryResult(query: WebGLQuery): number;
  45795. /**
  45796. * Initiates an occlusion query
  45797. * @param algorithmType defines the algorithm to use
  45798. * @param query defines the query to use
  45799. * @returns the current engine
  45800. * @see http://doc.babylonjs.com/features/occlusionquery
  45801. */
  45802. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  45803. /**
  45804. * Ends an occlusion query
  45805. * @see http://doc.babylonjs.com/features/occlusionquery
  45806. * @param algorithmType defines the algorithm to use
  45807. * @returns the current engine
  45808. */
  45809. endOcclusionQuery(algorithmType: number): Engine;
  45810. /**
  45811. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  45812. * Please note that only one query can be issued at a time
  45813. * @returns a time token used to track the time span
  45814. */
  45815. startTimeQuery(): Nullable<_TimeToken>;
  45816. /**
  45817. * Ends a time query
  45818. * @param token defines the token used to measure the time span
  45819. * @returns the time spent (in ns)
  45820. */
  45821. endTimeQuery(token: _TimeToken): int;
  45822. /** @hidden */
  45823. _currentNonTimestampToken: Nullable<_TimeToken>;
  45824. /** @hidden */
  45825. _createTimeQuery(): WebGLQuery;
  45826. /** @hidden */
  45827. _deleteTimeQuery(query: WebGLQuery): void;
  45828. /** @hidden */
  45829. _getGlAlgorithmType(algorithmType: number): number;
  45830. /** @hidden */
  45831. _getTimeQueryResult(query: WebGLQuery): any;
  45832. /** @hidden */
  45833. _getTimeQueryAvailability(query: WebGLQuery): any;
  45834. }
  45835. }
  45836. module "babylonjs/Meshes/abstractMesh" {
  45837. interface AbstractMesh {
  45838. /**
  45839. * Backing filed
  45840. * @hidden
  45841. */
  45842. __occlusionDataStorage: _OcclusionDataStorage;
  45843. /**
  45844. * Access property
  45845. * @hidden
  45846. */
  45847. _occlusionDataStorage: _OcclusionDataStorage;
  45848. /**
  45849. * 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.
  45850. * The default value is -1 which means don't break the query and wait till the result
  45851. * @see http://doc.babylonjs.com/features/occlusionquery
  45852. */
  45853. occlusionRetryCount: number;
  45854. /**
  45855. * 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:
  45856. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  45857. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  45858. * * 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.
  45859. * @see http://doc.babylonjs.com/features/occlusionquery
  45860. */
  45861. occlusionType: number;
  45862. /**
  45863. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  45864. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  45865. * * 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.
  45866. * @see http://doc.babylonjs.com/features/occlusionquery
  45867. */
  45868. occlusionQueryAlgorithmType: number;
  45869. /**
  45870. * 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
  45871. * @see http://doc.babylonjs.com/features/occlusionquery
  45872. */
  45873. isOccluded: boolean;
  45874. /**
  45875. * Flag to check the progress status of the query
  45876. * @see http://doc.babylonjs.com/features/occlusionquery
  45877. */
  45878. isOcclusionQueryInProgress: boolean;
  45879. }
  45880. }
  45881. }
  45882. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  45883. import { Nullable } from "babylonjs/types";
  45884. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45885. /** @hidden */
  45886. export var _forceTransformFeedbackToBundle: boolean;
  45887. module "babylonjs/Engines/engine" {
  45888. interface Engine {
  45889. /**
  45890. * Creates a webGL transform feedback object
  45891. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  45892. * @returns the webGL transform feedback object
  45893. */
  45894. createTransformFeedback(): WebGLTransformFeedback;
  45895. /**
  45896. * Delete a webGL transform feedback object
  45897. * @param value defines the webGL transform feedback object to delete
  45898. */
  45899. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  45900. /**
  45901. * Bind a webGL transform feedback object to the webgl context
  45902. * @param value defines the webGL transform feedback object to bind
  45903. */
  45904. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  45905. /**
  45906. * Begins a transform feedback operation
  45907. * @param usePoints defines if points or triangles must be used
  45908. */
  45909. beginTransformFeedback(usePoints: boolean): void;
  45910. /**
  45911. * Ends a transform feedback operation
  45912. */
  45913. endTransformFeedback(): void;
  45914. /**
  45915. * Specify the varyings to use with transform feedback
  45916. * @param program defines the associated webGL program
  45917. * @param value defines the list of strings representing the varying names
  45918. */
  45919. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  45920. /**
  45921. * Bind a webGL buffer for a transform feedback operation
  45922. * @param value defines the webGL buffer to bind
  45923. */
  45924. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  45925. }
  45926. }
  45927. }
  45928. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  45929. import { Scene } from "babylonjs/scene";
  45930. import { Engine } from "babylonjs/Engines/engine";
  45931. import { Texture } from "babylonjs/Materials/Textures/texture";
  45932. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  45933. import "babylonjs/Engines/Extensions/engine.multiRender";
  45934. /**
  45935. * Creation options of the multi render target texture.
  45936. */
  45937. export interface IMultiRenderTargetOptions {
  45938. /**
  45939. * Define if the texture needs to create mip maps after render.
  45940. */
  45941. generateMipMaps?: boolean;
  45942. /**
  45943. * Define the types of all the draw buffers we want to create
  45944. */
  45945. types?: number[];
  45946. /**
  45947. * Define the sampling modes of all the draw buffers we want to create
  45948. */
  45949. samplingModes?: number[];
  45950. /**
  45951. * Define if a depth buffer is required
  45952. */
  45953. generateDepthBuffer?: boolean;
  45954. /**
  45955. * Define if a stencil buffer is required
  45956. */
  45957. generateStencilBuffer?: boolean;
  45958. /**
  45959. * Define if a depth texture is required instead of a depth buffer
  45960. */
  45961. generateDepthTexture?: boolean;
  45962. /**
  45963. * Define the number of desired draw buffers
  45964. */
  45965. textureCount?: number;
  45966. /**
  45967. * Define if aspect ratio should be adapted to the texture or stay the scene one
  45968. */
  45969. doNotChangeAspectRatio?: boolean;
  45970. /**
  45971. * Define the default type of the buffers we are creating
  45972. */
  45973. defaultType?: number;
  45974. }
  45975. /**
  45976. * A multi render target, like a render target provides the ability to render to a texture.
  45977. * Unlike the render target, it can render to several draw buffers in one draw.
  45978. * This is specially interesting in deferred rendering or for any effects requiring more than
  45979. * just one color from a single pass.
  45980. */
  45981. export class MultiRenderTarget extends RenderTargetTexture {
  45982. private _internalTextures;
  45983. private _textures;
  45984. private _multiRenderTargetOptions;
  45985. /**
  45986. * Get if draw buffers are currently supported by the used hardware and browser.
  45987. */
  45988. readonly isSupported: boolean;
  45989. /**
  45990. * Get the list of textures generated by the multi render target.
  45991. */
  45992. readonly textures: Texture[];
  45993. /**
  45994. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  45995. */
  45996. readonly depthTexture: Texture;
  45997. /**
  45998. * Set the wrapping mode on U of all the textures we are rendering to.
  45999. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  46000. */
  46001. wrapU: number;
  46002. /**
  46003. * Set the wrapping mode on V of all the textures we are rendering to.
  46004. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  46005. */
  46006. wrapV: number;
  46007. /**
  46008. * Instantiate a new multi render target texture.
  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. * @param name Define the name of the texture
  46014. * @param size Define the size of the buffers to render to
  46015. * @param count Define the number of target we are rendering into
  46016. * @param scene Define the scene the texture belongs to
  46017. * @param options Define the options used to create the multi render target
  46018. */
  46019. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  46020. /** @hidden */
  46021. _rebuild(): void;
  46022. private _createInternalTextures;
  46023. private _createTextures;
  46024. /**
  46025. * Define the number of samples used if MSAA is enabled.
  46026. */
  46027. samples: number;
  46028. /**
  46029. * Resize all the textures in the multi render target.
  46030. * Be carrefull as it will recreate all the data in the new texture.
  46031. * @param size Define the new size
  46032. */
  46033. resize(size: any): void;
  46034. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  46035. /**
  46036. * Dispose the render targets and their associated resources
  46037. */
  46038. dispose(): void;
  46039. /**
  46040. * Release all the underlying texture used as draw buffers.
  46041. */
  46042. releaseInternalTextures(): void;
  46043. }
  46044. }
  46045. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  46046. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46047. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  46048. import { Nullable } from "babylonjs/types";
  46049. module "babylonjs/Engines/thinEngine" {
  46050. interface ThinEngine {
  46051. /**
  46052. * Unbind a list of render target textures from the webGL context
  46053. * This is used only when drawBuffer extension or webGL2 are active
  46054. * @param textures defines the render target textures to unbind
  46055. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46056. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46057. */
  46058. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  46059. /**
  46060. * Create a multi render target texture
  46061. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  46062. * @param size defines the size of the texture
  46063. * @param options defines the creation options
  46064. * @returns the cube texture as an InternalTexture
  46065. */
  46066. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  46067. /**
  46068. * Update the sample count for a given multiple render target texture
  46069. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  46070. * @param textures defines the textures to update
  46071. * @param samples defines the sample count to set
  46072. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  46073. */
  46074. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  46075. }
  46076. }
  46077. }
  46078. declare module "babylonjs/Engines/Extensions/index" {
  46079. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  46080. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  46081. export * from "babylonjs/Engines/Extensions/engine.multiview";
  46082. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  46083. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  46084. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  46085. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  46086. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  46087. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  46088. export * from "babylonjs/Engines/Extensions/engine.webVR";
  46089. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  46090. }
  46091. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  46092. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46093. /** @hidden */
  46094. export var rgbdEncodePixelShader: {
  46095. name: string;
  46096. shader: string;
  46097. };
  46098. }
  46099. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  46100. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46101. /** @hidden */
  46102. export var rgbdDecodePixelShader: {
  46103. name: string;
  46104. shader: string;
  46105. };
  46106. }
  46107. declare module "babylonjs/Misc/environmentTextureTools" {
  46108. import { Nullable } from "babylonjs/types";
  46109. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46110. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46111. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  46112. import "babylonjs/Engines/Extensions/engine.renderTarget";
  46113. import "babylonjs/Shaders/rgbdEncode.fragment";
  46114. import "babylonjs/Shaders/rgbdDecode.fragment";
  46115. /**
  46116. * Raw texture data and descriptor sufficient for WebGL texture upload
  46117. */
  46118. export interface EnvironmentTextureInfo {
  46119. /**
  46120. * Version of the environment map
  46121. */
  46122. version: number;
  46123. /**
  46124. * Width of image
  46125. */
  46126. width: number;
  46127. /**
  46128. * Irradiance information stored in the file.
  46129. */
  46130. irradiance: any;
  46131. /**
  46132. * Specular information stored in the file.
  46133. */
  46134. specular: any;
  46135. }
  46136. /**
  46137. * Defines One Image in the file. It requires only the position in the file
  46138. * as well as the length.
  46139. */
  46140. interface BufferImageData {
  46141. /**
  46142. * Length of the image data.
  46143. */
  46144. length: number;
  46145. /**
  46146. * Position of the data from the null terminator delimiting the end of the JSON.
  46147. */
  46148. position: number;
  46149. }
  46150. /**
  46151. * Defines the specular data enclosed in the file.
  46152. * This corresponds to the version 1 of the data.
  46153. */
  46154. export interface EnvironmentTextureSpecularInfoV1 {
  46155. /**
  46156. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  46157. */
  46158. specularDataPosition?: number;
  46159. /**
  46160. * This contains all the images data needed to reconstruct the cubemap.
  46161. */
  46162. mipmaps: Array<BufferImageData>;
  46163. /**
  46164. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  46165. */
  46166. lodGenerationScale: number;
  46167. }
  46168. /**
  46169. * Sets of helpers addressing the serialization and deserialization of environment texture
  46170. * stored in a BabylonJS env file.
  46171. * Those files are usually stored as .env files.
  46172. */
  46173. export class EnvironmentTextureTools {
  46174. /**
  46175. * Magic number identifying the env file.
  46176. */
  46177. private static _MagicBytes;
  46178. /**
  46179. * Gets the environment info from an env file.
  46180. * @param data The array buffer containing the .env bytes.
  46181. * @returns the environment file info (the json header) if successfully parsed.
  46182. */
  46183. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  46184. /**
  46185. * Creates an environment texture from a loaded cube texture.
  46186. * @param texture defines the cube texture to convert in env file
  46187. * @return a promise containing the environment data if succesfull.
  46188. */
  46189. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  46190. /**
  46191. * Creates a JSON representation of the spherical data.
  46192. * @param texture defines the texture containing the polynomials
  46193. * @return the JSON representation of the spherical info
  46194. */
  46195. private static _CreateEnvTextureIrradiance;
  46196. /**
  46197. * Creates the ArrayBufferViews used for initializing environment texture image data.
  46198. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  46199. * @param info parameters that determine what views will be created for accessing the underlying buffer
  46200. * @return the views described by info providing access to the underlying buffer
  46201. */
  46202. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  46203. /**
  46204. * Uploads the texture info contained in the env file to the GPU.
  46205. * @param texture defines the internal texture to upload to
  46206. * @param arrayBuffer defines the buffer cotaining the data to load
  46207. * @param info defines the texture info retrieved through the GetEnvInfo method
  46208. * @returns a promise
  46209. */
  46210. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  46211. /**
  46212. * Uploads the levels of image data to the GPU.
  46213. * @param texture defines the internal texture to upload to
  46214. * @param imageData defines the array buffer views of image data [mipmap][face]
  46215. * @returns a promise
  46216. */
  46217. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  46218. /**
  46219. * Uploads spherical polynomials information to the texture.
  46220. * @param texture defines the texture we are trying to upload the information to
  46221. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  46222. */
  46223. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  46224. /** @hidden */
  46225. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46226. }
  46227. }
  46228. declare module "babylonjs/Maths/math.vertexFormat" {
  46229. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  46230. /**
  46231. * Contains position and normal vectors for a vertex
  46232. */
  46233. export class PositionNormalVertex {
  46234. /** the position of the vertex (defaut: 0,0,0) */
  46235. position: Vector3;
  46236. /** the normal of the vertex (defaut: 0,1,0) */
  46237. normal: Vector3;
  46238. /**
  46239. * Creates a PositionNormalVertex
  46240. * @param position the position of the vertex (defaut: 0,0,0)
  46241. * @param normal the normal of the vertex (defaut: 0,1,0)
  46242. */
  46243. constructor(
  46244. /** the position of the vertex (defaut: 0,0,0) */
  46245. position?: Vector3,
  46246. /** the normal of the vertex (defaut: 0,1,0) */
  46247. normal?: Vector3);
  46248. /**
  46249. * Clones the PositionNormalVertex
  46250. * @returns the cloned PositionNormalVertex
  46251. */
  46252. clone(): PositionNormalVertex;
  46253. }
  46254. /**
  46255. * Contains position, normal and uv vectors for a vertex
  46256. */
  46257. export class PositionNormalTextureVertex {
  46258. /** the position of the vertex (defaut: 0,0,0) */
  46259. position: Vector3;
  46260. /** the normal of the vertex (defaut: 0,1,0) */
  46261. normal: Vector3;
  46262. /** the uv of the vertex (default: 0,0) */
  46263. uv: Vector2;
  46264. /**
  46265. * Creates a PositionNormalTextureVertex
  46266. * @param position the position of the vertex (defaut: 0,0,0)
  46267. * @param normal the normal of the vertex (defaut: 0,1,0)
  46268. * @param uv the uv of the vertex (default: 0,0)
  46269. */
  46270. constructor(
  46271. /** the position of the vertex (defaut: 0,0,0) */
  46272. position?: Vector3,
  46273. /** the normal of the vertex (defaut: 0,1,0) */
  46274. normal?: Vector3,
  46275. /** the uv of the vertex (default: 0,0) */
  46276. uv?: Vector2);
  46277. /**
  46278. * Clones the PositionNormalTextureVertex
  46279. * @returns the cloned PositionNormalTextureVertex
  46280. */
  46281. clone(): PositionNormalTextureVertex;
  46282. }
  46283. }
  46284. declare module "babylonjs/Maths/math" {
  46285. export * from "babylonjs/Maths/math.axis";
  46286. export * from "babylonjs/Maths/math.color";
  46287. export * from "babylonjs/Maths/math.constants";
  46288. export * from "babylonjs/Maths/math.frustum";
  46289. export * from "babylonjs/Maths/math.path";
  46290. export * from "babylonjs/Maths/math.plane";
  46291. export * from "babylonjs/Maths/math.size";
  46292. export * from "babylonjs/Maths/math.vector";
  46293. export * from "babylonjs/Maths/math.vertexFormat";
  46294. export * from "babylonjs/Maths/math.viewport";
  46295. }
  46296. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  46297. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  46298. /** @hidden */
  46299. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  46300. private _genericAttributeLocation;
  46301. private _varyingLocationCount;
  46302. private _varyingLocationMap;
  46303. private _replacements;
  46304. private _textureCount;
  46305. private _uniforms;
  46306. lineProcessor(line: string): string;
  46307. attributeProcessor(attribute: string): string;
  46308. varyingProcessor(varying: string, isFragment: boolean): string;
  46309. uniformProcessor(uniform: string): string;
  46310. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  46311. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  46312. }
  46313. }
  46314. declare module "babylonjs/Engines/nativeEngine" {
  46315. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  46316. import { Engine } from "babylonjs/Engines/engine";
  46317. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  46318. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46319. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46320. import { Effect } from "babylonjs/Materials/effect";
  46321. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  46322. import { Color4, Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  46323. import { Scene } from "babylonjs/scene";
  46324. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  46325. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  46326. /**
  46327. * Container for accessors for natively-stored mesh data buffers.
  46328. */
  46329. class NativeDataBuffer extends DataBuffer {
  46330. /**
  46331. * Accessor value used to identify/retrieve a natively-stored index buffer.
  46332. */
  46333. nativeIndexBuffer?: any;
  46334. /**
  46335. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  46336. */
  46337. nativeVertexBuffer?: any;
  46338. }
  46339. /** @hidden */
  46340. export class NativeEngine extends Engine {
  46341. private readonly _native;
  46342. getHardwareScalingLevel(): number;
  46343. constructor();
  46344. /**
  46345. * Can be used to override the current requestAnimationFrame requester.
  46346. * @hidden
  46347. */
  46348. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  46349. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46350. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  46351. createVertexBuffer(data: DataArray): NativeDataBuffer;
  46352. recordVertexArrayObject(vertexBuffers: {
  46353. [key: string]: VertexBuffer;
  46354. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  46355. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  46356. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  46357. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46358. /**
  46359. * Draw a list of indexed primitives
  46360. * @param fillMode defines the primitive to use
  46361. * @param indexStart defines the starting index
  46362. * @param indexCount defines the number of index to draw
  46363. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46364. */
  46365. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46366. /**
  46367. * Draw a list of unindexed primitives
  46368. * @param fillMode defines the primitive to use
  46369. * @param verticesStart defines the index of first vertex to draw
  46370. * @param verticesCount defines the count of vertices to draw
  46371. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46372. */
  46373. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46374. createPipelineContext(): IPipelineContext;
  46375. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  46376. /** @hidden */
  46377. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  46378. /** @hidden */
  46379. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  46380. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  46381. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  46382. protected _setProgram(program: WebGLProgram): void;
  46383. _releaseEffect(effect: Effect): void;
  46384. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  46385. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  46386. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  46387. bindSamplers(effect: Effect): void;
  46388. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  46389. getRenderWidth(useScreen?: boolean): number;
  46390. getRenderHeight(useScreen?: boolean): number;
  46391. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  46392. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  46393. /**
  46394. * Set the z offset to apply to current rendering
  46395. * @param value defines the offset to apply
  46396. */
  46397. setZOffset(value: number): void;
  46398. /**
  46399. * Gets the current value of the zOffset
  46400. * @returns the current zOffset state
  46401. */
  46402. getZOffset(): number;
  46403. /**
  46404. * Enable or disable depth buffering
  46405. * @param enable defines the state to set
  46406. */
  46407. setDepthBuffer(enable: boolean): void;
  46408. /**
  46409. * Gets a boolean indicating if depth writing is enabled
  46410. * @returns the current depth writing state
  46411. */
  46412. getDepthWrite(): boolean;
  46413. /**
  46414. * Enable or disable depth writing
  46415. * @param enable defines the state to set
  46416. */
  46417. setDepthWrite(enable: boolean): void;
  46418. /**
  46419. * Enable or disable color writing
  46420. * @param enable defines the state to set
  46421. */
  46422. setColorWrite(enable: boolean): void;
  46423. /**
  46424. * Gets a boolean indicating if color writing is enabled
  46425. * @returns the current color writing state
  46426. */
  46427. getColorWrite(): boolean;
  46428. /**
  46429. * Sets alpha constants used by some alpha blending modes
  46430. * @param r defines the red component
  46431. * @param g defines the green component
  46432. * @param b defines the blue component
  46433. * @param a defines the alpha component
  46434. */
  46435. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  46436. /**
  46437. * Sets the current alpha mode
  46438. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  46439. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  46440. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46441. */
  46442. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  46443. /**
  46444. * Gets the current alpha mode
  46445. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46446. * @returns the current alpha mode
  46447. */
  46448. getAlphaMode(): number;
  46449. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  46450. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  46451. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  46452. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  46453. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  46454. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  46455. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  46456. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  46457. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  46458. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  46459. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  46460. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  46461. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  46462. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46463. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46464. setFloat(uniform: WebGLUniformLocation, value: number): void;
  46465. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  46466. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  46467. setBool(uniform: WebGLUniformLocation, bool: number): void;
  46468. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  46469. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  46470. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  46471. wipeCaches(bruteForce?: boolean): void;
  46472. _createTexture(): WebGLTexture;
  46473. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  46474. /**
  46475. * Usually called from BABYLON.Texture.ts.
  46476. * Passed information to create a WebGLTexture
  46477. * @param urlArg defines a value which contains one of the following:
  46478. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  46479. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  46480. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  46481. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  46482. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  46483. * @param scene needed for loading to the correct scene
  46484. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  46485. * @param onLoad optional callback to be called upon successful completion
  46486. * @param onError optional callback to be called upon failure
  46487. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  46488. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  46489. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  46490. * @param forcedExtension defines the extension to use to pick the right loader
  46491. * @returns a InternalTexture for assignment back into BABYLON.Texture
  46492. */
  46493. 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;
  46494. /**
  46495. * Creates a cube texture
  46496. * @param rootUrl defines the url where the files to load is located
  46497. * @param scene defines the current scene
  46498. * @param files defines the list of files to load (1 per face)
  46499. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  46500. * @param onLoad defines an optional callback raised when the texture is loaded
  46501. * @param onError defines an optional callback raised if there is an issue to load the texture
  46502. * @param format defines the format of the data
  46503. * @param forcedExtension defines the extension to use to pick the right loader
  46504. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  46505. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  46506. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  46507. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  46508. * @returns the cube texture as an InternalTexture
  46509. */
  46510. 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;
  46511. private _getSamplingFilter;
  46512. private static _GetNativeTextureFormat;
  46513. createRenderTargetTexture(size: number | {
  46514. width: number;
  46515. height: number;
  46516. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  46517. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  46518. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  46519. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46520. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  46521. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  46522. /**
  46523. * Updates a dynamic vertex buffer.
  46524. * @param vertexBuffer the vertex buffer to update
  46525. * @param data the data used to update the vertex buffer
  46526. * @param byteOffset the byte offset of the data (optional)
  46527. * @param byteLength the byte length of the data (optional)
  46528. */
  46529. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  46530. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  46531. private _updateAnisotropicLevel;
  46532. private _getAddressMode;
  46533. /** @hidden */
  46534. _bindTexture(channel: number, texture: InternalTexture): void;
  46535. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  46536. releaseEffects(): void;
  46537. /** @hidden */
  46538. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46539. /** @hidden */
  46540. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46541. /** @hidden */
  46542. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46543. /** @hidden */
  46544. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  46545. }
  46546. }
  46547. declare module "babylonjs/Engines/index" {
  46548. export * from "babylonjs/Engines/constants";
  46549. export * from "babylonjs/Engines/engineCapabilities";
  46550. export * from "babylonjs/Engines/instancingAttributeInfo";
  46551. export * from "babylonjs/Engines/thinEngine";
  46552. export * from "babylonjs/Engines/engine";
  46553. export * from "babylonjs/Engines/engineStore";
  46554. export * from "babylonjs/Engines/nullEngine";
  46555. export * from "babylonjs/Engines/Extensions/index";
  46556. export * from "babylonjs/Engines/IPipelineContext";
  46557. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  46558. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  46559. export * from "babylonjs/Engines/nativeEngine";
  46560. }
  46561. declare module "babylonjs/Events/clipboardEvents" {
  46562. /**
  46563. * Gather the list of clipboard event types as constants.
  46564. */
  46565. export class ClipboardEventTypes {
  46566. /**
  46567. * The clipboard event is fired when a copy command is active (pressed).
  46568. */
  46569. static readonly COPY: number;
  46570. /**
  46571. * The clipboard event is fired when a cut command is active (pressed).
  46572. */
  46573. static readonly CUT: number;
  46574. /**
  46575. * The clipboard event is fired when a paste command is active (pressed).
  46576. */
  46577. static readonly PASTE: number;
  46578. }
  46579. /**
  46580. * This class is used to store clipboard related info for the onClipboardObservable event.
  46581. */
  46582. export class ClipboardInfo {
  46583. /**
  46584. * Defines the type of event (BABYLON.ClipboardEventTypes)
  46585. */
  46586. type: number;
  46587. /**
  46588. * Defines the related dom event
  46589. */
  46590. event: ClipboardEvent;
  46591. /**
  46592. *Creates an instance of ClipboardInfo.
  46593. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  46594. * @param event Defines the related dom event
  46595. */
  46596. constructor(
  46597. /**
  46598. * Defines the type of event (BABYLON.ClipboardEventTypes)
  46599. */
  46600. type: number,
  46601. /**
  46602. * Defines the related dom event
  46603. */
  46604. event: ClipboardEvent);
  46605. /**
  46606. * Get the clipboard event's type from the keycode.
  46607. * @param keyCode Defines the keyCode for the current keyboard event.
  46608. * @return {number}
  46609. */
  46610. static GetTypeFromCharacter(keyCode: number): number;
  46611. }
  46612. }
  46613. declare module "babylonjs/Events/index" {
  46614. export * from "babylonjs/Events/keyboardEvents";
  46615. export * from "babylonjs/Events/pointerEvents";
  46616. export * from "babylonjs/Events/clipboardEvents";
  46617. }
  46618. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  46619. import { Scene } from "babylonjs/scene";
  46620. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46621. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  46622. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46623. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46624. /**
  46625. * Google Daydream controller
  46626. */
  46627. export class DaydreamController extends WebVRController {
  46628. /**
  46629. * Base Url for the controller model.
  46630. */
  46631. static MODEL_BASE_URL: string;
  46632. /**
  46633. * File name for the controller model.
  46634. */
  46635. static MODEL_FILENAME: string;
  46636. /**
  46637. * Gamepad Id prefix used to identify Daydream Controller.
  46638. */
  46639. static readonly GAMEPAD_ID_PREFIX: string;
  46640. /**
  46641. * Creates a new DaydreamController from a gamepad
  46642. * @param vrGamepad the gamepad that the controller should be created from
  46643. */
  46644. constructor(vrGamepad: any);
  46645. /**
  46646. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  46647. * @param scene scene in which to add meshes
  46648. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  46649. */
  46650. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  46651. /**
  46652. * Called once for each button that changed state since the last frame
  46653. * @param buttonIdx Which button index changed
  46654. * @param state New state of the button
  46655. * @param changes Which properties on the state changed since last frame
  46656. */
  46657. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  46658. }
  46659. }
  46660. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  46661. import { Scene } from "babylonjs/scene";
  46662. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46663. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  46664. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46665. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46666. /**
  46667. * Gear VR Controller
  46668. */
  46669. export class GearVRController extends WebVRController {
  46670. /**
  46671. * Base Url for the controller model.
  46672. */
  46673. static MODEL_BASE_URL: string;
  46674. /**
  46675. * File name for the controller model.
  46676. */
  46677. static MODEL_FILENAME: string;
  46678. /**
  46679. * Gamepad Id prefix used to identify this controller.
  46680. */
  46681. static readonly GAMEPAD_ID_PREFIX: string;
  46682. private readonly _buttonIndexToObservableNameMap;
  46683. /**
  46684. * Creates a new GearVRController from a gamepad
  46685. * @param vrGamepad the gamepad that the controller should be created from
  46686. */
  46687. constructor(vrGamepad: any);
  46688. /**
  46689. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  46690. * @param scene scene in which to add meshes
  46691. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  46692. */
  46693. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  46694. /**
  46695. * Called once for each button that changed state since the last frame
  46696. * @param buttonIdx Which button index changed
  46697. * @param state New state of the button
  46698. * @param changes Which properties on the state changed since last frame
  46699. */
  46700. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  46701. }
  46702. }
  46703. declare module "babylonjs/Gamepads/Controllers/index" {
  46704. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  46705. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  46706. export * from "babylonjs/Gamepads/Controllers/genericController";
  46707. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  46708. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46709. export * from "babylonjs/Gamepads/Controllers/viveController";
  46710. export * from "babylonjs/Gamepads/Controllers/webVRController";
  46711. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  46712. }
  46713. declare module "babylonjs/Gamepads/index" {
  46714. export * from "babylonjs/Gamepads/Controllers/index";
  46715. export * from "babylonjs/Gamepads/gamepad";
  46716. export * from "babylonjs/Gamepads/gamepadManager";
  46717. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  46718. export * from "babylonjs/Gamepads/xboxGamepad";
  46719. export * from "babylonjs/Gamepads/dualShockGamepad";
  46720. }
  46721. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  46722. import { Scene } from "babylonjs/scene";
  46723. import { Vector4 } from "babylonjs/Maths/math.vector";
  46724. import { Color4 } from "babylonjs/Maths/math.color";
  46725. import { Mesh } from "babylonjs/Meshes/mesh";
  46726. import { Nullable } from "babylonjs/types";
  46727. /**
  46728. * Class containing static functions to help procedurally build meshes
  46729. */
  46730. export class PolyhedronBuilder {
  46731. /**
  46732. * Creates a polyhedron mesh
  46733. * * 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
  46734. * * The parameter `size` (positive float, default 1) sets the polygon size
  46735. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  46736. * * 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`
  46737. * * 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
  46738. * * 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)`)
  46739. * * 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
  46740. * * 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
  46741. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46742. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  46743. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46744. * @param name defines the name of the mesh
  46745. * @param options defines the options used to create the mesh
  46746. * @param scene defines the hosting scene
  46747. * @returns the polyhedron mesh
  46748. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  46749. */
  46750. static CreatePolyhedron(name: string, options: {
  46751. type?: number;
  46752. size?: number;
  46753. sizeX?: number;
  46754. sizeY?: number;
  46755. sizeZ?: number;
  46756. custom?: any;
  46757. faceUV?: Vector4[];
  46758. faceColors?: Color4[];
  46759. flat?: boolean;
  46760. updatable?: boolean;
  46761. sideOrientation?: number;
  46762. frontUVs?: Vector4;
  46763. backUVs?: Vector4;
  46764. }, scene?: Nullable<Scene>): Mesh;
  46765. }
  46766. }
  46767. declare module "babylonjs/Gizmos/scaleGizmo" {
  46768. import { Observable } from "babylonjs/Misc/observable";
  46769. import { Nullable } from "babylonjs/types";
  46770. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46771. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46772. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  46773. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46774. /**
  46775. * Gizmo that enables scaling a mesh along 3 axis
  46776. */
  46777. export class ScaleGizmo extends Gizmo {
  46778. /**
  46779. * Internal gizmo used for interactions on the x axis
  46780. */
  46781. xGizmo: AxisScaleGizmo;
  46782. /**
  46783. * Internal gizmo used for interactions on the y axis
  46784. */
  46785. yGizmo: AxisScaleGizmo;
  46786. /**
  46787. * Internal gizmo used for interactions on the z axis
  46788. */
  46789. zGizmo: AxisScaleGizmo;
  46790. /**
  46791. * Internal gizmo used to scale all axis equally
  46792. */
  46793. uniformScaleGizmo: AxisScaleGizmo;
  46794. private _meshAttached;
  46795. private _updateGizmoRotationToMatchAttachedMesh;
  46796. private _snapDistance;
  46797. private _scaleRatio;
  46798. private _uniformScalingMesh;
  46799. private _octahedron;
  46800. /** Fires an event when any of it's sub gizmos are dragged */
  46801. onDragStartObservable: Observable<unknown>;
  46802. /** Fires an event when any of it's sub gizmos are released from dragging */
  46803. onDragEndObservable: Observable<unknown>;
  46804. attachedMesh: Nullable<AbstractMesh>;
  46805. /**
  46806. * Creates a ScaleGizmo
  46807. * @param gizmoLayer The utility layer the gizmo will be added to
  46808. */
  46809. constructor(gizmoLayer?: UtilityLayerRenderer);
  46810. updateGizmoRotationToMatchAttachedMesh: boolean;
  46811. /**
  46812. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46813. */
  46814. snapDistance: number;
  46815. /**
  46816. * Ratio for the scale of the gizmo (Default: 1)
  46817. */
  46818. scaleRatio: number;
  46819. /**
  46820. * Disposes of the gizmo
  46821. */
  46822. dispose(): void;
  46823. }
  46824. }
  46825. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  46826. import { Observable } from "babylonjs/Misc/observable";
  46827. import { Nullable } from "babylonjs/types";
  46828. import { Vector3 } from "babylonjs/Maths/math.vector";
  46829. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46830. import { Mesh } from "babylonjs/Meshes/mesh";
  46831. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  46832. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46833. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46834. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  46835. import { Color3 } from "babylonjs/Maths/math.color";
  46836. /**
  46837. * Single axis scale gizmo
  46838. */
  46839. export class AxisScaleGizmo extends Gizmo {
  46840. /**
  46841. * Drag behavior responsible for the gizmos dragging interactions
  46842. */
  46843. dragBehavior: PointerDragBehavior;
  46844. private _pointerObserver;
  46845. /**
  46846. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46847. */
  46848. snapDistance: number;
  46849. /**
  46850. * Event that fires each time the gizmo snaps to a new location.
  46851. * * snapDistance is the the change in distance
  46852. */
  46853. onSnapObservable: Observable<{
  46854. snapDistance: number;
  46855. }>;
  46856. /**
  46857. * If the scaling operation should be done on all axis (default: false)
  46858. */
  46859. uniformScaling: boolean;
  46860. private _isEnabled;
  46861. private _parent;
  46862. private _arrow;
  46863. private _coloredMaterial;
  46864. private _hoverMaterial;
  46865. /**
  46866. * Creates an AxisScaleGizmo
  46867. * @param gizmoLayer The utility layer the gizmo will be added to
  46868. * @param dragAxis The axis which the gizmo will be able to scale on
  46869. * @param color The color of the gizmo
  46870. */
  46871. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  46872. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46873. /**
  46874. * If the gizmo is enabled
  46875. */
  46876. isEnabled: boolean;
  46877. /**
  46878. * Disposes of the gizmo
  46879. */
  46880. dispose(): void;
  46881. /**
  46882. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  46883. * @param mesh The mesh to replace the default mesh of the gizmo
  46884. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  46885. */
  46886. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  46887. }
  46888. }
  46889. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  46890. import { Observable } from "babylonjs/Misc/observable";
  46891. import { Nullable } from "babylonjs/types";
  46892. import { Vector3 } from "babylonjs/Maths/math.vector";
  46893. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46894. import { Mesh } from "babylonjs/Meshes/mesh";
  46895. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46896. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46897. import { Color3 } from "babylonjs/Maths/math.color";
  46898. import "babylonjs/Meshes/Builders/boxBuilder";
  46899. /**
  46900. * Bounding box gizmo
  46901. */
  46902. export class BoundingBoxGizmo extends Gizmo {
  46903. private _lineBoundingBox;
  46904. private _rotateSpheresParent;
  46905. private _scaleBoxesParent;
  46906. private _boundingDimensions;
  46907. private _renderObserver;
  46908. private _pointerObserver;
  46909. private _scaleDragSpeed;
  46910. private _tmpQuaternion;
  46911. private _tmpVector;
  46912. private _tmpRotationMatrix;
  46913. /**
  46914. * 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)
  46915. */
  46916. ignoreChildren: boolean;
  46917. /**
  46918. * 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)
  46919. */
  46920. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  46921. /**
  46922. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  46923. */
  46924. rotationSphereSize: number;
  46925. /**
  46926. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  46927. */
  46928. scaleBoxSize: number;
  46929. /**
  46930. * 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)
  46931. */
  46932. fixedDragMeshScreenSize: boolean;
  46933. /**
  46934. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  46935. */
  46936. fixedDragMeshScreenSizeDistanceFactor: number;
  46937. /**
  46938. * Fired when a rotation sphere or scale box is dragged
  46939. */
  46940. onDragStartObservable: Observable<{}>;
  46941. /**
  46942. * Fired when a scale box is dragged
  46943. */
  46944. onScaleBoxDragObservable: Observable<{}>;
  46945. /**
  46946. * Fired when a scale box drag is ended
  46947. */
  46948. onScaleBoxDragEndObservable: Observable<{}>;
  46949. /**
  46950. * Fired when a rotation sphere is dragged
  46951. */
  46952. onRotationSphereDragObservable: Observable<{}>;
  46953. /**
  46954. * Fired when a rotation sphere drag is ended
  46955. */
  46956. onRotationSphereDragEndObservable: Observable<{}>;
  46957. /**
  46958. * 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)
  46959. */
  46960. scalePivot: Nullable<Vector3>;
  46961. /**
  46962. * Mesh used as a pivot to rotate the attached mesh
  46963. */
  46964. private _anchorMesh;
  46965. private _existingMeshScale;
  46966. private _dragMesh;
  46967. private pointerDragBehavior;
  46968. private coloredMaterial;
  46969. private hoverColoredMaterial;
  46970. /**
  46971. * Sets the color of the bounding box gizmo
  46972. * @param color the color to set
  46973. */
  46974. setColor(color: Color3): void;
  46975. /**
  46976. * Creates an BoundingBoxGizmo
  46977. * @param gizmoLayer The utility layer the gizmo will be added to
  46978. * @param color The color of the gizmo
  46979. */
  46980. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  46981. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46982. private _selectNode;
  46983. /**
  46984. * Updates the bounding box information for the Gizmo
  46985. */
  46986. updateBoundingBox(): void;
  46987. private _updateRotationSpheres;
  46988. private _updateScaleBoxes;
  46989. /**
  46990. * Enables rotation on the specified axis and disables rotation on the others
  46991. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  46992. */
  46993. setEnabledRotationAxis(axis: string): void;
  46994. /**
  46995. * Enables/disables scaling
  46996. * @param enable if scaling should be enabled
  46997. */
  46998. setEnabledScaling(enable: boolean): void;
  46999. private _updateDummy;
  47000. /**
  47001. * Enables a pointer drag behavior on the bounding box of the gizmo
  47002. */
  47003. enableDragBehavior(): void;
  47004. /**
  47005. * Disposes of the gizmo
  47006. */
  47007. dispose(): void;
  47008. /**
  47009. * 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)
  47010. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  47011. * @returns the bounding box mesh with the passed in mesh as a child
  47012. */
  47013. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  47014. /**
  47015. * CustomMeshes are not supported by this gizmo
  47016. * @param mesh The mesh to replace the default mesh of the gizmo
  47017. */
  47018. setCustomMesh(mesh: Mesh): void;
  47019. }
  47020. }
  47021. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  47022. import { Observable } from "babylonjs/Misc/observable";
  47023. import { Nullable } from "babylonjs/types";
  47024. import { Vector3 } from "babylonjs/Maths/math.vector";
  47025. import { Color3 } from "babylonjs/Maths/math.color";
  47026. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47027. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47028. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47029. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47030. import "babylonjs/Meshes/Builders/linesBuilder";
  47031. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  47032. /**
  47033. * Single plane rotation gizmo
  47034. */
  47035. export class PlaneRotationGizmo extends Gizmo {
  47036. /**
  47037. * Drag behavior responsible for the gizmos dragging interactions
  47038. */
  47039. dragBehavior: PointerDragBehavior;
  47040. private _pointerObserver;
  47041. /**
  47042. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  47043. */
  47044. snapDistance: number;
  47045. /**
  47046. * Event that fires each time the gizmo snaps to a new location.
  47047. * * snapDistance is the the change in distance
  47048. */
  47049. onSnapObservable: Observable<{
  47050. snapDistance: number;
  47051. }>;
  47052. private _isEnabled;
  47053. private _parent;
  47054. /**
  47055. * Creates a PlaneRotationGizmo
  47056. * @param gizmoLayer The utility layer the gizmo will be added to
  47057. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  47058. * @param color The color of the gizmo
  47059. * @param tessellation Amount of tessellation to be used when creating rotation circles
  47060. * @param useEulerRotation Use and update Euler angle instead of quaternion
  47061. */
  47062. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  47063. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47064. /**
  47065. * If the gizmo is enabled
  47066. */
  47067. isEnabled: boolean;
  47068. /**
  47069. * Disposes of the gizmo
  47070. */
  47071. dispose(): void;
  47072. }
  47073. }
  47074. declare module "babylonjs/Gizmos/rotationGizmo" {
  47075. import { Observable } from "babylonjs/Misc/observable";
  47076. import { Nullable } from "babylonjs/types";
  47077. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47078. import { Mesh } from "babylonjs/Meshes/mesh";
  47079. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47080. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  47081. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47082. /**
  47083. * Gizmo that enables rotating a mesh along 3 axis
  47084. */
  47085. export class RotationGizmo extends Gizmo {
  47086. /**
  47087. * Internal gizmo used for interactions on the x axis
  47088. */
  47089. xGizmo: PlaneRotationGizmo;
  47090. /**
  47091. * Internal gizmo used for interactions on the y axis
  47092. */
  47093. yGizmo: PlaneRotationGizmo;
  47094. /**
  47095. * Internal gizmo used for interactions on the z axis
  47096. */
  47097. zGizmo: PlaneRotationGizmo;
  47098. /** Fires an event when any of it's sub gizmos are dragged */
  47099. onDragStartObservable: Observable<unknown>;
  47100. /** Fires an event when any of it's sub gizmos are released from dragging */
  47101. onDragEndObservable: Observable<unknown>;
  47102. private _meshAttached;
  47103. attachedMesh: Nullable<AbstractMesh>;
  47104. /**
  47105. * Creates a RotationGizmo
  47106. * @param gizmoLayer The utility layer the gizmo will be added to
  47107. * @param tessellation Amount of tessellation to be used when creating rotation circles
  47108. * @param useEulerRotation Use and update Euler angle instead of quaternion
  47109. */
  47110. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  47111. updateGizmoRotationToMatchAttachedMesh: boolean;
  47112. /**
  47113. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47114. */
  47115. snapDistance: number;
  47116. /**
  47117. * Ratio for the scale of the gizmo (Default: 1)
  47118. */
  47119. scaleRatio: number;
  47120. /**
  47121. * Disposes of the gizmo
  47122. */
  47123. dispose(): void;
  47124. /**
  47125. * CustomMeshes are not supported by this gizmo
  47126. * @param mesh The mesh to replace the default mesh of the gizmo
  47127. */
  47128. setCustomMesh(mesh: Mesh): void;
  47129. }
  47130. }
  47131. declare module "babylonjs/Gizmos/gizmoManager" {
  47132. import { Observable } from "babylonjs/Misc/observable";
  47133. import { Nullable } from "babylonjs/types";
  47134. import { Scene, IDisposable } from "babylonjs/scene";
  47135. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47136. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47137. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  47138. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  47139. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47140. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  47141. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  47142. /**
  47143. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  47144. */
  47145. export class GizmoManager implements IDisposable {
  47146. private scene;
  47147. /**
  47148. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  47149. */
  47150. gizmos: {
  47151. positionGizmo: Nullable<PositionGizmo>;
  47152. rotationGizmo: Nullable<RotationGizmo>;
  47153. scaleGizmo: Nullable<ScaleGizmo>;
  47154. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  47155. };
  47156. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  47157. clearGizmoOnEmptyPointerEvent: boolean;
  47158. /** Fires an event when the manager is attached to a mesh */
  47159. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  47160. private _gizmosEnabled;
  47161. private _pointerObserver;
  47162. private _attachedMesh;
  47163. private _boundingBoxColor;
  47164. private _defaultUtilityLayer;
  47165. private _defaultKeepDepthUtilityLayer;
  47166. /**
  47167. * When bounding box gizmo is enabled, this can be used to track drag/end events
  47168. */
  47169. boundingBoxDragBehavior: SixDofDragBehavior;
  47170. /**
  47171. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  47172. */
  47173. attachableMeshes: Nullable<Array<AbstractMesh>>;
  47174. /**
  47175. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  47176. */
  47177. usePointerToAttachGizmos: boolean;
  47178. /**
  47179. * Utility layer that the bounding box gizmo belongs to
  47180. */
  47181. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  47182. /**
  47183. * Utility layer that all gizmos besides bounding box belong to
  47184. */
  47185. readonly utilityLayer: UtilityLayerRenderer;
  47186. /**
  47187. * Instatiates a gizmo manager
  47188. * @param scene the scene to overlay the gizmos on top of
  47189. */
  47190. constructor(scene: Scene);
  47191. /**
  47192. * Attaches a set of gizmos to the specified mesh
  47193. * @param mesh The mesh the gizmo's should be attached to
  47194. */
  47195. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  47196. /**
  47197. * If the position gizmo is enabled
  47198. */
  47199. positionGizmoEnabled: boolean;
  47200. /**
  47201. * If the rotation gizmo is enabled
  47202. */
  47203. rotationGizmoEnabled: boolean;
  47204. /**
  47205. * If the scale gizmo is enabled
  47206. */
  47207. scaleGizmoEnabled: boolean;
  47208. /**
  47209. * If the boundingBox gizmo is enabled
  47210. */
  47211. boundingBoxGizmoEnabled: boolean;
  47212. /**
  47213. * Disposes of the gizmo manager
  47214. */
  47215. dispose(): void;
  47216. }
  47217. }
  47218. declare module "babylonjs/Lights/directionalLight" {
  47219. import { Camera } from "babylonjs/Cameras/camera";
  47220. import { Scene } from "babylonjs/scene";
  47221. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47222. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47223. import { Light } from "babylonjs/Lights/light";
  47224. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  47225. import { Effect } from "babylonjs/Materials/effect";
  47226. /**
  47227. * A directional light is defined by a direction (what a surprise!).
  47228. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  47229. * 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.
  47230. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47231. */
  47232. export class DirectionalLight extends ShadowLight {
  47233. private _shadowFrustumSize;
  47234. /**
  47235. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  47236. */
  47237. /**
  47238. * Specifies a fix frustum size for the shadow generation.
  47239. */
  47240. shadowFrustumSize: number;
  47241. private _shadowOrthoScale;
  47242. /**
  47243. * Gets the shadow projection scale against the optimal computed one.
  47244. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47245. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47246. */
  47247. /**
  47248. * Sets the shadow projection scale against the optimal computed one.
  47249. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47250. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47251. */
  47252. shadowOrthoScale: number;
  47253. /**
  47254. * Automatically compute the projection matrix to best fit (including all the casters)
  47255. * on each frame.
  47256. */
  47257. autoUpdateExtends: boolean;
  47258. private _orthoLeft;
  47259. private _orthoRight;
  47260. private _orthoTop;
  47261. private _orthoBottom;
  47262. /**
  47263. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  47264. * The directional light is emitted from everywhere in the given direction.
  47265. * It can cast shadows.
  47266. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47267. * @param name The friendly name of the light
  47268. * @param direction The direction of the light
  47269. * @param scene The scene the light belongs to
  47270. */
  47271. constructor(name: string, direction: Vector3, scene: Scene);
  47272. /**
  47273. * Returns the string "DirectionalLight".
  47274. * @return The class name
  47275. */
  47276. getClassName(): string;
  47277. /**
  47278. * Returns the integer 1.
  47279. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47280. */
  47281. getTypeID(): number;
  47282. /**
  47283. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  47284. * Returns the DirectionalLight Shadow projection matrix.
  47285. */
  47286. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47287. /**
  47288. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  47289. * Returns the DirectionalLight Shadow projection matrix.
  47290. */
  47291. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  47292. /**
  47293. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  47294. * Returns the DirectionalLight Shadow projection matrix.
  47295. */
  47296. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47297. protected _buildUniformLayout(): void;
  47298. /**
  47299. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  47300. * @param effect The effect to update
  47301. * @param lightIndex The index of the light in the effect to update
  47302. * @returns The directional light
  47303. */
  47304. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  47305. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  47306. /**
  47307. * Gets the minZ used for shadow according to both the scene and the light.
  47308. *
  47309. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47310. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47311. * @param activeCamera The camera we are returning the min for
  47312. * @returns the depth min z
  47313. */
  47314. getDepthMinZ(activeCamera: Camera): number;
  47315. /**
  47316. * Gets the maxZ used for shadow according to both the scene and the light.
  47317. *
  47318. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47319. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47320. * @param activeCamera The camera we are returning the max for
  47321. * @returns the depth max z
  47322. */
  47323. getDepthMaxZ(activeCamera: Camera): number;
  47324. /**
  47325. * Prepares the list of defines specific to the light type.
  47326. * @param defines the list of defines
  47327. * @param lightIndex defines the index of the light for the effect
  47328. */
  47329. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47330. }
  47331. }
  47332. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  47333. import { Mesh } from "babylonjs/Meshes/mesh";
  47334. /**
  47335. * Class containing static functions to help procedurally build meshes
  47336. */
  47337. export class HemisphereBuilder {
  47338. /**
  47339. * Creates a hemisphere mesh
  47340. * @param name defines the name of the mesh
  47341. * @param options defines the options used to create the mesh
  47342. * @param scene defines the hosting scene
  47343. * @returns the hemisphere mesh
  47344. */
  47345. static CreateHemisphere(name: string, options: {
  47346. segments?: number;
  47347. diameter?: number;
  47348. sideOrientation?: number;
  47349. }, scene: any): Mesh;
  47350. }
  47351. }
  47352. declare module "babylonjs/Lights/spotLight" {
  47353. import { Nullable } from "babylonjs/types";
  47354. import { Scene } from "babylonjs/scene";
  47355. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47356. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47357. import { Effect } from "babylonjs/Materials/effect";
  47358. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47359. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  47360. /**
  47361. * A spot light is defined by a position, a direction, an angle, and an exponent.
  47362. * These values define a cone of light starting from the position, emitting toward the direction.
  47363. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  47364. * and the exponent defines the speed of the decay of the light with distance (reach).
  47365. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47366. */
  47367. export class SpotLight extends ShadowLight {
  47368. private _angle;
  47369. private _innerAngle;
  47370. private _cosHalfAngle;
  47371. private _lightAngleScale;
  47372. private _lightAngleOffset;
  47373. /**
  47374. * Gets the cone angle of the spot light in Radians.
  47375. */
  47376. /**
  47377. * Sets the cone angle of the spot light in Radians.
  47378. */
  47379. angle: number;
  47380. /**
  47381. * Only used in gltf falloff mode, this defines the angle where
  47382. * the directional falloff will start before cutting at angle which could be seen
  47383. * as outer angle.
  47384. */
  47385. /**
  47386. * Only used in gltf falloff mode, this defines the angle where
  47387. * the directional falloff will start before cutting at angle which could be seen
  47388. * as outer angle.
  47389. */
  47390. innerAngle: number;
  47391. private _shadowAngleScale;
  47392. /**
  47393. * Allows scaling the angle of the light for shadow generation only.
  47394. */
  47395. /**
  47396. * Allows scaling the angle of the light for shadow generation only.
  47397. */
  47398. shadowAngleScale: number;
  47399. /**
  47400. * The light decay speed with the distance from the emission spot.
  47401. */
  47402. exponent: number;
  47403. private _projectionTextureMatrix;
  47404. /**
  47405. * Allows reading the projecton texture
  47406. */
  47407. readonly projectionTextureMatrix: Matrix;
  47408. protected _projectionTextureLightNear: number;
  47409. /**
  47410. * Gets the near clip of the Spotlight for texture projection.
  47411. */
  47412. /**
  47413. * Sets the near clip of the Spotlight for texture projection.
  47414. */
  47415. projectionTextureLightNear: number;
  47416. protected _projectionTextureLightFar: number;
  47417. /**
  47418. * Gets the far clip of the Spotlight for texture projection.
  47419. */
  47420. /**
  47421. * Sets the far clip of the Spotlight for texture projection.
  47422. */
  47423. projectionTextureLightFar: number;
  47424. protected _projectionTextureUpDirection: Vector3;
  47425. /**
  47426. * Gets the Up vector of the Spotlight for texture projection.
  47427. */
  47428. /**
  47429. * Sets the Up vector of the Spotlight for texture projection.
  47430. */
  47431. projectionTextureUpDirection: Vector3;
  47432. private _projectionTexture;
  47433. /**
  47434. * Gets the projection texture of the light.
  47435. */
  47436. /**
  47437. * Sets the projection texture of the light.
  47438. */
  47439. projectionTexture: Nullable<BaseTexture>;
  47440. private _projectionTextureViewLightDirty;
  47441. private _projectionTextureProjectionLightDirty;
  47442. private _projectionTextureDirty;
  47443. private _projectionTextureViewTargetVector;
  47444. private _projectionTextureViewLightMatrix;
  47445. private _projectionTextureProjectionLightMatrix;
  47446. private _projectionTextureScalingMatrix;
  47447. /**
  47448. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  47449. * It can cast shadows.
  47450. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47451. * @param name The light friendly name
  47452. * @param position The position of the spot light in the scene
  47453. * @param direction The direction of the light in the scene
  47454. * @param angle The cone angle of the light in Radians
  47455. * @param exponent The light decay speed with the distance from the emission spot
  47456. * @param scene The scene the lights belongs to
  47457. */
  47458. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  47459. /**
  47460. * Returns the string "SpotLight".
  47461. * @returns the class name
  47462. */
  47463. getClassName(): string;
  47464. /**
  47465. * Returns the integer 2.
  47466. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47467. */
  47468. getTypeID(): number;
  47469. /**
  47470. * Overrides the direction setter to recompute the projection texture view light Matrix.
  47471. */
  47472. protected _setDirection(value: Vector3): void;
  47473. /**
  47474. * Overrides the position setter to recompute the projection texture view light Matrix.
  47475. */
  47476. protected _setPosition(value: Vector3): void;
  47477. /**
  47478. * 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.
  47479. * Returns the SpotLight.
  47480. */
  47481. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47482. protected _computeProjectionTextureViewLightMatrix(): void;
  47483. protected _computeProjectionTextureProjectionLightMatrix(): void;
  47484. /**
  47485. * Main function for light texture projection matrix computing.
  47486. */
  47487. protected _computeProjectionTextureMatrix(): void;
  47488. protected _buildUniformLayout(): void;
  47489. private _computeAngleValues;
  47490. /**
  47491. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  47492. * @param effect The effect to update
  47493. * @param lightIndex The index of the light in the effect to update
  47494. * @returns The spot light
  47495. */
  47496. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  47497. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  47498. /**
  47499. * Disposes the light and the associated resources.
  47500. */
  47501. dispose(): void;
  47502. /**
  47503. * Prepares the list of defines specific to the light type.
  47504. * @param defines the list of defines
  47505. * @param lightIndex defines the index of the light for the effect
  47506. */
  47507. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47508. }
  47509. }
  47510. declare module "babylonjs/Gizmos/lightGizmo" {
  47511. import { Nullable } from "babylonjs/types";
  47512. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47513. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47514. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47515. import { Light } from "babylonjs/Lights/light";
  47516. /**
  47517. * Gizmo that enables viewing a light
  47518. */
  47519. export class LightGizmo extends Gizmo {
  47520. private _lightMesh;
  47521. private _material;
  47522. private cachedPosition;
  47523. private cachedForward;
  47524. /**
  47525. * Creates a LightGizmo
  47526. * @param gizmoLayer The utility layer the gizmo will be added to
  47527. */
  47528. constructor(gizmoLayer?: UtilityLayerRenderer);
  47529. private _light;
  47530. /**
  47531. * The light that the gizmo is attached to
  47532. */
  47533. light: Nullable<Light>;
  47534. /**
  47535. * Gets the material used to render the light gizmo
  47536. */
  47537. readonly material: StandardMaterial;
  47538. /**
  47539. * @hidden
  47540. * Updates the gizmo to match the attached mesh's position/rotation
  47541. */
  47542. protected _update(): void;
  47543. private static _Scale;
  47544. /**
  47545. * Creates the lines for a light mesh
  47546. */
  47547. private static _createLightLines;
  47548. /**
  47549. * Disposes of the light gizmo
  47550. */
  47551. dispose(): void;
  47552. private static _CreateHemisphericLightMesh;
  47553. private static _CreatePointLightMesh;
  47554. private static _CreateSpotLightMesh;
  47555. private static _CreateDirectionalLightMesh;
  47556. }
  47557. }
  47558. declare module "babylonjs/Gizmos/index" {
  47559. export * from "babylonjs/Gizmos/axisDragGizmo";
  47560. export * from "babylonjs/Gizmos/axisScaleGizmo";
  47561. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  47562. export * from "babylonjs/Gizmos/gizmo";
  47563. export * from "babylonjs/Gizmos/gizmoManager";
  47564. export * from "babylonjs/Gizmos/planeRotationGizmo";
  47565. export * from "babylonjs/Gizmos/positionGizmo";
  47566. export * from "babylonjs/Gizmos/rotationGizmo";
  47567. export * from "babylonjs/Gizmos/scaleGizmo";
  47568. export * from "babylonjs/Gizmos/lightGizmo";
  47569. export * from "babylonjs/Gizmos/planeDragGizmo";
  47570. }
  47571. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  47572. /** @hidden */
  47573. export var backgroundFragmentDeclaration: {
  47574. name: string;
  47575. shader: string;
  47576. };
  47577. }
  47578. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  47579. /** @hidden */
  47580. export var backgroundUboDeclaration: {
  47581. name: string;
  47582. shader: string;
  47583. };
  47584. }
  47585. declare module "babylonjs/Shaders/background.fragment" {
  47586. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  47587. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  47588. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  47589. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  47590. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47591. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47592. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47593. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  47594. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  47595. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  47596. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  47597. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  47598. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  47599. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  47600. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  47601. /** @hidden */
  47602. export var backgroundPixelShader: {
  47603. name: string;
  47604. shader: string;
  47605. };
  47606. }
  47607. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  47608. /** @hidden */
  47609. export var backgroundVertexDeclaration: {
  47610. name: string;
  47611. shader: string;
  47612. };
  47613. }
  47614. declare module "babylonjs/Shaders/background.vertex" {
  47615. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  47616. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  47617. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47618. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  47619. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  47620. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  47621. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  47622. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47623. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47624. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  47625. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  47626. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  47627. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  47628. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  47629. /** @hidden */
  47630. export var backgroundVertexShader: {
  47631. name: string;
  47632. shader: string;
  47633. };
  47634. }
  47635. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  47636. import { Nullable, int, float } from "babylonjs/types";
  47637. import { Scene } from "babylonjs/scene";
  47638. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47639. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47640. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47641. import { Mesh } from "babylonjs/Meshes/mesh";
  47642. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  47643. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  47644. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  47645. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47646. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  47647. import { Color3 } from "babylonjs/Maths/math.color";
  47648. import "babylonjs/Shaders/background.fragment";
  47649. import "babylonjs/Shaders/background.vertex";
  47650. /**
  47651. * Background material used to create an efficient environement around your scene.
  47652. */
  47653. export class BackgroundMaterial extends PushMaterial {
  47654. /**
  47655. * Standard reflectance value at parallel view angle.
  47656. */
  47657. static StandardReflectance0: number;
  47658. /**
  47659. * Standard reflectance value at grazing angle.
  47660. */
  47661. static StandardReflectance90: number;
  47662. protected _primaryColor: Color3;
  47663. /**
  47664. * Key light Color (multiply against the environement texture)
  47665. */
  47666. primaryColor: Color3;
  47667. protected __perceptualColor: Nullable<Color3>;
  47668. /**
  47669. * Experimental Internal Use Only.
  47670. *
  47671. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  47672. * This acts as a helper to set the primary color to a more "human friendly" value.
  47673. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  47674. * output color as close as possible from the chosen value.
  47675. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  47676. * part of lighting setup.)
  47677. */
  47678. _perceptualColor: Nullable<Color3>;
  47679. protected _primaryColorShadowLevel: float;
  47680. /**
  47681. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  47682. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  47683. */
  47684. primaryColorShadowLevel: float;
  47685. protected _primaryColorHighlightLevel: float;
  47686. /**
  47687. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  47688. * The primary color is used at the level chosen to define what the white area would look.
  47689. */
  47690. primaryColorHighlightLevel: float;
  47691. protected _reflectionTexture: Nullable<BaseTexture>;
  47692. /**
  47693. * Reflection Texture used in the material.
  47694. * Should be author in a specific way for the best result (refer to the documentation).
  47695. */
  47696. reflectionTexture: Nullable<BaseTexture>;
  47697. protected _reflectionBlur: float;
  47698. /**
  47699. * Reflection Texture level of blur.
  47700. *
  47701. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  47702. * texture twice.
  47703. */
  47704. reflectionBlur: float;
  47705. protected _diffuseTexture: Nullable<BaseTexture>;
  47706. /**
  47707. * Diffuse Texture used in the material.
  47708. * Should be author in a specific way for the best result (refer to the documentation).
  47709. */
  47710. diffuseTexture: Nullable<BaseTexture>;
  47711. protected _shadowLights: Nullable<IShadowLight[]>;
  47712. /**
  47713. * Specify the list of lights casting shadow on the material.
  47714. * All scene shadow lights will be included if null.
  47715. */
  47716. shadowLights: Nullable<IShadowLight[]>;
  47717. protected _shadowLevel: float;
  47718. /**
  47719. * Helps adjusting the shadow to a softer level if required.
  47720. * 0 means black shadows and 1 means no shadows.
  47721. */
  47722. shadowLevel: float;
  47723. protected _sceneCenter: Vector3;
  47724. /**
  47725. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  47726. * It is usually zero but might be interesting to modify according to your setup.
  47727. */
  47728. sceneCenter: Vector3;
  47729. protected _opacityFresnel: boolean;
  47730. /**
  47731. * This helps specifying that the material is falling off to the sky box at grazing angle.
  47732. * This helps ensuring a nice transition when the camera goes under the ground.
  47733. */
  47734. opacityFresnel: boolean;
  47735. protected _reflectionFresnel: boolean;
  47736. /**
  47737. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  47738. * This helps adding a mirror texture on the ground.
  47739. */
  47740. reflectionFresnel: boolean;
  47741. protected _reflectionFalloffDistance: number;
  47742. /**
  47743. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  47744. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  47745. */
  47746. reflectionFalloffDistance: number;
  47747. protected _reflectionAmount: number;
  47748. /**
  47749. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  47750. */
  47751. reflectionAmount: number;
  47752. protected _reflectionReflectance0: number;
  47753. /**
  47754. * This specifies the weight of the reflection at grazing angle.
  47755. */
  47756. reflectionReflectance0: number;
  47757. protected _reflectionReflectance90: number;
  47758. /**
  47759. * This specifies the weight of the reflection at a perpendicular point of view.
  47760. */
  47761. reflectionReflectance90: number;
  47762. /**
  47763. * Sets the reflection reflectance fresnel values according to the default standard
  47764. * empirically know to work well :-)
  47765. */
  47766. reflectionStandardFresnelWeight: number;
  47767. protected _useRGBColor: boolean;
  47768. /**
  47769. * Helps to directly use the maps channels instead of their level.
  47770. */
  47771. useRGBColor: boolean;
  47772. protected _enableNoise: boolean;
  47773. /**
  47774. * This helps reducing the banding effect that could occur on the background.
  47775. */
  47776. enableNoise: boolean;
  47777. /**
  47778. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47779. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  47780. * Recommended to be keep at 1.0 except for special cases.
  47781. */
  47782. fovMultiplier: number;
  47783. private _fovMultiplier;
  47784. /**
  47785. * Enable the FOV adjustment feature controlled by fovMultiplier.
  47786. */
  47787. useEquirectangularFOV: boolean;
  47788. private _maxSimultaneousLights;
  47789. /**
  47790. * Number of Simultaneous lights allowed on the material.
  47791. */
  47792. maxSimultaneousLights: int;
  47793. /**
  47794. * Default configuration related to image processing available in the Background Material.
  47795. */
  47796. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47797. /**
  47798. * Keep track of the image processing observer to allow dispose and replace.
  47799. */
  47800. private _imageProcessingObserver;
  47801. /**
  47802. * Attaches a new image processing configuration to the PBR Material.
  47803. * @param configuration (if null the scene configuration will be use)
  47804. */
  47805. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47806. /**
  47807. * Gets the image processing configuration used either in this material.
  47808. */
  47809. /**
  47810. * Sets the Default image processing configuration used either in the this material.
  47811. *
  47812. * If sets to null, the scene one is in use.
  47813. */
  47814. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  47815. /**
  47816. * Gets wether the color curves effect is enabled.
  47817. */
  47818. /**
  47819. * Sets wether the color curves effect is enabled.
  47820. */
  47821. cameraColorCurvesEnabled: boolean;
  47822. /**
  47823. * Gets wether the color grading effect is enabled.
  47824. */
  47825. /**
  47826. * Gets wether the color grading effect is enabled.
  47827. */
  47828. cameraColorGradingEnabled: boolean;
  47829. /**
  47830. * Gets wether tonemapping is enabled or not.
  47831. */
  47832. /**
  47833. * Sets wether tonemapping is enabled or not
  47834. */
  47835. cameraToneMappingEnabled: boolean;
  47836. /**
  47837. * The camera exposure used on this material.
  47838. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47839. * This corresponds to a photographic exposure.
  47840. */
  47841. /**
  47842. * The camera exposure used on this material.
  47843. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47844. * This corresponds to a photographic exposure.
  47845. */
  47846. cameraExposure: float;
  47847. /**
  47848. * Gets The camera contrast used on this material.
  47849. */
  47850. /**
  47851. * Sets The camera contrast used on this material.
  47852. */
  47853. cameraContrast: float;
  47854. /**
  47855. * Gets the Color Grading 2D Lookup Texture.
  47856. */
  47857. /**
  47858. * Sets the Color Grading 2D Lookup Texture.
  47859. */
  47860. cameraColorGradingTexture: Nullable<BaseTexture>;
  47861. /**
  47862. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47863. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47864. * 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;
  47865. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47866. */
  47867. /**
  47868. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47869. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47870. * 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;
  47871. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47872. */
  47873. cameraColorCurves: Nullable<ColorCurves>;
  47874. /**
  47875. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  47876. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  47877. */
  47878. switchToBGR: boolean;
  47879. private _renderTargets;
  47880. private _reflectionControls;
  47881. private _white;
  47882. private _primaryShadowColor;
  47883. private _primaryHighlightColor;
  47884. /**
  47885. * Instantiates a Background Material in the given scene
  47886. * @param name The friendly name of the material
  47887. * @param scene The scene to add the material to
  47888. */
  47889. constructor(name: string, scene: Scene);
  47890. /**
  47891. * Gets a boolean indicating that current material needs to register RTT
  47892. */
  47893. readonly hasRenderTargetTextures: boolean;
  47894. /**
  47895. * The entire material has been created in order to prevent overdraw.
  47896. * @returns false
  47897. */
  47898. needAlphaTesting(): boolean;
  47899. /**
  47900. * The entire material has been created in order to prevent overdraw.
  47901. * @returns true if blending is enable
  47902. */
  47903. needAlphaBlending(): boolean;
  47904. /**
  47905. * Checks wether the material is ready to be rendered for a given mesh.
  47906. * @param mesh The mesh to render
  47907. * @param subMesh The submesh to check against
  47908. * @param useInstances Specify wether or not the material is used with instances
  47909. * @returns true if all the dependencies are ready (Textures, Effects...)
  47910. */
  47911. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  47912. /**
  47913. * Compute the primary color according to the chosen perceptual color.
  47914. */
  47915. private _computePrimaryColorFromPerceptualColor;
  47916. /**
  47917. * Compute the highlights and shadow colors according to their chosen levels.
  47918. */
  47919. private _computePrimaryColors;
  47920. /**
  47921. * Build the uniform buffer used in the material.
  47922. */
  47923. buildUniformLayout(): void;
  47924. /**
  47925. * Unbind the material.
  47926. */
  47927. unbind(): void;
  47928. /**
  47929. * Bind only the world matrix to the material.
  47930. * @param world The world matrix to bind.
  47931. */
  47932. bindOnlyWorldMatrix(world: Matrix): void;
  47933. /**
  47934. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  47935. * @param world The world matrix to bind.
  47936. * @param subMesh The submesh to bind for.
  47937. */
  47938. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  47939. /**
  47940. * Checks to see if a texture is used in the material.
  47941. * @param texture - Base texture to use.
  47942. * @returns - Boolean specifying if a texture is used in the material.
  47943. */
  47944. hasTexture(texture: BaseTexture): boolean;
  47945. /**
  47946. * Dispose the material.
  47947. * @param forceDisposeEffect Force disposal of the associated effect.
  47948. * @param forceDisposeTextures Force disposal of the associated textures.
  47949. */
  47950. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  47951. /**
  47952. * Clones the material.
  47953. * @param name The cloned name.
  47954. * @returns The cloned material.
  47955. */
  47956. clone(name: string): BackgroundMaterial;
  47957. /**
  47958. * Serializes the current material to its JSON representation.
  47959. * @returns The JSON representation.
  47960. */
  47961. serialize(): any;
  47962. /**
  47963. * Gets the class name of the material
  47964. * @returns "BackgroundMaterial"
  47965. */
  47966. getClassName(): string;
  47967. /**
  47968. * Parse a JSON input to create back a background material.
  47969. * @param source The JSON data to parse
  47970. * @param scene The scene to create the parsed material in
  47971. * @param rootUrl The root url of the assets the material depends upon
  47972. * @returns the instantiated BackgroundMaterial.
  47973. */
  47974. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  47975. }
  47976. }
  47977. declare module "babylonjs/Helpers/environmentHelper" {
  47978. import { Observable } from "babylonjs/Misc/observable";
  47979. import { Nullable } from "babylonjs/types";
  47980. import { Scene } from "babylonjs/scene";
  47981. import { Vector3 } from "babylonjs/Maths/math.vector";
  47982. import { Color3 } from "babylonjs/Maths/math.color";
  47983. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47984. import { Mesh } from "babylonjs/Meshes/mesh";
  47985. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47986. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  47987. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  47988. import "babylonjs/Meshes/Builders/planeBuilder";
  47989. import "babylonjs/Meshes/Builders/boxBuilder";
  47990. /**
  47991. * Represents the different options available during the creation of
  47992. * a Environment helper.
  47993. *
  47994. * This can control the default ground, skybox and image processing setup of your scene.
  47995. */
  47996. export interface IEnvironmentHelperOptions {
  47997. /**
  47998. * Specifies wether or not to create a ground.
  47999. * True by default.
  48000. */
  48001. createGround: boolean;
  48002. /**
  48003. * Specifies the ground size.
  48004. * 15 by default.
  48005. */
  48006. groundSize: number;
  48007. /**
  48008. * The texture used on the ground for the main color.
  48009. * Comes from the BabylonJS CDN by default.
  48010. *
  48011. * Remarks: Can be either a texture or a url.
  48012. */
  48013. groundTexture: string | BaseTexture;
  48014. /**
  48015. * The color mixed in the ground texture by default.
  48016. * BabylonJS clearColor by default.
  48017. */
  48018. groundColor: Color3;
  48019. /**
  48020. * Specifies the ground opacity.
  48021. * 1 by default.
  48022. */
  48023. groundOpacity: number;
  48024. /**
  48025. * Enables the ground to receive shadows.
  48026. * True by default.
  48027. */
  48028. enableGroundShadow: boolean;
  48029. /**
  48030. * Helps preventing the shadow to be fully black on the ground.
  48031. * 0.5 by default.
  48032. */
  48033. groundShadowLevel: number;
  48034. /**
  48035. * Creates a mirror texture attach to the ground.
  48036. * false by default.
  48037. */
  48038. enableGroundMirror: boolean;
  48039. /**
  48040. * Specifies the ground mirror size ratio.
  48041. * 0.3 by default as the default kernel is 64.
  48042. */
  48043. groundMirrorSizeRatio: number;
  48044. /**
  48045. * Specifies the ground mirror blur kernel size.
  48046. * 64 by default.
  48047. */
  48048. groundMirrorBlurKernel: number;
  48049. /**
  48050. * Specifies the ground mirror visibility amount.
  48051. * 1 by default
  48052. */
  48053. groundMirrorAmount: number;
  48054. /**
  48055. * Specifies the ground mirror reflectance weight.
  48056. * This uses the standard weight of the background material to setup the fresnel effect
  48057. * of the mirror.
  48058. * 1 by default.
  48059. */
  48060. groundMirrorFresnelWeight: number;
  48061. /**
  48062. * Specifies the ground mirror Falloff distance.
  48063. * This can helps reducing the size of the reflection.
  48064. * 0 by Default.
  48065. */
  48066. groundMirrorFallOffDistance: number;
  48067. /**
  48068. * Specifies the ground mirror texture type.
  48069. * Unsigned Int by Default.
  48070. */
  48071. groundMirrorTextureType: number;
  48072. /**
  48073. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  48074. * the shown objects.
  48075. */
  48076. groundYBias: number;
  48077. /**
  48078. * Specifies wether or not to create a skybox.
  48079. * True by default.
  48080. */
  48081. createSkybox: boolean;
  48082. /**
  48083. * Specifies the skybox size.
  48084. * 20 by default.
  48085. */
  48086. skyboxSize: number;
  48087. /**
  48088. * The texture used on the skybox for the main color.
  48089. * Comes from the BabylonJS CDN by default.
  48090. *
  48091. * Remarks: Can be either a texture or a url.
  48092. */
  48093. skyboxTexture: string | BaseTexture;
  48094. /**
  48095. * The color mixed in the skybox texture by default.
  48096. * BabylonJS clearColor by default.
  48097. */
  48098. skyboxColor: Color3;
  48099. /**
  48100. * The background rotation around the Y axis of the scene.
  48101. * This helps aligning the key lights of your scene with the background.
  48102. * 0 by default.
  48103. */
  48104. backgroundYRotation: number;
  48105. /**
  48106. * Compute automatically the size of the elements to best fit with the scene.
  48107. */
  48108. sizeAuto: boolean;
  48109. /**
  48110. * Default position of the rootMesh if autoSize is not true.
  48111. */
  48112. rootPosition: Vector3;
  48113. /**
  48114. * Sets up the image processing in the scene.
  48115. * true by default.
  48116. */
  48117. setupImageProcessing: boolean;
  48118. /**
  48119. * The texture used as your environment texture in the scene.
  48120. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  48121. *
  48122. * Remarks: Can be either a texture or a url.
  48123. */
  48124. environmentTexture: string | BaseTexture;
  48125. /**
  48126. * The value of the exposure to apply to the scene.
  48127. * 0.6 by default if setupImageProcessing is true.
  48128. */
  48129. cameraExposure: number;
  48130. /**
  48131. * The value of the contrast to apply to the scene.
  48132. * 1.6 by default if setupImageProcessing is true.
  48133. */
  48134. cameraContrast: number;
  48135. /**
  48136. * Specifies wether or not tonemapping should be enabled in the scene.
  48137. * true by default if setupImageProcessing is true.
  48138. */
  48139. toneMappingEnabled: boolean;
  48140. }
  48141. /**
  48142. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  48143. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  48144. * It also helps with the default setup of your imageProcessing configuration.
  48145. */
  48146. export class EnvironmentHelper {
  48147. /**
  48148. * Default ground texture URL.
  48149. */
  48150. private static _groundTextureCDNUrl;
  48151. /**
  48152. * Default skybox texture URL.
  48153. */
  48154. private static _skyboxTextureCDNUrl;
  48155. /**
  48156. * Default environment texture URL.
  48157. */
  48158. private static _environmentTextureCDNUrl;
  48159. /**
  48160. * Creates the default options for the helper.
  48161. */
  48162. private static _getDefaultOptions;
  48163. private _rootMesh;
  48164. /**
  48165. * Gets the root mesh created by the helper.
  48166. */
  48167. readonly rootMesh: Mesh;
  48168. private _skybox;
  48169. /**
  48170. * Gets the skybox created by the helper.
  48171. */
  48172. readonly skybox: Nullable<Mesh>;
  48173. private _skyboxTexture;
  48174. /**
  48175. * Gets the skybox texture created by the helper.
  48176. */
  48177. readonly skyboxTexture: Nullable<BaseTexture>;
  48178. private _skyboxMaterial;
  48179. /**
  48180. * Gets the skybox material created by the helper.
  48181. */
  48182. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  48183. private _ground;
  48184. /**
  48185. * Gets the ground mesh created by the helper.
  48186. */
  48187. readonly ground: Nullable<Mesh>;
  48188. private _groundTexture;
  48189. /**
  48190. * Gets the ground texture created by the helper.
  48191. */
  48192. readonly groundTexture: Nullable<BaseTexture>;
  48193. private _groundMirror;
  48194. /**
  48195. * Gets the ground mirror created by the helper.
  48196. */
  48197. readonly groundMirror: Nullable<MirrorTexture>;
  48198. /**
  48199. * Gets the ground mirror render list to helps pushing the meshes
  48200. * you wish in the ground reflection.
  48201. */
  48202. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  48203. private _groundMaterial;
  48204. /**
  48205. * Gets the ground material created by the helper.
  48206. */
  48207. readonly groundMaterial: Nullable<BackgroundMaterial>;
  48208. /**
  48209. * Stores the creation options.
  48210. */
  48211. private readonly _scene;
  48212. private _options;
  48213. /**
  48214. * This observable will be notified with any error during the creation of the environment,
  48215. * mainly texture creation errors.
  48216. */
  48217. onErrorObservable: Observable<{
  48218. message?: string;
  48219. exception?: any;
  48220. }>;
  48221. /**
  48222. * constructor
  48223. * @param options Defines the options we want to customize the helper
  48224. * @param scene The scene to add the material to
  48225. */
  48226. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  48227. /**
  48228. * Updates the background according to the new options
  48229. * @param options
  48230. */
  48231. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  48232. /**
  48233. * Sets the primary color of all the available elements.
  48234. * @param color the main color to affect to the ground and the background
  48235. */
  48236. setMainColor(color: Color3): void;
  48237. /**
  48238. * Setup the image processing according to the specified options.
  48239. */
  48240. private _setupImageProcessing;
  48241. /**
  48242. * Setup the environment texture according to the specified options.
  48243. */
  48244. private _setupEnvironmentTexture;
  48245. /**
  48246. * Setup the background according to the specified options.
  48247. */
  48248. private _setupBackground;
  48249. /**
  48250. * Get the scene sizes according to the setup.
  48251. */
  48252. private _getSceneSize;
  48253. /**
  48254. * Setup the ground according to the specified options.
  48255. */
  48256. private _setupGround;
  48257. /**
  48258. * Setup the ground material according to the specified options.
  48259. */
  48260. private _setupGroundMaterial;
  48261. /**
  48262. * Setup the ground diffuse texture according to the specified options.
  48263. */
  48264. private _setupGroundDiffuseTexture;
  48265. /**
  48266. * Setup the ground mirror texture according to the specified options.
  48267. */
  48268. private _setupGroundMirrorTexture;
  48269. /**
  48270. * Setup the ground to receive the mirror texture.
  48271. */
  48272. private _setupMirrorInGroundMaterial;
  48273. /**
  48274. * Setup the skybox according to the specified options.
  48275. */
  48276. private _setupSkybox;
  48277. /**
  48278. * Setup the skybox material according to the specified options.
  48279. */
  48280. private _setupSkyboxMaterial;
  48281. /**
  48282. * Setup the skybox reflection texture according to the specified options.
  48283. */
  48284. private _setupSkyboxReflectionTexture;
  48285. private _errorHandler;
  48286. /**
  48287. * Dispose all the elements created by the Helper.
  48288. */
  48289. dispose(): void;
  48290. }
  48291. }
  48292. declare module "babylonjs/Helpers/photoDome" {
  48293. import { Observable } from "babylonjs/Misc/observable";
  48294. import { Nullable } from "babylonjs/types";
  48295. import { Scene } from "babylonjs/scene";
  48296. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48297. import { Mesh } from "babylonjs/Meshes/mesh";
  48298. import { Texture } from "babylonjs/Materials/Textures/texture";
  48299. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  48300. import "babylonjs/Meshes/Builders/sphereBuilder";
  48301. /**
  48302. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  48303. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  48304. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  48305. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48306. */
  48307. export class PhotoDome extends TransformNode {
  48308. /**
  48309. * Define the image as a Monoscopic panoramic 360 image.
  48310. */
  48311. static readonly MODE_MONOSCOPIC: number;
  48312. /**
  48313. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  48314. */
  48315. static readonly MODE_TOPBOTTOM: number;
  48316. /**
  48317. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  48318. */
  48319. static readonly MODE_SIDEBYSIDE: number;
  48320. private _useDirectMapping;
  48321. /**
  48322. * The texture being displayed on the sphere
  48323. */
  48324. protected _photoTexture: Texture;
  48325. /**
  48326. * Gets or sets the texture being displayed on the sphere
  48327. */
  48328. photoTexture: Texture;
  48329. /**
  48330. * Observable raised when an error occured while loading the 360 image
  48331. */
  48332. onLoadErrorObservable: Observable<string>;
  48333. /**
  48334. * The skybox material
  48335. */
  48336. protected _material: BackgroundMaterial;
  48337. /**
  48338. * The surface used for the skybox
  48339. */
  48340. protected _mesh: Mesh;
  48341. /**
  48342. * Gets the mesh used for the skybox.
  48343. */
  48344. readonly mesh: Mesh;
  48345. /**
  48346. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48347. * Also see the options.resolution property.
  48348. */
  48349. fovMultiplier: number;
  48350. private _imageMode;
  48351. /**
  48352. * Gets or set the current video mode for the video. It can be:
  48353. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  48354. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  48355. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  48356. */
  48357. imageMode: number;
  48358. /**
  48359. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  48360. * @param name Element's name, child elements will append suffixes for their own names.
  48361. * @param urlsOfPhoto defines the url of the photo to display
  48362. * @param options defines an object containing optional or exposed sub element properties
  48363. * @param onError defines a callback called when an error occured while loading the texture
  48364. */
  48365. constructor(name: string, urlOfPhoto: string, options: {
  48366. resolution?: number;
  48367. size?: number;
  48368. useDirectMapping?: boolean;
  48369. faceForward?: boolean;
  48370. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  48371. private _onBeforeCameraRenderObserver;
  48372. private _changeImageMode;
  48373. /**
  48374. * Releases resources associated with this node.
  48375. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48376. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48377. */
  48378. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48379. }
  48380. }
  48381. declare module "babylonjs/Misc/rgbdTextureTools" {
  48382. import "babylonjs/Shaders/rgbdDecode.fragment";
  48383. import { Texture } from "babylonjs/Materials/Textures/texture";
  48384. /**
  48385. * Class used to host RGBD texture specific utilities
  48386. */
  48387. export class RGBDTextureTools {
  48388. /**
  48389. * Expand the RGBD Texture from RGBD to Half Float if possible.
  48390. * @param texture the texture to expand.
  48391. */
  48392. static ExpandRGBDTexture(texture: Texture): void;
  48393. }
  48394. }
  48395. declare module "babylonjs/Misc/brdfTextureTools" {
  48396. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48397. import { Scene } from "babylonjs/scene";
  48398. /**
  48399. * Class used to host texture specific utilities
  48400. */
  48401. export class BRDFTextureTools {
  48402. /**
  48403. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  48404. * @param scene defines the hosting scene
  48405. * @returns the environment BRDF texture
  48406. */
  48407. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  48408. private static _environmentBRDFBase64Texture;
  48409. }
  48410. }
  48411. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  48412. import { Nullable } from "babylonjs/types";
  48413. import { Color3 } from "babylonjs/Maths/math.color";
  48414. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48415. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48416. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48417. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  48418. import { Engine } from "babylonjs/Engines/engine";
  48419. import { Scene } from "babylonjs/scene";
  48420. /**
  48421. * @hidden
  48422. */
  48423. export interface IMaterialClearCoatDefines {
  48424. CLEARCOAT: boolean;
  48425. CLEARCOAT_DEFAULTIOR: boolean;
  48426. CLEARCOAT_TEXTURE: boolean;
  48427. CLEARCOAT_TEXTUREDIRECTUV: number;
  48428. CLEARCOAT_BUMP: boolean;
  48429. CLEARCOAT_BUMPDIRECTUV: number;
  48430. CLEARCOAT_TINT: boolean;
  48431. CLEARCOAT_TINT_TEXTURE: boolean;
  48432. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  48433. /** @hidden */
  48434. _areTexturesDirty: boolean;
  48435. }
  48436. /**
  48437. * Define the code related to the clear coat parameters of the pbr material.
  48438. */
  48439. export class PBRClearCoatConfiguration {
  48440. /**
  48441. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  48442. * The default fits with a polyurethane material.
  48443. */
  48444. private static readonly _DefaultIndexOfRefraction;
  48445. private _isEnabled;
  48446. /**
  48447. * Defines if the clear coat is enabled in the material.
  48448. */
  48449. isEnabled: boolean;
  48450. /**
  48451. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  48452. */
  48453. intensity: number;
  48454. /**
  48455. * Defines the clear coat layer roughness.
  48456. */
  48457. roughness: number;
  48458. private _indexOfRefraction;
  48459. /**
  48460. * Defines the index of refraction of the clear coat.
  48461. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  48462. * The default fits with a polyurethane material.
  48463. * Changing the default value is more performance intensive.
  48464. */
  48465. indexOfRefraction: number;
  48466. private _texture;
  48467. /**
  48468. * Stores the clear coat values in a texture.
  48469. */
  48470. texture: Nullable<BaseTexture>;
  48471. private _bumpTexture;
  48472. /**
  48473. * Define the clear coat specific bump texture.
  48474. */
  48475. bumpTexture: Nullable<BaseTexture>;
  48476. private _isTintEnabled;
  48477. /**
  48478. * Defines if the clear coat tint is enabled in the material.
  48479. */
  48480. isTintEnabled: boolean;
  48481. /**
  48482. * Defines the clear coat tint of the material.
  48483. * This is only use if tint is enabled
  48484. */
  48485. tintColor: Color3;
  48486. /**
  48487. * Defines the distance at which the tint color should be found in the
  48488. * clear coat media.
  48489. * This is only use if tint is enabled
  48490. */
  48491. tintColorAtDistance: number;
  48492. /**
  48493. * Defines the clear coat layer thickness.
  48494. * This is only use if tint is enabled
  48495. */
  48496. tintThickness: number;
  48497. private _tintTexture;
  48498. /**
  48499. * Stores the clear tint values in a texture.
  48500. * rgb is tint
  48501. * a is a thickness factor
  48502. */
  48503. tintTexture: Nullable<BaseTexture>;
  48504. /** @hidden */
  48505. private _internalMarkAllSubMeshesAsTexturesDirty;
  48506. /** @hidden */
  48507. _markAllSubMeshesAsTexturesDirty(): void;
  48508. /**
  48509. * Instantiate a new istance of clear coat configuration.
  48510. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48511. */
  48512. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48513. /**
  48514. * Gets wehter the submesh is ready to be used or not.
  48515. * @param defines the list of "defines" to update.
  48516. * @param scene defines the scene the material belongs to.
  48517. * @param engine defines the engine the material belongs to.
  48518. * @param disableBumpMap defines wether the material disables bump or not.
  48519. * @returns - boolean indicating that the submesh is ready or not.
  48520. */
  48521. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  48522. /**
  48523. * Checks to see if a texture is used in the material.
  48524. * @param defines the list of "defines" to update.
  48525. * @param scene defines the scene to the material belongs to.
  48526. */
  48527. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  48528. /**
  48529. * Binds the material data.
  48530. * @param uniformBuffer defines the Uniform buffer to fill in.
  48531. * @param scene defines the scene the material belongs to.
  48532. * @param engine defines the engine the material belongs to.
  48533. * @param disableBumpMap defines wether the material disables bump or not.
  48534. * @param isFrozen defines wether the material is frozen or not.
  48535. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  48536. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  48537. */
  48538. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  48539. /**
  48540. * Checks to see if a texture is used in the material.
  48541. * @param texture - Base texture to use.
  48542. * @returns - Boolean specifying if a texture is used in the material.
  48543. */
  48544. hasTexture(texture: BaseTexture): boolean;
  48545. /**
  48546. * Returns an array of the actively used textures.
  48547. * @param activeTextures Array of BaseTextures
  48548. */
  48549. getActiveTextures(activeTextures: BaseTexture[]): void;
  48550. /**
  48551. * Returns the animatable textures.
  48552. * @param animatables Array of animatable textures.
  48553. */
  48554. getAnimatables(animatables: IAnimatable[]): void;
  48555. /**
  48556. * Disposes the resources of the material.
  48557. * @param forceDisposeTextures - Forces the disposal of all textures.
  48558. */
  48559. dispose(forceDisposeTextures?: boolean): void;
  48560. /**
  48561. * Get the current class name of the texture useful for serialization or dynamic coding.
  48562. * @returns "PBRClearCoatConfiguration"
  48563. */
  48564. getClassName(): string;
  48565. /**
  48566. * Add fallbacks to the effect fallbacks list.
  48567. * @param defines defines the Base texture to use.
  48568. * @param fallbacks defines the current fallback list.
  48569. * @param currentRank defines the current fallback rank.
  48570. * @returns the new fallback rank.
  48571. */
  48572. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48573. /**
  48574. * Add the required uniforms to the current list.
  48575. * @param uniforms defines the current uniform list.
  48576. */
  48577. static AddUniforms(uniforms: string[]): void;
  48578. /**
  48579. * Add the required samplers to the current list.
  48580. * @param samplers defines the current sampler list.
  48581. */
  48582. static AddSamplers(samplers: string[]): void;
  48583. /**
  48584. * Add the required uniforms to the current buffer.
  48585. * @param uniformBuffer defines the current uniform buffer.
  48586. */
  48587. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48588. /**
  48589. * Makes a duplicate of the current configuration into another one.
  48590. * @param clearCoatConfiguration define the config where to copy the info
  48591. */
  48592. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  48593. /**
  48594. * Serializes this clear coat configuration.
  48595. * @returns - An object with the serialized config.
  48596. */
  48597. serialize(): any;
  48598. /**
  48599. * Parses a anisotropy Configuration from a serialized object.
  48600. * @param source - Serialized object.
  48601. * @param scene Defines the scene we are parsing for
  48602. * @param rootUrl Defines the rootUrl to load from
  48603. */
  48604. parse(source: any, scene: Scene, rootUrl: string): void;
  48605. }
  48606. }
  48607. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  48608. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48609. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48610. import { Vector2 } from "babylonjs/Maths/math.vector";
  48611. import { Scene } from "babylonjs/scene";
  48612. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48613. import { Nullable } from "babylonjs/types";
  48614. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48615. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  48616. /**
  48617. * @hidden
  48618. */
  48619. export interface IMaterialAnisotropicDefines {
  48620. ANISOTROPIC: boolean;
  48621. ANISOTROPIC_TEXTURE: boolean;
  48622. ANISOTROPIC_TEXTUREDIRECTUV: number;
  48623. MAINUV1: boolean;
  48624. _areTexturesDirty: boolean;
  48625. _needUVs: boolean;
  48626. }
  48627. /**
  48628. * Define the code related to the anisotropic parameters of the pbr material.
  48629. */
  48630. export class PBRAnisotropicConfiguration {
  48631. private _isEnabled;
  48632. /**
  48633. * Defines if the anisotropy is enabled in the material.
  48634. */
  48635. isEnabled: boolean;
  48636. /**
  48637. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  48638. */
  48639. intensity: number;
  48640. /**
  48641. * Defines if the effect is along the tangents, bitangents or in between.
  48642. * By default, the effect is "strectching" the highlights along the tangents.
  48643. */
  48644. direction: Vector2;
  48645. private _texture;
  48646. /**
  48647. * Stores the anisotropy values in a texture.
  48648. * rg is direction (like normal from -1 to 1)
  48649. * b is a intensity
  48650. */
  48651. texture: Nullable<BaseTexture>;
  48652. /** @hidden */
  48653. private _internalMarkAllSubMeshesAsTexturesDirty;
  48654. /** @hidden */
  48655. _markAllSubMeshesAsTexturesDirty(): void;
  48656. /**
  48657. * Instantiate a new istance of anisotropy configuration.
  48658. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48659. */
  48660. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48661. /**
  48662. * Specifies that the submesh is ready to be used.
  48663. * @param defines the list of "defines" to update.
  48664. * @param scene defines the scene the material belongs to.
  48665. * @returns - boolean indicating that the submesh is ready or not.
  48666. */
  48667. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  48668. /**
  48669. * Checks to see if a texture is used in the material.
  48670. * @param defines the list of "defines" to update.
  48671. * @param mesh the mesh we are preparing the defines for.
  48672. * @param scene defines the scene the material belongs to.
  48673. */
  48674. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  48675. /**
  48676. * Binds the material data.
  48677. * @param uniformBuffer defines the Uniform buffer to fill in.
  48678. * @param scene defines the scene the material belongs to.
  48679. * @param isFrozen defines wether the material is frozen or not.
  48680. */
  48681. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  48682. /**
  48683. * Checks to see if a texture is used in the material.
  48684. * @param texture - Base texture to use.
  48685. * @returns - Boolean specifying if a texture is used in the material.
  48686. */
  48687. hasTexture(texture: BaseTexture): boolean;
  48688. /**
  48689. * Returns an array of the actively used textures.
  48690. * @param activeTextures Array of BaseTextures
  48691. */
  48692. getActiveTextures(activeTextures: BaseTexture[]): void;
  48693. /**
  48694. * Returns the animatable textures.
  48695. * @param animatables Array of animatable textures.
  48696. */
  48697. getAnimatables(animatables: IAnimatable[]): void;
  48698. /**
  48699. * Disposes the resources of the material.
  48700. * @param forceDisposeTextures - Forces the disposal of all textures.
  48701. */
  48702. dispose(forceDisposeTextures?: boolean): void;
  48703. /**
  48704. * Get the current class name of the texture useful for serialization or dynamic coding.
  48705. * @returns "PBRAnisotropicConfiguration"
  48706. */
  48707. getClassName(): string;
  48708. /**
  48709. * Add fallbacks to the effect fallbacks list.
  48710. * @param defines defines the Base texture to use.
  48711. * @param fallbacks defines the current fallback list.
  48712. * @param currentRank defines the current fallback rank.
  48713. * @returns the new fallback rank.
  48714. */
  48715. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48716. /**
  48717. * Add the required uniforms to the current list.
  48718. * @param uniforms defines the current uniform list.
  48719. */
  48720. static AddUniforms(uniforms: string[]): void;
  48721. /**
  48722. * Add the required uniforms to the current buffer.
  48723. * @param uniformBuffer defines the current uniform buffer.
  48724. */
  48725. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48726. /**
  48727. * Add the required samplers to the current list.
  48728. * @param samplers defines the current sampler list.
  48729. */
  48730. static AddSamplers(samplers: string[]): void;
  48731. /**
  48732. * Makes a duplicate of the current configuration into another one.
  48733. * @param anisotropicConfiguration define the config where to copy the info
  48734. */
  48735. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  48736. /**
  48737. * Serializes this anisotropy configuration.
  48738. * @returns - An object with the serialized config.
  48739. */
  48740. serialize(): any;
  48741. /**
  48742. * Parses a anisotropy Configuration from a serialized object.
  48743. * @param source - Serialized object.
  48744. * @param scene Defines the scene we are parsing for
  48745. * @param rootUrl Defines the rootUrl to load from
  48746. */
  48747. parse(source: any, scene: Scene, rootUrl: string): void;
  48748. }
  48749. }
  48750. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  48751. import { Scene } from "babylonjs/scene";
  48752. /**
  48753. * @hidden
  48754. */
  48755. export interface IMaterialBRDFDefines {
  48756. BRDF_V_HEIGHT_CORRELATED: boolean;
  48757. MS_BRDF_ENERGY_CONSERVATION: boolean;
  48758. SPHERICAL_HARMONICS: boolean;
  48759. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  48760. /** @hidden */
  48761. _areMiscDirty: boolean;
  48762. }
  48763. /**
  48764. * Define the code related to the BRDF parameters of the pbr material.
  48765. */
  48766. export class PBRBRDFConfiguration {
  48767. /**
  48768. * Default value used for the energy conservation.
  48769. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  48770. */
  48771. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  48772. /**
  48773. * Default value used for the Smith Visibility Height Correlated mode.
  48774. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  48775. */
  48776. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  48777. /**
  48778. * Default value used for the IBL diffuse part.
  48779. * This can help switching back to the polynomials mode globally which is a tiny bit
  48780. * less GPU intensive at the drawback of a lower quality.
  48781. */
  48782. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  48783. /**
  48784. * Default value used for activating energy conservation for the specular workflow.
  48785. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  48786. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  48787. */
  48788. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  48789. private _useEnergyConservation;
  48790. /**
  48791. * Defines if the material uses energy conservation.
  48792. */
  48793. useEnergyConservation: boolean;
  48794. private _useSmithVisibilityHeightCorrelated;
  48795. /**
  48796. * LEGACY Mode set to false
  48797. * Defines if the material uses height smith correlated visibility term.
  48798. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  48799. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  48800. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  48801. * Not relying on height correlated will also disable energy conservation.
  48802. */
  48803. useSmithVisibilityHeightCorrelated: boolean;
  48804. private _useSphericalHarmonics;
  48805. /**
  48806. * LEGACY Mode set to false
  48807. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  48808. * diffuse part of the IBL.
  48809. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  48810. * to the ground truth.
  48811. */
  48812. useSphericalHarmonics: boolean;
  48813. private _useSpecularGlossinessInputEnergyConservation;
  48814. /**
  48815. * Defines if the material uses energy conservation, when the specular workflow is active.
  48816. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  48817. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  48818. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  48819. */
  48820. useSpecularGlossinessInputEnergyConservation: boolean;
  48821. /** @hidden */
  48822. private _internalMarkAllSubMeshesAsMiscDirty;
  48823. /** @hidden */
  48824. _markAllSubMeshesAsMiscDirty(): void;
  48825. /**
  48826. * Instantiate a new istance of clear coat configuration.
  48827. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  48828. */
  48829. constructor(markAllSubMeshesAsMiscDirty: () => void);
  48830. /**
  48831. * Checks to see if a texture is used in the material.
  48832. * @param defines the list of "defines" to update.
  48833. */
  48834. prepareDefines(defines: IMaterialBRDFDefines): void;
  48835. /**
  48836. * Get the current class name of the texture useful for serialization or dynamic coding.
  48837. * @returns "PBRClearCoatConfiguration"
  48838. */
  48839. getClassName(): string;
  48840. /**
  48841. * Makes a duplicate of the current configuration into another one.
  48842. * @param brdfConfiguration define the config where to copy the info
  48843. */
  48844. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  48845. /**
  48846. * Serializes this BRDF configuration.
  48847. * @returns - An object with the serialized config.
  48848. */
  48849. serialize(): any;
  48850. /**
  48851. * Parses a anisotropy Configuration from a serialized object.
  48852. * @param source - Serialized object.
  48853. * @param scene Defines the scene we are parsing for
  48854. * @param rootUrl Defines the rootUrl to load from
  48855. */
  48856. parse(source: any, scene: Scene, rootUrl: string): void;
  48857. }
  48858. }
  48859. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  48860. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48861. import { Color3 } from "babylonjs/Maths/math.color";
  48862. import { Scene } from "babylonjs/scene";
  48863. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48864. import { Nullable } from "babylonjs/types";
  48865. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48866. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  48867. /**
  48868. * @hidden
  48869. */
  48870. export interface IMaterialSheenDefines {
  48871. SHEEN: boolean;
  48872. SHEEN_TEXTURE: boolean;
  48873. SHEEN_TEXTUREDIRECTUV: number;
  48874. SHEEN_LINKWITHALBEDO: boolean;
  48875. /** @hidden */
  48876. _areTexturesDirty: boolean;
  48877. }
  48878. /**
  48879. * Define the code related to the Sheen parameters of the pbr material.
  48880. */
  48881. export class PBRSheenConfiguration {
  48882. private _isEnabled;
  48883. /**
  48884. * Defines if the material uses sheen.
  48885. */
  48886. isEnabled: boolean;
  48887. private _linkSheenWithAlbedo;
  48888. /**
  48889. * Defines if the sheen is linked to the sheen color.
  48890. */
  48891. linkSheenWithAlbedo: boolean;
  48892. /**
  48893. * Defines the sheen intensity.
  48894. */
  48895. intensity: number;
  48896. /**
  48897. * Defines the sheen color.
  48898. */
  48899. color: Color3;
  48900. private _texture;
  48901. /**
  48902. * Stores the sheen tint values in a texture.
  48903. * rgb is tint
  48904. * a is a intensity
  48905. */
  48906. texture: Nullable<BaseTexture>;
  48907. /** @hidden */
  48908. private _internalMarkAllSubMeshesAsTexturesDirty;
  48909. /** @hidden */
  48910. _markAllSubMeshesAsTexturesDirty(): void;
  48911. /**
  48912. * Instantiate a new istance of clear coat configuration.
  48913. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48914. */
  48915. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48916. /**
  48917. * Specifies that the submesh is ready to be used.
  48918. * @param defines the list of "defines" to update.
  48919. * @param scene defines the scene the material belongs to.
  48920. * @returns - boolean indicating that the submesh is ready or not.
  48921. */
  48922. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  48923. /**
  48924. * Checks to see if a texture is used in the material.
  48925. * @param defines the list of "defines" to update.
  48926. * @param scene defines the scene the material belongs to.
  48927. */
  48928. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  48929. /**
  48930. * Binds the material data.
  48931. * @param uniformBuffer defines the Uniform buffer to fill in.
  48932. * @param scene defines the scene the material belongs to.
  48933. * @param isFrozen defines wether the material is frozen or not.
  48934. */
  48935. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  48936. /**
  48937. * Checks to see if a texture is used in the material.
  48938. * @param texture - Base texture to use.
  48939. * @returns - Boolean specifying if a texture is used in the material.
  48940. */
  48941. hasTexture(texture: BaseTexture): boolean;
  48942. /**
  48943. * Returns an array of the actively used textures.
  48944. * @param activeTextures Array of BaseTextures
  48945. */
  48946. getActiveTextures(activeTextures: BaseTexture[]): void;
  48947. /**
  48948. * Returns the animatable textures.
  48949. * @param animatables Array of animatable textures.
  48950. */
  48951. getAnimatables(animatables: IAnimatable[]): void;
  48952. /**
  48953. * Disposes the resources of the material.
  48954. * @param forceDisposeTextures - Forces the disposal of all textures.
  48955. */
  48956. dispose(forceDisposeTextures?: boolean): void;
  48957. /**
  48958. * Get the current class name of the texture useful for serialization or dynamic coding.
  48959. * @returns "PBRSheenConfiguration"
  48960. */
  48961. getClassName(): string;
  48962. /**
  48963. * Add fallbacks to the effect fallbacks list.
  48964. * @param defines defines the Base texture to use.
  48965. * @param fallbacks defines the current fallback list.
  48966. * @param currentRank defines the current fallback rank.
  48967. * @returns the new fallback rank.
  48968. */
  48969. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48970. /**
  48971. * Add the required uniforms to the current list.
  48972. * @param uniforms defines the current uniform list.
  48973. */
  48974. static AddUniforms(uniforms: string[]): void;
  48975. /**
  48976. * Add the required uniforms to the current buffer.
  48977. * @param uniformBuffer defines the current uniform buffer.
  48978. */
  48979. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48980. /**
  48981. * Add the required samplers to the current list.
  48982. * @param samplers defines the current sampler list.
  48983. */
  48984. static AddSamplers(samplers: string[]): void;
  48985. /**
  48986. * Makes a duplicate of the current configuration into another one.
  48987. * @param sheenConfiguration define the config where to copy the info
  48988. */
  48989. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  48990. /**
  48991. * Serializes this BRDF configuration.
  48992. * @returns - An object with the serialized config.
  48993. */
  48994. serialize(): any;
  48995. /**
  48996. * Parses a anisotropy Configuration from a serialized object.
  48997. * @param source - Serialized object.
  48998. * @param scene Defines the scene we are parsing for
  48999. * @param rootUrl Defines the rootUrl to load from
  49000. */
  49001. parse(source: any, scene: Scene, rootUrl: string): void;
  49002. }
  49003. }
  49004. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  49005. import { Nullable } from "babylonjs/types";
  49006. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49007. import { Color3 } from "babylonjs/Maths/math.color";
  49008. import { SmartArray } from "babylonjs/Misc/smartArray";
  49009. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49010. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49011. import { Effect } from "babylonjs/Materials/effect";
  49012. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49013. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49014. import { Engine } from "babylonjs/Engines/engine";
  49015. import { Scene } from "babylonjs/scene";
  49016. /**
  49017. * @hidden
  49018. */
  49019. export interface IMaterialSubSurfaceDefines {
  49020. SUBSURFACE: boolean;
  49021. SS_REFRACTION: boolean;
  49022. SS_TRANSLUCENCY: boolean;
  49023. SS_SCATERRING: boolean;
  49024. SS_THICKNESSANDMASK_TEXTURE: boolean;
  49025. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  49026. SS_REFRACTIONMAP_3D: boolean;
  49027. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  49028. SS_LODINREFRACTIONALPHA: boolean;
  49029. SS_GAMMAREFRACTION: boolean;
  49030. SS_RGBDREFRACTION: boolean;
  49031. SS_LINEARSPECULARREFRACTION: boolean;
  49032. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  49033. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  49034. /** @hidden */
  49035. _areTexturesDirty: boolean;
  49036. }
  49037. /**
  49038. * Define the code related to the sub surface parameters of the pbr material.
  49039. */
  49040. export class PBRSubSurfaceConfiguration {
  49041. private _isRefractionEnabled;
  49042. /**
  49043. * Defines if the refraction is enabled in the material.
  49044. */
  49045. isRefractionEnabled: boolean;
  49046. private _isTranslucencyEnabled;
  49047. /**
  49048. * Defines if the translucency is enabled in the material.
  49049. */
  49050. isTranslucencyEnabled: boolean;
  49051. private _isScatteringEnabled;
  49052. /**
  49053. * Defines the refraction intensity of the material.
  49054. * The refraction when enabled replaces the Diffuse part of the material.
  49055. * The intensity helps transitionning between diffuse and refraction.
  49056. */
  49057. refractionIntensity: number;
  49058. /**
  49059. * Defines the translucency intensity of the material.
  49060. * When translucency has been enabled, this defines how much of the "translucency"
  49061. * is addded to the diffuse part of the material.
  49062. */
  49063. translucencyIntensity: number;
  49064. /**
  49065. * Defines the scattering intensity of the material.
  49066. * When scattering has been enabled, this defines how much of the "scattered light"
  49067. * is addded to the diffuse part of the material.
  49068. */
  49069. scatteringIntensity: number;
  49070. private _thicknessTexture;
  49071. /**
  49072. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  49073. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  49074. * 0 would mean minimumThickness
  49075. * 1 would mean maximumThickness
  49076. * The other channels might be use as a mask to vary the different effects intensity.
  49077. */
  49078. thicknessTexture: Nullable<BaseTexture>;
  49079. private _refractionTexture;
  49080. /**
  49081. * Defines the texture to use for refraction.
  49082. */
  49083. refractionTexture: Nullable<BaseTexture>;
  49084. private _indexOfRefraction;
  49085. /**
  49086. * Defines the index of refraction used in the material.
  49087. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  49088. */
  49089. indexOfRefraction: number;
  49090. private _invertRefractionY;
  49091. /**
  49092. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  49093. */
  49094. invertRefractionY: boolean;
  49095. private _linkRefractionWithTransparency;
  49096. /**
  49097. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  49098. * Materials half opaque for instance using refraction could benefit from this control.
  49099. */
  49100. linkRefractionWithTransparency: boolean;
  49101. /**
  49102. * Defines the minimum thickness stored in the thickness map.
  49103. * If no thickness map is defined, this value will be used to simulate thickness.
  49104. */
  49105. minimumThickness: number;
  49106. /**
  49107. * Defines the maximum thickness stored in the thickness map.
  49108. */
  49109. maximumThickness: number;
  49110. /**
  49111. * Defines the volume tint of the material.
  49112. * This is used for both translucency and scattering.
  49113. */
  49114. tintColor: Color3;
  49115. /**
  49116. * Defines the distance at which the tint color should be found in the media.
  49117. * This is used for refraction only.
  49118. */
  49119. tintColorAtDistance: number;
  49120. /**
  49121. * Defines how far each channel transmit through the media.
  49122. * It is defined as a color to simplify it selection.
  49123. */
  49124. diffusionDistance: Color3;
  49125. private _useMaskFromThicknessTexture;
  49126. /**
  49127. * Stores the intensity of the different subsurface effects in the thickness texture.
  49128. * * the green channel is the translucency intensity.
  49129. * * the blue channel is the scattering intensity.
  49130. * * the alpha channel is the refraction intensity.
  49131. */
  49132. useMaskFromThicknessTexture: boolean;
  49133. /** @hidden */
  49134. private _internalMarkAllSubMeshesAsTexturesDirty;
  49135. /** @hidden */
  49136. _markAllSubMeshesAsTexturesDirty(): void;
  49137. /**
  49138. * Instantiate a new istance of sub surface configuration.
  49139. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49140. */
  49141. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49142. /**
  49143. * Gets wehter the submesh is ready to be used or not.
  49144. * @param defines the list of "defines" to update.
  49145. * @param scene defines the scene the material belongs to.
  49146. * @returns - boolean indicating that the submesh is ready or not.
  49147. */
  49148. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  49149. /**
  49150. * Checks to see if a texture is used in the material.
  49151. * @param defines the list of "defines" to update.
  49152. * @param scene defines the scene to the material belongs to.
  49153. */
  49154. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  49155. /**
  49156. * Binds the material data.
  49157. * @param uniformBuffer defines the Uniform buffer to fill in.
  49158. * @param scene defines the scene the material belongs to.
  49159. * @param engine defines the engine the material belongs to.
  49160. * @param isFrozen defines wether the material is frozen or not.
  49161. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  49162. */
  49163. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  49164. /**
  49165. * Unbinds the material from the mesh.
  49166. * @param activeEffect defines the effect that should be unbound from.
  49167. * @returns true if unbound, otherwise false
  49168. */
  49169. unbind(activeEffect: Effect): boolean;
  49170. /**
  49171. * Returns the texture used for refraction or null if none is used.
  49172. * @param scene defines the scene the material belongs to.
  49173. * @returns - Refraction texture if present. If no refraction texture and refraction
  49174. * is linked with transparency, returns environment texture. Otherwise, returns null.
  49175. */
  49176. private _getRefractionTexture;
  49177. /**
  49178. * Returns true if alpha blending should be disabled.
  49179. */
  49180. readonly disableAlphaBlending: boolean;
  49181. /**
  49182. * Fills the list of render target textures.
  49183. * @param renderTargets the list of render targets to update
  49184. */
  49185. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  49186. /**
  49187. * Checks to see if a texture is used in the material.
  49188. * @param texture - Base texture to use.
  49189. * @returns - Boolean specifying if a texture is used in the material.
  49190. */
  49191. hasTexture(texture: BaseTexture): boolean;
  49192. /**
  49193. * Gets a boolean indicating that current material needs to register RTT
  49194. * @returns true if this uses a render target otherwise false.
  49195. */
  49196. hasRenderTargetTextures(): boolean;
  49197. /**
  49198. * Returns an array of the actively used textures.
  49199. * @param activeTextures Array of BaseTextures
  49200. */
  49201. getActiveTextures(activeTextures: BaseTexture[]): void;
  49202. /**
  49203. * Returns the animatable textures.
  49204. * @param animatables Array of animatable textures.
  49205. */
  49206. getAnimatables(animatables: IAnimatable[]): void;
  49207. /**
  49208. * Disposes the resources of the material.
  49209. * @param forceDisposeTextures - Forces the disposal of all textures.
  49210. */
  49211. dispose(forceDisposeTextures?: boolean): void;
  49212. /**
  49213. * Get the current class name of the texture useful for serialization or dynamic coding.
  49214. * @returns "PBRSubSurfaceConfiguration"
  49215. */
  49216. getClassName(): string;
  49217. /**
  49218. * Add fallbacks to the effect fallbacks list.
  49219. * @param defines defines the Base texture to use.
  49220. * @param fallbacks defines the current fallback list.
  49221. * @param currentRank defines the current fallback rank.
  49222. * @returns the new fallback rank.
  49223. */
  49224. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49225. /**
  49226. * Add the required uniforms to the current list.
  49227. * @param uniforms defines the current uniform list.
  49228. */
  49229. static AddUniforms(uniforms: string[]): void;
  49230. /**
  49231. * Add the required samplers to the current list.
  49232. * @param samplers defines the current sampler list.
  49233. */
  49234. static AddSamplers(samplers: string[]): void;
  49235. /**
  49236. * Add the required uniforms to the current buffer.
  49237. * @param uniformBuffer defines the current uniform buffer.
  49238. */
  49239. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49240. /**
  49241. * Makes a duplicate of the current configuration into another one.
  49242. * @param configuration define the config where to copy the info
  49243. */
  49244. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  49245. /**
  49246. * Serializes this Sub Surface configuration.
  49247. * @returns - An object with the serialized config.
  49248. */
  49249. serialize(): any;
  49250. /**
  49251. * Parses a anisotropy Configuration from a serialized object.
  49252. * @param source - Serialized object.
  49253. * @param scene Defines the scene we are parsing for
  49254. * @param rootUrl Defines the rootUrl to load from
  49255. */
  49256. parse(source: any, scene: Scene, rootUrl: string): void;
  49257. }
  49258. }
  49259. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  49260. /** @hidden */
  49261. export var pbrFragmentDeclaration: {
  49262. name: string;
  49263. shader: string;
  49264. };
  49265. }
  49266. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  49267. /** @hidden */
  49268. export var pbrUboDeclaration: {
  49269. name: string;
  49270. shader: string;
  49271. };
  49272. }
  49273. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  49274. /** @hidden */
  49275. export var pbrFragmentExtraDeclaration: {
  49276. name: string;
  49277. shader: string;
  49278. };
  49279. }
  49280. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  49281. /** @hidden */
  49282. export var pbrFragmentSamplersDeclaration: {
  49283. name: string;
  49284. shader: string;
  49285. };
  49286. }
  49287. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  49288. /** @hidden */
  49289. export var pbrHelperFunctions: {
  49290. name: string;
  49291. shader: string;
  49292. };
  49293. }
  49294. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  49295. /** @hidden */
  49296. export var harmonicsFunctions: {
  49297. name: string;
  49298. shader: string;
  49299. };
  49300. }
  49301. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  49302. /** @hidden */
  49303. export var pbrDirectLightingSetupFunctions: {
  49304. name: string;
  49305. shader: string;
  49306. };
  49307. }
  49308. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  49309. /** @hidden */
  49310. export var pbrDirectLightingFalloffFunctions: {
  49311. name: string;
  49312. shader: string;
  49313. };
  49314. }
  49315. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  49316. /** @hidden */
  49317. export var pbrBRDFFunctions: {
  49318. name: string;
  49319. shader: string;
  49320. };
  49321. }
  49322. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  49323. /** @hidden */
  49324. export var pbrDirectLightingFunctions: {
  49325. name: string;
  49326. shader: string;
  49327. };
  49328. }
  49329. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  49330. /** @hidden */
  49331. export var pbrIBLFunctions: {
  49332. name: string;
  49333. shader: string;
  49334. };
  49335. }
  49336. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  49337. /** @hidden */
  49338. export var pbrDebug: {
  49339. name: string;
  49340. shader: string;
  49341. };
  49342. }
  49343. declare module "babylonjs/Shaders/pbr.fragment" {
  49344. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  49345. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  49346. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  49347. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  49348. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  49349. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  49350. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  49351. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  49352. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  49353. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  49354. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49355. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  49356. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  49357. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  49358. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  49359. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  49360. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  49361. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  49362. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  49363. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  49364. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  49365. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  49366. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  49367. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  49368. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  49369. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  49370. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  49371. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  49372. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  49373. /** @hidden */
  49374. export var pbrPixelShader: {
  49375. name: string;
  49376. shader: string;
  49377. };
  49378. }
  49379. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  49380. /** @hidden */
  49381. export var pbrVertexDeclaration: {
  49382. name: string;
  49383. shader: string;
  49384. };
  49385. }
  49386. declare module "babylonjs/Shaders/pbr.vertex" {
  49387. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  49388. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  49389. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49390. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  49391. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  49392. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  49393. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  49394. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  49395. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  49396. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  49397. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  49398. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  49399. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  49400. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  49401. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  49402. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  49403. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  49404. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  49405. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  49406. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  49407. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  49408. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  49409. /** @hidden */
  49410. export var pbrVertexShader: {
  49411. name: string;
  49412. shader: string;
  49413. };
  49414. }
  49415. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  49416. import { Nullable } from "babylonjs/types";
  49417. import { Scene } from "babylonjs/scene";
  49418. import { Matrix } from "babylonjs/Maths/math.vector";
  49419. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49420. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49421. import { Mesh } from "babylonjs/Meshes/mesh";
  49422. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  49423. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  49424. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  49425. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  49426. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  49427. import { Color3 } from "babylonjs/Maths/math.color";
  49428. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  49429. import { Material } from "babylonjs/Materials/material";
  49430. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  49431. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  49432. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49433. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49434. import "babylonjs/Shaders/pbr.fragment";
  49435. import "babylonjs/Shaders/pbr.vertex";
  49436. /**
  49437. * Manages the defines for the PBR Material.
  49438. * @hidden
  49439. */
  49440. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  49441. PBR: boolean;
  49442. MAINUV1: boolean;
  49443. MAINUV2: boolean;
  49444. UV1: boolean;
  49445. UV2: boolean;
  49446. ALBEDO: boolean;
  49447. ALBEDODIRECTUV: number;
  49448. VERTEXCOLOR: boolean;
  49449. AMBIENT: boolean;
  49450. AMBIENTDIRECTUV: number;
  49451. AMBIENTINGRAYSCALE: boolean;
  49452. OPACITY: boolean;
  49453. VERTEXALPHA: boolean;
  49454. OPACITYDIRECTUV: number;
  49455. OPACITYRGB: boolean;
  49456. ALPHATEST: boolean;
  49457. DEPTHPREPASS: boolean;
  49458. ALPHABLEND: boolean;
  49459. ALPHAFROMALBEDO: boolean;
  49460. ALPHATESTVALUE: string;
  49461. SPECULAROVERALPHA: boolean;
  49462. RADIANCEOVERALPHA: boolean;
  49463. ALPHAFRESNEL: boolean;
  49464. LINEARALPHAFRESNEL: boolean;
  49465. PREMULTIPLYALPHA: boolean;
  49466. EMISSIVE: boolean;
  49467. EMISSIVEDIRECTUV: number;
  49468. REFLECTIVITY: boolean;
  49469. REFLECTIVITYDIRECTUV: number;
  49470. SPECULARTERM: boolean;
  49471. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  49472. MICROSURFACEAUTOMATIC: boolean;
  49473. LODBASEDMICROSFURACE: boolean;
  49474. MICROSURFACEMAP: boolean;
  49475. MICROSURFACEMAPDIRECTUV: number;
  49476. METALLICWORKFLOW: boolean;
  49477. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  49478. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  49479. METALLNESSSTOREINMETALMAPBLUE: boolean;
  49480. AOSTOREINMETALMAPRED: boolean;
  49481. ENVIRONMENTBRDF: boolean;
  49482. ENVIRONMENTBRDF_RGBD: boolean;
  49483. NORMAL: boolean;
  49484. TANGENT: boolean;
  49485. BUMP: boolean;
  49486. BUMPDIRECTUV: number;
  49487. OBJECTSPACE_NORMALMAP: boolean;
  49488. PARALLAX: boolean;
  49489. PARALLAXOCCLUSION: boolean;
  49490. NORMALXYSCALE: boolean;
  49491. LIGHTMAP: boolean;
  49492. LIGHTMAPDIRECTUV: number;
  49493. USELIGHTMAPASSHADOWMAP: boolean;
  49494. GAMMALIGHTMAP: boolean;
  49495. RGBDLIGHTMAP: boolean;
  49496. REFLECTION: boolean;
  49497. REFLECTIONMAP_3D: boolean;
  49498. REFLECTIONMAP_SPHERICAL: boolean;
  49499. REFLECTIONMAP_PLANAR: boolean;
  49500. REFLECTIONMAP_CUBIC: boolean;
  49501. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  49502. REFLECTIONMAP_PROJECTION: boolean;
  49503. REFLECTIONMAP_SKYBOX: boolean;
  49504. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  49505. REFLECTIONMAP_EXPLICIT: boolean;
  49506. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  49507. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  49508. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  49509. INVERTCUBICMAP: boolean;
  49510. USESPHERICALFROMREFLECTIONMAP: boolean;
  49511. USEIRRADIANCEMAP: boolean;
  49512. SPHERICAL_HARMONICS: boolean;
  49513. USESPHERICALINVERTEX: boolean;
  49514. REFLECTIONMAP_OPPOSITEZ: boolean;
  49515. LODINREFLECTIONALPHA: boolean;
  49516. GAMMAREFLECTION: boolean;
  49517. RGBDREFLECTION: boolean;
  49518. LINEARSPECULARREFLECTION: boolean;
  49519. RADIANCEOCCLUSION: boolean;
  49520. HORIZONOCCLUSION: boolean;
  49521. INSTANCES: boolean;
  49522. NUM_BONE_INFLUENCERS: number;
  49523. BonesPerMesh: number;
  49524. BONETEXTURE: boolean;
  49525. NONUNIFORMSCALING: boolean;
  49526. MORPHTARGETS: boolean;
  49527. MORPHTARGETS_NORMAL: boolean;
  49528. MORPHTARGETS_TANGENT: boolean;
  49529. MORPHTARGETS_UV: boolean;
  49530. NUM_MORPH_INFLUENCERS: number;
  49531. IMAGEPROCESSING: boolean;
  49532. VIGNETTE: boolean;
  49533. VIGNETTEBLENDMODEMULTIPLY: boolean;
  49534. VIGNETTEBLENDMODEOPAQUE: boolean;
  49535. TONEMAPPING: boolean;
  49536. TONEMAPPING_ACES: boolean;
  49537. CONTRAST: boolean;
  49538. COLORCURVES: boolean;
  49539. COLORGRADING: boolean;
  49540. COLORGRADING3D: boolean;
  49541. SAMPLER3DGREENDEPTH: boolean;
  49542. SAMPLER3DBGRMAP: boolean;
  49543. IMAGEPROCESSINGPOSTPROCESS: boolean;
  49544. EXPOSURE: boolean;
  49545. MULTIVIEW: boolean;
  49546. USEPHYSICALLIGHTFALLOFF: boolean;
  49547. USEGLTFLIGHTFALLOFF: boolean;
  49548. TWOSIDEDLIGHTING: boolean;
  49549. SHADOWFLOAT: boolean;
  49550. CLIPPLANE: boolean;
  49551. CLIPPLANE2: boolean;
  49552. CLIPPLANE3: boolean;
  49553. CLIPPLANE4: boolean;
  49554. POINTSIZE: boolean;
  49555. FOG: boolean;
  49556. LOGARITHMICDEPTH: boolean;
  49557. FORCENORMALFORWARD: boolean;
  49558. SPECULARAA: boolean;
  49559. CLEARCOAT: boolean;
  49560. CLEARCOAT_DEFAULTIOR: boolean;
  49561. CLEARCOAT_TEXTURE: boolean;
  49562. CLEARCOAT_TEXTUREDIRECTUV: number;
  49563. CLEARCOAT_BUMP: boolean;
  49564. CLEARCOAT_BUMPDIRECTUV: number;
  49565. CLEARCOAT_TINT: boolean;
  49566. CLEARCOAT_TINT_TEXTURE: boolean;
  49567. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  49568. ANISOTROPIC: boolean;
  49569. ANISOTROPIC_TEXTURE: boolean;
  49570. ANISOTROPIC_TEXTUREDIRECTUV: number;
  49571. BRDF_V_HEIGHT_CORRELATED: boolean;
  49572. MS_BRDF_ENERGY_CONSERVATION: boolean;
  49573. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  49574. SHEEN: boolean;
  49575. SHEEN_TEXTURE: boolean;
  49576. SHEEN_TEXTUREDIRECTUV: number;
  49577. SHEEN_LINKWITHALBEDO: boolean;
  49578. SUBSURFACE: boolean;
  49579. SS_REFRACTION: boolean;
  49580. SS_TRANSLUCENCY: boolean;
  49581. SS_SCATERRING: boolean;
  49582. SS_THICKNESSANDMASK_TEXTURE: boolean;
  49583. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  49584. SS_REFRACTIONMAP_3D: boolean;
  49585. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  49586. SS_LODINREFRACTIONALPHA: boolean;
  49587. SS_GAMMAREFRACTION: boolean;
  49588. SS_RGBDREFRACTION: boolean;
  49589. SS_LINEARSPECULARREFRACTION: boolean;
  49590. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  49591. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  49592. UNLIT: boolean;
  49593. DEBUGMODE: number;
  49594. /**
  49595. * Initializes the PBR Material defines.
  49596. */
  49597. constructor();
  49598. /**
  49599. * Resets the PBR Material defines.
  49600. */
  49601. reset(): void;
  49602. }
  49603. /**
  49604. * The Physically based material base class of BJS.
  49605. *
  49606. * This offers the main features of a standard PBR material.
  49607. * For more information, please refer to the documentation :
  49608. * https://doc.babylonjs.com/how_to/physically_based_rendering
  49609. */
  49610. export abstract class PBRBaseMaterial extends PushMaterial {
  49611. /**
  49612. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  49613. */
  49614. static readonly PBRMATERIAL_OPAQUE: number;
  49615. /**
  49616. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  49617. */
  49618. static readonly PBRMATERIAL_ALPHATEST: number;
  49619. /**
  49620. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49621. */
  49622. static readonly PBRMATERIAL_ALPHABLEND: number;
  49623. /**
  49624. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49625. * They are also discarded below the alpha cutoff threshold to improve performances.
  49626. */
  49627. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  49628. /**
  49629. * Defines the default value of how much AO map is occluding the analytical lights
  49630. * (point spot...).
  49631. */
  49632. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  49633. /**
  49634. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  49635. */
  49636. static readonly LIGHTFALLOFF_PHYSICAL: number;
  49637. /**
  49638. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  49639. * to enhance interoperability with other engines.
  49640. */
  49641. static readonly LIGHTFALLOFF_GLTF: number;
  49642. /**
  49643. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  49644. * to enhance interoperability with other materials.
  49645. */
  49646. static readonly LIGHTFALLOFF_STANDARD: number;
  49647. /**
  49648. * Intensity of the direct lights e.g. the four lights available in your scene.
  49649. * This impacts both the direct diffuse and specular highlights.
  49650. */
  49651. protected _directIntensity: number;
  49652. /**
  49653. * Intensity of the emissive part of the material.
  49654. * This helps controlling the emissive effect without modifying the emissive color.
  49655. */
  49656. protected _emissiveIntensity: number;
  49657. /**
  49658. * Intensity of the environment e.g. how much the environment will light the object
  49659. * either through harmonics for rough material or through the refelction for shiny ones.
  49660. */
  49661. protected _environmentIntensity: number;
  49662. /**
  49663. * This is a special control allowing the reduction of the specular highlights coming from the
  49664. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  49665. */
  49666. protected _specularIntensity: number;
  49667. /**
  49668. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  49669. */
  49670. private _lightingInfos;
  49671. /**
  49672. * Debug Control allowing disabling the bump map on this material.
  49673. */
  49674. protected _disableBumpMap: boolean;
  49675. /**
  49676. * AKA Diffuse Texture in standard nomenclature.
  49677. */
  49678. protected _albedoTexture: Nullable<BaseTexture>;
  49679. /**
  49680. * AKA Occlusion Texture in other nomenclature.
  49681. */
  49682. protected _ambientTexture: Nullable<BaseTexture>;
  49683. /**
  49684. * AKA Occlusion Texture Intensity in other nomenclature.
  49685. */
  49686. protected _ambientTextureStrength: number;
  49687. /**
  49688. * Defines how much the AO map is occluding the analytical lights (point spot...).
  49689. * 1 means it completely occludes it
  49690. * 0 mean it has no impact
  49691. */
  49692. protected _ambientTextureImpactOnAnalyticalLights: number;
  49693. /**
  49694. * Stores the alpha values in a texture.
  49695. */
  49696. protected _opacityTexture: Nullable<BaseTexture>;
  49697. /**
  49698. * Stores the reflection values in a texture.
  49699. */
  49700. protected _reflectionTexture: Nullable<BaseTexture>;
  49701. /**
  49702. * Stores the emissive values in a texture.
  49703. */
  49704. protected _emissiveTexture: Nullable<BaseTexture>;
  49705. /**
  49706. * AKA Specular texture in other nomenclature.
  49707. */
  49708. protected _reflectivityTexture: Nullable<BaseTexture>;
  49709. /**
  49710. * Used to switch from specular/glossiness to metallic/roughness workflow.
  49711. */
  49712. protected _metallicTexture: Nullable<BaseTexture>;
  49713. /**
  49714. * Specifies the metallic scalar of the metallic/roughness workflow.
  49715. * Can also be used to scale the metalness values of the metallic texture.
  49716. */
  49717. protected _metallic: Nullable<number>;
  49718. /**
  49719. * Specifies the roughness scalar of the metallic/roughness workflow.
  49720. * Can also be used to scale the roughness values of the metallic texture.
  49721. */
  49722. protected _roughness: Nullable<number>;
  49723. /**
  49724. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  49725. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  49726. */
  49727. protected _microSurfaceTexture: Nullable<BaseTexture>;
  49728. /**
  49729. * Stores surface normal data used to displace a mesh in a texture.
  49730. */
  49731. protected _bumpTexture: Nullable<BaseTexture>;
  49732. /**
  49733. * Stores the pre-calculated light information of a mesh in a texture.
  49734. */
  49735. protected _lightmapTexture: Nullable<BaseTexture>;
  49736. /**
  49737. * The color of a material in ambient lighting.
  49738. */
  49739. protected _ambientColor: Color3;
  49740. /**
  49741. * AKA Diffuse Color in other nomenclature.
  49742. */
  49743. protected _albedoColor: Color3;
  49744. /**
  49745. * AKA Specular Color in other nomenclature.
  49746. */
  49747. protected _reflectivityColor: Color3;
  49748. /**
  49749. * The color applied when light is reflected from a material.
  49750. */
  49751. protected _reflectionColor: Color3;
  49752. /**
  49753. * The color applied when light is emitted from a material.
  49754. */
  49755. protected _emissiveColor: Color3;
  49756. /**
  49757. * AKA Glossiness in other nomenclature.
  49758. */
  49759. protected _microSurface: number;
  49760. /**
  49761. * Specifies that the material will use the light map as a show map.
  49762. */
  49763. protected _useLightmapAsShadowmap: boolean;
  49764. /**
  49765. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  49766. * makes the reflect vector face the model (under horizon).
  49767. */
  49768. protected _useHorizonOcclusion: boolean;
  49769. /**
  49770. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  49771. * too much the area relying on ambient texture to define their ambient occlusion.
  49772. */
  49773. protected _useRadianceOcclusion: boolean;
  49774. /**
  49775. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  49776. */
  49777. protected _useAlphaFromAlbedoTexture: boolean;
  49778. /**
  49779. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  49780. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  49781. */
  49782. protected _useSpecularOverAlpha: boolean;
  49783. /**
  49784. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  49785. */
  49786. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  49787. /**
  49788. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  49789. */
  49790. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  49791. /**
  49792. * Specifies if the metallic texture contains the roughness information in its green channel.
  49793. */
  49794. protected _useRoughnessFromMetallicTextureGreen: boolean;
  49795. /**
  49796. * Specifies if the metallic texture contains the metallness information in its blue channel.
  49797. */
  49798. protected _useMetallnessFromMetallicTextureBlue: boolean;
  49799. /**
  49800. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  49801. */
  49802. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  49803. /**
  49804. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  49805. */
  49806. protected _useAmbientInGrayScale: boolean;
  49807. /**
  49808. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  49809. * The material will try to infer what glossiness each pixel should be.
  49810. */
  49811. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  49812. /**
  49813. * Defines the falloff type used in this material.
  49814. * It by default is Physical.
  49815. */
  49816. protected _lightFalloff: number;
  49817. /**
  49818. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  49819. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  49820. */
  49821. protected _useRadianceOverAlpha: boolean;
  49822. /**
  49823. * Allows using an object space normal map (instead of tangent space).
  49824. */
  49825. protected _useObjectSpaceNormalMap: boolean;
  49826. /**
  49827. * Allows using the bump map in parallax mode.
  49828. */
  49829. protected _useParallax: boolean;
  49830. /**
  49831. * Allows using the bump map in parallax occlusion mode.
  49832. */
  49833. protected _useParallaxOcclusion: boolean;
  49834. /**
  49835. * Controls the scale bias of the parallax mode.
  49836. */
  49837. protected _parallaxScaleBias: number;
  49838. /**
  49839. * If sets to true, disables all the lights affecting the material.
  49840. */
  49841. protected _disableLighting: boolean;
  49842. /**
  49843. * Number of Simultaneous lights allowed on the material.
  49844. */
  49845. protected _maxSimultaneousLights: number;
  49846. /**
  49847. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  49848. */
  49849. protected _invertNormalMapX: boolean;
  49850. /**
  49851. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  49852. */
  49853. protected _invertNormalMapY: boolean;
  49854. /**
  49855. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49856. */
  49857. protected _twoSidedLighting: boolean;
  49858. /**
  49859. * Defines the alpha limits in alpha test mode.
  49860. */
  49861. protected _alphaCutOff: number;
  49862. /**
  49863. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  49864. */
  49865. protected _forceAlphaTest: boolean;
  49866. /**
  49867. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49868. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  49869. */
  49870. protected _useAlphaFresnel: boolean;
  49871. /**
  49872. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49873. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  49874. */
  49875. protected _useLinearAlphaFresnel: boolean;
  49876. /**
  49877. * The transparency mode of the material.
  49878. */
  49879. protected _transparencyMode: Nullable<number>;
  49880. /**
  49881. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  49882. * from cos thetav and roughness:
  49883. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  49884. */
  49885. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  49886. /**
  49887. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  49888. */
  49889. protected _forceIrradianceInFragment: boolean;
  49890. /**
  49891. * Force normal to face away from face.
  49892. */
  49893. protected _forceNormalForward: boolean;
  49894. /**
  49895. * Enables specular anti aliasing in the PBR shader.
  49896. * It will both interacts on the Geometry for analytical and IBL lighting.
  49897. * It also prefilter the roughness map based on the bump values.
  49898. */
  49899. protected _enableSpecularAntiAliasing: boolean;
  49900. /**
  49901. * Default configuration related to image processing available in the PBR Material.
  49902. */
  49903. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  49904. /**
  49905. * Keep track of the image processing observer to allow dispose and replace.
  49906. */
  49907. private _imageProcessingObserver;
  49908. /**
  49909. * Attaches a new image processing configuration to the PBR Material.
  49910. * @param configuration
  49911. */
  49912. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  49913. /**
  49914. * Stores the available render targets.
  49915. */
  49916. private _renderTargets;
  49917. /**
  49918. * Sets the global ambient color for the material used in lighting calculations.
  49919. */
  49920. private _globalAmbientColor;
  49921. /**
  49922. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  49923. */
  49924. private _useLogarithmicDepth;
  49925. /**
  49926. * If set to true, no lighting calculations will be applied.
  49927. */
  49928. private _unlit;
  49929. private _debugMode;
  49930. /**
  49931. * @hidden
  49932. * This is reserved for the inspector.
  49933. * Defines the material debug mode.
  49934. * It helps seeing only some components of the material while troubleshooting.
  49935. */
  49936. debugMode: number;
  49937. /**
  49938. * @hidden
  49939. * This is reserved for the inspector.
  49940. * Specify from where on screen the debug mode should start.
  49941. * The value goes from -1 (full screen) to 1 (not visible)
  49942. * It helps with side by side comparison against the final render
  49943. * This defaults to -1
  49944. */
  49945. private debugLimit;
  49946. /**
  49947. * @hidden
  49948. * This is reserved for the inspector.
  49949. * As the default viewing range might not be enough (if the ambient is really small for instance)
  49950. * You can use the factor to better multiply the final value.
  49951. */
  49952. private debugFactor;
  49953. /**
  49954. * Defines the clear coat layer parameters for the material.
  49955. */
  49956. readonly clearCoat: PBRClearCoatConfiguration;
  49957. /**
  49958. * Defines the anisotropic parameters for the material.
  49959. */
  49960. readonly anisotropy: PBRAnisotropicConfiguration;
  49961. /**
  49962. * Defines the BRDF parameters for the material.
  49963. */
  49964. readonly brdf: PBRBRDFConfiguration;
  49965. /**
  49966. * Defines the Sheen parameters for the material.
  49967. */
  49968. readonly sheen: PBRSheenConfiguration;
  49969. /**
  49970. * Defines the SubSurface parameters for the material.
  49971. */
  49972. readonly subSurface: PBRSubSurfaceConfiguration;
  49973. /**
  49974. * Custom callback helping to override the default shader used in the material.
  49975. */
  49976. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  49977. protected _rebuildInParallel: boolean;
  49978. /**
  49979. * Instantiates a new PBRMaterial instance.
  49980. *
  49981. * @param name The material name
  49982. * @param scene The scene the material will be use in.
  49983. */
  49984. constructor(name: string, scene: Scene);
  49985. /**
  49986. * Gets a boolean indicating that current material needs to register RTT
  49987. */
  49988. readonly hasRenderTargetTextures: boolean;
  49989. /**
  49990. * Gets the name of the material class.
  49991. */
  49992. getClassName(): string;
  49993. /**
  49994. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  49995. */
  49996. /**
  49997. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  49998. */
  49999. useLogarithmicDepth: boolean;
  50000. /**
  50001. * Gets the current transparency mode.
  50002. */
  50003. /**
  50004. * Sets the transparency mode of the material.
  50005. *
  50006. * | Value | Type | Description |
  50007. * | ----- | ----------------------------------- | ----------- |
  50008. * | 0 | OPAQUE | |
  50009. * | 1 | ALPHATEST | |
  50010. * | 2 | ALPHABLEND | |
  50011. * | 3 | ALPHATESTANDBLEND | |
  50012. *
  50013. */
  50014. transparencyMode: Nullable<number>;
  50015. /**
  50016. * Returns true if alpha blending should be disabled.
  50017. */
  50018. private readonly _disableAlphaBlending;
  50019. /**
  50020. * Specifies whether or not this material should be rendered in alpha blend mode.
  50021. */
  50022. needAlphaBlending(): boolean;
  50023. /**
  50024. * Specifies if the mesh will require alpha blending.
  50025. * @param mesh - BJS mesh.
  50026. */
  50027. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  50028. /**
  50029. * Specifies whether or not this material should be rendered in alpha test mode.
  50030. */
  50031. needAlphaTesting(): boolean;
  50032. /**
  50033. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  50034. */
  50035. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  50036. /**
  50037. * Gets the texture used for the alpha test.
  50038. */
  50039. getAlphaTestTexture(): Nullable<BaseTexture>;
  50040. /**
  50041. * Specifies that the submesh is ready to be used.
  50042. * @param mesh - BJS mesh.
  50043. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  50044. * @param useInstances - Specifies that instances should be used.
  50045. * @returns - boolean indicating that the submesh is ready or not.
  50046. */
  50047. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  50048. /**
  50049. * Specifies if the material uses metallic roughness workflow.
  50050. * @returns boolean specifiying if the material uses metallic roughness workflow.
  50051. */
  50052. isMetallicWorkflow(): boolean;
  50053. private _prepareEffect;
  50054. private _prepareDefines;
  50055. /**
  50056. * Force shader compilation
  50057. */
  50058. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  50059. clipPlane: boolean;
  50060. }>): void;
  50061. /**
  50062. * Initializes the uniform buffer layout for the shader.
  50063. */
  50064. buildUniformLayout(): void;
  50065. /**
  50066. * Unbinds the material from the mesh
  50067. */
  50068. unbind(): void;
  50069. /**
  50070. * Binds the submesh data.
  50071. * @param world - The world matrix.
  50072. * @param mesh - The BJS mesh.
  50073. * @param subMesh - A submesh of the BJS mesh.
  50074. */
  50075. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  50076. /**
  50077. * Returns the animatable textures.
  50078. * @returns - Array of animatable textures.
  50079. */
  50080. getAnimatables(): IAnimatable[];
  50081. /**
  50082. * Returns the texture used for reflections.
  50083. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  50084. */
  50085. private _getReflectionTexture;
  50086. /**
  50087. * Returns an array of the actively used textures.
  50088. * @returns - Array of BaseTextures
  50089. */
  50090. getActiveTextures(): BaseTexture[];
  50091. /**
  50092. * Checks to see if a texture is used in the material.
  50093. * @param texture - Base texture to use.
  50094. * @returns - Boolean specifying if a texture is used in the material.
  50095. */
  50096. hasTexture(texture: BaseTexture): boolean;
  50097. /**
  50098. * Disposes the resources of the material.
  50099. * @param forceDisposeEffect - Forces the disposal of effects.
  50100. * @param forceDisposeTextures - Forces the disposal of all textures.
  50101. */
  50102. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  50103. }
  50104. }
  50105. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  50106. import { Nullable } from "babylonjs/types";
  50107. import { Scene } from "babylonjs/scene";
  50108. import { Color3 } from "babylonjs/Maths/math.color";
  50109. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  50110. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  50111. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50112. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  50113. /**
  50114. * The Physically based material of BJS.
  50115. *
  50116. * This offers the main features of a standard PBR material.
  50117. * For more information, please refer to the documentation :
  50118. * https://doc.babylonjs.com/how_to/physically_based_rendering
  50119. */
  50120. export class PBRMaterial extends PBRBaseMaterial {
  50121. /**
  50122. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  50123. */
  50124. static readonly PBRMATERIAL_OPAQUE: number;
  50125. /**
  50126. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  50127. */
  50128. static readonly PBRMATERIAL_ALPHATEST: number;
  50129. /**
  50130. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50131. */
  50132. static readonly PBRMATERIAL_ALPHABLEND: number;
  50133. /**
  50134. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50135. * They are also discarded below the alpha cutoff threshold to improve performances.
  50136. */
  50137. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  50138. /**
  50139. * Defines the default value of how much AO map is occluding the analytical lights
  50140. * (point spot...).
  50141. */
  50142. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  50143. /**
  50144. * Intensity of the direct lights e.g. the four lights available in your scene.
  50145. * This impacts both the direct diffuse and specular highlights.
  50146. */
  50147. directIntensity: number;
  50148. /**
  50149. * Intensity of the emissive part of the material.
  50150. * This helps controlling the emissive effect without modifying the emissive color.
  50151. */
  50152. emissiveIntensity: number;
  50153. /**
  50154. * Intensity of the environment e.g. how much the environment will light the object
  50155. * either through harmonics for rough material or through the refelction for shiny ones.
  50156. */
  50157. environmentIntensity: number;
  50158. /**
  50159. * This is a special control allowing the reduction of the specular highlights coming from the
  50160. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  50161. */
  50162. specularIntensity: number;
  50163. /**
  50164. * Debug Control allowing disabling the bump map on this material.
  50165. */
  50166. disableBumpMap: boolean;
  50167. /**
  50168. * AKA Diffuse Texture in standard nomenclature.
  50169. */
  50170. albedoTexture: BaseTexture;
  50171. /**
  50172. * AKA Occlusion Texture in other nomenclature.
  50173. */
  50174. ambientTexture: BaseTexture;
  50175. /**
  50176. * AKA Occlusion Texture Intensity in other nomenclature.
  50177. */
  50178. ambientTextureStrength: number;
  50179. /**
  50180. * Defines how much the AO map is occluding the analytical lights (point spot...).
  50181. * 1 means it completely occludes it
  50182. * 0 mean it has no impact
  50183. */
  50184. ambientTextureImpactOnAnalyticalLights: number;
  50185. /**
  50186. * Stores the alpha values in a texture.
  50187. */
  50188. opacityTexture: BaseTexture;
  50189. /**
  50190. * Stores the reflection values in a texture.
  50191. */
  50192. reflectionTexture: Nullable<BaseTexture>;
  50193. /**
  50194. * Stores the emissive values in a texture.
  50195. */
  50196. emissiveTexture: BaseTexture;
  50197. /**
  50198. * AKA Specular texture in other nomenclature.
  50199. */
  50200. reflectivityTexture: BaseTexture;
  50201. /**
  50202. * Used to switch from specular/glossiness to metallic/roughness workflow.
  50203. */
  50204. metallicTexture: BaseTexture;
  50205. /**
  50206. * Specifies the metallic scalar of the metallic/roughness workflow.
  50207. * Can also be used to scale the metalness values of the metallic texture.
  50208. */
  50209. metallic: Nullable<number>;
  50210. /**
  50211. * Specifies the roughness scalar of the metallic/roughness workflow.
  50212. * Can also be used to scale the roughness values of the metallic texture.
  50213. */
  50214. roughness: Nullable<number>;
  50215. /**
  50216. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  50217. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  50218. */
  50219. microSurfaceTexture: BaseTexture;
  50220. /**
  50221. * Stores surface normal data used to displace a mesh in a texture.
  50222. */
  50223. bumpTexture: BaseTexture;
  50224. /**
  50225. * Stores the pre-calculated light information of a mesh in a texture.
  50226. */
  50227. lightmapTexture: BaseTexture;
  50228. /**
  50229. * Stores the refracted light information in a texture.
  50230. */
  50231. refractionTexture: Nullable<BaseTexture>;
  50232. /**
  50233. * The color of a material in ambient lighting.
  50234. */
  50235. ambientColor: Color3;
  50236. /**
  50237. * AKA Diffuse Color in other nomenclature.
  50238. */
  50239. albedoColor: Color3;
  50240. /**
  50241. * AKA Specular Color in other nomenclature.
  50242. */
  50243. reflectivityColor: Color3;
  50244. /**
  50245. * The color reflected from the material.
  50246. */
  50247. reflectionColor: Color3;
  50248. /**
  50249. * The color emitted from the material.
  50250. */
  50251. emissiveColor: Color3;
  50252. /**
  50253. * AKA Glossiness in other nomenclature.
  50254. */
  50255. microSurface: number;
  50256. /**
  50257. * source material index of refraction (IOR)' / 'destination material IOR.
  50258. */
  50259. indexOfRefraction: number;
  50260. /**
  50261. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  50262. */
  50263. invertRefractionY: boolean;
  50264. /**
  50265. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  50266. * Materials half opaque for instance using refraction could benefit from this control.
  50267. */
  50268. linkRefractionWithTransparency: boolean;
  50269. /**
  50270. * If true, the light map contains occlusion information instead of lighting info.
  50271. */
  50272. useLightmapAsShadowmap: boolean;
  50273. /**
  50274. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  50275. */
  50276. useAlphaFromAlbedoTexture: boolean;
  50277. /**
  50278. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  50279. */
  50280. forceAlphaTest: boolean;
  50281. /**
  50282. * Defines the alpha limits in alpha test mode.
  50283. */
  50284. alphaCutOff: number;
  50285. /**
  50286. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  50287. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  50288. */
  50289. useSpecularOverAlpha: boolean;
  50290. /**
  50291. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  50292. */
  50293. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  50294. /**
  50295. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  50296. */
  50297. useRoughnessFromMetallicTextureAlpha: boolean;
  50298. /**
  50299. * Specifies if the metallic texture contains the roughness information in its green channel.
  50300. */
  50301. useRoughnessFromMetallicTextureGreen: boolean;
  50302. /**
  50303. * Specifies if the metallic texture contains the metallness information in its blue channel.
  50304. */
  50305. useMetallnessFromMetallicTextureBlue: boolean;
  50306. /**
  50307. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  50308. */
  50309. useAmbientOcclusionFromMetallicTextureRed: boolean;
  50310. /**
  50311. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  50312. */
  50313. useAmbientInGrayScale: boolean;
  50314. /**
  50315. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  50316. * The material will try to infer what glossiness each pixel should be.
  50317. */
  50318. useAutoMicroSurfaceFromReflectivityMap: boolean;
  50319. /**
  50320. * BJS is using an harcoded light falloff based on a manually sets up range.
  50321. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  50322. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  50323. */
  50324. /**
  50325. * BJS is using an harcoded light falloff based on a manually sets up range.
  50326. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  50327. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  50328. */
  50329. usePhysicalLightFalloff: boolean;
  50330. /**
  50331. * In order to support the falloff compatibility with gltf, a special mode has been added
  50332. * to reproduce the gltf light falloff.
  50333. */
  50334. /**
  50335. * In order to support the falloff compatibility with gltf, a special mode has been added
  50336. * to reproduce the gltf light falloff.
  50337. */
  50338. useGLTFLightFalloff: boolean;
  50339. /**
  50340. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  50341. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  50342. */
  50343. useRadianceOverAlpha: boolean;
  50344. /**
  50345. * Allows using an object space normal map (instead of tangent space).
  50346. */
  50347. useObjectSpaceNormalMap: boolean;
  50348. /**
  50349. * Allows using the bump map in parallax mode.
  50350. */
  50351. useParallax: boolean;
  50352. /**
  50353. * Allows using the bump map in parallax occlusion mode.
  50354. */
  50355. useParallaxOcclusion: boolean;
  50356. /**
  50357. * Controls the scale bias of the parallax mode.
  50358. */
  50359. parallaxScaleBias: number;
  50360. /**
  50361. * If sets to true, disables all the lights affecting the material.
  50362. */
  50363. disableLighting: boolean;
  50364. /**
  50365. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  50366. */
  50367. forceIrradianceInFragment: boolean;
  50368. /**
  50369. * Number of Simultaneous lights allowed on the material.
  50370. */
  50371. maxSimultaneousLights: number;
  50372. /**
  50373. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  50374. */
  50375. invertNormalMapX: boolean;
  50376. /**
  50377. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  50378. */
  50379. invertNormalMapY: boolean;
  50380. /**
  50381. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50382. */
  50383. twoSidedLighting: boolean;
  50384. /**
  50385. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50386. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  50387. */
  50388. useAlphaFresnel: boolean;
  50389. /**
  50390. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50391. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  50392. */
  50393. useLinearAlphaFresnel: boolean;
  50394. /**
  50395. * Let user defines the brdf lookup texture used for IBL.
  50396. * A default 8bit version is embedded but you could point at :
  50397. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  50398. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  50399. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  50400. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  50401. */
  50402. environmentBRDFTexture: Nullable<BaseTexture>;
  50403. /**
  50404. * Force normal to face away from face.
  50405. */
  50406. forceNormalForward: boolean;
  50407. /**
  50408. * Enables specular anti aliasing in the PBR shader.
  50409. * It will both interacts on the Geometry for analytical and IBL lighting.
  50410. * It also prefilter the roughness map based on the bump values.
  50411. */
  50412. enableSpecularAntiAliasing: boolean;
  50413. /**
  50414. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  50415. * makes the reflect vector face the model (under horizon).
  50416. */
  50417. useHorizonOcclusion: boolean;
  50418. /**
  50419. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  50420. * too much the area relying on ambient texture to define their ambient occlusion.
  50421. */
  50422. useRadianceOcclusion: boolean;
  50423. /**
  50424. * If set to true, no lighting calculations will be applied.
  50425. */
  50426. unlit: boolean;
  50427. /**
  50428. * Gets the image processing configuration used either in this material.
  50429. */
  50430. /**
  50431. * Sets the Default image processing configuration used either in the this material.
  50432. *
  50433. * If sets to null, the scene one is in use.
  50434. */
  50435. imageProcessingConfiguration: ImageProcessingConfiguration;
  50436. /**
  50437. * Gets wether the color curves effect is enabled.
  50438. */
  50439. /**
  50440. * Sets wether the color curves effect is enabled.
  50441. */
  50442. cameraColorCurvesEnabled: boolean;
  50443. /**
  50444. * Gets wether the color grading effect is enabled.
  50445. */
  50446. /**
  50447. * Gets wether the color grading effect is enabled.
  50448. */
  50449. cameraColorGradingEnabled: boolean;
  50450. /**
  50451. * Gets wether tonemapping is enabled or not.
  50452. */
  50453. /**
  50454. * Sets wether tonemapping is enabled or not
  50455. */
  50456. cameraToneMappingEnabled: boolean;
  50457. /**
  50458. * The camera exposure used on this material.
  50459. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50460. * This corresponds to a photographic exposure.
  50461. */
  50462. /**
  50463. * The camera exposure used on this material.
  50464. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50465. * This corresponds to a photographic exposure.
  50466. */
  50467. cameraExposure: number;
  50468. /**
  50469. * Gets The camera contrast used on this material.
  50470. */
  50471. /**
  50472. * Sets The camera contrast used on this material.
  50473. */
  50474. cameraContrast: number;
  50475. /**
  50476. * Gets the Color Grading 2D Lookup Texture.
  50477. */
  50478. /**
  50479. * Sets the Color Grading 2D Lookup Texture.
  50480. */
  50481. cameraColorGradingTexture: Nullable<BaseTexture>;
  50482. /**
  50483. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50484. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50485. * 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;
  50486. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50487. */
  50488. /**
  50489. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50490. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50491. * 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;
  50492. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50493. */
  50494. cameraColorCurves: Nullable<ColorCurves>;
  50495. /**
  50496. * Instantiates a new PBRMaterial instance.
  50497. *
  50498. * @param name The material name
  50499. * @param scene The scene the material will be use in.
  50500. */
  50501. constructor(name: string, scene: Scene);
  50502. /**
  50503. * Returns the name of this material class.
  50504. */
  50505. getClassName(): string;
  50506. /**
  50507. * Makes a duplicate of the current material.
  50508. * @param name - name to use for the new material.
  50509. */
  50510. clone(name: string): PBRMaterial;
  50511. /**
  50512. * Serializes this PBR Material.
  50513. * @returns - An object with the serialized material.
  50514. */
  50515. serialize(): any;
  50516. /**
  50517. * Parses a PBR Material from a serialized object.
  50518. * @param source - Serialized object.
  50519. * @param scene - BJS scene instance.
  50520. * @param rootUrl - url for the scene object
  50521. * @returns - PBRMaterial
  50522. */
  50523. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  50524. }
  50525. }
  50526. declare module "babylonjs/Misc/dds" {
  50527. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  50528. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50529. import { Nullable } from "babylonjs/types";
  50530. import { Scene } from "babylonjs/scene";
  50531. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  50532. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  50533. /**
  50534. * Direct draw surface info
  50535. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  50536. */
  50537. export interface DDSInfo {
  50538. /**
  50539. * Width of the texture
  50540. */
  50541. width: number;
  50542. /**
  50543. * Width of the texture
  50544. */
  50545. height: number;
  50546. /**
  50547. * Number of Mipmaps for the texture
  50548. * @see https://en.wikipedia.org/wiki/Mipmap
  50549. */
  50550. mipmapCount: number;
  50551. /**
  50552. * If the textures format is a known fourCC format
  50553. * @see https://www.fourcc.org/
  50554. */
  50555. isFourCC: boolean;
  50556. /**
  50557. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  50558. */
  50559. isRGB: boolean;
  50560. /**
  50561. * If the texture is a lumincance format
  50562. */
  50563. isLuminance: boolean;
  50564. /**
  50565. * If this is a cube texture
  50566. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  50567. */
  50568. isCube: boolean;
  50569. /**
  50570. * If the texture is a compressed format eg. FOURCC_DXT1
  50571. */
  50572. isCompressed: boolean;
  50573. /**
  50574. * The dxgiFormat of the texture
  50575. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  50576. */
  50577. dxgiFormat: number;
  50578. /**
  50579. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  50580. */
  50581. textureType: number;
  50582. /**
  50583. * Sphericle polynomial created for the dds texture
  50584. */
  50585. sphericalPolynomial?: SphericalPolynomial;
  50586. }
  50587. /**
  50588. * Class used to provide DDS decompression tools
  50589. */
  50590. export class DDSTools {
  50591. /**
  50592. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  50593. */
  50594. static StoreLODInAlphaChannel: boolean;
  50595. /**
  50596. * Gets DDS information from an array buffer
  50597. * @param arrayBuffer defines the array buffer to read data from
  50598. * @returns the DDS information
  50599. */
  50600. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  50601. private static _FloatView;
  50602. private static _Int32View;
  50603. private static _ToHalfFloat;
  50604. private static _FromHalfFloat;
  50605. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  50606. private static _GetHalfFloatRGBAArrayBuffer;
  50607. private static _GetFloatRGBAArrayBuffer;
  50608. private static _GetFloatAsUIntRGBAArrayBuffer;
  50609. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  50610. private static _GetRGBAArrayBuffer;
  50611. private static _ExtractLongWordOrder;
  50612. private static _GetRGBArrayBuffer;
  50613. private static _GetLuminanceArrayBuffer;
  50614. /**
  50615. * Uploads DDS Levels to a Babylon Texture
  50616. * @hidden
  50617. */
  50618. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  50619. }
  50620. module "babylonjs/Engines/thinEngine" {
  50621. interface ThinEngine {
  50622. /**
  50623. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  50624. * @param rootUrl defines the url where the file to load is located
  50625. * @param scene defines the current scene
  50626. * @param lodScale defines scale to apply to the mip map selection
  50627. * @param lodOffset defines offset to apply to the mip map selection
  50628. * @param onLoad defines an optional callback raised when the texture is loaded
  50629. * @param onError defines an optional callback raised if there is an issue to load the texture
  50630. * @param format defines the format of the data
  50631. * @param forcedExtension defines the extension to use to pick the right loader
  50632. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  50633. * @returns the cube texture as an InternalTexture
  50634. */
  50635. 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;
  50636. }
  50637. }
  50638. }
  50639. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  50640. import { Nullable } from "babylonjs/types";
  50641. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50642. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50643. /**
  50644. * Implementation of the DDS Texture Loader.
  50645. * @hidden
  50646. */
  50647. export class _DDSTextureLoader implements IInternalTextureLoader {
  50648. /**
  50649. * Defines wether the loader supports cascade loading the different faces.
  50650. */
  50651. readonly supportCascades: boolean;
  50652. /**
  50653. * This returns if the loader support the current file information.
  50654. * @param extension defines the file extension of the file being loaded
  50655. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50656. * @param fallback defines the fallback internal texture if any
  50657. * @param isBase64 defines whether the texture is encoded as a base64
  50658. * @param isBuffer defines whether the texture data are stored as a buffer
  50659. * @returns true if the loader can load the specified file
  50660. */
  50661. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50662. /**
  50663. * Transform the url before loading if required.
  50664. * @param rootUrl the url of the texture
  50665. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50666. * @returns the transformed texture
  50667. */
  50668. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50669. /**
  50670. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50671. * @param rootUrl the url of the texture
  50672. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50673. * @returns the fallback texture
  50674. */
  50675. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50676. /**
  50677. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50678. * @param data contains the texture data
  50679. * @param texture defines the BabylonJS internal texture
  50680. * @param createPolynomials will be true if polynomials have been requested
  50681. * @param onLoad defines the callback to trigger once the texture is ready
  50682. * @param onError defines the callback to trigger in case of error
  50683. */
  50684. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50685. /**
  50686. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50687. * @param data contains the texture data
  50688. * @param texture defines the BabylonJS internal texture
  50689. * @param callback defines the method to call once ready to upload
  50690. */
  50691. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50692. }
  50693. }
  50694. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  50695. import { Nullable } from "babylonjs/types";
  50696. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50697. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50698. /**
  50699. * Implementation of the ENV Texture Loader.
  50700. * @hidden
  50701. */
  50702. export class _ENVTextureLoader implements IInternalTextureLoader {
  50703. /**
  50704. * Defines wether the loader supports cascade loading the different faces.
  50705. */
  50706. readonly supportCascades: boolean;
  50707. /**
  50708. * This returns if the loader support the current file information.
  50709. * @param extension defines the file extension of the file being loaded
  50710. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50711. * @param fallback defines the fallback internal texture if any
  50712. * @param isBase64 defines whether the texture is encoded as a base64
  50713. * @param isBuffer defines whether the texture data are stored as a buffer
  50714. * @returns true if the loader can load the specified file
  50715. */
  50716. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50717. /**
  50718. * Transform the url before loading if required.
  50719. * @param rootUrl the url of the texture
  50720. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50721. * @returns the transformed texture
  50722. */
  50723. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50724. /**
  50725. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50726. * @param rootUrl the url of the texture
  50727. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50728. * @returns the fallback texture
  50729. */
  50730. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50731. /**
  50732. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50733. * @param data contains the texture data
  50734. * @param texture defines the BabylonJS internal texture
  50735. * @param createPolynomials will be true if polynomials have been requested
  50736. * @param onLoad defines the callback to trigger once the texture is ready
  50737. * @param onError defines the callback to trigger in case of error
  50738. */
  50739. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50740. /**
  50741. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50742. * @param data contains the texture data
  50743. * @param texture defines the BabylonJS internal texture
  50744. * @param callback defines the method to call once ready to upload
  50745. */
  50746. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50747. }
  50748. }
  50749. declare module "babylonjs/Misc/khronosTextureContainer" {
  50750. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50751. /**
  50752. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  50753. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  50754. */
  50755. export class KhronosTextureContainer {
  50756. /** contents of the KTX container file */
  50757. arrayBuffer: any;
  50758. private static HEADER_LEN;
  50759. private static COMPRESSED_2D;
  50760. private static COMPRESSED_3D;
  50761. private static TEX_2D;
  50762. private static TEX_3D;
  50763. /**
  50764. * Gets the openGL type
  50765. */
  50766. glType: number;
  50767. /**
  50768. * Gets the openGL type size
  50769. */
  50770. glTypeSize: number;
  50771. /**
  50772. * Gets the openGL format
  50773. */
  50774. glFormat: number;
  50775. /**
  50776. * Gets the openGL internal format
  50777. */
  50778. glInternalFormat: number;
  50779. /**
  50780. * Gets the base internal format
  50781. */
  50782. glBaseInternalFormat: number;
  50783. /**
  50784. * Gets image width in pixel
  50785. */
  50786. pixelWidth: number;
  50787. /**
  50788. * Gets image height in pixel
  50789. */
  50790. pixelHeight: number;
  50791. /**
  50792. * Gets image depth in pixels
  50793. */
  50794. pixelDepth: number;
  50795. /**
  50796. * Gets the number of array elements
  50797. */
  50798. numberOfArrayElements: number;
  50799. /**
  50800. * Gets the number of faces
  50801. */
  50802. numberOfFaces: number;
  50803. /**
  50804. * Gets the number of mipmap levels
  50805. */
  50806. numberOfMipmapLevels: number;
  50807. /**
  50808. * Gets the bytes of key value data
  50809. */
  50810. bytesOfKeyValueData: number;
  50811. /**
  50812. * Gets the load type
  50813. */
  50814. loadType: number;
  50815. /**
  50816. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  50817. */
  50818. isInvalid: boolean;
  50819. /**
  50820. * Creates a new KhronosTextureContainer
  50821. * @param arrayBuffer contents of the KTX container file
  50822. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  50823. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  50824. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  50825. */
  50826. constructor(
  50827. /** contents of the KTX container file */
  50828. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  50829. /**
  50830. * Uploads KTX content to a Babylon Texture.
  50831. * It is assumed that the texture has already been created & is currently bound
  50832. * @hidden
  50833. */
  50834. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  50835. private _upload2DCompressedLevels;
  50836. }
  50837. }
  50838. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  50839. import { Nullable } from "babylonjs/types";
  50840. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50841. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50842. /**
  50843. * Implementation of the KTX Texture Loader.
  50844. * @hidden
  50845. */
  50846. export class _KTXTextureLoader implements IInternalTextureLoader {
  50847. /**
  50848. * Defines wether the loader supports cascade loading the different faces.
  50849. */
  50850. readonly supportCascades: boolean;
  50851. /**
  50852. * This returns if the loader support the current file information.
  50853. * @param extension defines the file extension of the file being loaded
  50854. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50855. * @param fallback defines the fallback internal texture if any
  50856. * @param isBase64 defines whether the texture is encoded as a base64
  50857. * @param isBuffer defines whether the texture data are stored as a buffer
  50858. * @returns true if the loader can load the specified file
  50859. */
  50860. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50861. /**
  50862. * Transform the url before loading if required.
  50863. * @param rootUrl the url of the texture
  50864. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50865. * @returns the transformed texture
  50866. */
  50867. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50868. /**
  50869. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50870. * @param rootUrl the url of the texture
  50871. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50872. * @returns the fallback texture
  50873. */
  50874. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50875. /**
  50876. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50877. * @param data contains the texture data
  50878. * @param texture defines the BabylonJS internal texture
  50879. * @param createPolynomials will be true if polynomials have been requested
  50880. * @param onLoad defines the callback to trigger once the texture is ready
  50881. * @param onError defines the callback to trigger in case of error
  50882. */
  50883. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50884. /**
  50885. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50886. * @param data contains the texture data
  50887. * @param texture defines the BabylonJS internal texture
  50888. * @param callback defines the method to call once ready to upload
  50889. */
  50890. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  50891. }
  50892. }
  50893. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  50894. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  50895. import { Scene } from "babylonjs/scene";
  50896. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  50897. import { WebXRControllerModelLoader } from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  50898. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  50899. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  50900. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  50901. import { WebXREnterExitUI } from "babylonjs/Cameras/XR/webXREnterExitUI";
  50902. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50903. /**
  50904. * Options for the default xr helper
  50905. */
  50906. export class WebXRDefaultExperienceOptions {
  50907. /**
  50908. * Floor meshes that should be used for teleporting
  50909. */
  50910. floorMeshes: Array<AbstractMesh>;
  50911. }
  50912. /**
  50913. * Default experience which provides a similar setup to the previous webVRExperience
  50914. */
  50915. export class WebXRDefaultExperience {
  50916. /**
  50917. * Base experience
  50918. */
  50919. baseExperience: WebXRExperienceHelper;
  50920. /**
  50921. * Input experience extension
  50922. */
  50923. input: WebXRInput;
  50924. /**
  50925. * Loads the controller models
  50926. */
  50927. controllerModelLoader: WebXRControllerModelLoader;
  50928. /**
  50929. * Enables laser pointer and selection
  50930. */
  50931. pointerSelection: WebXRControllerPointerSelection;
  50932. /**
  50933. * Enables teleportation
  50934. */
  50935. teleportation: WebXRControllerTeleportation;
  50936. /**
  50937. * Enables ui for enetering/exiting xr
  50938. */
  50939. enterExitUI: WebXREnterExitUI;
  50940. /**
  50941. * Default output canvas xr should render to
  50942. */
  50943. outputCanvas: WebXRManagedOutputCanvas;
  50944. /**
  50945. * Creates the default xr experience
  50946. * @param scene scene
  50947. * @param options options for basic configuration
  50948. * @returns resulting WebXRDefaultExperience
  50949. */
  50950. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  50951. private constructor();
  50952. /**
  50953. * DIsposes of the experience helper
  50954. */
  50955. dispose(): void;
  50956. }
  50957. }
  50958. declare module "babylonjs/Helpers/sceneHelpers" {
  50959. import { Nullable } from "babylonjs/types";
  50960. import { Mesh } from "babylonjs/Meshes/mesh";
  50961. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50962. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  50963. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  50964. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  50965. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  50966. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  50967. import "babylonjs/Meshes/Builders/boxBuilder";
  50968. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  50969. /** @hidden */
  50970. export var _forceSceneHelpersToBundle: boolean;
  50971. module "babylonjs/scene" {
  50972. interface Scene {
  50973. /**
  50974. * Creates a default light for the scene.
  50975. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  50976. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  50977. */
  50978. createDefaultLight(replace?: boolean): void;
  50979. /**
  50980. * Creates a default camera for the scene.
  50981. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  50982. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  50983. * @param replace has default false, when true replaces the active camera in the scene
  50984. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  50985. */
  50986. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  50987. /**
  50988. * Creates a default camera and a default light.
  50989. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  50990. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  50991. * @param replace has the default false, when true replaces the active camera/light in the scene
  50992. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  50993. */
  50994. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  50995. /**
  50996. * Creates a new sky box
  50997. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  50998. * @param environmentTexture defines the texture to use as environment texture
  50999. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  51000. * @param scale defines the overall scale of the skybox
  51001. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  51002. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  51003. * @returns a new mesh holding the sky box
  51004. */
  51005. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  51006. /**
  51007. * Creates a new environment
  51008. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  51009. * @param options defines the options you can use to configure the environment
  51010. * @returns the new EnvironmentHelper
  51011. */
  51012. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  51013. /**
  51014. * Creates a new VREXperienceHelper
  51015. * @see http://doc.babylonjs.com/how_to/webvr_helper
  51016. * @param webVROptions defines the options used to create the new VREXperienceHelper
  51017. * @returns a new VREXperienceHelper
  51018. */
  51019. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  51020. /**
  51021. * Creates a new WebXRDefaultExperience
  51022. * @see http://doc.babylonjs.com/how_to/webxr
  51023. * @param options experience options
  51024. * @returns a promise for a new WebXRDefaultExperience
  51025. */
  51026. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51027. }
  51028. }
  51029. }
  51030. declare module "babylonjs/Helpers/videoDome" {
  51031. import { Scene } from "babylonjs/scene";
  51032. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51033. import { Mesh } from "babylonjs/Meshes/mesh";
  51034. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  51035. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51036. import "babylonjs/Meshes/Builders/sphereBuilder";
  51037. /**
  51038. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  51039. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  51040. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  51041. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  51042. */
  51043. export class VideoDome extends TransformNode {
  51044. /**
  51045. * Define the video source as a Monoscopic panoramic 360 video.
  51046. */
  51047. static readonly MODE_MONOSCOPIC: number;
  51048. /**
  51049. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  51050. */
  51051. static readonly MODE_TOPBOTTOM: number;
  51052. /**
  51053. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  51054. */
  51055. static readonly MODE_SIDEBYSIDE: number;
  51056. private _halfDome;
  51057. private _useDirectMapping;
  51058. /**
  51059. * The video texture being displayed on the sphere
  51060. */
  51061. protected _videoTexture: VideoTexture;
  51062. /**
  51063. * Gets the video texture being displayed on the sphere
  51064. */
  51065. readonly videoTexture: VideoTexture;
  51066. /**
  51067. * The skybox material
  51068. */
  51069. protected _material: BackgroundMaterial;
  51070. /**
  51071. * The surface used for the skybox
  51072. */
  51073. protected _mesh: Mesh;
  51074. /**
  51075. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  51076. */
  51077. private _halfDomeMask;
  51078. /**
  51079. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51080. * Also see the options.resolution property.
  51081. */
  51082. fovMultiplier: number;
  51083. private _videoMode;
  51084. /**
  51085. * Gets or set the current video mode for the video. It can be:
  51086. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  51087. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  51088. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  51089. */
  51090. videoMode: number;
  51091. /**
  51092. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  51093. *
  51094. */
  51095. /**
  51096. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  51097. */
  51098. halfDome: boolean;
  51099. /**
  51100. * Oberserver used in Stereoscopic VR Mode.
  51101. */
  51102. private _onBeforeCameraRenderObserver;
  51103. /**
  51104. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  51105. * @param name Element's name, child elements will append suffixes for their own names.
  51106. * @param urlsOrVideo defines the url(s) or the video element to use
  51107. * @param options An object containing optional or exposed sub element properties
  51108. */
  51109. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  51110. resolution?: number;
  51111. clickToPlay?: boolean;
  51112. autoPlay?: boolean;
  51113. loop?: boolean;
  51114. size?: number;
  51115. poster?: string;
  51116. faceForward?: boolean;
  51117. useDirectMapping?: boolean;
  51118. halfDomeMode?: boolean;
  51119. }, scene: Scene);
  51120. private _changeVideoMode;
  51121. /**
  51122. * Releases resources associated with this node.
  51123. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  51124. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  51125. */
  51126. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  51127. }
  51128. }
  51129. declare module "babylonjs/Helpers/index" {
  51130. export * from "babylonjs/Helpers/environmentHelper";
  51131. export * from "babylonjs/Helpers/photoDome";
  51132. export * from "babylonjs/Helpers/sceneHelpers";
  51133. export * from "babylonjs/Helpers/videoDome";
  51134. }
  51135. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  51136. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  51137. import { IDisposable } from "babylonjs/scene";
  51138. import { Engine } from "babylonjs/Engines/engine";
  51139. /**
  51140. * This class can be used to get instrumentation data from a Babylon engine
  51141. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  51142. */
  51143. export class EngineInstrumentation implements IDisposable {
  51144. /**
  51145. * Define the instrumented engine.
  51146. */
  51147. engine: Engine;
  51148. private _captureGPUFrameTime;
  51149. private _gpuFrameTimeToken;
  51150. private _gpuFrameTime;
  51151. private _captureShaderCompilationTime;
  51152. private _shaderCompilationTime;
  51153. private _onBeginFrameObserver;
  51154. private _onEndFrameObserver;
  51155. private _onBeforeShaderCompilationObserver;
  51156. private _onAfterShaderCompilationObserver;
  51157. /**
  51158. * Gets the perf counter used for GPU frame time
  51159. */
  51160. readonly gpuFrameTimeCounter: PerfCounter;
  51161. /**
  51162. * Gets the GPU frame time capture status
  51163. */
  51164. /**
  51165. * Enable or disable the GPU frame time capture
  51166. */
  51167. captureGPUFrameTime: boolean;
  51168. /**
  51169. * Gets the perf counter used for shader compilation time
  51170. */
  51171. readonly shaderCompilationTimeCounter: PerfCounter;
  51172. /**
  51173. * Gets the shader compilation time capture status
  51174. */
  51175. /**
  51176. * Enable or disable the shader compilation time capture
  51177. */
  51178. captureShaderCompilationTime: boolean;
  51179. /**
  51180. * Instantiates a new engine instrumentation.
  51181. * This class can be used to get instrumentation data from a Babylon engine
  51182. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  51183. * @param engine Defines the engine to instrument
  51184. */
  51185. constructor(
  51186. /**
  51187. * Define the instrumented engine.
  51188. */
  51189. engine: Engine);
  51190. /**
  51191. * Dispose and release associated resources.
  51192. */
  51193. dispose(): void;
  51194. }
  51195. }
  51196. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  51197. import { Scene, IDisposable } from "babylonjs/scene";
  51198. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  51199. /**
  51200. * This class can be used to get instrumentation data from a Babylon engine
  51201. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  51202. */
  51203. export class SceneInstrumentation implements IDisposable {
  51204. /**
  51205. * Defines the scene to instrument
  51206. */
  51207. scene: Scene;
  51208. private _captureActiveMeshesEvaluationTime;
  51209. private _activeMeshesEvaluationTime;
  51210. private _captureRenderTargetsRenderTime;
  51211. private _renderTargetsRenderTime;
  51212. private _captureFrameTime;
  51213. private _frameTime;
  51214. private _captureRenderTime;
  51215. private _renderTime;
  51216. private _captureInterFrameTime;
  51217. private _interFrameTime;
  51218. private _captureParticlesRenderTime;
  51219. private _particlesRenderTime;
  51220. private _captureSpritesRenderTime;
  51221. private _spritesRenderTime;
  51222. private _capturePhysicsTime;
  51223. private _physicsTime;
  51224. private _captureAnimationsTime;
  51225. private _animationsTime;
  51226. private _captureCameraRenderTime;
  51227. private _cameraRenderTime;
  51228. private _onBeforeActiveMeshesEvaluationObserver;
  51229. private _onAfterActiveMeshesEvaluationObserver;
  51230. private _onBeforeRenderTargetsRenderObserver;
  51231. private _onAfterRenderTargetsRenderObserver;
  51232. private _onAfterRenderObserver;
  51233. private _onBeforeDrawPhaseObserver;
  51234. private _onAfterDrawPhaseObserver;
  51235. private _onBeforeAnimationsObserver;
  51236. private _onBeforeParticlesRenderingObserver;
  51237. private _onAfterParticlesRenderingObserver;
  51238. private _onBeforeSpritesRenderingObserver;
  51239. private _onAfterSpritesRenderingObserver;
  51240. private _onBeforePhysicsObserver;
  51241. private _onAfterPhysicsObserver;
  51242. private _onAfterAnimationsObserver;
  51243. private _onBeforeCameraRenderObserver;
  51244. private _onAfterCameraRenderObserver;
  51245. /**
  51246. * Gets the perf counter used for active meshes evaluation time
  51247. */
  51248. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  51249. /**
  51250. * Gets the active meshes evaluation time capture status
  51251. */
  51252. /**
  51253. * Enable or disable the active meshes evaluation time capture
  51254. */
  51255. captureActiveMeshesEvaluationTime: boolean;
  51256. /**
  51257. * Gets the perf counter used for render targets render time
  51258. */
  51259. readonly renderTargetsRenderTimeCounter: PerfCounter;
  51260. /**
  51261. * Gets the render targets render time capture status
  51262. */
  51263. /**
  51264. * Enable or disable the render targets render time capture
  51265. */
  51266. captureRenderTargetsRenderTime: boolean;
  51267. /**
  51268. * Gets the perf counter used for particles render time
  51269. */
  51270. readonly particlesRenderTimeCounter: PerfCounter;
  51271. /**
  51272. * Gets the particles render time capture status
  51273. */
  51274. /**
  51275. * Enable or disable the particles render time capture
  51276. */
  51277. captureParticlesRenderTime: boolean;
  51278. /**
  51279. * Gets the perf counter used for sprites render time
  51280. */
  51281. readonly spritesRenderTimeCounter: PerfCounter;
  51282. /**
  51283. * Gets the sprites render time capture status
  51284. */
  51285. /**
  51286. * Enable or disable the sprites render time capture
  51287. */
  51288. captureSpritesRenderTime: boolean;
  51289. /**
  51290. * Gets the perf counter used for physics time
  51291. */
  51292. readonly physicsTimeCounter: PerfCounter;
  51293. /**
  51294. * Gets the physics time capture status
  51295. */
  51296. /**
  51297. * Enable or disable the physics time capture
  51298. */
  51299. capturePhysicsTime: boolean;
  51300. /**
  51301. * Gets the perf counter used for animations time
  51302. */
  51303. readonly animationsTimeCounter: PerfCounter;
  51304. /**
  51305. * Gets the animations time capture status
  51306. */
  51307. /**
  51308. * Enable or disable the animations time capture
  51309. */
  51310. captureAnimationsTime: boolean;
  51311. /**
  51312. * Gets the perf counter used for frame time capture
  51313. */
  51314. readonly frameTimeCounter: PerfCounter;
  51315. /**
  51316. * Gets the frame time capture status
  51317. */
  51318. /**
  51319. * Enable or disable the frame time capture
  51320. */
  51321. captureFrameTime: boolean;
  51322. /**
  51323. * Gets the perf counter used for inter-frames time capture
  51324. */
  51325. readonly interFrameTimeCounter: PerfCounter;
  51326. /**
  51327. * Gets the inter-frames time capture status
  51328. */
  51329. /**
  51330. * Enable or disable the inter-frames time capture
  51331. */
  51332. captureInterFrameTime: boolean;
  51333. /**
  51334. * Gets the perf counter used for render time capture
  51335. */
  51336. readonly renderTimeCounter: PerfCounter;
  51337. /**
  51338. * Gets the render time capture status
  51339. */
  51340. /**
  51341. * Enable or disable the render time capture
  51342. */
  51343. captureRenderTime: boolean;
  51344. /**
  51345. * Gets the perf counter used for camera render time capture
  51346. */
  51347. readonly cameraRenderTimeCounter: PerfCounter;
  51348. /**
  51349. * Gets the camera render time capture status
  51350. */
  51351. /**
  51352. * Enable or disable the camera render time capture
  51353. */
  51354. captureCameraRenderTime: boolean;
  51355. /**
  51356. * Gets the perf counter used for draw calls
  51357. */
  51358. readonly drawCallsCounter: PerfCounter;
  51359. /**
  51360. * Instantiates a new scene instrumentation.
  51361. * This class can be used to get instrumentation data from a Babylon engine
  51362. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  51363. * @param scene Defines the scene to instrument
  51364. */
  51365. constructor(
  51366. /**
  51367. * Defines the scene to instrument
  51368. */
  51369. scene: Scene);
  51370. /**
  51371. * Dispose and release associated resources.
  51372. */
  51373. dispose(): void;
  51374. }
  51375. }
  51376. declare module "babylonjs/Instrumentation/index" {
  51377. export * from "babylonjs/Instrumentation/engineInstrumentation";
  51378. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  51379. export * from "babylonjs/Instrumentation/timeToken";
  51380. }
  51381. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  51382. /** @hidden */
  51383. export var glowMapGenerationPixelShader: {
  51384. name: string;
  51385. shader: string;
  51386. };
  51387. }
  51388. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  51389. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  51390. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  51391. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  51392. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  51393. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  51394. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  51395. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  51396. /** @hidden */
  51397. export var glowMapGenerationVertexShader: {
  51398. name: string;
  51399. shader: string;
  51400. };
  51401. }
  51402. declare module "babylonjs/Layers/effectLayer" {
  51403. import { Observable } from "babylonjs/Misc/observable";
  51404. import { Nullable } from "babylonjs/types";
  51405. import { Camera } from "babylonjs/Cameras/camera";
  51406. import { Scene } from "babylonjs/scene";
  51407. import { ISize } from "babylonjs/Maths/math.size";
  51408. import { Color4 } from "babylonjs/Maths/math.color";
  51409. import { Engine } from "babylonjs/Engines/engine";
  51410. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51411. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51412. import { Mesh } from "babylonjs/Meshes/mesh";
  51413. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  51414. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51415. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51416. import { Effect } from "babylonjs/Materials/effect";
  51417. import { Material } from "babylonjs/Materials/material";
  51418. import "babylonjs/Shaders/glowMapGeneration.fragment";
  51419. import "babylonjs/Shaders/glowMapGeneration.vertex";
  51420. /**
  51421. * Effect layer options. This helps customizing the behaviour
  51422. * of the effect layer.
  51423. */
  51424. export interface IEffectLayerOptions {
  51425. /**
  51426. * Multiplication factor apply to the canvas size to compute the render target size
  51427. * used to generated the objects (the smaller the faster).
  51428. */
  51429. mainTextureRatio: number;
  51430. /**
  51431. * Enforces a fixed size texture to ensure effect stability across devices.
  51432. */
  51433. mainTextureFixedSize?: number;
  51434. /**
  51435. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  51436. */
  51437. alphaBlendingMode: number;
  51438. /**
  51439. * The camera attached to the layer.
  51440. */
  51441. camera: Nullable<Camera>;
  51442. /**
  51443. * The rendering group to draw the layer in.
  51444. */
  51445. renderingGroupId: number;
  51446. }
  51447. /**
  51448. * The effect layer Helps adding post process effect blended with the main pass.
  51449. *
  51450. * This can be for instance use to generate glow or higlight effects on the scene.
  51451. *
  51452. * The effect layer class can not be used directly and is intented to inherited from to be
  51453. * customized per effects.
  51454. */
  51455. export abstract class EffectLayer {
  51456. private _vertexBuffers;
  51457. private _indexBuffer;
  51458. private _cachedDefines;
  51459. private _effectLayerMapGenerationEffect;
  51460. private _effectLayerOptions;
  51461. private _mergeEffect;
  51462. protected _scene: Scene;
  51463. protected _engine: Engine;
  51464. protected _maxSize: number;
  51465. protected _mainTextureDesiredSize: ISize;
  51466. protected _mainTexture: RenderTargetTexture;
  51467. protected _shouldRender: boolean;
  51468. protected _postProcesses: PostProcess[];
  51469. protected _textures: BaseTexture[];
  51470. protected _emissiveTextureAndColor: {
  51471. texture: Nullable<BaseTexture>;
  51472. color: Color4;
  51473. };
  51474. /**
  51475. * The name of the layer
  51476. */
  51477. name: string;
  51478. /**
  51479. * The clear color of the texture used to generate the glow map.
  51480. */
  51481. neutralColor: Color4;
  51482. /**
  51483. * Specifies wether the highlight layer is enabled or not.
  51484. */
  51485. isEnabled: boolean;
  51486. /**
  51487. * Gets the camera attached to the layer.
  51488. */
  51489. readonly camera: Nullable<Camera>;
  51490. /**
  51491. * Gets the rendering group id the layer should render in.
  51492. */
  51493. renderingGroupId: number;
  51494. /**
  51495. * An event triggered when the effect layer has been disposed.
  51496. */
  51497. onDisposeObservable: Observable<EffectLayer>;
  51498. /**
  51499. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  51500. */
  51501. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  51502. /**
  51503. * An event triggered when the generated texture is being merged in the scene.
  51504. */
  51505. onBeforeComposeObservable: Observable<EffectLayer>;
  51506. /**
  51507. * An event triggered when the generated texture has been merged in the scene.
  51508. */
  51509. onAfterComposeObservable: Observable<EffectLayer>;
  51510. /**
  51511. * An event triggered when the efffect layer changes its size.
  51512. */
  51513. onSizeChangedObservable: Observable<EffectLayer>;
  51514. /** @hidden */
  51515. static _SceneComponentInitialization: (scene: Scene) => void;
  51516. /**
  51517. * Instantiates a new effect Layer and references it in the scene.
  51518. * @param name The name of the layer
  51519. * @param scene The scene to use the layer in
  51520. */
  51521. constructor(
  51522. /** The Friendly of the effect in the scene */
  51523. name: string, scene: Scene);
  51524. /**
  51525. * Get the effect name of the layer.
  51526. * @return The effect name
  51527. */
  51528. abstract getEffectName(): string;
  51529. /**
  51530. * Checks for the readiness of the element composing the layer.
  51531. * @param subMesh the mesh to check for
  51532. * @param useInstances specify wether or not to use instances to render the mesh
  51533. * @return true if ready otherwise, false
  51534. */
  51535. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51536. /**
  51537. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51538. * @returns true if the effect requires stencil during the main canvas render pass.
  51539. */
  51540. abstract needStencil(): boolean;
  51541. /**
  51542. * Create the merge effect. This is the shader use to blit the information back
  51543. * to the main canvas at the end of the scene rendering.
  51544. * @returns The effect containing the shader used to merge the effect on the main canvas
  51545. */
  51546. protected abstract _createMergeEffect(): Effect;
  51547. /**
  51548. * Creates the render target textures and post processes used in the effect layer.
  51549. */
  51550. protected abstract _createTextureAndPostProcesses(): void;
  51551. /**
  51552. * Implementation specific of rendering the generating effect on the main canvas.
  51553. * @param effect The effect used to render through
  51554. */
  51555. protected abstract _internalRender(effect: Effect): void;
  51556. /**
  51557. * Sets the required values for both the emissive texture and and the main color.
  51558. */
  51559. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51560. /**
  51561. * Free any resources and references associated to a mesh.
  51562. * Internal use
  51563. * @param mesh The mesh to free.
  51564. */
  51565. abstract _disposeMesh(mesh: Mesh): void;
  51566. /**
  51567. * Serializes this layer (Glow or Highlight for example)
  51568. * @returns a serialized layer object
  51569. */
  51570. abstract serialize?(): any;
  51571. /**
  51572. * Initializes the effect layer with the required options.
  51573. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  51574. */
  51575. protected _init(options: Partial<IEffectLayerOptions>): void;
  51576. /**
  51577. * Generates the index buffer of the full screen quad blending to the main canvas.
  51578. */
  51579. private _generateIndexBuffer;
  51580. /**
  51581. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  51582. */
  51583. private _generateVertexBuffer;
  51584. /**
  51585. * Sets the main texture desired size which is the closest power of two
  51586. * of the engine canvas size.
  51587. */
  51588. private _setMainTextureSize;
  51589. /**
  51590. * Creates the main texture for the effect layer.
  51591. */
  51592. protected _createMainTexture(): void;
  51593. /**
  51594. * Adds specific effects defines.
  51595. * @param defines The defines to add specifics to.
  51596. */
  51597. protected _addCustomEffectDefines(defines: string[]): void;
  51598. /**
  51599. * Checks for the readiness of the element composing the layer.
  51600. * @param subMesh the mesh to check for
  51601. * @param useInstances specify wether or not to use instances to render the mesh
  51602. * @param emissiveTexture the associated emissive texture used to generate the glow
  51603. * @return true if ready otherwise, false
  51604. */
  51605. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  51606. /**
  51607. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  51608. */
  51609. render(): void;
  51610. /**
  51611. * Determine if a given mesh will be used in the current effect.
  51612. * @param mesh mesh to test
  51613. * @returns true if the mesh will be used
  51614. */
  51615. hasMesh(mesh: AbstractMesh): boolean;
  51616. /**
  51617. * Returns true if the layer contains information to display, otherwise false.
  51618. * @returns true if the glow layer should be rendered
  51619. */
  51620. shouldRender(): boolean;
  51621. /**
  51622. * Returns true if the mesh should render, otherwise false.
  51623. * @param mesh The mesh to render
  51624. * @returns true if it should render otherwise false
  51625. */
  51626. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  51627. /**
  51628. * Returns true if the mesh can be rendered, otherwise false.
  51629. * @param mesh The mesh to render
  51630. * @param material The material used on the mesh
  51631. * @returns true if it can be rendered otherwise false
  51632. */
  51633. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  51634. /**
  51635. * Returns true if the mesh should render, otherwise false.
  51636. * @param mesh The mesh to render
  51637. * @returns true if it should render otherwise false
  51638. */
  51639. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  51640. /**
  51641. * Renders the submesh passed in parameter to the generation map.
  51642. */
  51643. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  51644. /**
  51645. * Rebuild the required buffers.
  51646. * @hidden Internal use only.
  51647. */
  51648. _rebuild(): void;
  51649. /**
  51650. * Dispose only the render target textures and post process.
  51651. */
  51652. private _disposeTextureAndPostProcesses;
  51653. /**
  51654. * Dispose the highlight layer and free resources.
  51655. */
  51656. dispose(): void;
  51657. /**
  51658. * Gets the class name of the effect layer
  51659. * @returns the string with the class name of the effect layer
  51660. */
  51661. getClassName(): string;
  51662. /**
  51663. * Creates an effect layer from parsed effect layer data
  51664. * @param parsedEffectLayer defines effect layer data
  51665. * @param scene defines the current scene
  51666. * @param rootUrl defines the root URL containing the effect layer information
  51667. * @returns a parsed effect Layer
  51668. */
  51669. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  51670. }
  51671. }
  51672. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  51673. import { Scene } from "babylonjs/scene";
  51674. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  51675. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51676. import { AbstractScene } from "babylonjs/abstractScene";
  51677. module "babylonjs/abstractScene" {
  51678. interface AbstractScene {
  51679. /**
  51680. * The list of effect layers (highlights/glow) added to the scene
  51681. * @see http://doc.babylonjs.com/how_to/highlight_layer
  51682. * @see http://doc.babylonjs.com/how_to/glow_layer
  51683. */
  51684. effectLayers: Array<EffectLayer>;
  51685. /**
  51686. * Removes the given effect layer from this scene.
  51687. * @param toRemove defines the effect layer to remove
  51688. * @returns the index of the removed effect layer
  51689. */
  51690. removeEffectLayer(toRemove: EffectLayer): number;
  51691. /**
  51692. * Adds the given effect layer to this scene
  51693. * @param newEffectLayer defines the effect layer to add
  51694. */
  51695. addEffectLayer(newEffectLayer: EffectLayer): void;
  51696. }
  51697. }
  51698. /**
  51699. * Defines the layer scene component responsible to manage any effect layers
  51700. * in a given scene.
  51701. */
  51702. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  51703. /**
  51704. * The component name helpfull to identify the component in the list of scene components.
  51705. */
  51706. readonly name: string;
  51707. /**
  51708. * The scene the component belongs to.
  51709. */
  51710. scene: Scene;
  51711. private _engine;
  51712. private _renderEffects;
  51713. private _needStencil;
  51714. private _previousStencilState;
  51715. /**
  51716. * Creates a new instance of the component for the given scene
  51717. * @param scene Defines the scene to register the component in
  51718. */
  51719. constructor(scene: Scene);
  51720. /**
  51721. * Registers the component in a given scene
  51722. */
  51723. register(): void;
  51724. /**
  51725. * Rebuilds the elements related to this component in case of
  51726. * context lost for instance.
  51727. */
  51728. rebuild(): void;
  51729. /**
  51730. * Serializes the component data to the specified json object
  51731. * @param serializationObject The object to serialize to
  51732. */
  51733. serialize(serializationObject: any): void;
  51734. /**
  51735. * Adds all the elements from the container to the scene
  51736. * @param container the container holding the elements
  51737. */
  51738. addFromContainer(container: AbstractScene): void;
  51739. /**
  51740. * Removes all the elements in the container from the scene
  51741. * @param container contains the elements to remove
  51742. * @param dispose if the removed element should be disposed (default: false)
  51743. */
  51744. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51745. /**
  51746. * Disposes the component and the associated ressources.
  51747. */
  51748. dispose(): void;
  51749. private _isReadyForMesh;
  51750. private _renderMainTexture;
  51751. private _setStencil;
  51752. private _setStencilBack;
  51753. private _draw;
  51754. private _drawCamera;
  51755. private _drawRenderingGroup;
  51756. }
  51757. }
  51758. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  51759. /** @hidden */
  51760. export var glowMapMergePixelShader: {
  51761. name: string;
  51762. shader: string;
  51763. };
  51764. }
  51765. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  51766. /** @hidden */
  51767. export var glowMapMergeVertexShader: {
  51768. name: string;
  51769. shader: string;
  51770. };
  51771. }
  51772. declare module "babylonjs/Layers/glowLayer" {
  51773. import { Nullable } from "babylonjs/types";
  51774. import { Camera } from "babylonjs/Cameras/camera";
  51775. import { Scene } from "babylonjs/scene";
  51776. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51777. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51778. import { Mesh } from "babylonjs/Meshes/mesh";
  51779. import { Texture } from "babylonjs/Materials/Textures/texture";
  51780. import { Effect } from "babylonjs/Materials/effect";
  51781. import { Material } from "babylonjs/Materials/material";
  51782. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51783. import { Color4 } from "babylonjs/Maths/math.color";
  51784. import "babylonjs/Shaders/glowMapMerge.fragment";
  51785. import "babylonjs/Shaders/glowMapMerge.vertex";
  51786. import "babylonjs/Layers/effectLayerSceneComponent";
  51787. module "babylonjs/abstractScene" {
  51788. interface AbstractScene {
  51789. /**
  51790. * Return a the first highlight layer of the scene with a given name.
  51791. * @param name The name of the highlight layer to look for.
  51792. * @return The highlight layer if found otherwise null.
  51793. */
  51794. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  51795. }
  51796. }
  51797. /**
  51798. * Glow layer options. This helps customizing the behaviour
  51799. * of the glow layer.
  51800. */
  51801. export interface IGlowLayerOptions {
  51802. /**
  51803. * Multiplication factor apply to the canvas size to compute the render target size
  51804. * used to generated the glowing objects (the smaller the faster).
  51805. */
  51806. mainTextureRatio: number;
  51807. /**
  51808. * Enforces a fixed size texture to ensure resize independant blur.
  51809. */
  51810. mainTextureFixedSize?: number;
  51811. /**
  51812. * How big is the kernel of the blur texture.
  51813. */
  51814. blurKernelSize: number;
  51815. /**
  51816. * The camera attached to the layer.
  51817. */
  51818. camera: Nullable<Camera>;
  51819. /**
  51820. * Enable MSAA by chosing the number of samples.
  51821. */
  51822. mainTextureSamples?: number;
  51823. /**
  51824. * The rendering group to draw the layer in.
  51825. */
  51826. renderingGroupId: number;
  51827. }
  51828. /**
  51829. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  51830. *
  51831. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  51832. * glowy meshes to your scene.
  51833. *
  51834. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  51835. */
  51836. export class GlowLayer extends EffectLayer {
  51837. /**
  51838. * Effect Name of the layer.
  51839. */
  51840. static readonly EffectName: string;
  51841. /**
  51842. * The default blur kernel size used for the glow.
  51843. */
  51844. static DefaultBlurKernelSize: number;
  51845. /**
  51846. * The default texture size ratio used for the glow.
  51847. */
  51848. static DefaultTextureRatio: number;
  51849. /**
  51850. * Sets the kernel size of the blur.
  51851. */
  51852. /**
  51853. * Gets the kernel size of the blur.
  51854. */
  51855. blurKernelSize: number;
  51856. /**
  51857. * Sets the glow intensity.
  51858. */
  51859. /**
  51860. * Gets the glow intensity.
  51861. */
  51862. intensity: number;
  51863. private _options;
  51864. private _intensity;
  51865. private _horizontalBlurPostprocess1;
  51866. private _verticalBlurPostprocess1;
  51867. private _horizontalBlurPostprocess2;
  51868. private _verticalBlurPostprocess2;
  51869. private _blurTexture1;
  51870. private _blurTexture2;
  51871. private _postProcesses1;
  51872. private _postProcesses2;
  51873. private _includedOnlyMeshes;
  51874. private _excludedMeshes;
  51875. /**
  51876. * Callback used to let the user override the color selection on a per mesh basis
  51877. */
  51878. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  51879. /**
  51880. * Callback used to let the user override the texture selection on a per mesh basis
  51881. */
  51882. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  51883. /**
  51884. * Instantiates a new glow Layer and references it to the scene.
  51885. * @param name The name of the layer
  51886. * @param scene The scene to use the layer in
  51887. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  51888. */
  51889. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  51890. /**
  51891. * Get the effect name of the layer.
  51892. * @return The effect name
  51893. */
  51894. getEffectName(): string;
  51895. /**
  51896. * Create the merge effect. This is the shader use to blit the information back
  51897. * to the main canvas at the end of the scene rendering.
  51898. */
  51899. protected _createMergeEffect(): Effect;
  51900. /**
  51901. * Creates the render target textures and post processes used in the glow layer.
  51902. */
  51903. protected _createTextureAndPostProcesses(): void;
  51904. /**
  51905. * Checks for the readiness of the element composing the layer.
  51906. * @param subMesh the mesh to check for
  51907. * @param useInstances specify wether or not to use instances to render the mesh
  51908. * @param emissiveTexture the associated emissive texture used to generate the glow
  51909. * @return true if ready otherwise, false
  51910. */
  51911. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51912. /**
  51913. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51914. */
  51915. needStencil(): boolean;
  51916. /**
  51917. * Returns true if the mesh can be rendered, otherwise false.
  51918. * @param mesh The mesh to render
  51919. * @param material The material used on the mesh
  51920. * @returns true if it can be rendered otherwise false
  51921. */
  51922. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  51923. /**
  51924. * Implementation specific of rendering the generating effect on the main canvas.
  51925. * @param effect The effect used to render through
  51926. */
  51927. protected _internalRender(effect: Effect): void;
  51928. /**
  51929. * Sets the required values for both the emissive texture and and the main color.
  51930. */
  51931. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51932. /**
  51933. * Returns true if the mesh should render, otherwise false.
  51934. * @param mesh The mesh to render
  51935. * @returns true if it should render otherwise false
  51936. */
  51937. protected _shouldRenderMesh(mesh: Mesh): boolean;
  51938. /**
  51939. * Adds specific effects defines.
  51940. * @param defines The defines to add specifics to.
  51941. */
  51942. protected _addCustomEffectDefines(defines: string[]): void;
  51943. /**
  51944. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  51945. * @param mesh The mesh to exclude from the glow layer
  51946. */
  51947. addExcludedMesh(mesh: Mesh): void;
  51948. /**
  51949. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  51950. * @param mesh The mesh to remove
  51951. */
  51952. removeExcludedMesh(mesh: Mesh): void;
  51953. /**
  51954. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  51955. * @param mesh The mesh to include in the glow layer
  51956. */
  51957. addIncludedOnlyMesh(mesh: Mesh): void;
  51958. /**
  51959. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  51960. * @param mesh The mesh to remove
  51961. */
  51962. removeIncludedOnlyMesh(mesh: Mesh): void;
  51963. /**
  51964. * Determine if a given mesh will be used in the glow layer
  51965. * @param mesh The mesh to test
  51966. * @returns true if the mesh will be highlighted by the current glow layer
  51967. */
  51968. hasMesh(mesh: AbstractMesh): boolean;
  51969. /**
  51970. * Free any resources and references associated to a mesh.
  51971. * Internal use
  51972. * @param mesh The mesh to free.
  51973. * @hidden
  51974. */
  51975. _disposeMesh(mesh: Mesh): void;
  51976. /**
  51977. * Gets the class name of the effect layer
  51978. * @returns the string with the class name of the effect layer
  51979. */
  51980. getClassName(): string;
  51981. /**
  51982. * Serializes this glow layer
  51983. * @returns a serialized glow layer object
  51984. */
  51985. serialize(): any;
  51986. /**
  51987. * Creates a Glow Layer from parsed glow layer data
  51988. * @param parsedGlowLayer defines glow layer data
  51989. * @param scene defines the current scene
  51990. * @param rootUrl defines the root URL containing the glow layer information
  51991. * @returns a parsed Glow Layer
  51992. */
  51993. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  51994. }
  51995. }
  51996. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  51997. /** @hidden */
  51998. export var glowBlurPostProcessPixelShader: {
  51999. name: string;
  52000. shader: string;
  52001. };
  52002. }
  52003. declare module "babylonjs/Layers/highlightLayer" {
  52004. import { Observable } from "babylonjs/Misc/observable";
  52005. import { Nullable } from "babylonjs/types";
  52006. import { Camera } from "babylonjs/Cameras/camera";
  52007. import { Scene } from "babylonjs/scene";
  52008. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52009. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52010. import { Mesh } from "babylonjs/Meshes/mesh";
  52011. import { Effect } from "babylonjs/Materials/effect";
  52012. import { Material } from "babylonjs/Materials/material";
  52013. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  52014. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  52015. import "babylonjs/Shaders/glowMapMerge.fragment";
  52016. import "babylonjs/Shaders/glowMapMerge.vertex";
  52017. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  52018. module "babylonjs/abstractScene" {
  52019. interface AbstractScene {
  52020. /**
  52021. * Return a the first highlight layer of the scene with a given name.
  52022. * @param name The name of the highlight layer to look for.
  52023. * @return The highlight layer if found otherwise null.
  52024. */
  52025. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  52026. }
  52027. }
  52028. /**
  52029. * Highlight layer options. This helps customizing the behaviour
  52030. * of the highlight layer.
  52031. */
  52032. export interface IHighlightLayerOptions {
  52033. /**
  52034. * Multiplication factor apply to the canvas size to compute the render target size
  52035. * used to generated the glowing objects (the smaller the faster).
  52036. */
  52037. mainTextureRatio: number;
  52038. /**
  52039. * Enforces a fixed size texture to ensure resize independant blur.
  52040. */
  52041. mainTextureFixedSize?: number;
  52042. /**
  52043. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  52044. * of the picture to blur (the smaller the faster).
  52045. */
  52046. blurTextureSizeRatio: number;
  52047. /**
  52048. * How big in texel of the blur texture is the vertical blur.
  52049. */
  52050. blurVerticalSize: number;
  52051. /**
  52052. * How big in texel of the blur texture is the horizontal blur.
  52053. */
  52054. blurHorizontalSize: number;
  52055. /**
  52056. * Alpha blending mode used to apply the blur. Default is combine.
  52057. */
  52058. alphaBlendingMode: number;
  52059. /**
  52060. * The camera attached to the layer.
  52061. */
  52062. camera: Nullable<Camera>;
  52063. /**
  52064. * Should we display highlight as a solid stroke?
  52065. */
  52066. isStroke?: boolean;
  52067. /**
  52068. * The rendering group to draw the layer in.
  52069. */
  52070. renderingGroupId: number;
  52071. }
  52072. /**
  52073. * The highlight layer Helps adding a glow effect around a mesh.
  52074. *
  52075. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  52076. * glowy meshes to your scene.
  52077. *
  52078. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  52079. */
  52080. export class HighlightLayer extends EffectLayer {
  52081. name: string;
  52082. /**
  52083. * Effect Name of the highlight layer.
  52084. */
  52085. static readonly EffectName: string;
  52086. /**
  52087. * The neutral color used during the preparation of the glow effect.
  52088. * This is black by default as the blend operation is a blend operation.
  52089. */
  52090. static NeutralColor: Color4;
  52091. /**
  52092. * Stencil value used for glowing meshes.
  52093. */
  52094. static GlowingMeshStencilReference: number;
  52095. /**
  52096. * Stencil value used for the other meshes in the scene.
  52097. */
  52098. static NormalMeshStencilReference: number;
  52099. /**
  52100. * Specifies whether or not the inner glow is ACTIVE in the layer.
  52101. */
  52102. innerGlow: boolean;
  52103. /**
  52104. * Specifies whether or not the outer glow is ACTIVE in the layer.
  52105. */
  52106. outerGlow: boolean;
  52107. /**
  52108. * Specifies the horizontal size of the blur.
  52109. */
  52110. /**
  52111. * Gets the horizontal size of the blur.
  52112. */
  52113. blurHorizontalSize: number;
  52114. /**
  52115. * Specifies the vertical size of the blur.
  52116. */
  52117. /**
  52118. * Gets the vertical size of the blur.
  52119. */
  52120. blurVerticalSize: number;
  52121. /**
  52122. * An event triggered when the highlight layer is being blurred.
  52123. */
  52124. onBeforeBlurObservable: Observable<HighlightLayer>;
  52125. /**
  52126. * An event triggered when the highlight layer has been blurred.
  52127. */
  52128. onAfterBlurObservable: Observable<HighlightLayer>;
  52129. private _instanceGlowingMeshStencilReference;
  52130. private _options;
  52131. private _downSamplePostprocess;
  52132. private _horizontalBlurPostprocess;
  52133. private _verticalBlurPostprocess;
  52134. private _blurTexture;
  52135. private _meshes;
  52136. private _excludedMeshes;
  52137. /**
  52138. * Instantiates a new highlight Layer and references it to the scene..
  52139. * @param name The name of the layer
  52140. * @param scene The scene to use the layer in
  52141. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  52142. */
  52143. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  52144. /**
  52145. * Get the effect name of the layer.
  52146. * @return The effect name
  52147. */
  52148. getEffectName(): string;
  52149. /**
  52150. * Create the merge effect. This is the shader use to blit the information back
  52151. * to the main canvas at the end of the scene rendering.
  52152. */
  52153. protected _createMergeEffect(): Effect;
  52154. /**
  52155. * Creates the render target textures and post processes used in the highlight layer.
  52156. */
  52157. protected _createTextureAndPostProcesses(): void;
  52158. /**
  52159. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52160. */
  52161. needStencil(): boolean;
  52162. /**
  52163. * Checks for the readiness of the element composing the layer.
  52164. * @param subMesh the mesh to check for
  52165. * @param useInstances specify wether or not to use instances to render the mesh
  52166. * @param emissiveTexture the associated emissive texture used to generate the glow
  52167. * @return true if ready otherwise, false
  52168. */
  52169. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52170. /**
  52171. * Implementation specific of rendering the generating effect on the main canvas.
  52172. * @param effect The effect used to render through
  52173. */
  52174. protected _internalRender(effect: Effect): void;
  52175. /**
  52176. * Returns true if the layer contains information to display, otherwise false.
  52177. */
  52178. shouldRender(): boolean;
  52179. /**
  52180. * Returns true if the mesh should render, otherwise false.
  52181. * @param mesh The mesh to render
  52182. * @returns true if it should render otherwise false
  52183. */
  52184. protected _shouldRenderMesh(mesh: Mesh): boolean;
  52185. /**
  52186. * Sets the required values for both the emissive texture and and the main color.
  52187. */
  52188. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52189. /**
  52190. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  52191. * @param mesh The mesh to exclude from the highlight layer
  52192. */
  52193. addExcludedMesh(mesh: Mesh): void;
  52194. /**
  52195. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  52196. * @param mesh The mesh to highlight
  52197. */
  52198. removeExcludedMesh(mesh: Mesh): void;
  52199. /**
  52200. * Determine if a given mesh will be highlighted by the current HighlightLayer
  52201. * @param mesh mesh to test
  52202. * @returns true if the mesh will be highlighted by the current HighlightLayer
  52203. */
  52204. hasMesh(mesh: AbstractMesh): boolean;
  52205. /**
  52206. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  52207. * @param mesh The mesh to highlight
  52208. * @param color The color of the highlight
  52209. * @param glowEmissiveOnly Extract the glow from the emissive texture
  52210. */
  52211. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  52212. /**
  52213. * Remove a mesh from the highlight layer in order to make it stop glowing.
  52214. * @param mesh The mesh to highlight
  52215. */
  52216. removeMesh(mesh: Mesh): void;
  52217. /**
  52218. * Force the stencil to the normal expected value for none glowing parts
  52219. */
  52220. private _defaultStencilReference;
  52221. /**
  52222. * Free any resources and references associated to a mesh.
  52223. * Internal use
  52224. * @param mesh The mesh to free.
  52225. * @hidden
  52226. */
  52227. _disposeMesh(mesh: Mesh): void;
  52228. /**
  52229. * Dispose the highlight layer and free resources.
  52230. */
  52231. dispose(): void;
  52232. /**
  52233. * Gets the class name of the effect layer
  52234. * @returns the string with the class name of the effect layer
  52235. */
  52236. getClassName(): string;
  52237. /**
  52238. * Serializes this Highlight layer
  52239. * @returns a serialized Highlight layer object
  52240. */
  52241. serialize(): any;
  52242. /**
  52243. * Creates a Highlight layer from parsed Highlight layer data
  52244. * @param parsedHightlightLayer defines the Highlight layer data
  52245. * @param scene defines the current scene
  52246. * @param rootUrl defines the root URL containing the Highlight layer information
  52247. * @returns a parsed Highlight layer
  52248. */
  52249. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  52250. }
  52251. }
  52252. declare module "babylonjs/Layers/layerSceneComponent" {
  52253. import { Scene } from "babylonjs/scene";
  52254. import { ISceneComponent } from "babylonjs/sceneComponent";
  52255. import { Layer } from "babylonjs/Layers/layer";
  52256. import { AbstractScene } from "babylonjs/abstractScene";
  52257. module "babylonjs/abstractScene" {
  52258. interface AbstractScene {
  52259. /**
  52260. * The list of layers (background and foreground) of the scene
  52261. */
  52262. layers: Array<Layer>;
  52263. }
  52264. }
  52265. /**
  52266. * Defines the layer scene component responsible to manage any layers
  52267. * in a given scene.
  52268. */
  52269. export class LayerSceneComponent implements ISceneComponent {
  52270. /**
  52271. * The component name helpfull to identify the component in the list of scene components.
  52272. */
  52273. readonly name: string;
  52274. /**
  52275. * The scene the component belongs to.
  52276. */
  52277. scene: Scene;
  52278. private _engine;
  52279. /**
  52280. * Creates a new instance of the component for the given scene
  52281. * @param scene Defines the scene to register the component in
  52282. */
  52283. constructor(scene: Scene);
  52284. /**
  52285. * Registers the component in a given scene
  52286. */
  52287. register(): void;
  52288. /**
  52289. * Rebuilds the elements related to this component in case of
  52290. * context lost for instance.
  52291. */
  52292. rebuild(): void;
  52293. /**
  52294. * Disposes the component and the associated ressources.
  52295. */
  52296. dispose(): void;
  52297. private _draw;
  52298. private _drawCameraPredicate;
  52299. private _drawCameraBackground;
  52300. private _drawCameraForeground;
  52301. private _drawRenderTargetPredicate;
  52302. private _drawRenderTargetBackground;
  52303. private _drawRenderTargetForeground;
  52304. /**
  52305. * Adds all the elements from the container to the scene
  52306. * @param container the container holding the elements
  52307. */
  52308. addFromContainer(container: AbstractScene): void;
  52309. /**
  52310. * Removes all the elements in the container from the scene
  52311. * @param container contains the elements to remove
  52312. * @param dispose if the removed element should be disposed (default: false)
  52313. */
  52314. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52315. }
  52316. }
  52317. declare module "babylonjs/Shaders/layer.fragment" {
  52318. /** @hidden */
  52319. export var layerPixelShader: {
  52320. name: string;
  52321. shader: string;
  52322. };
  52323. }
  52324. declare module "babylonjs/Shaders/layer.vertex" {
  52325. /** @hidden */
  52326. export var layerVertexShader: {
  52327. name: string;
  52328. shader: string;
  52329. };
  52330. }
  52331. declare module "babylonjs/Layers/layer" {
  52332. import { Observable } from "babylonjs/Misc/observable";
  52333. import { Nullable } from "babylonjs/types";
  52334. import { Scene } from "babylonjs/scene";
  52335. import { Vector2 } from "babylonjs/Maths/math.vector";
  52336. import { Color4 } from "babylonjs/Maths/math.color";
  52337. import { Texture } from "babylonjs/Materials/Textures/texture";
  52338. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52339. import "babylonjs/Shaders/layer.fragment";
  52340. import "babylonjs/Shaders/layer.vertex";
  52341. /**
  52342. * This represents a full screen 2d layer.
  52343. * This can be useful to display a picture in the background of your scene for instance.
  52344. * @see https://www.babylonjs-playground.com/#08A2BS#1
  52345. */
  52346. export class Layer {
  52347. /**
  52348. * Define the name of the layer.
  52349. */
  52350. name: string;
  52351. /**
  52352. * Define the texture the layer should display.
  52353. */
  52354. texture: Nullable<Texture>;
  52355. /**
  52356. * Is the layer in background or foreground.
  52357. */
  52358. isBackground: boolean;
  52359. /**
  52360. * Define the color of the layer (instead of texture).
  52361. */
  52362. color: Color4;
  52363. /**
  52364. * Define the scale of the layer in order to zoom in out of the texture.
  52365. */
  52366. scale: Vector2;
  52367. /**
  52368. * Define an offset for the layer in order to shift the texture.
  52369. */
  52370. offset: Vector2;
  52371. /**
  52372. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  52373. */
  52374. alphaBlendingMode: number;
  52375. /**
  52376. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  52377. * Alpha test will not mix with the background color in case of transparency.
  52378. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  52379. */
  52380. alphaTest: boolean;
  52381. /**
  52382. * Define a mask to restrict the layer to only some of the scene cameras.
  52383. */
  52384. layerMask: number;
  52385. /**
  52386. * Define the list of render target the layer is visible into.
  52387. */
  52388. renderTargetTextures: RenderTargetTexture[];
  52389. /**
  52390. * Define if the layer is only used in renderTarget or if it also
  52391. * renders in the main frame buffer of the canvas.
  52392. */
  52393. renderOnlyInRenderTargetTextures: boolean;
  52394. private _scene;
  52395. private _vertexBuffers;
  52396. private _indexBuffer;
  52397. private _effect;
  52398. private _alphaTestEffect;
  52399. /**
  52400. * An event triggered when the layer is disposed.
  52401. */
  52402. onDisposeObservable: Observable<Layer>;
  52403. private _onDisposeObserver;
  52404. /**
  52405. * Back compatibility with callback before the onDisposeObservable existed.
  52406. * The set callback will be triggered when the layer has been disposed.
  52407. */
  52408. onDispose: () => void;
  52409. /**
  52410. * An event triggered before rendering the scene
  52411. */
  52412. onBeforeRenderObservable: Observable<Layer>;
  52413. private _onBeforeRenderObserver;
  52414. /**
  52415. * Back compatibility with callback before the onBeforeRenderObservable existed.
  52416. * The set callback will be triggered just before rendering the layer.
  52417. */
  52418. onBeforeRender: () => void;
  52419. /**
  52420. * An event triggered after rendering the scene
  52421. */
  52422. onAfterRenderObservable: Observable<Layer>;
  52423. private _onAfterRenderObserver;
  52424. /**
  52425. * Back compatibility with callback before the onAfterRenderObservable existed.
  52426. * The set callback will be triggered just after rendering the layer.
  52427. */
  52428. onAfterRender: () => void;
  52429. /**
  52430. * Instantiates a new layer.
  52431. * This represents a full screen 2d layer.
  52432. * This can be useful to display a picture in the background of your scene for instance.
  52433. * @see https://www.babylonjs-playground.com/#08A2BS#1
  52434. * @param name Define the name of the layer in the scene
  52435. * @param imgUrl Define the url of the texture to display in the layer
  52436. * @param scene Define the scene the layer belongs to
  52437. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  52438. * @param color Defines a color for the layer
  52439. */
  52440. constructor(
  52441. /**
  52442. * Define the name of the layer.
  52443. */
  52444. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  52445. private _createIndexBuffer;
  52446. /** @hidden */
  52447. _rebuild(): void;
  52448. /**
  52449. * Renders the layer in the scene.
  52450. */
  52451. render(): void;
  52452. /**
  52453. * Disposes and releases the associated ressources.
  52454. */
  52455. dispose(): void;
  52456. }
  52457. }
  52458. declare module "babylonjs/Layers/index" {
  52459. export * from "babylonjs/Layers/effectLayer";
  52460. export * from "babylonjs/Layers/effectLayerSceneComponent";
  52461. export * from "babylonjs/Layers/glowLayer";
  52462. export * from "babylonjs/Layers/highlightLayer";
  52463. export * from "babylonjs/Layers/layer";
  52464. export * from "babylonjs/Layers/layerSceneComponent";
  52465. }
  52466. declare module "babylonjs/Shaders/lensFlare.fragment" {
  52467. /** @hidden */
  52468. export var lensFlarePixelShader: {
  52469. name: string;
  52470. shader: string;
  52471. };
  52472. }
  52473. declare module "babylonjs/Shaders/lensFlare.vertex" {
  52474. /** @hidden */
  52475. export var lensFlareVertexShader: {
  52476. name: string;
  52477. shader: string;
  52478. };
  52479. }
  52480. declare module "babylonjs/LensFlares/lensFlareSystem" {
  52481. import { Scene } from "babylonjs/scene";
  52482. import { Vector3 } from "babylonjs/Maths/math.vector";
  52483. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52484. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  52485. import "babylonjs/Shaders/lensFlare.fragment";
  52486. import "babylonjs/Shaders/lensFlare.vertex";
  52487. import { Viewport } from "babylonjs/Maths/math.viewport";
  52488. /**
  52489. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  52490. * It is usually composed of several `lensFlare`.
  52491. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52492. */
  52493. export class LensFlareSystem {
  52494. /**
  52495. * Define the name of the lens flare system
  52496. */
  52497. name: string;
  52498. /**
  52499. * List of lens flares used in this system.
  52500. */
  52501. lensFlares: LensFlare[];
  52502. /**
  52503. * Define a limit from the border the lens flare can be visible.
  52504. */
  52505. borderLimit: number;
  52506. /**
  52507. * Define a viewport border we do not want to see the lens flare in.
  52508. */
  52509. viewportBorder: number;
  52510. /**
  52511. * Define a predicate which could limit the list of meshes able to occlude the effect.
  52512. */
  52513. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  52514. /**
  52515. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  52516. */
  52517. layerMask: number;
  52518. /**
  52519. * Define the id of the lens flare system in the scene.
  52520. * (equal to name by default)
  52521. */
  52522. id: string;
  52523. private _scene;
  52524. private _emitter;
  52525. private _vertexBuffers;
  52526. private _indexBuffer;
  52527. private _effect;
  52528. private _positionX;
  52529. private _positionY;
  52530. private _isEnabled;
  52531. /** @hidden */
  52532. static _SceneComponentInitialization: (scene: Scene) => void;
  52533. /**
  52534. * Instantiates a lens flare system.
  52535. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  52536. * It is usually composed of several `lensFlare`.
  52537. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52538. * @param name Define the name of the lens flare system in the scene
  52539. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  52540. * @param scene Define the scene the lens flare system belongs to
  52541. */
  52542. constructor(
  52543. /**
  52544. * Define the name of the lens flare system
  52545. */
  52546. name: string, emitter: any, scene: Scene);
  52547. /**
  52548. * Define if the lens flare system is enabled.
  52549. */
  52550. isEnabled: boolean;
  52551. /**
  52552. * Get the scene the effects belongs to.
  52553. * @returns the scene holding the lens flare system
  52554. */
  52555. getScene(): Scene;
  52556. /**
  52557. * Get the emitter of the lens flare system.
  52558. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  52559. * @returns the emitter of the lens flare system
  52560. */
  52561. getEmitter(): any;
  52562. /**
  52563. * Set the emitter of the lens flare system.
  52564. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  52565. * @param newEmitter Define the new emitter of the system
  52566. */
  52567. setEmitter(newEmitter: any): void;
  52568. /**
  52569. * Get the lens flare system emitter position.
  52570. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  52571. * @returns the position
  52572. */
  52573. getEmitterPosition(): Vector3;
  52574. /**
  52575. * @hidden
  52576. */
  52577. computeEffectivePosition(globalViewport: Viewport): boolean;
  52578. /** @hidden */
  52579. _isVisible(): boolean;
  52580. /**
  52581. * @hidden
  52582. */
  52583. render(): boolean;
  52584. /**
  52585. * Dispose and release the lens flare with its associated resources.
  52586. */
  52587. dispose(): void;
  52588. /**
  52589. * Parse a lens flare system from a JSON repressentation
  52590. * @param parsedLensFlareSystem Define the JSON to parse
  52591. * @param scene Define the scene the parsed system should be instantiated in
  52592. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  52593. * @returns the parsed system
  52594. */
  52595. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  52596. /**
  52597. * Serialize the current Lens Flare System into a JSON representation.
  52598. * @returns the serialized JSON
  52599. */
  52600. serialize(): any;
  52601. }
  52602. }
  52603. declare module "babylonjs/LensFlares/lensFlare" {
  52604. import { Nullable } from "babylonjs/types";
  52605. import { Color3 } from "babylonjs/Maths/math.color";
  52606. import { Texture } from "babylonjs/Materials/Textures/texture";
  52607. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  52608. /**
  52609. * This represents one of the lens effect in a `lensFlareSystem`.
  52610. * It controls one of the indiviual texture used in the effect.
  52611. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52612. */
  52613. export class LensFlare {
  52614. /**
  52615. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52616. */
  52617. size: number;
  52618. /**
  52619. * 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.
  52620. */
  52621. position: number;
  52622. /**
  52623. * Define the lens color.
  52624. */
  52625. color: Color3;
  52626. /**
  52627. * Define the lens texture.
  52628. */
  52629. texture: Nullable<Texture>;
  52630. /**
  52631. * Define the alpha mode to render this particular lens.
  52632. */
  52633. alphaMode: number;
  52634. private _system;
  52635. /**
  52636. * Creates a new Lens Flare.
  52637. * This represents one of the lens effect in a `lensFlareSystem`.
  52638. * It controls one of the indiviual texture used in the effect.
  52639. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52640. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  52641. * @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.
  52642. * @param color Define the lens color
  52643. * @param imgUrl Define the lens texture url
  52644. * @param system Define the `lensFlareSystem` this flare is part of
  52645. * @returns The newly created Lens Flare
  52646. */
  52647. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  52648. /**
  52649. * Instantiates a new Lens Flare.
  52650. * This represents one of the lens effect in a `lensFlareSystem`.
  52651. * It controls one of the indiviual texture used in the effect.
  52652. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52653. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  52654. * @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.
  52655. * @param color Define the lens color
  52656. * @param imgUrl Define the lens texture url
  52657. * @param system Define the `lensFlareSystem` this flare is part of
  52658. */
  52659. constructor(
  52660. /**
  52661. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52662. */
  52663. size: number,
  52664. /**
  52665. * 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.
  52666. */
  52667. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  52668. /**
  52669. * Dispose and release the lens flare with its associated resources.
  52670. */
  52671. dispose(): void;
  52672. }
  52673. }
  52674. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  52675. import { Nullable } from "babylonjs/types";
  52676. import { Scene } from "babylonjs/scene";
  52677. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52678. import { AbstractScene } from "babylonjs/abstractScene";
  52679. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  52680. module "babylonjs/abstractScene" {
  52681. interface AbstractScene {
  52682. /**
  52683. * The list of lens flare system added to the scene
  52684. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52685. */
  52686. lensFlareSystems: Array<LensFlareSystem>;
  52687. /**
  52688. * Removes the given lens flare system from this scene.
  52689. * @param toRemove The lens flare system to remove
  52690. * @returns The index of the removed lens flare system
  52691. */
  52692. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  52693. /**
  52694. * Adds the given lens flare system to this scene
  52695. * @param newLensFlareSystem The lens flare system to add
  52696. */
  52697. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  52698. /**
  52699. * Gets a lens flare system using its name
  52700. * @param name defines the name to look for
  52701. * @returns the lens flare system or null if not found
  52702. */
  52703. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  52704. /**
  52705. * Gets a lens flare system using its id
  52706. * @param id defines the id to look for
  52707. * @returns the lens flare system or null if not found
  52708. */
  52709. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  52710. }
  52711. }
  52712. /**
  52713. * Defines the lens flare scene component responsible to manage any lens flares
  52714. * in a given scene.
  52715. */
  52716. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  52717. /**
  52718. * The component name helpfull to identify the component in the list of scene components.
  52719. */
  52720. readonly name: string;
  52721. /**
  52722. * The scene the component belongs to.
  52723. */
  52724. scene: Scene;
  52725. /**
  52726. * Creates a new instance of the component for the given scene
  52727. * @param scene Defines the scene to register the component in
  52728. */
  52729. constructor(scene: Scene);
  52730. /**
  52731. * Registers the component in a given scene
  52732. */
  52733. register(): void;
  52734. /**
  52735. * Rebuilds the elements related to this component in case of
  52736. * context lost for instance.
  52737. */
  52738. rebuild(): void;
  52739. /**
  52740. * Adds all the elements from the container to the scene
  52741. * @param container the container holding the elements
  52742. */
  52743. addFromContainer(container: AbstractScene): void;
  52744. /**
  52745. * Removes all the elements in the container from the scene
  52746. * @param container contains the elements to remove
  52747. * @param dispose if the removed element should be disposed (default: false)
  52748. */
  52749. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52750. /**
  52751. * Serializes the component data to the specified json object
  52752. * @param serializationObject The object to serialize to
  52753. */
  52754. serialize(serializationObject: any): void;
  52755. /**
  52756. * Disposes the component and the associated ressources.
  52757. */
  52758. dispose(): void;
  52759. private _draw;
  52760. }
  52761. }
  52762. declare module "babylonjs/LensFlares/index" {
  52763. export * from "babylonjs/LensFlares/lensFlare";
  52764. export * from "babylonjs/LensFlares/lensFlareSystem";
  52765. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  52766. }
  52767. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  52768. import { Scene } from "babylonjs/scene";
  52769. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52770. import { AbstractScene } from "babylonjs/abstractScene";
  52771. /**
  52772. * Defines the shadow generator component responsible to manage any shadow generators
  52773. * in a given scene.
  52774. */
  52775. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  52776. /**
  52777. * The component name helpfull to identify the component in the list of scene components.
  52778. */
  52779. readonly name: string;
  52780. /**
  52781. * The scene the component belongs to.
  52782. */
  52783. scene: Scene;
  52784. /**
  52785. * Creates a new instance of the component for the given scene
  52786. * @param scene Defines the scene to register the component in
  52787. */
  52788. constructor(scene: Scene);
  52789. /**
  52790. * Registers the component in a given scene
  52791. */
  52792. register(): void;
  52793. /**
  52794. * Rebuilds the elements related to this component in case of
  52795. * context lost for instance.
  52796. */
  52797. rebuild(): void;
  52798. /**
  52799. * Serializes the component data to the specified json object
  52800. * @param serializationObject The object to serialize to
  52801. */
  52802. serialize(serializationObject: any): void;
  52803. /**
  52804. * Adds all the elements from the container to the scene
  52805. * @param container the container holding the elements
  52806. */
  52807. addFromContainer(container: AbstractScene): void;
  52808. /**
  52809. * Removes all the elements in the container from the scene
  52810. * @param container contains the elements to remove
  52811. * @param dispose if the removed element should be disposed (default: false)
  52812. */
  52813. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52814. /**
  52815. * Rebuilds the elements related to this component in case of
  52816. * context lost for instance.
  52817. */
  52818. dispose(): void;
  52819. private _gatherRenderTargets;
  52820. }
  52821. }
  52822. declare module "babylonjs/Lights/Shadows/index" {
  52823. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  52824. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  52825. }
  52826. declare module "babylonjs/Lights/pointLight" {
  52827. import { Scene } from "babylonjs/scene";
  52828. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  52829. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52830. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  52831. import { Effect } from "babylonjs/Materials/effect";
  52832. /**
  52833. * A point light is a light defined by an unique point in world space.
  52834. * The light is emitted in every direction from this point.
  52835. * A good example of a point light is a standard light bulb.
  52836. * Documentation: https://doc.babylonjs.com/babylon101/lights
  52837. */
  52838. export class PointLight extends ShadowLight {
  52839. private _shadowAngle;
  52840. /**
  52841. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52842. * This specifies what angle the shadow will use to be created.
  52843. *
  52844. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  52845. */
  52846. /**
  52847. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52848. * This specifies what angle the shadow will use to be created.
  52849. *
  52850. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  52851. */
  52852. shadowAngle: number;
  52853. /**
  52854. * Gets the direction if it has been set.
  52855. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52856. */
  52857. /**
  52858. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52859. */
  52860. direction: Vector3;
  52861. /**
  52862. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  52863. * A PointLight emits the light in every direction.
  52864. * It can cast shadows.
  52865. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  52866. * ```javascript
  52867. * var pointLight = new PointLight("pl", camera.position, scene);
  52868. * ```
  52869. * Documentation : https://doc.babylonjs.com/babylon101/lights
  52870. * @param name The light friendly name
  52871. * @param position The position of the point light in the scene
  52872. * @param scene The scene the lights belongs to
  52873. */
  52874. constructor(name: string, position: Vector3, scene: Scene);
  52875. /**
  52876. * Returns the string "PointLight"
  52877. * @returns the class name
  52878. */
  52879. getClassName(): string;
  52880. /**
  52881. * Returns the integer 0.
  52882. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  52883. */
  52884. getTypeID(): number;
  52885. /**
  52886. * Specifies wether or not the shadowmap should be a cube texture.
  52887. * @returns true if the shadowmap needs to be a cube texture.
  52888. */
  52889. needCube(): boolean;
  52890. /**
  52891. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  52892. * @param faceIndex The index of the face we are computed the direction to generate shadow
  52893. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  52894. */
  52895. getShadowDirection(faceIndex?: number): Vector3;
  52896. /**
  52897. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  52898. * - fov = PI / 2
  52899. * - aspect ratio : 1.0
  52900. * - z-near and far equal to the active camera minZ and maxZ.
  52901. * Returns the PointLight.
  52902. */
  52903. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52904. protected _buildUniformLayout(): void;
  52905. /**
  52906. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  52907. * @param effect The effect to update
  52908. * @param lightIndex The index of the light in the effect to update
  52909. * @returns The point light
  52910. */
  52911. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  52912. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  52913. /**
  52914. * Prepares the list of defines specific to the light type.
  52915. * @param defines the list of defines
  52916. * @param lightIndex defines the index of the light for the effect
  52917. */
  52918. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  52919. }
  52920. }
  52921. declare module "babylonjs/Lights/index" {
  52922. export * from "babylonjs/Lights/light";
  52923. export * from "babylonjs/Lights/shadowLight";
  52924. export * from "babylonjs/Lights/Shadows/index";
  52925. export * from "babylonjs/Lights/directionalLight";
  52926. export * from "babylonjs/Lights/hemisphericLight";
  52927. export * from "babylonjs/Lights/pointLight";
  52928. export * from "babylonjs/Lights/spotLight";
  52929. }
  52930. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  52931. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  52932. /**
  52933. * Header information of HDR texture files.
  52934. */
  52935. export interface HDRInfo {
  52936. /**
  52937. * The height of the texture in pixels.
  52938. */
  52939. height: number;
  52940. /**
  52941. * The width of the texture in pixels.
  52942. */
  52943. width: number;
  52944. /**
  52945. * The index of the beginning of the data in the binary file.
  52946. */
  52947. dataPosition: number;
  52948. }
  52949. /**
  52950. * This groups tools to convert HDR texture to native colors array.
  52951. */
  52952. export class HDRTools {
  52953. private static Ldexp;
  52954. private static Rgbe2float;
  52955. private static readStringLine;
  52956. /**
  52957. * Reads header information from an RGBE texture stored in a native array.
  52958. * More information on this format are available here:
  52959. * https://en.wikipedia.org/wiki/RGBE_image_format
  52960. *
  52961. * @param uint8array The binary file stored in native array.
  52962. * @return The header information.
  52963. */
  52964. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  52965. /**
  52966. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  52967. * This RGBE texture needs to store the information as a panorama.
  52968. *
  52969. * More information on this format are available here:
  52970. * https://en.wikipedia.org/wiki/RGBE_image_format
  52971. *
  52972. * @param buffer The binary file stored in an array buffer.
  52973. * @param size The expected size of the extracted cubemap.
  52974. * @return The Cube Map information.
  52975. */
  52976. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  52977. /**
  52978. * Returns the pixels data extracted from an RGBE texture.
  52979. * This pixels will be stored left to right up to down in the R G B order in one array.
  52980. *
  52981. * More information on this format are available here:
  52982. * https://en.wikipedia.org/wiki/RGBE_image_format
  52983. *
  52984. * @param uint8array The binary file stored in an array buffer.
  52985. * @param hdrInfo The header information of the file.
  52986. * @return The pixels data in RGB right to left up to down order.
  52987. */
  52988. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  52989. private static RGBE_ReadPixels_RLE;
  52990. }
  52991. }
  52992. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  52993. import { Nullable } from "babylonjs/types";
  52994. import { Scene } from "babylonjs/scene";
  52995. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  52996. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52997. import "babylonjs/Engines/Extensions/engine.rawTexture";
  52998. /**
  52999. * This represents a texture coming from an HDR input.
  53000. *
  53001. * The only supported format is currently panorama picture stored in RGBE format.
  53002. * Example of such files can be found on HDRLib: http://hdrlib.com/
  53003. */
  53004. export class HDRCubeTexture extends BaseTexture {
  53005. private static _facesMapping;
  53006. private _generateHarmonics;
  53007. private _noMipmap;
  53008. private _textureMatrix;
  53009. private _size;
  53010. private _onLoad;
  53011. private _onError;
  53012. /**
  53013. * The texture URL.
  53014. */
  53015. url: string;
  53016. /**
  53017. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  53018. */
  53019. coordinatesMode: number;
  53020. protected _isBlocking: boolean;
  53021. /**
  53022. * Sets wether or not the texture is blocking during loading.
  53023. */
  53024. /**
  53025. * Gets wether or not the texture is blocking during loading.
  53026. */
  53027. isBlocking: boolean;
  53028. protected _rotationY: number;
  53029. /**
  53030. * Sets texture matrix rotation angle around Y axis in radians.
  53031. */
  53032. /**
  53033. * Gets texture matrix rotation angle around Y axis radians.
  53034. */
  53035. rotationY: number;
  53036. /**
  53037. * Gets or sets the center of the bounding box associated with the cube texture
  53038. * It must define where the camera used to render the texture was set
  53039. */
  53040. boundingBoxPosition: Vector3;
  53041. private _boundingBoxSize;
  53042. /**
  53043. * Gets or sets the size of the bounding box associated with the cube texture
  53044. * When defined, the cubemap will switch to local mode
  53045. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  53046. * @example https://www.babylonjs-playground.com/#RNASML
  53047. */
  53048. boundingBoxSize: Vector3;
  53049. /**
  53050. * Instantiates an HDRTexture from the following parameters.
  53051. *
  53052. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  53053. * @param scene The scene the texture will be used in
  53054. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  53055. * @param noMipmap Forces to not generate the mipmap if true
  53056. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  53057. * @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)
  53058. * @param reserved Reserved flag for internal use.
  53059. */
  53060. 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>);
  53061. /**
  53062. * Get the current class name of the texture useful for serialization or dynamic coding.
  53063. * @returns "HDRCubeTexture"
  53064. */
  53065. getClassName(): string;
  53066. /**
  53067. * Occurs when the file is raw .hdr file.
  53068. */
  53069. private loadTexture;
  53070. clone(): HDRCubeTexture;
  53071. delayLoad(): void;
  53072. /**
  53073. * Get the texture reflection matrix used to rotate/transform the reflection.
  53074. * @returns the reflection matrix
  53075. */
  53076. getReflectionTextureMatrix(): Matrix;
  53077. /**
  53078. * Set the texture reflection matrix used to rotate/transform the reflection.
  53079. * @param value Define the reflection matrix to set
  53080. */
  53081. setReflectionTextureMatrix(value: Matrix): void;
  53082. /**
  53083. * Parses a JSON representation of an HDR Texture in order to create the texture
  53084. * @param parsedTexture Define the JSON representation
  53085. * @param scene Define the scene the texture should be created in
  53086. * @param rootUrl Define the root url in case we need to load relative dependencies
  53087. * @returns the newly created texture after parsing
  53088. */
  53089. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  53090. serialize(): any;
  53091. }
  53092. }
  53093. declare module "babylonjs/Physics/physicsEngine" {
  53094. import { Nullable } from "babylonjs/types";
  53095. import { Vector3 } from "babylonjs/Maths/math.vector";
  53096. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  53097. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  53098. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  53099. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53100. /**
  53101. * Class used to control physics engine
  53102. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  53103. */
  53104. export class PhysicsEngine implements IPhysicsEngine {
  53105. private _physicsPlugin;
  53106. /**
  53107. * Global value used to control the smallest number supported by the simulation
  53108. */
  53109. static Epsilon: number;
  53110. private _impostors;
  53111. private _joints;
  53112. /**
  53113. * Gets the gravity vector used by the simulation
  53114. */
  53115. gravity: Vector3;
  53116. /**
  53117. * Factory used to create the default physics plugin.
  53118. * @returns The default physics plugin
  53119. */
  53120. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  53121. /**
  53122. * Creates a new Physics Engine
  53123. * @param gravity defines the gravity vector used by the simulation
  53124. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  53125. */
  53126. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  53127. /**
  53128. * Sets the gravity vector used by the simulation
  53129. * @param gravity defines the gravity vector to use
  53130. */
  53131. setGravity(gravity: Vector3): void;
  53132. /**
  53133. * Set the time step of the physics engine.
  53134. * Default is 1/60.
  53135. * To slow it down, enter 1/600 for example.
  53136. * To speed it up, 1/30
  53137. * @param newTimeStep defines the new timestep to apply to this world.
  53138. */
  53139. setTimeStep(newTimeStep?: number): void;
  53140. /**
  53141. * Get the time step of the physics engine.
  53142. * @returns the current time step
  53143. */
  53144. getTimeStep(): number;
  53145. /**
  53146. * Release all resources
  53147. */
  53148. dispose(): void;
  53149. /**
  53150. * Gets the name of the current physics plugin
  53151. * @returns the name of the plugin
  53152. */
  53153. getPhysicsPluginName(): string;
  53154. /**
  53155. * Adding a new impostor for the impostor tracking.
  53156. * This will be done by the impostor itself.
  53157. * @param impostor the impostor to add
  53158. */
  53159. addImpostor(impostor: PhysicsImpostor): void;
  53160. /**
  53161. * Remove an impostor from the engine.
  53162. * This impostor and its mesh will not longer be updated by the physics engine.
  53163. * @param impostor the impostor to remove
  53164. */
  53165. removeImpostor(impostor: PhysicsImpostor): void;
  53166. /**
  53167. * Add a joint to the physics engine
  53168. * @param mainImpostor defines the main impostor to which the joint is added.
  53169. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  53170. * @param joint defines the joint that will connect both impostors.
  53171. */
  53172. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  53173. /**
  53174. * Removes a joint from the simulation
  53175. * @param mainImpostor defines the impostor used with the joint
  53176. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  53177. * @param joint defines the joint to remove
  53178. */
  53179. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  53180. /**
  53181. * Called by the scene. No need to call it.
  53182. * @param delta defines the timespam between frames
  53183. */
  53184. _step(delta: number): void;
  53185. /**
  53186. * Gets the current plugin used to run the simulation
  53187. * @returns current plugin
  53188. */
  53189. getPhysicsPlugin(): IPhysicsEnginePlugin;
  53190. /**
  53191. * Gets the list of physic impostors
  53192. * @returns an array of PhysicsImpostor
  53193. */
  53194. getImpostors(): Array<PhysicsImpostor>;
  53195. /**
  53196. * Gets the impostor for a physics enabled object
  53197. * @param object defines the object impersonated by the impostor
  53198. * @returns the PhysicsImpostor or null if not found
  53199. */
  53200. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  53201. /**
  53202. * Gets the impostor for a physics body object
  53203. * @param body defines physics body used by the impostor
  53204. * @returns the PhysicsImpostor or null if not found
  53205. */
  53206. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  53207. /**
  53208. * Does a raycast in the physics world
  53209. * @param from when should the ray start?
  53210. * @param to when should the ray end?
  53211. * @returns PhysicsRaycastResult
  53212. */
  53213. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53214. }
  53215. }
  53216. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  53217. import { Nullable } from "babylonjs/types";
  53218. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  53219. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53220. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  53221. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53222. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  53223. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53224. /** @hidden */
  53225. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  53226. private _useDeltaForWorldStep;
  53227. world: any;
  53228. name: string;
  53229. private _physicsMaterials;
  53230. private _fixedTimeStep;
  53231. private _cannonRaycastResult;
  53232. private _raycastResult;
  53233. private _physicsBodysToRemoveAfterStep;
  53234. BJSCANNON: any;
  53235. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  53236. setGravity(gravity: Vector3): void;
  53237. setTimeStep(timeStep: number): void;
  53238. getTimeStep(): number;
  53239. executeStep(delta: number): void;
  53240. private _removeMarkedPhysicsBodiesFromWorld;
  53241. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53242. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53243. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53244. private _processChildMeshes;
  53245. removePhysicsBody(impostor: PhysicsImpostor): void;
  53246. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53247. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53248. private _addMaterial;
  53249. private _checkWithEpsilon;
  53250. private _createShape;
  53251. private _createHeightmap;
  53252. private _minus90X;
  53253. private _plus90X;
  53254. private _tmpPosition;
  53255. private _tmpDeltaPosition;
  53256. private _tmpUnityRotation;
  53257. private _updatePhysicsBodyTransformation;
  53258. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53259. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53260. isSupported(): boolean;
  53261. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53262. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53263. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53264. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53265. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53266. getBodyMass(impostor: PhysicsImpostor): number;
  53267. getBodyFriction(impostor: PhysicsImpostor): number;
  53268. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53269. getBodyRestitution(impostor: PhysicsImpostor): number;
  53270. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53271. sleepBody(impostor: PhysicsImpostor): void;
  53272. wakeUpBody(impostor: PhysicsImpostor): void;
  53273. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  53274. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  53275. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  53276. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53277. getRadius(impostor: PhysicsImpostor): number;
  53278. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53279. dispose(): void;
  53280. private _extendNamespace;
  53281. /**
  53282. * Does a raycast in the physics world
  53283. * @param from when should the ray start?
  53284. * @param to when should the ray end?
  53285. * @returns PhysicsRaycastResult
  53286. */
  53287. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53288. }
  53289. }
  53290. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  53291. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  53292. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53293. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  53294. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53295. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  53296. import { Nullable } from "babylonjs/types";
  53297. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53298. /** @hidden */
  53299. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  53300. world: any;
  53301. name: string;
  53302. BJSOIMO: any;
  53303. private _raycastResult;
  53304. constructor(iterations?: number, oimoInjection?: any);
  53305. setGravity(gravity: Vector3): void;
  53306. setTimeStep(timeStep: number): void;
  53307. getTimeStep(): number;
  53308. private _tmpImpostorsArray;
  53309. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  53310. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53311. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53312. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53313. private _tmpPositionVector;
  53314. removePhysicsBody(impostor: PhysicsImpostor): void;
  53315. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53316. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53317. isSupported(): boolean;
  53318. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53319. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53320. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53321. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53322. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53323. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53324. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53325. getBodyMass(impostor: PhysicsImpostor): number;
  53326. getBodyFriction(impostor: PhysicsImpostor): number;
  53327. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53328. getBodyRestitution(impostor: PhysicsImpostor): number;
  53329. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53330. sleepBody(impostor: PhysicsImpostor): void;
  53331. wakeUpBody(impostor: PhysicsImpostor): void;
  53332. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  53333. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  53334. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  53335. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53336. getRadius(impostor: PhysicsImpostor): number;
  53337. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53338. dispose(): void;
  53339. /**
  53340. * Does a raycast in the physics world
  53341. * @param from when should the ray start?
  53342. * @param to when should the ray end?
  53343. * @returns PhysicsRaycastResult
  53344. */
  53345. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53346. }
  53347. }
  53348. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  53349. import { Nullable } from "babylonjs/types";
  53350. import { Scene } from "babylonjs/scene";
  53351. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  53352. import { Color4 } from "babylonjs/Maths/math.color";
  53353. import { Mesh } from "babylonjs/Meshes/mesh";
  53354. /**
  53355. * Class containing static functions to help procedurally build meshes
  53356. */
  53357. export class RibbonBuilder {
  53358. /**
  53359. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53360. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  53361. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  53362. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  53363. * * 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
  53364. * * 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
  53365. * * 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
  53366. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53367. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53368. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53369. * * 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
  53370. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  53371. * * 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
  53372. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  53373. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53374. * @param name defines the name of the mesh
  53375. * @param options defines the options used to create the mesh
  53376. * @param scene defines the hosting scene
  53377. * @returns the ribbon mesh
  53378. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  53379. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53380. */
  53381. static CreateRibbon(name: string, options: {
  53382. pathArray: Vector3[][];
  53383. closeArray?: boolean;
  53384. closePath?: boolean;
  53385. offset?: number;
  53386. updatable?: boolean;
  53387. sideOrientation?: number;
  53388. frontUVs?: Vector4;
  53389. backUVs?: Vector4;
  53390. instance?: Mesh;
  53391. invertUV?: boolean;
  53392. uvs?: Vector2[];
  53393. colors?: Color4[];
  53394. }, scene?: Nullable<Scene>): Mesh;
  53395. }
  53396. }
  53397. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  53398. import { Nullable } from "babylonjs/types";
  53399. import { Scene } from "babylonjs/scene";
  53400. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  53401. import { Mesh } from "babylonjs/Meshes/mesh";
  53402. /**
  53403. * Class containing static functions to help procedurally build meshes
  53404. */
  53405. export class ShapeBuilder {
  53406. /**
  53407. * 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.
  53408. * * 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.
  53409. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53410. * * 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.
  53411. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  53412. * * 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
  53413. * * 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
  53414. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  53415. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53416. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53417. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  53418. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53419. * @param name defines the name of the mesh
  53420. * @param options defines the options used to create the mesh
  53421. * @param scene defines the hosting scene
  53422. * @returns the extruded shape mesh
  53423. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53424. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53425. */
  53426. static ExtrudeShape(name: string, options: {
  53427. shape: Vector3[];
  53428. path: Vector3[];
  53429. scale?: number;
  53430. rotation?: number;
  53431. cap?: number;
  53432. updatable?: boolean;
  53433. sideOrientation?: number;
  53434. frontUVs?: Vector4;
  53435. backUVs?: Vector4;
  53436. instance?: Mesh;
  53437. invertUV?: boolean;
  53438. }, scene?: Nullable<Scene>): Mesh;
  53439. /**
  53440. * Creates an custom extruded shape mesh.
  53441. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  53442. * * 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.
  53443. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53444. * * 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
  53445. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  53446. * * 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
  53447. * * It must returns a float value that will be the scale value applied to the shape on each path point
  53448. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  53449. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  53450. * * 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
  53451. * * 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
  53452. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  53453. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53454. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53455. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53456. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53457. * @param name defines the name of the mesh
  53458. * @param options defines the options used to create the mesh
  53459. * @param scene defines the hosting scene
  53460. * @returns the custom extruded shape mesh
  53461. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  53462. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53463. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53464. */
  53465. static ExtrudeShapeCustom(name: string, options: {
  53466. shape: Vector3[];
  53467. path: Vector3[];
  53468. scaleFunction?: any;
  53469. rotationFunction?: any;
  53470. ribbonCloseArray?: boolean;
  53471. ribbonClosePath?: boolean;
  53472. cap?: number;
  53473. updatable?: boolean;
  53474. sideOrientation?: number;
  53475. frontUVs?: Vector4;
  53476. backUVs?: Vector4;
  53477. instance?: Mesh;
  53478. invertUV?: boolean;
  53479. }, scene?: Nullable<Scene>): Mesh;
  53480. private static _ExtrudeShapeGeneric;
  53481. }
  53482. }
  53483. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  53484. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  53485. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  53486. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53487. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  53488. import { Nullable } from "babylonjs/types";
  53489. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53490. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53491. /**
  53492. * AmmoJS Physics plugin
  53493. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  53494. * @see https://github.com/kripken/ammo.js/
  53495. */
  53496. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  53497. private _useDeltaForWorldStep;
  53498. /**
  53499. * Reference to the Ammo library
  53500. */
  53501. bjsAMMO: any;
  53502. /**
  53503. * Created ammoJS world which physics bodies are added to
  53504. */
  53505. world: any;
  53506. /**
  53507. * Name of the plugin
  53508. */
  53509. name: string;
  53510. private _timeStep;
  53511. private _fixedTimeStep;
  53512. private _maxSteps;
  53513. private _tmpQuaternion;
  53514. private _tmpAmmoTransform;
  53515. private _tmpAmmoQuaternion;
  53516. private _tmpAmmoConcreteContactResultCallback;
  53517. private _collisionConfiguration;
  53518. private _dispatcher;
  53519. private _overlappingPairCache;
  53520. private _solver;
  53521. private _softBodySolver;
  53522. private _tmpAmmoVectorA;
  53523. private _tmpAmmoVectorB;
  53524. private _tmpAmmoVectorC;
  53525. private _tmpAmmoVectorD;
  53526. private _tmpContactCallbackResult;
  53527. private _tmpAmmoVectorRCA;
  53528. private _tmpAmmoVectorRCB;
  53529. private _raycastResult;
  53530. private static readonly DISABLE_COLLISION_FLAG;
  53531. private static readonly KINEMATIC_FLAG;
  53532. private static readonly DISABLE_DEACTIVATION_FLAG;
  53533. /**
  53534. * Initializes the ammoJS plugin
  53535. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  53536. * @param ammoInjection can be used to inject your own ammo reference
  53537. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  53538. */
  53539. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  53540. /**
  53541. * Sets the gravity of the physics world (m/(s^2))
  53542. * @param gravity Gravity to set
  53543. */
  53544. setGravity(gravity: Vector3): void;
  53545. /**
  53546. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  53547. * @param timeStep timestep to use in seconds
  53548. */
  53549. setTimeStep(timeStep: number): void;
  53550. /**
  53551. * 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)
  53552. * @param fixedTimeStep fixedTimeStep to use in seconds
  53553. */
  53554. setFixedTimeStep(fixedTimeStep: number): void;
  53555. /**
  53556. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  53557. * @param maxSteps the maximum number of steps by the physics engine per frame
  53558. */
  53559. setMaxSteps(maxSteps: number): void;
  53560. /**
  53561. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  53562. * @returns the current timestep in seconds
  53563. */
  53564. getTimeStep(): number;
  53565. private _isImpostorInContact;
  53566. private _isImpostorPairInContact;
  53567. private _stepSimulation;
  53568. /**
  53569. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  53570. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  53571. * After the step the babylon meshes are set to the position of the physics imposters
  53572. * @param delta amount of time to step forward
  53573. * @param impostors array of imposters to update before/after the step
  53574. */
  53575. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  53576. /**
  53577. * Update babylon mesh to match physics world object
  53578. * @param impostor imposter to match
  53579. */
  53580. private _afterSoftStep;
  53581. /**
  53582. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53583. * @param impostor imposter to match
  53584. */
  53585. private _ropeStep;
  53586. /**
  53587. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53588. * @param impostor imposter to match
  53589. */
  53590. private _softbodyOrClothStep;
  53591. private _tmpVector;
  53592. private _tmpMatrix;
  53593. /**
  53594. * Applies an impulse on the imposter
  53595. * @param impostor imposter to apply impulse to
  53596. * @param force amount of force to be applied to the imposter
  53597. * @param contactPoint the location to apply the impulse on the imposter
  53598. */
  53599. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53600. /**
  53601. * Applies a force on the imposter
  53602. * @param impostor imposter to apply force
  53603. * @param force amount of force to be applied to the imposter
  53604. * @param contactPoint the location to apply the force on the imposter
  53605. */
  53606. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53607. /**
  53608. * Creates a physics body using the plugin
  53609. * @param impostor the imposter to create the physics body on
  53610. */
  53611. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53612. /**
  53613. * Removes the physics body from the imposter and disposes of the body's memory
  53614. * @param impostor imposter to remove the physics body from
  53615. */
  53616. removePhysicsBody(impostor: PhysicsImpostor): void;
  53617. /**
  53618. * Generates a joint
  53619. * @param impostorJoint the imposter joint to create the joint with
  53620. */
  53621. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53622. /**
  53623. * Removes a joint
  53624. * @param impostorJoint the imposter joint to remove the joint from
  53625. */
  53626. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53627. private _addMeshVerts;
  53628. /**
  53629. * Initialise the soft body vertices to match its object's (mesh) vertices
  53630. * Softbody vertices (nodes) are in world space and to match this
  53631. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  53632. * @param impostor to create the softbody for
  53633. */
  53634. private _softVertexData;
  53635. /**
  53636. * Create an impostor's soft body
  53637. * @param impostor to create the softbody for
  53638. */
  53639. private _createSoftbody;
  53640. /**
  53641. * Create cloth for an impostor
  53642. * @param impostor to create the softbody for
  53643. */
  53644. private _createCloth;
  53645. /**
  53646. * Create rope for an impostor
  53647. * @param impostor to create the softbody for
  53648. */
  53649. private _createRope;
  53650. private _addHullVerts;
  53651. private _createShape;
  53652. /**
  53653. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  53654. * @param impostor imposter containing the physics body and babylon object
  53655. */
  53656. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53657. /**
  53658. * Sets the babylon object's position/rotation from the physics body's position/rotation
  53659. * @param impostor imposter containing the physics body and babylon object
  53660. * @param newPosition new position
  53661. * @param newRotation new rotation
  53662. */
  53663. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53664. /**
  53665. * If this plugin is supported
  53666. * @returns true if its supported
  53667. */
  53668. isSupported(): boolean;
  53669. /**
  53670. * Sets the linear velocity of the physics body
  53671. * @param impostor imposter to set the velocity on
  53672. * @param velocity velocity to set
  53673. */
  53674. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53675. /**
  53676. * Sets the angular velocity of the physics body
  53677. * @param impostor imposter to set the velocity on
  53678. * @param velocity velocity to set
  53679. */
  53680. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53681. /**
  53682. * gets the linear velocity
  53683. * @param impostor imposter to get linear velocity from
  53684. * @returns linear velocity
  53685. */
  53686. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53687. /**
  53688. * gets the angular velocity
  53689. * @param impostor imposter to get angular velocity from
  53690. * @returns angular velocity
  53691. */
  53692. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53693. /**
  53694. * Sets the mass of physics body
  53695. * @param impostor imposter to set the mass on
  53696. * @param mass mass to set
  53697. */
  53698. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53699. /**
  53700. * Gets the mass of the physics body
  53701. * @param impostor imposter to get the mass from
  53702. * @returns mass
  53703. */
  53704. getBodyMass(impostor: PhysicsImpostor): number;
  53705. /**
  53706. * Gets friction of the impostor
  53707. * @param impostor impostor to get friction from
  53708. * @returns friction value
  53709. */
  53710. getBodyFriction(impostor: PhysicsImpostor): number;
  53711. /**
  53712. * Sets friction of the impostor
  53713. * @param impostor impostor to set friction on
  53714. * @param friction friction value
  53715. */
  53716. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53717. /**
  53718. * Gets restitution of the impostor
  53719. * @param impostor impostor to get restitution from
  53720. * @returns restitution value
  53721. */
  53722. getBodyRestitution(impostor: PhysicsImpostor): number;
  53723. /**
  53724. * Sets resitution of the impostor
  53725. * @param impostor impostor to set resitution on
  53726. * @param restitution resitution value
  53727. */
  53728. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53729. /**
  53730. * Gets pressure inside the impostor
  53731. * @param impostor impostor to get pressure from
  53732. * @returns pressure value
  53733. */
  53734. getBodyPressure(impostor: PhysicsImpostor): number;
  53735. /**
  53736. * Sets pressure inside a soft body impostor
  53737. * Cloth and rope must remain 0 pressure
  53738. * @param impostor impostor to set pressure on
  53739. * @param pressure pressure value
  53740. */
  53741. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  53742. /**
  53743. * Gets stiffness of the impostor
  53744. * @param impostor impostor to get stiffness from
  53745. * @returns pressure value
  53746. */
  53747. getBodyStiffness(impostor: PhysicsImpostor): number;
  53748. /**
  53749. * Sets stiffness of the impostor
  53750. * @param impostor impostor to set stiffness on
  53751. * @param stiffness stiffness value from 0 to 1
  53752. */
  53753. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  53754. /**
  53755. * Gets velocityIterations of the impostor
  53756. * @param impostor impostor to get velocity iterations from
  53757. * @returns velocityIterations value
  53758. */
  53759. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  53760. /**
  53761. * Sets velocityIterations of the impostor
  53762. * @param impostor impostor to set velocity iterations on
  53763. * @param velocityIterations velocityIterations value
  53764. */
  53765. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  53766. /**
  53767. * Gets positionIterations of the impostor
  53768. * @param impostor impostor to get position iterations from
  53769. * @returns positionIterations value
  53770. */
  53771. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  53772. /**
  53773. * Sets positionIterations of the impostor
  53774. * @param impostor impostor to set position on
  53775. * @param positionIterations positionIterations value
  53776. */
  53777. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  53778. /**
  53779. * Append an anchor to a cloth object
  53780. * @param impostor is the cloth impostor to add anchor to
  53781. * @param otherImpostor is the rigid impostor to anchor to
  53782. * @param width ratio across width from 0 to 1
  53783. * @param height ratio up height from 0 to 1
  53784. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  53785. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53786. */
  53787. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53788. /**
  53789. * Append an hook to a rope object
  53790. * @param impostor is the rope impostor to add hook to
  53791. * @param otherImpostor is the rigid impostor to hook to
  53792. * @param length ratio along the rope from 0 to 1
  53793. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  53794. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53795. */
  53796. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53797. /**
  53798. * Sleeps the physics body and stops it from being active
  53799. * @param impostor impostor to sleep
  53800. */
  53801. sleepBody(impostor: PhysicsImpostor): void;
  53802. /**
  53803. * Activates the physics body
  53804. * @param impostor impostor to activate
  53805. */
  53806. wakeUpBody(impostor: PhysicsImpostor): void;
  53807. /**
  53808. * Updates the distance parameters of the joint
  53809. * @param joint joint to update
  53810. * @param maxDistance maximum distance of the joint
  53811. * @param minDistance minimum distance of the joint
  53812. */
  53813. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  53814. /**
  53815. * Sets a motor on the joint
  53816. * @param joint joint to set motor on
  53817. * @param speed speed of the motor
  53818. * @param maxForce maximum force of the motor
  53819. * @param motorIndex index of the motor
  53820. */
  53821. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  53822. /**
  53823. * Sets the motors limit
  53824. * @param joint joint to set limit on
  53825. * @param upperLimit upper limit
  53826. * @param lowerLimit lower limit
  53827. */
  53828. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  53829. /**
  53830. * Syncs the position and rotation of a mesh with the impostor
  53831. * @param mesh mesh to sync
  53832. * @param impostor impostor to update the mesh with
  53833. */
  53834. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53835. /**
  53836. * Gets the radius of the impostor
  53837. * @param impostor impostor to get radius from
  53838. * @returns the radius
  53839. */
  53840. getRadius(impostor: PhysicsImpostor): number;
  53841. /**
  53842. * Gets the box size of the impostor
  53843. * @param impostor impostor to get box size from
  53844. * @param result the resulting box size
  53845. */
  53846. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53847. /**
  53848. * Disposes of the impostor
  53849. */
  53850. dispose(): void;
  53851. /**
  53852. * Does a raycast in the physics world
  53853. * @param from when should the ray start?
  53854. * @param to when should the ray end?
  53855. * @returns PhysicsRaycastResult
  53856. */
  53857. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53858. }
  53859. }
  53860. declare module "babylonjs/Probes/reflectionProbe" {
  53861. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53862. import { Vector3 } from "babylonjs/Maths/math.vector";
  53863. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53864. import { Nullable } from "babylonjs/types";
  53865. import { Scene } from "babylonjs/scene";
  53866. module "babylonjs/abstractScene" {
  53867. interface AbstractScene {
  53868. /**
  53869. * The list of reflection probes added to the scene
  53870. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  53871. */
  53872. reflectionProbes: Array<ReflectionProbe>;
  53873. /**
  53874. * Removes the given reflection probe from this scene.
  53875. * @param toRemove The reflection probe to remove
  53876. * @returns The index of the removed reflection probe
  53877. */
  53878. removeReflectionProbe(toRemove: ReflectionProbe): number;
  53879. /**
  53880. * Adds the given reflection probe to this scene.
  53881. * @param newReflectionProbe The reflection probe to add
  53882. */
  53883. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  53884. }
  53885. }
  53886. /**
  53887. * Class used to generate realtime reflection / refraction cube textures
  53888. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  53889. */
  53890. export class ReflectionProbe {
  53891. /** defines the name of the probe */
  53892. name: string;
  53893. private _scene;
  53894. private _renderTargetTexture;
  53895. private _projectionMatrix;
  53896. private _viewMatrix;
  53897. private _target;
  53898. private _add;
  53899. private _attachedMesh;
  53900. private _invertYAxis;
  53901. /** Gets or sets probe position (center of the cube map) */
  53902. position: Vector3;
  53903. /**
  53904. * Creates a new reflection probe
  53905. * @param name defines the name of the probe
  53906. * @param size defines the texture resolution (for each face)
  53907. * @param scene defines the hosting scene
  53908. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  53909. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  53910. */
  53911. constructor(
  53912. /** defines the name of the probe */
  53913. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  53914. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  53915. samples: number;
  53916. /** Gets or sets the refresh rate to use (on every frame by default) */
  53917. refreshRate: number;
  53918. /**
  53919. * Gets the hosting scene
  53920. * @returns a Scene
  53921. */
  53922. getScene(): Scene;
  53923. /** Gets the internal CubeTexture used to render to */
  53924. readonly cubeTexture: RenderTargetTexture;
  53925. /** Gets the list of meshes to render */
  53926. readonly renderList: Nullable<AbstractMesh[]>;
  53927. /**
  53928. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  53929. * @param mesh defines the mesh to attach to
  53930. */
  53931. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  53932. /**
  53933. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  53934. * @param renderingGroupId The rendering group id corresponding to its index
  53935. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  53936. */
  53937. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  53938. /**
  53939. * Clean all associated resources
  53940. */
  53941. dispose(): void;
  53942. /**
  53943. * Converts the reflection probe information to a readable string for debug purpose.
  53944. * @param fullDetails Supports for multiple levels of logging within scene loading
  53945. * @returns the human readable reflection probe info
  53946. */
  53947. toString(fullDetails?: boolean): string;
  53948. /**
  53949. * Get the class name of the relfection probe.
  53950. * @returns "ReflectionProbe"
  53951. */
  53952. getClassName(): string;
  53953. /**
  53954. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  53955. * @returns The JSON representation of the texture
  53956. */
  53957. serialize(): any;
  53958. /**
  53959. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  53960. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  53961. * @param scene Define the scene the parsed reflection probe should be instantiated in
  53962. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  53963. * @returns The parsed reflection probe if successful
  53964. */
  53965. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  53966. }
  53967. }
  53968. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  53969. /** @hidden */
  53970. export var _BabylonLoaderRegistered: boolean;
  53971. }
  53972. declare module "babylonjs/Loading/Plugins/index" {
  53973. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  53974. }
  53975. declare module "babylonjs/Loading/index" {
  53976. export * from "babylonjs/Loading/loadingScreen";
  53977. export * from "babylonjs/Loading/Plugins/index";
  53978. export * from "babylonjs/Loading/sceneLoader";
  53979. export * from "babylonjs/Loading/sceneLoaderFlags";
  53980. }
  53981. declare module "babylonjs/Materials/Background/index" {
  53982. export * from "babylonjs/Materials/Background/backgroundMaterial";
  53983. }
  53984. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  53985. import { Scene } from "babylonjs/scene";
  53986. import { Color3 } from "babylonjs/Maths/math.color";
  53987. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  53988. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53989. /**
  53990. * The Physically based simple base material of BJS.
  53991. *
  53992. * This enables better naming and convention enforcements on top of the pbrMaterial.
  53993. * It is used as the base class for both the specGloss and metalRough conventions.
  53994. */
  53995. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  53996. /**
  53997. * Number of Simultaneous lights allowed on the material.
  53998. */
  53999. maxSimultaneousLights: number;
  54000. /**
  54001. * If sets to true, disables all the lights affecting the material.
  54002. */
  54003. disableLighting: boolean;
  54004. /**
  54005. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  54006. */
  54007. environmentTexture: BaseTexture;
  54008. /**
  54009. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  54010. */
  54011. invertNormalMapX: boolean;
  54012. /**
  54013. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  54014. */
  54015. invertNormalMapY: boolean;
  54016. /**
  54017. * Normal map used in the model.
  54018. */
  54019. normalTexture: BaseTexture;
  54020. /**
  54021. * Emissivie color used to self-illuminate the model.
  54022. */
  54023. emissiveColor: Color3;
  54024. /**
  54025. * Emissivie texture used to self-illuminate the model.
  54026. */
  54027. emissiveTexture: BaseTexture;
  54028. /**
  54029. * Occlusion Channel Strenght.
  54030. */
  54031. occlusionStrength: number;
  54032. /**
  54033. * Occlusion Texture of the material (adding extra occlusion effects).
  54034. */
  54035. occlusionTexture: BaseTexture;
  54036. /**
  54037. * Defines the alpha limits in alpha test mode.
  54038. */
  54039. alphaCutOff: number;
  54040. /**
  54041. * Gets the current double sided mode.
  54042. */
  54043. /**
  54044. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54045. */
  54046. doubleSided: boolean;
  54047. /**
  54048. * Stores the pre-calculated light information of a mesh in a texture.
  54049. */
  54050. lightmapTexture: BaseTexture;
  54051. /**
  54052. * If true, the light map contains occlusion information instead of lighting info.
  54053. */
  54054. useLightmapAsShadowmap: boolean;
  54055. /**
  54056. * Instantiates a new PBRMaterial instance.
  54057. *
  54058. * @param name The material name
  54059. * @param scene The scene the material will be use in.
  54060. */
  54061. constructor(name: string, scene: Scene);
  54062. getClassName(): string;
  54063. }
  54064. }
  54065. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  54066. import { Scene } from "babylonjs/scene";
  54067. import { Color3 } from "babylonjs/Maths/math.color";
  54068. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54069. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54070. /**
  54071. * The PBR material of BJS following the metal roughness convention.
  54072. *
  54073. * This fits to the PBR convention in the GLTF definition:
  54074. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  54075. */
  54076. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  54077. /**
  54078. * The base color has two different interpretations depending on the value of metalness.
  54079. * When the material is a metal, the base color is the specific measured reflectance value
  54080. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  54081. * of the material.
  54082. */
  54083. baseColor: Color3;
  54084. /**
  54085. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  54086. * well as opacity information in the alpha channel.
  54087. */
  54088. baseTexture: BaseTexture;
  54089. /**
  54090. * Specifies the metallic scalar value of the material.
  54091. * Can also be used to scale the metalness values of the metallic texture.
  54092. */
  54093. metallic: number;
  54094. /**
  54095. * Specifies the roughness scalar value of the material.
  54096. * Can also be used to scale the roughness values of the metallic texture.
  54097. */
  54098. roughness: number;
  54099. /**
  54100. * Texture containing both the metallic value in the B channel and the
  54101. * roughness value in the G channel to keep better precision.
  54102. */
  54103. metallicRoughnessTexture: BaseTexture;
  54104. /**
  54105. * Instantiates a new PBRMetalRoughnessMaterial instance.
  54106. *
  54107. * @param name The material name
  54108. * @param scene The scene the material will be use in.
  54109. */
  54110. constructor(name: string, scene: Scene);
  54111. /**
  54112. * Return the currrent class name of the material.
  54113. */
  54114. getClassName(): string;
  54115. /**
  54116. * Makes a duplicate of the current material.
  54117. * @param name - name to use for the new material.
  54118. */
  54119. clone(name: string): PBRMetallicRoughnessMaterial;
  54120. /**
  54121. * Serialize the material to a parsable JSON object.
  54122. */
  54123. serialize(): any;
  54124. /**
  54125. * Parses a JSON object correponding to the serialize function.
  54126. */
  54127. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  54128. }
  54129. }
  54130. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  54131. import { Scene } from "babylonjs/scene";
  54132. import { Color3 } from "babylonjs/Maths/math.color";
  54133. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54134. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54135. /**
  54136. * The PBR material of BJS following the specular glossiness convention.
  54137. *
  54138. * This fits to the PBR convention in the GLTF definition:
  54139. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  54140. */
  54141. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  54142. /**
  54143. * Specifies the diffuse color of the material.
  54144. */
  54145. diffuseColor: Color3;
  54146. /**
  54147. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  54148. * channel.
  54149. */
  54150. diffuseTexture: BaseTexture;
  54151. /**
  54152. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  54153. */
  54154. specularColor: Color3;
  54155. /**
  54156. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  54157. */
  54158. glossiness: number;
  54159. /**
  54160. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  54161. */
  54162. specularGlossinessTexture: BaseTexture;
  54163. /**
  54164. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  54165. *
  54166. * @param name The material name
  54167. * @param scene The scene the material will be use in.
  54168. */
  54169. constructor(name: string, scene: Scene);
  54170. /**
  54171. * Return the currrent class name of the material.
  54172. */
  54173. getClassName(): string;
  54174. /**
  54175. * Makes a duplicate of the current material.
  54176. * @param name - name to use for the new material.
  54177. */
  54178. clone(name: string): PBRSpecularGlossinessMaterial;
  54179. /**
  54180. * Serialize the material to a parsable JSON object.
  54181. */
  54182. serialize(): any;
  54183. /**
  54184. * Parses a JSON object correponding to the serialize function.
  54185. */
  54186. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  54187. }
  54188. }
  54189. declare module "babylonjs/Materials/PBR/index" {
  54190. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  54191. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54192. export * from "babylonjs/Materials/PBR/pbrMaterial";
  54193. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  54194. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  54195. }
  54196. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  54197. import { Nullable } from "babylonjs/types";
  54198. import { Scene } from "babylonjs/scene";
  54199. import { Matrix } from "babylonjs/Maths/math.vector";
  54200. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54201. /**
  54202. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  54203. * It can help converting any input color in a desired output one. This can then be used to create effects
  54204. * from sepia, black and white to sixties or futuristic rendering...
  54205. *
  54206. * The only supported format is currently 3dl.
  54207. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  54208. */
  54209. export class ColorGradingTexture extends BaseTexture {
  54210. /**
  54211. * The current texture matrix. (will always be identity in color grading texture)
  54212. */
  54213. private _textureMatrix;
  54214. /**
  54215. * The texture URL.
  54216. */
  54217. url: string;
  54218. /**
  54219. * Empty line regex stored for GC.
  54220. */
  54221. private static _noneEmptyLineRegex;
  54222. private _engine;
  54223. /**
  54224. * Instantiates a ColorGradingTexture from the following parameters.
  54225. *
  54226. * @param url The location of the color gradind data (currently only supporting 3dl)
  54227. * @param scene The scene the texture will be used in
  54228. */
  54229. constructor(url: string, scene: Scene);
  54230. /**
  54231. * Returns the texture matrix used in most of the material.
  54232. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  54233. */
  54234. getTextureMatrix(): Matrix;
  54235. /**
  54236. * Occurs when the file being loaded is a .3dl LUT file.
  54237. */
  54238. private load3dlTexture;
  54239. /**
  54240. * Starts the loading process of the texture.
  54241. */
  54242. private loadTexture;
  54243. /**
  54244. * Clones the color gradind texture.
  54245. */
  54246. clone(): ColorGradingTexture;
  54247. /**
  54248. * Called during delayed load for textures.
  54249. */
  54250. delayLoad(): void;
  54251. /**
  54252. * Parses a color grading texture serialized by Babylon.
  54253. * @param parsedTexture The texture information being parsedTexture
  54254. * @param scene The scene to load the texture in
  54255. * @param rootUrl The root url of the data assets to load
  54256. * @return A color gradind texture
  54257. */
  54258. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  54259. /**
  54260. * Serializes the LUT texture to json format.
  54261. */
  54262. serialize(): any;
  54263. }
  54264. }
  54265. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  54266. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54267. import { Scene } from "babylonjs/scene";
  54268. import { Nullable } from "babylonjs/types";
  54269. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54270. /**
  54271. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  54272. */
  54273. export class EquiRectangularCubeTexture extends BaseTexture {
  54274. /** The six faces of the cube. */
  54275. private static _FacesMapping;
  54276. private _noMipmap;
  54277. private _onLoad;
  54278. private _onError;
  54279. /** The size of the cubemap. */
  54280. private _size;
  54281. /** The buffer of the image. */
  54282. private _buffer;
  54283. /** The width of the input image. */
  54284. private _width;
  54285. /** The height of the input image. */
  54286. private _height;
  54287. /** The URL to the image. */
  54288. url: string;
  54289. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  54290. coordinatesMode: number;
  54291. /**
  54292. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  54293. * @param url The location of the image
  54294. * @param scene The scene the texture will be used in
  54295. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  54296. * @param noMipmap Forces to not generate the mipmap if true
  54297. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  54298. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  54299. * @param onLoad — defines a callback called when texture is loaded
  54300. * @param onError — defines a callback called if there is an error
  54301. */
  54302. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  54303. /**
  54304. * Load the image data, by putting the image on a canvas and extracting its buffer.
  54305. */
  54306. private loadImage;
  54307. /**
  54308. * Convert the image buffer into a cubemap and create a CubeTexture.
  54309. */
  54310. private loadTexture;
  54311. /**
  54312. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  54313. * @param buffer The ArrayBuffer that should be converted.
  54314. * @returns The buffer as Float32Array.
  54315. */
  54316. private getFloat32ArrayFromArrayBuffer;
  54317. /**
  54318. * Get the current class name of the texture useful for serialization or dynamic coding.
  54319. * @returns "EquiRectangularCubeTexture"
  54320. */
  54321. getClassName(): string;
  54322. /**
  54323. * Create a clone of the current EquiRectangularCubeTexture and return it.
  54324. * @returns A clone of the current EquiRectangularCubeTexture.
  54325. */
  54326. clone(): EquiRectangularCubeTexture;
  54327. }
  54328. }
  54329. declare module "babylonjs/Misc/tga" {
  54330. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54331. /**
  54332. * Based on jsTGALoader - Javascript loader for TGA file
  54333. * By Vincent Thibault
  54334. * @see http://blog.robrowser.com/javascript-tga-loader.html
  54335. */
  54336. export class TGATools {
  54337. private static _TYPE_INDEXED;
  54338. private static _TYPE_RGB;
  54339. private static _TYPE_GREY;
  54340. private static _TYPE_RLE_INDEXED;
  54341. private static _TYPE_RLE_RGB;
  54342. private static _TYPE_RLE_GREY;
  54343. private static _ORIGIN_MASK;
  54344. private static _ORIGIN_SHIFT;
  54345. private static _ORIGIN_BL;
  54346. private static _ORIGIN_BR;
  54347. private static _ORIGIN_UL;
  54348. private static _ORIGIN_UR;
  54349. /**
  54350. * Gets the header of a TGA file
  54351. * @param data defines the TGA data
  54352. * @returns the header
  54353. */
  54354. static GetTGAHeader(data: Uint8Array): any;
  54355. /**
  54356. * Uploads TGA content to a Babylon Texture
  54357. * @hidden
  54358. */
  54359. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  54360. /** @hidden */
  54361. 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;
  54362. /** @hidden */
  54363. 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;
  54364. /** @hidden */
  54365. 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;
  54366. /** @hidden */
  54367. 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;
  54368. /** @hidden */
  54369. 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;
  54370. /** @hidden */
  54371. 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;
  54372. }
  54373. }
  54374. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  54375. import { Nullable } from "babylonjs/types";
  54376. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54377. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54378. /**
  54379. * Implementation of the TGA Texture Loader.
  54380. * @hidden
  54381. */
  54382. export class _TGATextureLoader implements IInternalTextureLoader {
  54383. /**
  54384. * Defines wether the loader supports cascade loading the different faces.
  54385. */
  54386. readonly supportCascades: boolean;
  54387. /**
  54388. * This returns if the loader support the current file information.
  54389. * @param extension defines the file extension of the file being loaded
  54390. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54391. * @param fallback defines the fallback internal texture if any
  54392. * @param isBase64 defines whether the texture is encoded as a base64
  54393. * @param isBuffer defines whether the texture data are stored as a buffer
  54394. * @returns true if the loader can load the specified file
  54395. */
  54396. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54397. /**
  54398. * Transform the url before loading if required.
  54399. * @param rootUrl the url of the texture
  54400. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54401. * @returns the transformed texture
  54402. */
  54403. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54404. /**
  54405. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54406. * @param rootUrl the url of the texture
  54407. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54408. * @returns the fallback texture
  54409. */
  54410. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54411. /**
  54412. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  54413. * @param data contains the texture data
  54414. * @param texture defines the BabylonJS internal texture
  54415. * @param createPolynomials will be true if polynomials have been requested
  54416. * @param onLoad defines the callback to trigger once the texture is ready
  54417. * @param onError defines the callback to trigger in case of error
  54418. */
  54419. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54420. /**
  54421. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54422. * @param data contains the texture data
  54423. * @param texture defines the BabylonJS internal texture
  54424. * @param callback defines the method to call once ready to upload
  54425. */
  54426. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54427. }
  54428. }
  54429. declare module "babylonjs/Misc/basis" {
  54430. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54431. /**
  54432. * Info about the .basis files
  54433. */
  54434. class BasisFileInfo {
  54435. /**
  54436. * If the file has alpha
  54437. */
  54438. hasAlpha: boolean;
  54439. /**
  54440. * Info about each image of the basis file
  54441. */
  54442. images: Array<{
  54443. levels: Array<{
  54444. width: number;
  54445. height: number;
  54446. transcodedPixels: ArrayBufferView;
  54447. }>;
  54448. }>;
  54449. }
  54450. /**
  54451. * Result of transcoding a basis file
  54452. */
  54453. class TranscodeResult {
  54454. /**
  54455. * Info about the .basis file
  54456. */
  54457. fileInfo: BasisFileInfo;
  54458. /**
  54459. * Format to use when loading the file
  54460. */
  54461. format: number;
  54462. }
  54463. /**
  54464. * Configuration options for the Basis transcoder
  54465. */
  54466. export class BasisTranscodeConfiguration {
  54467. /**
  54468. * Supported compression formats used to determine the supported output format of the transcoder
  54469. */
  54470. supportedCompressionFormats?: {
  54471. /**
  54472. * etc1 compression format
  54473. */
  54474. etc1?: boolean;
  54475. /**
  54476. * s3tc compression format
  54477. */
  54478. s3tc?: boolean;
  54479. /**
  54480. * pvrtc compression format
  54481. */
  54482. pvrtc?: boolean;
  54483. /**
  54484. * etc2 compression format
  54485. */
  54486. etc2?: boolean;
  54487. };
  54488. /**
  54489. * If mipmap levels should be loaded for transcoded images (Default: true)
  54490. */
  54491. loadMipmapLevels?: boolean;
  54492. /**
  54493. * Index of a single image to load (Default: all images)
  54494. */
  54495. loadSingleImage?: number;
  54496. }
  54497. /**
  54498. * Used to load .Basis files
  54499. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  54500. */
  54501. export class BasisTools {
  54502. private static _IgnoreSupportedFormats;
  54503. /**
  54504. * URL to use when loading the basis transcoder
  54505. */
  54506. static JSModuleURL: string;
  54507. /**
  54508. * URL to use when loading the wasm module for the transcoder
  54509. */
  54510. static WasmModuleURL: string;
  54511. /**
  54512. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  54513. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  54514. * @returns internal format corresponding to the Basis format
  54515. */
  54516. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  54517. private static _WorkerPromise;
  54518. private static _Worker;
  54519. private static _actionId;
  54520. private static _CreateWorkerAsync;
  54521. /**
  54522. * Transcodes a loaded image file to compressed pixel data
  54523. * @param imageData image data to transcode
  54524. * @param config configuration options for the transcoding
  54525. * @returns a promise resulting in the transcoded image
  54526. */
  54527. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  54528. /**
  54529. * Loads a texture from the transcode result
  54530. * @param texture texture load to
  54531. * @param transcodeResult the result of transcoding the basis file to load from
  54532. */
  54533. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  54534. }
  54535. }
  54536. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  54537. import { Nullable } from "babylonjs/types";
  54538. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54539. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54540. /**
  54541. * Loader for .basis file format
  54542. */
  54543. export class _BasisTextureLoader implements IInternalTextureLoader {
  54544. /**
  54545. * Defines whether the loader supports cascade loading the different faces.
  54546. */
  54547. readonly supportCascades: boolean;
  54548. /**
  54549. * This returns if the loader support the current file information.
  54550. * @param extension defines the file extension of the file being loaded
  54551. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54552. * @param fallback defines the fallback internal texture if any
  54553. * @param isBase64 defines whether the texture is encoded as a base64
  54554. * @param isBuffer defines whether the texture data are stored as a buffer
  54555. * @returns true if the loader can load the specified file
  54556. */
  54557. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54558. /**
  54559. * Transform the url before loading if required.
  54560. * @param rootUrl the url of the texture
  54561. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54562. * @returns the transformed texture
  54563. */
  54564. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54565. /**
  54566. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54567. * @param rootUrl the url of the texture
  54568. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54569. * @returns the fallback texture
  54570. */
  54571. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54572. /**
  54573. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  54574. * @param data contains the texture data
  54575. * @param texture defines the BabylonJS internal texture
  54576. * @param createPolynomials will be true if polynomials have been requested
  54577. * @param onLoad defines the callback to trigger once the texture is ready
  54578. * @param onError defines the callback to trigger in case of error
  54579. */
  54580. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54581. /**
  54582. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54583. * @param data contains the texture data
  54584. * @param texture defines the BabylonJS internal texture
  54585. * @param callback defines the method to call once ready to upload
  54586. */
  54587. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54588. }
  54589. }
  54590. declare module "babylonjs/Materials/Textures/Loaders/index" {
  54591. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  54592. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  54593. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  54594. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  54595. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  54596. }
  54597. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  54598. import { Scene } from "babylonjs/scene";
  54599. import { Texture } from "babylonjs/Materials/Textures/texture";
  54600. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54601. /**
  54602. * 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.
  54603. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54604. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54605. */
  54606. export class CustomProceduralTexture extends ProceduralTexture {
  54607. private _animate;
  54608. private _time;
  54609. private _config;
  54610. private _texturePath;
  54611. /**
  54612. * Instantiates a new Custom Procedural Texture.
  54613. * 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.
  54614. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54615. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54616. * @param name Define the name of the texture
  54617. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  54618. * @param size Define the size of the texture to create
  54619. * @param scene Define the scene the texture belongs to
  54620. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  54621. * @param generateMipMaps Define if the texture should creates mip maps or not
  54622. */
  54623. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54624. private _loadJson;
  54625. /**
  54626. * Is the texture ready to be used ? (rendered at least once)
  54627. * @returns true if ready, otherwise, false.
  54628. */
  54629. isReady(): boolean;
  54630. /**
  54631. * Render the texture to its associated render target.
  54632. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  54633. */
  54634. render(useCameraPostProcess?: boolean): void;
  54635. /**
  54636. * Update the list of dependant textures samplers in the shader.
  54637. */
  54638. updateTextures(): void;
  54639. /**
  54640. * Update the uniform values of the procedural texture in the shader.
  54641. */
  54642. updateShaderUniforms(): void;
  54643. /**
  54644. * Define if the texture animates or not.
  54645. */
  54646. animate: boolean;
  54647. }
  54648. }
  54649. declare module "babylonjs/Shaders/noise.fragment" {
  54650. /** @hidden */
  54651. export var noisePixelShader: {
  54652. name: string;
  54653. shader: string;
  54654. };
  54655. }
  54656. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  54657. import { Nullable } from "babylonjs/types";
  54658. import { Scene } from "babylonjs/scene";
  54659. import { Texture } from "babylonjs/Materials/Textures/texture";
  54660. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54661. import "babylonjs/Shaders/noise.fragment";
  54662. /**
  54663. * Class used to generate noise procedural textures
  54664. */
  54665. export class NoiseProceduralTexture extends ProceduralTexture {
  54666. private _time;
  54667. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  54668. brightness: number;
  54669. /** Defines the number of octaves to process */
  54670. octaves: number;
  54671. /** Defines the level of persistence (0.8 by default) */
  54672. persistence: number;
  54673. /** Gets or sets animation speed factor (default is 1) */
  54674. animationSpeedFactor: number;
  54675. /**
  54676. * Creates a new NoiseProceduralTexture
  54677. * @param name defines the name fo the texture
  54678. * @param size defines the size of the texture (default is 256)
  54679. * @param scene defines the hosting scene
  54680. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  54681. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  54682. */
  54683. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54684. private _updateShaderUniforms;
  54685. protected _getDefines(): string;
  54686. /** Generate the current state of the procedural texture */
  54687. render(useCameraPostProcess?: boolean): void;
  54688. /**
  54689. * Serializes this noise procedural texture
  54690. * @returns a serialized noise procedural texture object
  54691. */
  54692. serialize(): any;
  54693. /**
  54694. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  54695. * @param parsedTexture defines parsed texture data
  54696. * @param scene defines the current scene
  54697. * @param rootUrl defines the root URL containing noise procedural texture information
  54698. * @returns a parsed NoiseProceduralTexture
  54699. */
  54700. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  54701. }
  54702. }
  54703. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  54704. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  54705. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  54706. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54707. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  54708. }
  54709. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  54710. import { Nullable } from "babylonjs/types";
  54711. import { Scene } from "babylonjs/scene";
  54712. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54713. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54714. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  54715. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54716. /**
  54717. * Raw cube texture where the raw buffers are passed in
  54718. */
  54719. export class RawCubeTexture extends CubeTexture {
  54720. /**
  54721. * Creates a cube texture where the raw buffers are passed in.
  54722. * @param scene defines the scene the texture is attached to
  54723. * @param data defines the array of data to use to create each face
  54724. * @param size defines the size of the textures
  54725. * @param format defines the format of the data
  54726. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  54727. * @param generateMipMaps defines if the engine should generate the mip levels
  54728. * @param invertY defines if data must be stored with Y axis inverted
  54729. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  54730. * @param compression defines the compression used (null by default)
  54731. */
  54732. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  54733. /**
  54734. * Updates the raw cube texture.
  54735. * @param data defines the data to store
  54736. * @param format defines the data format
  54737. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  54738. * @param invertY defines if data must be stored with Y axis inverted
  54739. * @param compression defines the compression used (null by default)
  54740. * @param level defines which level of the texture to update
  54741. */
  54742. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  54743. /**
  54744. * Updates a raw cube texture with RGBD encoded data.
  54745. * @param data defines the array of data [mipmap][face] to use to create each face
  54746. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  54747. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  54748. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  54749. * @returns a promsie that resolves when the operation is complete
  54750. */
  54751. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  54752. /**
  54753. * Clones the raw cube texture.
  54754. * @return a new cube texture
  54755. */
  54756. clone(): CubeTexture;
  54757. /** @hidden */
  54758. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  54759. }
  54760. }
  54761. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  54762. import { Scene } from "babylonjs/scene";
  54763. import { Texture } from "babylonjs/Materials/Textures/texture";
  54764. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54765. /**
  54766. * Class used to store 3D textures containing user data
  54767. */
  54768. export class RawTexture3D extends Texture {
  54769. /** Gets or sets the texture format to use */
  54770. format: number;
  54771. private _engine;
  54772. /**
  54773. * Create a new RawTexture3D
  54774. * @param data defines the data of the texture
  54775. * @param width defines the width of the texture
  54776. * @param height defines the height of the texture
  54777. * @param depth defines the depth of the texture
  54778. * @param format defines the texture format to use
  54779. * @param scene defines the hosting scene
  54780. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  54781. * @param invertY defines if texture must be stored with Y axis inverted
  54782. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  54783. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  54784. */
  54785. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  54786. /** Gets or sets the texture format to use */
  54787. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  54788. /**
  54789. * Update the texture with new data
  54790. * @param data defines the data to store in the texture
  54791. */
  54792. update(data: ArrayBufferView): void;
  54793. }
  54794. }
  54795. declare module "babylonjs/Materials/Textures/refractionTexture" {
  54796. import { Scene } from "babylonjs/scene";
  54797. import { Plane } from "babylonjs/Maths/math.plane";
  54798. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54799. /**
  54800. * Creates a refraction texture used by refraction channel of the standard material.
  54801. * It is like a mirror but to see through a material.
  54802. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54803. */
  54804. export class RefractionTexture extends RenderTargetTexture {
  54805. /**
  54806. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  54807. * 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.
  54808. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54809. */
  54810. refractionPlane: Plane;
  54811. /**
  54812. * Define how deep under the surface we should see.
  54813. */
  54814. depth: number;
  54815. /**
  54816. * Creates a refraction texture used by refraction channel of the standard material.
  54817. * It is like a mirror but to see through a material.
  54818. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54819. * @param name Define the texture name
  54820. * @param size Define the size of the underlying texture
  54821. * @param scene Define the scene the refraction belongs to
  54822. * @param generateMipMaps Define if we need to generate mips level for the refraction
  54823. */
  54824. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  54825. /**
  54826. * Clone the refraction texture.
  54827. * @returns the cloned texture
  54828. */
  54829. clone(): RefractionTexture;
  54830. /**
  54831. * Serialize the texture to a JSON representation you could use in Parse later on
  54832. * @returns the serialized JSON representation
  54833. */
  54834. serialize(): any;
  54835. }
  54836. }
  54837. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  54838. import { Nullable } from "babylonjs/types";
  54839. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54840. import { Matrix } from "babylonjs/Maths/math.vector";
  54841. import { Engine } from "babylonjs/Engines/engine";
  54842. import { Scene } from "babylonjs/scene";
  54843. /**
  54844. * Defines the options related to the creation of an HtmlElementTexture
  54845. */
  54846. export interface IHtmlElementTextureOptions {
  54847. /**
  54848. * Defines wether mip maps should be created or not.
  54849. */
  54850. generateMipMaps?: boolean;
  54851. /**
  54852. * Defines the sampling mode of the texture.
  54853. */
  54854. samplingMode?: number;
  54855. /**
  54856. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  54857. */
  54858. engine: Nullable<Engine>;
  54859. /**
  54860. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  54861. */
  54862. scene: Nullable<Scene>;
  54863. }
  54864. /**
  54865. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  54866. * To be as efficient as possible depending on your constraints nothing aside the first upload
  54867. * is automatically managed.
  54868. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  54869. * in your application.
  54870. *
  54871. * As the update is not automatic, you need to call them manually.
  54872. */
  54873. export class HtmlElementTexture extends BaseTexture {
  54874. /**
  54875. * The texture URL.
  54876. */
  54877. element: HTMLVideoElement | HTMLCanvasElement;
  54878. private static readonly DefaultOptions;
  54879. private _textureMatrix;
  54880. private _engine;
  54881. private _isVideo;
  54882. private _generateMipMaps;
  54883. private _samplingMode;
  54884. /**
  54885. * Instantiates a HtmlElementTexture from the following parameters.
  54886. *
  54887. * @param name Defines the name of the texture
  54888. * @param element Defines the video or canvas the texture is filled with
  54889. * @param options Defines the other none mandatory texture creation options
  54890. */
  54891. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  54892. private _createInternalTexture;
  54893. /**
  54894. * Returns the texture matrix used in most of the material.
  54895. */
  54896. getTextureMatrix(): Matrix;
  54897. /**
  54898. * Updates the content of the texture.
  54899. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  54900. */
  54901. update(invertY?: Nullable<boolean>): void;
  54902. }
  54903. }
  54904. declare module "babylonjs/Materials/Textures/index" {
  54905. export * from "babylonjs/Materials/Textures/baseTexture";
  54906. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  54907. export * from "babylonjs/Materials/Textures/cubeTexture";
  54908. export * from "babylonjs/Materials/Textures/dynamicTexture";
  54909. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  54910. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  54911. export * from "babylonjs/Materials/Textures/internalTexture";
  54912. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  54913. export * from "babylonjs/Materials/Textures/Loaders/index";
  54914. export * from "babylonjs/Materials/Textures/mirrorTexture";
  54915. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  54916. export * from "babylonjs/Materials/Textures/Procedurals/index";
  54917. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  54918. export * from "babylonjs/Materials/Textures/rawTexture";
  54919. export * from "babylonjs/Materials/Textures/rawTexture3D";
  54920. export * from "babylonjs/Materials/Textures/refractionTexture";
  54921. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  54922. export * from "babylonjs/Materials/Textures/texture";
  54923. export * from "babylonjs/Materials/Textures/videoTexture";
  54924. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  54925. }
  54926. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  54927. /**
  54928. * Enum used to define the target of a block
  54929. */
  54930. export enum NodeMaterialBlockTargets {
  54931. /** Vertex shader */
  54932. Vertex = 1,
  54933. /** Fragment shader */
  54934. Fragment = 2,
  54935. /** Neutral */
  54936. Neutral = 4,
  54937. /** Vertex and Fragment */
  54938. VertexAndFragment = 3
  54939. }
  54940. }
  54941. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  54942. /**
  54943. * Defines the kind of connection point for node based material
  54944. */
  54945. export enum NodeMaterialBlockConnectionPointTypes {
  54946. /** Float */
  54947. Float = 1,
  54948. /** Int */
  54949. Int = 2,
  54950. /** Vector2 */
  54951. Vector2 = 4,
  54952. /** Vector3 */
  54953. Vector3 = 8,
  54954. /** Vector4 */
  54955. Vector4 = 16,
  54956. /** Color3 */
  54957. Color3 = 32,
  54958. /** Color4 */
  54959. Color4 = 64,
  54960. /** Matrix */
  54961. Matrix = 128,
  54962. /** Detect type based on connection */
  54963. AutoDetect = 1024,
  54964. /** Output type that will be defined by input type */
  54965. BasedOnInput = 2048
  54966. }
  54967. }
  54968. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  54969. /**
  54970. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  54971. */
  54972. export enum NodeMaterialBlockConnectionPointMode {
  54973. /** Value is an uniform */
  54974. Uniform = 0,
  54975. /** Value is a mesh attribute */
  54976. Attribute = 1,
  54977. /** Value is a varying between vertex and fragment shaders */
  54978. Varying = 2,
  54979. /** Mode is undefined */
  54980. Undefined = 3
  54981. }
  54982. }
  54983. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  54984. /**
  54985. * Enum used to define system values e.g. values automatically provided by the system
  54986. */
  54987. export enum NodeMaterialSystemValues {
  54988. /** World */
  54989. World = 1,
  54990. /** View */
  54991. View = 2,
  54992. /** Projection */
  54993. Projection = 3,
  54994. /** ViewProjection */
  54995. ViewProjection = 4,
  54996. /** WorldView */
  54997. WorldView = 5,
  54998. /** WorldViewProjection */
  54999. WorldViewProjection = 6,
  55000. /** CameraPosition */
  55001. CameraPosition = 7,
  55002. /** Fog Color */
  55003. FogColor = 8,
  55004. /** Delta time */
  55005. DeltaTime = 9
  55006. }
  55007. }
  55008. declare module "babylonjs/Materials/Node/Enums/index" {
  55009. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55010. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55011. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  55012. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  55013. }
  55014. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  55015. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55016. /**
  55017. * Root class for all node material optimizers
  55018. */
  55019. export class NodeMaterialOptimizer {
  55020. /**
  55021. * Function used to optimize a NodeMaterial graph
  55022. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  55023. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  55024. */
  55025. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  55026. }
  55027. }
  55028. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  55029. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55030. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55031. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55032. import { Scene } from "babylonjs/scene";
  55033. /**
  55034. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  55035. */
  55036. export class TransformBlock extends NodeMaterialBlock {
  55037. /**
  55038. * Defines the value to use to complement W value to transform it to a Vector4
  55039. */
  55040. complementW: number;
  55041. /**
  55042. * Defines the value to use to complement z value to transform it to a Vector4
  55043. */
  55044. complementZ: number;
  55045. /**
  55046. * Creates a new TransformBlock
  55047. * @param name defines the block name
  55048. */
  55049. constructor(name: string);
  55050. /**
  55051. * Gets the current class name
  55052. * @returns the class name
  55053. */
  55054. getClassName(): string;
  55055. /**
  55056. * Gets the vector input
  55057. */
  55058. readonly vector: NodeMaterialConnectionPoint;
  55059. /**
  55060. * Gets the output component
  55061. */
  55062. readonly output: NodeMaterialConnectionPoint;
  55063. /**
  55064. * Gets the matrix transform input
  55065. */
  55066. readonly transform: NodeMaterialConnectionPoint;
  55067. protected _buildBlock(state: NodeMaterialBuildState): this;
  55068. serialize(): any;
  55069. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55070. protected _dumpPropertiesCode(): string;
  55071. }
  55072. }
  55073. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  55074. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55075. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55076. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55077. /**
  55078. * Block used to output the vertex position
  55079. */
  55080. export class VertexOutputBlock extends NodeMaterialBlock {
  55081. /**
  55082. * Creates a new VertexOutputBlock
  55083. * @param name defines the block name
  55084. */
  55085. constructor(name: string);
  55086. /**
  55087. * Gets the current class name
  55088. * @returns the class name
  55089. */
  55090. getClassName(): string;
  55091. /**
  55092. * Gets the vector input component
  55093. */
  55094. readonly vector: NodeMaterialConnectionPoint;
  55095. protected _buildBlock(state: NodeMaterialBuildState): this;
  55096. }
  55097. }
  55098. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  55099. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55100. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55101. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55102. /**
  55103. * Block used to output the final color
  55104. */
  55105. export class FragmentOutputBlock extends NodeMaterialBlock {
  55106. /**
  55107. * Create a new FragmentOutputBlock
  55108. * @param name defines the block name
  55109. */
  55110. constructor(name: string);
  55111. /**
  55112. * Gets the current class name
  55113. * @returns the class name
  55114. */
  55115. getClassName(): string;
  55116. /**
  55117. * Gets the rgba input component
  55118. */
  55119. readonly rgba: NodeMaterialConnectionPoint;
  55120. /**
  55121. * Gets the rgb input component
  55122. */
  55123. readonly rgb: NodeMaterialConnectionPoint;
  55124. /**
  55125. * Gets the a input component
  55126. */
  55127. readonly a: NodeMaterialConnectionPoint;
  55128. protected _buildBlock(state: NodeMaterialBuildState): this;
  55129. }
  55130. }
  55131. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  55132. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55133. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55134. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55135. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55136. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55137. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55138. import { Effect } from "babylonjs/Materials/effect";
  55139. import { Mesh } from "babylonjs/Meshes/mesh";
  55140. import { Nullable } from "babylonjs/types";
  55141. import { Scene } from "babylonjs/scene";
  55142. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  55143. /**
  55144. * Block used to read a reflection texture from a sampler
  55145. */
  55146. export class ReflectionTextureBlock extends NodeMaterialBlock {
  55147. private _define3DName;
  55148. private _defineCubicName;
  55149. private _defineExplicitName;
  55150. private _defineProjectionName;
  55151. private _defineLocalCubicName;
  55152. private _defineSphericalName;
  55153. private _definePlanarName;
  55154. private _defineEquirectangularName;
  55155. private _defineMirroredEquirectangularFixedName;
  55156. private _defineEquirectangularFixedName;
  55157. private _defineSkyboxName;
  55158. private _cubeSamplerName;
  55159. private _2DSamplerName;
  55160. private _positionUVWName;
  55161. private _directionWName;
  55162. private _reflectionCoordsName;
  55163. private _reflection2DCoordsName;
  55164. private _reflectionColorName;
  55165. private _reflectionMatrixName;
  55166. /**
  55167. * Gets or sets the texture associated with the node
  55168. */
  55169. texture: Nullable<BaseTexture>;
  55170. /**
  55171. * Create a new TextureBlock
  55172. * @param name defines the block name
  55173. */
  55174. constructor(name: string);
  55175. /**
  55176. * Gets the current class name
  55177. * @returns the class name
  55178. */
  55179. getClassName(): string;
  55180. /**
  55181. * Gets the world position input component
  55182. */
  55183. readonly position: NodeMaterialConnectionPoint;
  55184. /**
  55185. * Gets the world position input component
  55186. */
  55187. readonly worldPosition: NodeMaterialConnectionPoint;
  55188. /**
  55189. * Gets the world normal input component
  55190. */
  55191. readonly worldNormal: NodeMaterialConnectionPoint;
  55192. /**
  55193. * Gets the world input component
  55194. */
  55195. readonly world: NodeMaterialConnectionPoint;
  55196. /**
  55197. * Gets the camera (or eye) position component
  55198. */
  55199. readonly cameraPosition: NodeMaterialConnectionPoint;
  55200. /**
  55201. * Gets the view input component
  55202. */
  55203. readonly view: NodeMaterialConnectionPoint;
  55204. /**
  55205. * Gets the rgb output component
  55206. */
  55207. readonly rgb: NodeMaterialConnectionPoint;
  55208. /**
  55209. * Gets the r output component
  55210. */
  55211. readonly r: NodeMaterialConnectionPoint;
  55212. /**
  55213. * Gets the g output component
  55214. */
  55215. readonly g: NodeMaterialConnectionPoint;
  55216. /**
  55217. * Gets the b output component
  55218. */
  55219. readonly b: NodeMaterialConnectionPoint;
  55220. autoConfigure(material: NodeMaterial): void;
  55221. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55222. isReady(): boolean;
  55223. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55224. private _injectVertexCode;
  55225. private _writeOutput;
  55226. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55227. serialize(): any;
  55228. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55229. }
  55230. }
  55231. declare module "babylonjs/Materials/Node/nodeMaterial" {
  55232. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55233. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  55234. import { Scene } from "babylonjs/scene";
  55235. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55236. import { Matrix } from "babylonjs/Maths/math.vector";
  55237. import { Mesh } from "babylonjs/Meshes/mesh";
  55238. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55239. import { Observable } from "babylonjs/Misc/observable";
  55240. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55241. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  55242. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  55243. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  55244. import { Nullable } from "babylonjs/types";
  55245. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55246. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  55247. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  55248. /**
  55249. * Interface used to configure the node material editor
  55250. */
  55251. export interface INodeMaterialEditorOptions {
  55252. /** Define the URl to load node editor script */
  55253. editorURL?: string;
  55254. }
  55255. /** @hidden */
  55256. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  55257. /** BONES */
  55258. NUM_BONE_INFLUENCERS: number;
  55259. BonesPerMesh: number;
  55260. BONETEXTURE: boolean;
  55261. /** MORPH TARGETS */
  55262. MORPHTARGETS: boolean;
  55263. MORPHTARGETS_NORMAL: boolean;
  55264. MORPHTARGETS_TANGENT: boolean;
  55265. MORPHTARGETS_UV: boolean;
  55266. NUM_MORPH_INFLUENCERS: number;
  55267. /** IMAGE PROCESSING */
  55268. IMAGEPROCESSING: boolean;
  55269. VIGNETTE: boolean;
  55270. VIGNETTEBLENDMODEMULTIPLY: boolean;
  55271. VIGNETTEBLENDMODEOPAQUE: boolean;
  55272. TONEMAPPING: boolean;
  55273. TONEMAPPING_ACES: boolean;
  55274. CONTRAST: boolean;
  55275. EXPOSURE: boolean;
  55276. COLORCURVES: boolean;
  55277. COLORGRADING: boolean;
  55278. COLORGRADING3D: boolean;
  55279. SAMPLER3DGREENDEPTH: boolean;
  55280. SAMPLER3DBGRMAP: boolean;
  55281. IMAGEPROCESSINGPOSTPROCESS: boolean;
  55282. /** MISC. */
  55283. BUMPDIRECTUV: number;
  55284. constructor();
  55285. setValue(name: string, value: boolean): void;
  55286. }
  55287. /**
  55288. * Class used to configure NodeMaterial
  55289. */
  55290. export interface INodeMaterialOptions {
  55291. /**
  55292. * Defines if blocks should emit comments
  55293. */
  55294. emitComments: boolean;
  55295. }
  55296. /**
  55297. * Class used to create a node based material built by assembling shader blocks
  55298. */
  55299. export class NodeMaterial extends PushMaterial {
  55300. private static _BuildIdGenerator;
  55301. private _options;
  55302. private _vertexCompilationState;
  55303. private _fragmentCompilationState;
  55304. private _sharedData;
  55305. private _buildId;
  55306. private _buildWasSuccessful;
  55307. private _cachedWorldViewMatrix;
  55308. private _cachedWorldViewProjectionMatrix;
  55309. private _optimizers;
  55310. private _animationFrame;
  55311. /** Define the URl to load node editor script */
  55312. static EditorURL: string;
  55313. private BJSNODEMATERIALEDITOR;
  55314. /** Get the inspector from bundle or global */
  55315. private _getGlobalNodeMaterialEditor;
  55316. /**
  55317. * 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)
  55318. */
  55319. ignoreAlpha: boolean;
  55320. /**
  55321. * Defines the maximum number of lights that can be used in the material
  55322. */
  55323. maxSimultaneousLights: number;
  55324. /**
  55325. * Observable raised when the material is built
  55326. */
  55327. onBuildObservable: Observable<NodeMaterial>;
  55328. /**
  55329. * Gets or sets the root nodes of the material vertex shader
  55330. */
  55331. _vertexOutputNodes: NodeMaterialBlock[];
  55332. /**
  55333. * Gets or sets the root nodes of the material fragment (pixel) shader
  55334. */
  55335. _fragmentOutputNodes: NodeMaterialBlock[];
  55336. /** Gets or sets options to control the node material overall behavior */
  55337. options: INodeMaterialOptions;
  55338. /**
  55339. * Default configuration related to image processing available in the standard Material.
  55340. */
  55341. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  55342. /**
  55343. * Gets the image processing configuration used either in this material.
  55344. */
  55345. /**
  55346. * Sets the Default image processing configuration used either in the this material.
  55347. *
  55348. * If sets to null, the scene one is in use.
  55349. */
  55350. imageProcessingConfiguration: ImageProcessingConfiguration;
  55351. /**
  55352. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  55353. */
  55354. attachedBlocks: NodeMaterialBlock[];
  55355. /**
  55356. * Create a new node based material
  55357. * @param name defines the material name
  55358. * @param scene defines the hosting scene
  55359. * @param options defines creation option
  55360. */
  55361. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  55362. /**
  55363. * Gets the current class name of the material e.g. "NodeMaterial"
  55364. * @returns the class name
  55365. */
  55366. getClassName(): string;
  55367. /**
  55368. * Keep track of the image processing observer to allow dispose and replace.
  55369. */
  55370. private _imageProcessingObserver;
  55371. /**
  55372. * Attaches a new image processing configuration to the Standard Material.
  55373. * @param configuration
  55374. */
  55375. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  55376. /**
  55377. * Get a block by its name
  55378. * @param name defines the name of the block to retrieve
  55379. * @returns the required block or null if not found
  55380. */
  55381. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  55382. /**
  55383. * Get a block by its name
  55384. * @param predicate defines the predicate used to find the good candidate
  55385. * @returns the required block or null if not found
  55386. */
  55387. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  55388. /**
  55389. * Get an input block by its name
  55390. * @param predicate defines the predicate used to find the good candidate
  55391. * @returns the required input block or null if not found
  55392. */
  55393. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  55394. /**
  55395. * Gets the list of input blocks attached to this material
  55396. * @returns an array of InputBlocks
  55397. */
  55398. getInputBlocks(): InputBlock[];
  55399. /**
  55400. * Adds a new optimizer to the list of optimizers
  55401. * @param optimizer defines the optimizers to add
  55402. * @returns the current material
  55403. */
  55404. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  55405. /**
  55406. * Remove an optimizer from the list of optimizers
  55407. * @param optimizer defines the optimizers to remove
  55408. * @returns the current material
  55409. */
  55410. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  55411. /**
  55412. * Add a new block to the list of output nodes
  55413. * @param node defines the node to add
  55414. * @returns the current material
  55415. */
  55416. addOutputNode(node: NodeMaterialBlock): this;
  55417. /**
  55418. * Remove a block from the list of root nodes
  55419. * @param node defines the node to remove
  55420. * @returns the current material
  55421. */
  55422. removeOutputNode(node: NodeMaterialBlock): this;
  55423. private _addVertexOutputNode;
  55424. private _removeVertexOutputNode;
  55425. private _addFragmentOutputNode;
  55426. private _removeFragmentOutputNode;
  55427. /**
  55428. * Specifies if the material will require alpha blending
  55429. * @returns a boolean specifying if alpha blending is needed
  55430. */
  55431. needAlphaBlending(): boolean;
  55432. /**
  55433. * Specifies if this material should be rendered in alpha test mode
  55434. * @returns a boolean specifying if an alpha test is needed.
  55435. */
  55436. needAlphaTesting(): boolean;
  55437. private _initializeBlock;
  55438. private _resetDualBlocks;
  55439. /**
  55440. * Build the material and generates the inner effect
  55441. * @param verbose defines if the build should log activity
  55442. */
  55443. build(verbose?: boolean): void;
  55444. /**
  55445. * Runs an otpimization phase to try to improve the shader code
  55446. */
  55447. optimize(): void;
  55448. private _prepareDefinesForAttributes;
  55449. /**
  55450. * Get if the submesh is ready to be used and all its information available.
  55451. * Child classes can use it to update shaders
  55452. * @param mesh defines the mesh to check
  55453. * @param subMesh defines which submesh to check
  55454. * @param useInstances specifies that instances should be used
  55455. * @returns a boolean indicating that the submesh is ready or not
  55456. */
  55457. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  55458. /**
  55459. * Get a string representing the shaders built by the current node graph
  55460. */
  55461. readonly compiledShaders: string;
  55462. /**
  55463. * Binds the world matrix to the material
  55464. * @param world defines the world transformation matrix
  55465. */
  55466. bindOnlyWorldMatrix(world: Matrix): void;
  55467. /**
  55468. * Binds the submesh to this material by preparing the effect and shader to draw
  55469. * @param world defines the world transformation matrix
  55470. * @param mesh defines the mesh containing the submesh
  55471. * @param subMesh defines the submesh to bind the material to
  55472. */
  55473. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  55474. /**
  55475. * Gets the active textures from the material
  55476. * @returns an array of textures
  55477. */
  55478. getActiveTextures(): BaseTexture[];
  55479. /**
  55480. * Gets the list of texture blocks
  55481. * @returns an array of texture blocks
  55482. */
  55483. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  55484. /**
  55485. * Specifies if the material uses a texture
  55486. * @param texture defines the texture to check against the material
  55487. * @returns a boolean specifying if the material uses the texture
  55488. */
  55489. hasTexture(texture: BaseTexture): boolean;
  55490. /**
  55491. * Disposes the material
  55492. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  55493. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  55494. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  55495. */
  55496. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  55497. /** Creates the node editor window. */
  55498. private _createNodeEditor;
  55499. /**
  55500. * Launch the node material editor
  55501. * @param config Define the configuration of the editor
  55502. * @return a promise fulfilled when the node editor is visible
  55503. */
  55504. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  55505. /**
  55506. * Clear the current material
  55507. */
  55508. clear(): void;
  55509. /**
  55510. * Clear the current material and set it to a default state
  55511. */
  55512. setToDefault(): void;
  55513. /**
  55514. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  55515. * @param url defines the url to load from
  55516. * @returns a promise that will fullfil when the material is fully loaded
  55517. */
  55518. loadAsync(url: string): Promise<unknown>;
  55519. private _gatherBlocks;
  55520. /**
  55521. * Generate a string containing the code declaration required to create an equivalent of this material
  55522. * @returns a string
  55523. */
  55524. generateCode(): string;
  55525. /**
  55526. * Serializes this material in a JSON representation
  55527. * @returns the serialized material object
  55528. */
  55529. serialize(): any;
  55530. private _restoreConnections;
  55531. /**
  55532. * Clear the current graph and load a new one from a serialization object
  55533. * @param source defines the JSON representation of the material
  55534. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55535. */
  55536. loadFromSerialization(source: any, rootUrl?: string): void;
  55537. /**
  55538. * Creates a node material from parsed material data
  55539. * @param source defines the JSON representation of the material
  55540. * @param scene defines the hosting scene
  55541. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55542. * @returns a new node material
  55543. */
  55544. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  55545. /**
  55546. * Creates a new node material set to default basic configuration
  55547. * @param name defines the name of the material
  55548. * @param scene defines the hosting scene
  55549. * @returns a new NodeMaterial
  55550. */
  55551. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  55552. }
  55553. }
  55554. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  55555. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55556. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55557. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55558. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55559. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55560. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55561. import { Effect } from "babylonjs/Materials/effect";
  55562. import { Mesh } from "babylonjs/Meshes/mesh";
  55563. import { Nullable } from "babylonjs/types";
  55564. import { Texture } from "babylonjs/Materials/Textures/texture";
  55565. import { Scene } from "babylonjs/scene";
  55566. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55567. /**
  55568. * Block used to read a texture from a sampler
  55569. */
  55570. export class TextureBlock extends NodeMaterialBlock {
  55571. private _defineName;
  55572. private _linearDefineName;
  55573. private _samplerName;
  55574. private _transformedUVName;
  55575. private _textureTransformName;
  55576. private _textureInfoName;
  55577. private _mainUVName;
  55578. private _mainUVDefineName;
  55579. /**
  55580. * Gets or sets the texture associated with the node
  55581. */
  55582. texture: Nullable<Texture>;
  55583. /**
  55584. * Create a new TextureBlock
  55585. * @param name defines the block name
  55586. */
  55587. constructor(name: string);
  55588. /**
  55589. * Gets the current class name
  55590. * @returns the class name
  55591. */
  55592. getClassName(): string;
  55593. /**
  55594. * Gets the uv input component
  55595. */
  55596. readonly uv: NodeMaterialConnectionPoint;
  55597. /**
  55598. * Gets the rgba output component
  55599. */
  55600. readonly rgba: NodeMaterialConnectionPoint;
  55601. /**
  55602. * Gets the rgb output component
  55603. */
  55604. readonly rgb: NodeMaterialConnectionPoint;
  55605. /**
  55606. * Gets the r output component
  55607. */
  55608. readonly r: NodeMaterialConnectionPoint;
  55609. /**
  55610. * Gets the g output component
  55611. */
  55612. readonly g: NodeMaterialConnectionPoint;
  55613. /**
  55614. * Gets the b output component
  55615. */
  55616. readonly b: NodeMaterialConnectionPoint;
  55617. /**
  55618. * Gets the a output component
  55619. */
  55620. readonly a: NodeMaterialConnectionPoint;
  55621. readonly target: NodeMaterialBlockTargets;
  55622. autoConfigure(material: NodeMaterial): void;
  55623. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55624. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55625. isReady(): boolean;
  55626. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55627. private readonly _isMixed;
  55628. private _injectVertexCode;
  55629. private _writeOutput;
  55630. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55631. protected _dumpPropertiesCode(): string;
  55632. serialize(): any;
  55633. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55634. }
  55635. }
  55636. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  55637. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55638. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55639. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55640. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  55641. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  55642. import { Scene } from "babylonjs/scene";
  55643. /**
  55644. * Class used to store shared data between 2 NodeMaterialBuildState
  55645. */
  55646. export class NodeMaterialBuildStateSharedData {
  55647. /**
  55648. * Gets the list of emitted varyings
  55649. */
  55650. temps: string[];
  55651. /**
  55652. * Gets the list of emitted varyings
  55653. */
  55654. varyings: string[];
  55655. /**
  55656. * Gets the varying declaration string
  55657. */
  55658. varyingDeclaration: string;
  55659. /**
  55660. * Input blocks
  55661. */
  55662. inputBlocks: InputBlock[];
  55663. /**
  55664. * Input blocks
  55665. */
  55666. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  55667. /**
  55668. * Bindable blocks (Blocks that need to set data to the effect)
  55669. */
  55670. bindableBlocks: NodeMaterialBlock[];
  55671. /**
  55672. * List of blocks that can provide a compilation fallback
  55673. */
  55674. blocksWithFallbacks: NodeMaterialBlock[];
  55675. /**
  55676. * List of blocks that can provide a define update
  55677. */
  55678. blocksWithDefines: NodeMaterialBlock[];
  55679. /**
  55680. * List of blocks that can provide a repeatable content
  55681. */
  55682. repeatableContentBlocks: NodeMaterialBlock[];
  55683. /**
  55684. * List of blocks that can provide a dynamic list of uniforms
  55685. */
  55686. dynamicUniformBlocks: NodeMaterialBlock[];
  55687. /**
  55688. * List of blocks that can block the isReady function for the material
  55689. */
  55690. blockingBlocks: NodeMaterialBlock[];
  55691. /**
  55692. * Gets the list of animated inputs
  55693. */
  55694. animatedInputs: InputBlock[];
  55695. /**
  55696. * Build Id used to avoid multiple recompilations
  55697. */
  55698. buildId: number;
  55699. /** List of emitted variables */
  55700. variableNames: {
  55701. [key: string]: number;
  55702. };
  55703. /** List of emitted defines */
  55704. defineNames: {
  55705. [key: string]: number;
  55706. };
  55707. /** Should emit comments? */
  55708. emitComments: boolean;
  55709. /** Emit build activity */
  55710. verbose: boolean;
  55711. /** Gets or sets the hosting scene */
  55712. scene: Scene;
  55713. /**
  55714. * Gets the compilation hints emitted at compilation time
  55715. */
  55716. hints: {
  55717. needWorldViewMatrix: boolean;
  55718. needWorldViewProjectionMatrix: boolean;
  55719. needAlphaBlending: boolean;
  55720. needAlphaTesting: boolean;
  55721. };
  55722. /**
  55723. * List of compilation checks
  55724. */
  55725. checks: {
  55726. emitVertex: boolean;
  55727. emitFragment: boolean;
  55728. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  55729. };
  55730. /** Creates a new shared data */
  55731. constructor();
  55732. /**
  55733. * Emits console errors and exceptions if there is a failing check
  55734. */
  55735. emitErrors(): void;
  55736. }
  55737. }
  55738. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  55739. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55740. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55741. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  55742. /**
  55743. * Class used to store node based material build state
  55744. */
  55745. export class NodeMaterialBuildState {
  55746. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  55747. supportUniformBuffers: boolean;
  55748. /**
  55749. * Gets the list of emitted attributes
  55750. */
  55751. attributes: string[];
  55752. /**
  55753. * Gets the list of emitted uniforms
  55754. */
  55755. uniforms: string[];
  55756. /**
  55757. * Gets the list of emitted constants
  55758. */
  55759. constants: string[];
  55760. /**
  55761. * Gets the list of emitted uniform buffers
  55762. */
  55763. uniformBuffers: string[];
  55764. /**
  55765. * Gets the list of emitted samplers
  55766. */
  55767. samplers: string[];
  55768. /**
  55769. * Gets the list of emitted functions
  55770. */
  55771. functions: {
  55772. [key: string]: string;
  55773. };
  55774. /**
  55775. * Gets the list of emitted extensions
  55776. */
  55777. extensions: {
  55778. [key: string]: string;
  55779. };
  55780. /**
  55781. * Gets the target of the compilation state
  55782. */
  55783. target: NodeMaterialBlockTargets;
  55784. /**
  55785. * Gets the list of emitted counters
  55786. */
  55787. counters: {
  55788. [key: string]: number;
  55789. };
  55790. /**
  55791. * Shared data between multiple NodeMaterialBuildState instances
  55792. */
  55793. sharedData: NodeMaterialBuildStateSharedData;
  55794. /** @hidden */
  55795. _vertexState: NodeMaterialBuildState;
  55796. /** @hidden */
  55797. _attributeDeclaration: string;
  55798. /** @hidden */
  55799. _uniformDeclaration: string;
  55800. /** @hidden */
  55801. _constantDeclaration: string;
  55802. /** @hidden */
  55803. _samplerDeclaration: string;
  55804. /** @hidden */
  55805. _varyingTransfer: string;
  55806. private _repeatableContentAnchorIndex;
  55807. /** @hidden */
  55808. _builtCompilationString: string;
  55809. /**
  55810. * Gets the emitted compilation strings
  55811. */
  55812. compilationString: string;
  55813. /**
  55814. * Finalize the compilation strings
  55815. * @param state defines the current compilation state
  55816. */
  55817. finalize(state: NodeMaterialBuildState): void;
  55818. /** @hidden */
  55819. readonly _repeatableContentAnchor: string;
  55820. /** @hidden */
  55821. _getFreeVariableName(prefix: string): string;
  55822. /** @hidden */
  55823. _getFreeDefineName(prefix: string): string;
  55824. /** @hidden */
  55825. _excludeVariableName(name: string): void;
  55826. /** @hidden */
  55827. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  55828. /** @hidden */
  55829. _emitExtension(name: string, extension: string): void;
  55830. /** @hidden */
  55831. _emitFunction(name: string, code: string, comments: string): void;
  55832. /** @hidden */
  55833. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  55834. replaceStrings?: {
  55835. search: RegExp;
  55836. replace: string;
  55837. }[];
  55838. repeatKey?: string;
  55839. }): string;
  55840. /** @hidden */
  55841. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  55842. repeatKey?: string;
  55843. removeAttributes?: boolean;
  55844. removeUniforms?: boolean;
  55845. removeVaryings?: boolean;
  55846. removeIfDef?: boolean;
  55847. replaceStrings?: {
  55848. search: RegExp;
  55849. replace: string;
  55850. }[];
  55851. }, storeKey?: string): void;
  55852. /** @hidden */
  55853. _registerTempVariable(name: string): boolean;
  55854. /** @hidden */
  55855. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  55856. /** @hidden */
  55857. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  55858. /** @hidden */
  55859. _emitFloat(value: number): string;
  55860. }
  55861. }
  55862. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  55863. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55864. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55865. import { Nullable } from "babylonjs/types";
  55866. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55867. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55868. import { Effect } from "babylonjs/Materials/effect";
  55869. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55870. import { Mesh } from "babylonjs/Meshes/mesh";
  55871. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55872. import { Scene } from "babylonjs/scene";
  55873. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  55874. /**
  55875. * Defines a block that can be used inside a node based material
  55876. */
  55877. export class NodeMaterialBlock {
  55878. private _buildId;
  55879. private _buildTarget;
  55880. private _target;
  55881. private _isFinalMerger;
  55882. private _isInput;
  55883. /** @hidden */
  55884. _codeVariableName: string;
  55885. /** @hidden */
  55886. _inputs: NodeMaterialConnectionPoint[];
  55887. /** @hidden */
  55888. _outputs: NodeMaterialConnectionPoint[];
  55889. /** @hidden */
  55890. _preparationId: number;
  55891. /**
  55892. * Gets or sets the name of the block
  55893. */
  55894. name: string;
  55895. /**
  55896. * Gets or sets the unique id of the node
  55897. */
  55898. uniqueId: number;
  55899. /**
  55900. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  55901. */
  55902. readonly isFinalMerger: boolean;
  55903. /**
  55904. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  55905. */
  55906. readonly isInput: boolean;
  55907. /**
  55908. * Gets or sets the build Id
  55909. */
  55910. buildId: number;
  55911. /**
  55912. * Gets or sets the target of the block
  55913. */
  55914. target: NodeMaterialBlockTargets;
  55915. /**
  55916. * Gets the list of input points
  55917. */
  55918. readonly inputs: NodeMaterialConnectionPoint[];
  55919. /** Gets the list of output points */
  55920. readonly outputs: NodeMaterialConnectionPoint[];
  55921. /**
  55922. * Find an input by its name
  55923. * @param name defines the name of the input to look for
  55924. * @returns the input or null if not found
  55925. */
  55926. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  55927. /**
  55928. * Find an output by its name
  55929. * @param name defines the name of the outputto look for
  55930. * @returns the output or null if not found
  55931. */
  55932. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  55933. /**
  55934. * Creates a new NodeMaterialBlock
  55935. * @param name defines the block name
  55936. * @param target defines the target of that block (Vertex by default)
  55937. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  55938. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  55939. */
  55940. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  55941. /**
  55942. * Initialize the block and prepare the context for build
  55943. * @param state defines the state that will be used for the build
  55944. */
  55945. initialize(state: NodeMaterialBuildState): void;
  55946. /**
  55947. * Bind data to effect. Will only be called for blocks with isBindable === true
  55948. * @param effect defines the effect to bind data to
  55949. * @param nodeMaterial defines the hosting NodeMaterial
  55950. * @param mesh defines the mesh that will be rendered
  55951. */
  55952. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55953. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  55954. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  55955. protected _writeFloat(value: number): string;
  55956. /**
  55957. * Gets the current class name e.g. "NodeMaterialBlock"
  55958. * @returns the class name
  55959. */
  55960. getClassName(): string;
  55961. /**
  55962. * Register a new input. Must be called inside a block constructor
  55963. * @param name defines the connection point name
  55964. * @param type defines the connection point type
  55965. * @param isOptional defines a boolean indicating that this input can be omitted
  55966. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  55967. * @returns the current block
  55968. */
  55969. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  55970. /**
  55971. * Register a new output. Must be called inside a block constructor
  55972. * @param name defines the connection point name
  55973. * @param type defines the connection point type
  55974. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  55975. * @returns the current block
  55976. */
  55977. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  55978. /**
  55979. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  55980. * @param forOutput defines an optional connection point to check compatibility with
  55981. * @returns the first available input or null
  55982. */
  55983. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  55984. /**
  55985. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  55986. * @param forBlock defines an optional block to check compatibility with
  55987. * @returns the first available input or null
  55988. */
  55989. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  55990. /**
  55991. * Gets the sibling of the given output
  55992. * @param current defines the current output
  55993. * @returns the next output in the list or null
  55994. */
  55995. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  55996. /**
  55997. * Connect current block with another block
  55998. * @param other defines the block to connect with
  55999. * @param options define the various options to help pick the right connections
  56000. * @returns the current block
  56001. */
  56002. connectTo(other: NodeMaterialBlock, options?: {
  56003. input?: string;
  56004. output?: string;
  56005. outputSwizzle?: string;
  56006. }): this | undefined;
  56007. protected _buildBlock(state: NodeMaterialBuildState): void;
  56008. /**
  56009. * Add uniforms, samplers and uniform buffers at compilation time
  56010. * @param state defines the state to update
  56011. * @param nodeMaterial defines the node material requesting the update
  56012. * @param defines defines the material defines to update
  56013. */
  56014. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56015. /**
  56016. * Add potential fallbacks if shader compilation fails
  56017. * @param mesh defines the mesh to be rendered
  56018. * @param fallbacks defines the current prioritized list of fallbacks
  56019. */
  56020. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  56021. /**
  56022. * Initialize defines for shader compilation
  56023. * @param mesh defines the mesh to be rendered
  56024. * @param nodeMaterial defines the node material requesting the update
  56025. * @param defines defines the material defines to update
  56026. * @param useInstances specifies that instances should be used
  56027. */
  56028. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56029. /**
  56030. * Update defines for shader compilation
  56031. * @param mesh defines the mesh to be rendered
  56032. * @param nodeMaterial defines the node material requesting the update
  56033. * @param defines defines the material defines to update
  56034. * @param useInstances specifies that instances should be used
  56035. */
  56036. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56037. /**
  56038. * Lets the block try to connect some inputs automatically
  56039. * @param material defines the hosting NodeMaterial
  56040. */
  56041. autoConfigure(material: NodeMaterial): void;
  56042. /**
  56043. * Function called when a block is declared as repeatable content generator
  56044. * @param vertexShaderState defines the current compilation state for the vertex shader
  56045. * @param fragmentShaderState defines the current compilation state for the fragment shader
  56046. * @param mesh defines the mesh to be rendered
  56047. * @param defines defines the material defines to update
  56048. */
  56049. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  56050. /**
  56051. * Checks if the block is ready
  56052. * @param mesh defines the mesh to be rendered
  56053. * @param nodeMaterial defines the node material requesting the update
  56054. * @param defines defines the material defines to update
  56055. * @param useInstances specifies that instances should be used
  56056. * @returns true if the block is ready
  56057. */
  56058. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  56059. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  56060. private _processBuild;
  56061. /**
  56062. * Compile the current node and generate the shader code
  56063. * @param state defines the current compilation state (uniforms, samplers, current string)
  56064. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  56065. * @returns true if already built
  56066. */
  56067. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  56068. protected _inputRename(name: string): string;
  56069. protected _outputRename(name: string): string;
  56070. protected _dumpPropertiesCode(): string;
  56071. /** @hidden */
  56072. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  56073. /**
  56074. * Clone the current block to a new identical block
  56075. * @param scene defines the hosting scene
  56076. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  56077. * @returns a copy of the current block
  56078. */
  56079. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  56080. /**
  56081. * Serializes this block in a JSON representation
  56082. * @returns the serialized block object
  56083. */
  56084. serialize(): any;
  56085. /** @hidden */
  56086. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56087. }
  56088. }
  56089. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  56090. /**
  56091. * Enum defining the type of animations supported by InputBlock
  56092. */
  56093. export enum AnimatedInputBlockTypes {
  56094. /** No animation */
  56095. None = 0,
  56096. /** Time based animation. Will only work for floats */
  56097. Time = 1
  56098. }
  56099. }
  56100. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  56101. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56102. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56103. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  56104. import { Nullable } from "babylonjs/types";
  56105. import { Effect } from "babylonjs/Materials/effect";
  56106. import { Matrix } from "babylonjs/Maths/math.vector";
  56107. import { Scene } from "babylonjs/scene";
  56108. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56109. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56110. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56111. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  56112. /**
  56113. * Block used to expose an input value
  56114. */
  56115. export class InputBlock extends NodeMaterialBlock {
  56116. private _mode;
  56117. private _associatedVariableName;
  56118. private _storedValue;
  56119. private _valueCallback;
  56120. private _type;
  56121. private _animationType;
  56122. /** Gets or set a value used to limit the range of float values */
  56123. min: number;
  56124. /** Gets or set a value used to limit the range of float values */
  56125. max: number;
  56126. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  56127. matrixMode: number;
  56128. /** @hidden */
  56129. _systemValue: Nullable<NodeMaterialSystemValues>;
  56130. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  56131. visibleInInspector: boolean;
  56132. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  56133. isConstant: boolean;
  56134. /**
  56135. * Gets or sets the connection point type (default is float)
  56136. */
  56137. readonly type: NodeMaterialBlockConnectionPointTypes;
  56138. /**
  56139. * Creates a new InputBlock
  56140. * @param name defines the block name
  56141. * @param target defines the target of that block (Vertex by default)
  56142. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  56143. */
  56144. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  56145. /**
  56146. * Gets the output component
  56147. */
  56148. readonly output: NodeMaterialConnectionPoint;
  56149. /**
  56150. * Set the source of this connection point to a vertex attribute
  56151. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  56152. * @returns the current connection point
  56153. */
  56154. setAsAttribute(attributeName?: string): InputBlock;
  56155. /**
  56156. * Set the source of this connection point to a system value
  56157. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  56158. * @returns the current connection point
  56159. */
  56160. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  56161. /**
  56162. * Gets or sets the value of that point.
  56163. * Please note that this value will be ignored if valueCallback is defined
  56164. */
  56165. value: any;
  56166. /**
  56167. * Gets or sets a callback used to get the value of that point.
  56168. * Please note that setting this value will force the connection point to ignore the value property
  56169. */
  56170. valueCallback: () => any;
  56171. /**
  56172. * Gets or sets the associated variable name in the shader
  56173. */
  56174. associatedVariableName: string;
  56175. /** Gets or sets the type of animation applied to the input */
  56176. animationType: AnimatedInputBlockTypes;
  56177. /**
  56178. * Gets a boolean indicating that this connection point not defined yet
  56179. */
  56180. readonly isUndefined: boolean;
  56181. /**
  56182. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  56183. * In this case the connection point name must be the name of the uniform to use.
  56184. * Can only be set on inputs
  56185. */
  56186. isUniform: boolean;
  56187. /**
  56188. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  56189. * In this case the connection point name must be the name of the attribute to use
  56190. * Can only be set on inputs
  56191. */
  56192. isAttribute: boolean;
  56193. /**
  56194. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  56195. * Can only be set on exit points
  56196. */
  56197. isVarying: boolean;
  56198. /**
  56199. * Gets a boolean indicating that the current connection point is a system value
  56200. */
  56201. readonly isSystemValue: boolean;
  56202. /**
  56203. * Gets or sets the current well known value or null if not defined as a system value
  56204. */
  56205. systemValue: Nullable<NodeMaterialSystemValues>;
  56206. /**
  56207. * Gets the current class name
  56208. * @returns the class name
  56209. */
  56210. getClassName(): string;
  56211. /**
  56212. * Animate the input if animationType !== None
  56213. * @param scene defines the rendering scene
  56214. */
  56215. animate(scene: Scene): void;
  56216. private _emitDefine;
  56217. initialize(state: NodeMaterialBuildState): void;
  56218. /**
  56219. * Set the input block to its default value (based on its type)
  56220. */
  56221. setDefaultValue(): void;
  56222. private _emitConstant;
  56223. private _emit;
  56224. /** @hidden */
  56225. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  56226. /** @hidden */
  56227. _transmit(effect: Effect, scene: Scene): void;
  56228. protected _buildBlock(state: NodeMaterialBuildState): void;
  56229. protected _dumpPropertiesCode(): string;
  56230. serialize(): any;
  56231. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56232. }
  56233. }
  56234. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  56235. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56236. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56237. import { Nullable } from "babylonjs/types";
  56238. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56239. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56240. /**
  56241. * Defines a connection point for a block
  56242. */
  56243. export class NodeMaterialConnectionPoint {
  56244. /** @hidden */
  56245. _ownerBlock: NodeMaterialBlock;
  56246. /** @hidden */
  56247. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  56248. private _endpoints;
  56249. private _associatedVariableName;
  56250. /** @hidden */
  56251. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  56252. /** @hidden */
  56253. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  56254. private _type;
  56255. /** @hidden */
  56256. _enforceAssociatedVariableName: boolean;
  56257. /**
  56258. * Gets or sets the additional types supported by this connection point
  56259. */
  56260. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  56261. /**
  56262. * Gets or sets the additional types excluded by this connection point
  56263. */
  56264. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  56265. /**
  56266. * Gets or sets the associated variable name in the shader
  56267. */
  56268. associatedVariableName: string;
  56269. /**
  56270. * Gets or sets the connection point type (default is float)
  56271. */
  56272. type: NodeMaterialBlockConnectionPointTypes;
  56273. /**
  56274. * Gets or sets the connection point name
  56275. */
  56276. name: string;
  56277. /**
  56278. * Gets or sets a boolean indicating that this connection point can be omitted
  56279. */
  56280. isOptional: boolean;
  56281. /**
  56282. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  56283. */
  56284. define: string;
  56285. /** Gets or sets the target of that connection point */
  56286. target: NodeMaterialBlockTargets;
  56287. /**
  56288. * Gets a boolean indicating that the current point is connected
  56289. */
  56290. readonly isConnected: boolean;
  56291. /**
  56292. * Gets a boolean indicating that the current point is connected to an input block
  56293. */
  56294. readonly isConnectedToInputBlock: boolean;
  56295. /**
  56296. * Gets a the connected input block (if any)
  56297. */
  56298. readonly connectInputBlock: Nullable<InputBlock>;
  56299. /** Get the other side of the connection (if any) */
  56300. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  56301. /** Get the block that owns this connection point */
  56302. readonly ownerBlock: NodeMaterialBlock;
  56303. /** Get the block connected on the other side of this connection (if any) */
  56304. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  56305. /** Get the block connected on the endpoints of this connection (if any) */
  56306. readonly connectedBlocks: Array<NodeMaterialBlock>;
  56307. /** Gets the list of connected endpoints */
  56308. readonly endpoints: NodeMaterialConnectionPoint[];
  56309. /** Gets a boolean indicating if that output point is connected to at least one input */
  56310. readonly hasEndpoints: boolean;
  56311. /**
  56312. * Creates a new connection point
  56313. * @param name defines the connection point name
  56314. * @param ownerBlock defines the block hosting this connection point
  56315. */
  56316. constructor(name: string, ownerBlock: NodeMaterialBlock);
  56317. /**
  56318. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  56319. * @returns the class name
  56320. */
  56321. getClassName(): string;
  56322. /**
  56323. * Gets an boolean indicating if the current point can be connected to another point
  56324. * @param connectionPoint defines the other connection point
  56325. * @returns true if the connection is possible
  56326. */
  56327. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  56328. /**
  56329. * Connect this point to another connection point
  56330. * @param connectionPoint defines the other connection point
  56331. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  56332. * @returns the current connection point
  56333. */
  56334. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  56335. /**
  56336. * Disconnect this point from one of his endpoint
  56337. * @param endpoint defines the other connection point
  56338. * @returns the current connection point
  56339. */
  56340. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  56341. /**
  56342. * Serializes this point in a JSON representation
  56343. * @returns the serialized point object
  56344. */
  56345. serialize(): any;
  56346. }
  56347. }
  56348. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  56349. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56350. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56351. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56352. import { Mesh } from "babylonjs/Meshes/mesh";
  56353. import { Effect } from "babylonjs/Materials/effect";
  56354. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56355. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56356. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56357. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56358. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56359. /**
  56360. * Block used to add support for vertex skinning (bones)
  56361. */
  56362. export class BonesBlock extends NodeMaterialBlock {
  56363. /**
  56364. * Creates a new BonesBlock
  56365. * @param name defines the block name
  56366. */
  56367. constructor(name: string);
  56368. /**
  56369. * Initialize the block and prepare the context for build
  56370. * @param state defines the state that will be used for the build
  56371. */
  56372. initialize(state: NodeMaterialBuildState): void;
  56373. /**
  56374. * Gets the current class name
  56375. * @returns the class name
  56376. */
  56377. getClassName(): string;
  56378. /**
  56379. * Gets the matrix indices input component
  56380. */
  56381. readonly matricesIndices: NodeMaterialConnectionPoint;
  56382. /**
  56383. * Gets the matrix weights input component
  56384. */
  56385. readonly matricesWeights: NodeMaterialConnectionPoint;
  56386. /**
  56387. * Gets the extra matrix indices input component
  56388. */
  56389. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  56390. /**
  56391. * Gets the extra matrix weights input component
  56392. */
  56393. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  56394. /**
  56395. * Gets the world input component
  56396. */
  56397. readonly world: NodeMaterialConnectionPoint;
  56398. /**
  56399. * Gets the output component
  56400. */
  56401. readonly output: NodeMaterialConnectionPoint;
  56402. autoConfigure(material: NodeMaterial): void;
  56403. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  56404. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56405. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56406. protected _buildBlock(state: NodeMaterialBuildState): this;
  56407. }
  56408. }
  56409. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  56410. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56411. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56412. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56413. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56414. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56415. /**
  56416. * Block used to add support for instances
  56417. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  56418. */
  56419. export class InstancesBlock extends NodeMaterialBlock {
  56420. /**
  56421. * Creates a new InstancesBlock
  56422. * @param name defines the block name
  56423. */
  56424. constructor(name: string);
  56425. /**
  56426. * Gets the current class name
  56427. * @returns the class name
  56428. */
  56429. getClassName(): string;
  56430. /**
  56431. * Gets the first world row input component
  56432. */
  56433. readonly world0: NodeMaterialConnectionPoint;
  56434. /**
  56435. * Gets the second world row input component
  56436. */
  56437. readonly world1: NodeMaterialConnectionPoint;
  56438. /**
  56439. * Gets the third world row input component
  56440. */
  56441. readonly world2: NodeMaterialConnectionPoint;
  56442. /**
  56443. * Gets the forth world row input component
  56444. */
  56445. readonly world3: NodeMaterialConnectionPoint;
  56446. /**
  56447. * Gets the world input component
  56448. */
  56449. readonly world: NodeMaterialConnectionPoint;
  56450. /**
  56451. * Gets the output component
  56452. */
  56453. readonly output: NodeMaterialConnectionPoint;
  56454. autoConfigure(material: NodeMaterial): void;
  56455. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56456. protected _buildBlock(state: NodeMaterialBuildState): this;
  56457. }
  56458. }
  56459. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  56460. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56461. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56462. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56463. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56464. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56465. import { Effect } from "babylonjs/Materials/effect";
  56466. import { Mesh } from "babylonjs/Meshes/mesh";
  56467. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  56468. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  56469. /**
  56470. * Block used to add morph targets support to vertex shader
  56471. */
  56472. export class MorphTargetsBlock extends NodeMaterialBlock {
  56473. private _repeatableContentAnchor;
  56474. private _repeatebleContentGenerated;
  56475. /**
  56476. * Create a new MorphTargetsBlock
  56477. * @param name defines the block name
  56478. */
  56479. constructor(name: string);
  56480. /**
  56481. * Gets the current class name
  56482. * @returns the class name
  56483. */
  56484. getClassName(): string;
  56485. /**
  56486. * Gets the position input component
  56487. */
  56488. readonly position: NodeMaterialConnectionPoint;
  56489. /**
  56490. * Gets the normal input component
  56491. */
  56492. readonly normal: NodeMaterialConnectionPoint;
  56493. /**
  56494. * Gets the tangent input component
  56495. */
  56496. readonly tangent: NodeMaterialConnectionPoint;
  56497. /**
  56498. * Gets the tangent input component
  56499. */
  56500. readonly uv: NodeMaterialConnectionPoint;
  56501. /**
  56502. * Gets the position output component
  56503. */
  56504. readonly positionOutput: NodeMaterialConnectionPoint;
  56505. /**
  56506. * Gets the normal output component
  56507. */
  56508. readonly normalOutput: NodeMaterialConnectionPoint;
  56509. /**
  56510. * Gets the tangent output component
  56511. */
  56512. readonly tangentOutput: NodeMaterialConnectionPoint;
  56513. /**
  56514. * Gets the tangent output component
  56515. */
  56516. readonly uvOutput: NodeMaterialConnectionPoint;
  56517. initialize(state: NodeMaterialBuildState): void;
  56518. autoConfigure(material: NodeMaterial): void;
  56519. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56520. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56521. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  56522. protected _buildBlock(state: NodeMaterialBuildState): this;
  56523. }
  56524. }
  56525. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  56526. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56527. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56528. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56529. import { Nullable } from "babylonjs/types";
  56530. import { Scene } from "babylonjs/scene";
  56531. import { Effect } from "babylonjs/Materials/effect";
  56532. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56533. import { Mesh } from "babylonjs/Meshes/mesh";
  56534. import { Light } from "babylonjs/Lights/light";
  56535. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56536. /**
  56537. * Block used to get data information from a light
  56538. */
  56539. export class LightInformationBlock extends NodeMaterialBlock {
  56540. private _lightDataUniformName;
  56541. private _lightColorUniformName;
  56542. private _lightTypeDefineName;
  56543. /**
  56544. * Gets or sets the light associated with this block
  56545. */
  56546. light: Nullable<Light>;
  56547. /**
  56548. * Creates a new LightInformationBlock
  56549. * @param name defines the block name
  56550. */
  56551. constructor(name: string);
  56552. /**
  56553. * Gets the current class name
  56554. * @returns the class name
  56555. */
  56556. getClassName(): string;
  56557. /**
  56558. * Gets the world position input component
  56559. */
  56560. readonly worldPosition: NodeMaterialConnectionPoint;
  56561. /**
  56562. * Gets the direction output component
  56563. */
  56564. readonly direction: NodeMaterialConnectionPoint;
  56565. /**
  56566. * Gets the direction output component
  56567. */
  56568. readonly color: NodeMaterialConnectionPoint;
  56569. /**
  56570. * Gets the direction output component
  56571. */
  56572. readonly intensity: NodeMaterialConnectionPoint;
  56573. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56574. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56575. protected _buildBlock(state: NodeMaterialBuildState): this;
  56576. serialize(): any;
  56577. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56578. }
  56579. }
  56580. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  56581. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  56582. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  56583. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  56584. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  56585. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  56586. }
  56587. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  56588. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56589. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56590. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56591. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56592. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56593. import { Effect } from "babylonjs/Materials/effect";
  56594. import { Mesh } from "babylonjs/Meshes/mesh";
  56595. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56596. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  56597. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  56598. /**
  56599. * Block used to add image processing support to fragment shader
  56600. */
  56601. export class ImageProcessingBlock extends NodeMaterialBlock {
  56602. /**
  56603. * Create a new ImageProcessingBlock
  56604. * @param name defines the block name
  56605. */
  56606. constructor(name: string);
  56607. /**
  56608. * Gets the current class name
  56609. * @returns the class name
  56610. */
  56611. getClassName(): string;
  56612. /**
  56613. * Gets the color input component
  56614. */
  56615. readonly color: NodeMaterialConnectionPoint;
  56616. /**
  56617. * Gets the output component
  56618. */
  56619. readonly output: NodeMaterialConnectionPoint;
  56620. /**
  56621. * Initialize the block and prepare the context for build
  56622. * @param state defines the state that will be used for the build
  56623. */
  56624. initialize(state: NodeMaterialBuildState): void;
  56625. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  56626. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56627. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56628. protected _buildBlock(state: NodeMaterialBuildState): this;
  56629. }
  56630. }
  56631. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  56632. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56633. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56634. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56635. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56636. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56637. import { Effect } from "babylonjs/Materials/effect";
  56638. import { Mesh } from "babylonjs/Meshes/mesh";
  56639. import { Scene } from "babylonjs/scene";
  56640. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  56641. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  56642. /**
  56643. * Block used to pertub normals based on a normal map
  56644. */
  56645. export class PerturbNormalBlock extends NodeMaterialBlock {
  56646. private _tangentSpaceParameterName;
  56647. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  56648. invertX: boolean;
  56649. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  56650. invertY: boolean;
  56651. /**
  56652. * Create a new PerturbNormalBlock
  56653. * @param name defines the block name
  56654. */
  56655. constructor(name: string);
  56656. /**
  56657. * Gets the current class name
  56658. * @returns the class name
  56659. */
  56660. getClassName(): string;
  56661. /**
  56662. * Gets the world position input component
  56663. */
  56664. readonly worldPosition: NodeMaterialConnectionPoint;
  56665. /**
  56666. * Gets the world normal input component
  56667. */
  56668. readonly worldNormal: NodeMaterialConnectionPoint;
  56669. /**
  56670. * Gets the uv input component
  56671. */
  56672. readonly uv: NodeMaterialConnectionPoint;
  56673. /**
  56674. * Gets the normal map color input component
  56675. */
  56676. readonly normalMapColor: NodeMaterialConnectionPoint;
  56677. /**
  56678. * Gets the strength input component
  56679. */
  56680. readonly strength: NodeMaterialConnectionPoint;
  56681. /**
  56682. * Gets the output component
  56683. */
  56684. readonly output: NodeMaterialConnectionPoint;
  56685. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56686. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56687. autoConfigure(material: NodeMaterial): void;
  56688. protected _buildBlock(state: NodeMaterialBuildState): this;
  56689. protected _dumpPropertiesCode(): string;
  56690. serialize(): any;
  56691. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56692. }
  56693. }
  56694. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  56695. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56696. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56697. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56698. /**
  56699. * Block used to discard a pixel if a value is smaller than a cutoff
  56700. */
  56701. export class DiscardBlock extends NodeMaterialBlock {
  56702. /**
  56703. * Create a new DiscardBlock
  56704. * @param name defines the block name
  56705. */
  56706. constructor(name: string);
  56707. /**
  56708. * Gets the current class name
  56709. * @returns the class name
  56710. */
  56711. getClassName(): string;
  56712. /**
  56713. * Gets the color input component
  56714. */
  56715. readonly value: NodeMaterialConnectionPoint;
  56716. /**
  56717. * Gets the cutoff input component
  56718. */
  56719. readonly cutoff: NodeMaterialConnectionPoint;
  56720. protected _buildBlock(state: NodeMaterialBuildState): this;
  56721. }
  56722. }
  56723. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  56724. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  56725. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  56726. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  56727. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  56728. }
  56729. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  56730. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56731. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56732. import { Mesh } from "babylonjs/Meshes/mesh";
  56733. import { Effect } from "babylonjs/Materials/effect";
  56734. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56735. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56736. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56737. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  56738. /**
  56739. * Block used to add support for scene fog
  56740. */
  56741. export class FogBlock extends NodeMaterialBlock {
  56742. private _fogDistanceName;
  56743. private _fogParameters;
  56744. /**
  56745. * Create a new FogBlock
  56746. * @param name defines the block name
  56747. */
  56748. constructor(name: string);
  56749. /**
  56750. * Gets the current class name
  56751. * @returns the class name
  56752. */
  56753. getClassName(): string;
  56754. /**
  56755. * Gets the world position input component
  56756. */
  56757. readonly worldPosition: NodeMaterialConnectionPoint;
  56758. /**
  56759. * Gets the view input component
  56760. */
  56761. readonly view: NodeMaterialConnectionPoint;
  56762. /**
  56763. * Gets the color input component
  56764. */
  56765. readonly input: NodeMaterialConnectionPoint;
  56766. /**
  56767. * Gets the fog color input component
  56768. */
  56769. readonly fogColor: NodeMaterialConnectionPoint;
  56770. /**
  56771. * Gets the output component
  56772. */
  56773. readonly output: NodeMaterialConnectionPoint;
  56774. autoConfigure(material: NodeMaterial): void;
  56775. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56776. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56777. protected _buildBlock(state: NodeMaterialBuildState): this;
  56778. }
  56779. }
  56780. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  56781. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56782. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56783. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56784. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56785. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56786. import { Effect } from "babylonjs/Materials/effect";
  56787. import { Mesh } from "babylonjs/Meshes/mesh";
  56788. import { Light } from "babylonjs/Lights/light";
  56789. import { Nullable } from "babylonjs/types";
  56790. import { Scene } from "babylonjs/scene";
  56791. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  56792. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  56793. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  56794. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56795. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  56796. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  56797. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  56798. /**
  56799. * Block used to add light in the fragment shader
  56800. */
  56801. export class LightBlock extends NodeMaterialBlock {
  56802. private _lightId;
  56803. /**
  56804. * Gets or sets the light associated with this block
  56805. */
  56806. light: Nullable<Light>;
  56807. /**
  56808. * Create a new LightBlock
  56809. * @param name defines the block name
  56810. */
  56811. constructor(name: string);
  56812. /**
  56813. * Gets the current class name
  56814. * @returns the class name
  56815. */
  56816. getClassName(): string;
  56817. /**
  56818. * Gets the world position input component
  56819. */
  56820. readonly worldPosition: NodeMaterialConnectionPoint;
  56821. /**
  56822. * Gets the world normal input component
  56823. */
  56824. readonly worldNormal: NodeMaterialConnectionPoint;
  56825. /**
  56826. * Gets the camera (or eye) position component
  56827. */
  56828. readonly cameraPosition: NodeMaterialConnectionPoint;
  56829. /**
  56830. * Gets the glossiness component
  56831. */
  56832. readonly glossiness: NodeMaterialConnectionPoint;
  56833. /**
  56834. * Gets the glossinness power component
  56835. */
  56836. readonly glossPower: NodeMaterialConnectionPoint;
  56837. /**
  56838. * Gets the diffuse color component
  56839. */
  56840. readonly diffuseColor: NodeMaterialConnectionPoint;
  56841. /**
  56842. * Gets the specular color component
  56843. */
  56844. readonly specularColor: NodeMaterialConnectionPoint;
  56845. /**
  56846. * Gets the diffuse output component
  56847. */
  56848. readonly diffuseOutput: NodeMaterialConnectionPoint;
  56849. /**
  56850. * Gets the specular output component
  56851. */
  56852. readonly specularOutput: NodeMaterialConnectionPoint;
  56853. autoConfigure(material: NodeMaterial): void;
  56854. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56855. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56856. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56857. private _injectVertexCode;
  56858. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56859. serialize(): any;
  56860. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56861. }
  56862. }
  56863. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  56864. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  56865. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  56866. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  56867. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  56868. }
  56869. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  56870. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56871. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  56872. }
  56873. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  56874. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56875. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56876. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56877. /**
  56878. * Block used to multiply 2 values
  56879. */
  56880. export class MultiplyBlock extends NodeMaterialBlock {
  56881. /**
  56882. * Creates a new MultiplyBlock
  56883. * @param name defines the block name
  56884. */
  56885. constructor(name: string);
  56886. /**
  56887. * Gets the current class name
  56888. * @returns the class name
  56889. */
  56890. getClassName(): string;
  56891. /**
  56892. * Gets the left operand input component
  56893. */
  56894. readonly left: NodeMaterialConnectionPoint;
  56895. /**
  56896. * Gets the right operand input component
  56897. */
  56898. readonly right: NodeMaterialConnectionPoint;
  56899. /**
  56900. * Gets the output component
  56901. */
  56902. readonly output: NodeMaterialConnectionPoint;
  56903. protected _buildBlock(state: NodeMaterialBuildState): this;
  56904. }
  56905. }
  56906. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  56907. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56908. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56909. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56910. /**
  56911. * Block used to add 2 vectors
  56912. */
  56913. export class AddBlock extends NodeMaterialBlock {
  56914. /**
  56915. * Creates a new AddBlock
  56916. * @param name defines the block name
  56917. */
  56918. constructor(name: string);
  56919. /**
  56920. * Gets the current class name
  56921. * @returns the class name
  56922. */
  56923. getClassName(): string;
  56924. /**
  56925. * Gets the left operand input component
  56926. */
  56927. readonly left: NodeMaterialConnectionPoint;
  56928. /**
  56929. * Gets the right operand input component
  56930. */
  56931. readonly right: NodeMaterialConnectionPoint;
  56932. /**
  56933. * Gets the output component
  56934. */
  56935. readonly output: NodeMaterialConnectionPoint;
  56936. protected _buildBlock(state: NodeMaterialBuildState): this;
  56937. }
  56938. }
  56939. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  56940. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56941. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56942. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56943. /**
  56944. * Block used to scale a vector by a float
  56945. */
  56946. export class ScaleBlock extends NodeMaterialBlock {
  56947. /**
  56948. * Creates a new ScaleBlock
  56949. * @param name defines the block name
  56950. */
  56951. constructor(name: string);
  56952. /**
  56953. * Gets the current class name
  56954. * @returns the class name
  56955. */
  56956. getClassName(): string;
  56957. /**
  56958. * Gets the input component
  56959. */
  56960. readonly input: NodeMaterialConnectionPoint;
  56961. /**
  56962. * Gets the factor input component
  56963. */
  56964. readonly factor: NodeMaterialConnectionPoint;
  56965. /**
  56966. * Gets the output component
  56967. */
  56968. readonly output: NodeMaterialConnectionPoint;
  56969. protected _buildBlock(state: NodeMaterialBuildState): this;
  56970. }
  56971. }
  56972. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  56973. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56974. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56975. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56976. import { Scene } from "babylonjs/scene";
  56977. /**
  56978. * Block used to clamp a float
  56979. */
  56980. export class ClampBlock extends NodeMaterialBlock {
  56981. /** Gets or sets the minimum range */
  56982. minimum: number;
  56983. /** Gets or sets the maximum range */
  56984. maximum: number;
  56985. /**
  56986. * Creates a new ClampBlock
  56987. * @param name defines the block name
  56988. */
  56989. constructor(name: string);
  56990. /**
  56991. * Gets the current class name
  56992. * @returns the class name
  56993. */
  56994. getClassName(): string;
  56995. /**
  56996. * Gets the value input component
  56997. */
  56998. readonly value: NodeMaterialConnectionPoint;
  56999. /**
  57000. * Gets the output component
  57001. */
  57002. readonly output: NodeMaterialConnectionPoint;
  57003. protected _buildBlock(state: NodeMaterialBuildState): this;
  57004. protected _dumpPropertiesCode(): string;
  57005. serialize(): any;
  57006. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57007. }
  57008. }
  57009. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  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. /**
  57014. * Block used to apply a cross product between 2 vectors
  57015. */
  57016. export class CrossBlock extends NodeMaterialBlock {
  57017. /**
  57018. * Creates a new CrossBlock
  57019. * @param name defines the block name
  57020. */
  57021. constructor(name: string);
  57022. /**
  57023. * Gets the current class name
  57024. * @returns the class name
  57025. */
  57026. getClassName(): string;
  57027. /**
  57028. * Gets the left operand input component
  57029. */
  57030. readonly left: NodeMaterialConnectionPoint;
  57031. /**
  57032. * Gets the right operand input component
  57033. */
  57034. readonly right: NodeMaterialConnectionPoint;
  57035. /**
  57036. * Gets the output component
  57037. */
  57038. readonly output: NodeMaterialConnectionPoint;
  57039. protected _buildBlock(state: NodeMaterialBuildState): this;
  57040. }
  57041. }
  57042. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  57043. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57044. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57045. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57046. /**
  57047. * Block used to apply a dot product between 2 vectors
  57048. */
  57049. export class DotBlock extends NodeMaterialBlock {
  57050. /**
  57051. * Creates a new DotBlock
  57052. * @param name defines the block name
  57053. */
  57054. constructor(name: string);
  57055. /**
  57056. * Gets the current class name
  57057. * @returns the class name
  57058. */
  57059. getClassName(): string;
  57060. /**
  57061. * Gets the left operand input component
  57062. */
  57063. readonly left: NodeMaterialConnectionPoint;
  57064. /**
  57065. * Gets the right operand input component
  57066. */
  57067. readonly right: NodeMaterialConnectionPoint;
  57068. /**
  57069. * Gets the output component
  57070. */
  57071. readonly output: NodeMaterialConnectionPoint;
  57072. protected _buildBlock(state: NodeMaterialBuildState): this;
  57073. }
  57074. }
  57075. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  57076. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57077. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57078. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57079. import { Vector2 } from "babylonjs/Maths/math.vector";
  57080. import { Scene } from "babylonjs/scene";
  57081. /**
  57082. * Block used to remap a float from a range to a new one
  57083. */
  57084. export class RemapBlock extends NodeMaterialBlock {
  57085. /**
  57086. * Gets or sets the source range
  57087. */
  57088. sourceRange: Vector2;
  57089. /**
  57090. * Gets or sets the target range
  57091. */
  57092. targetRange: Vector2;
  57093. /**
  57094. * Creates a new RemapBlock
  57095. * @param name defines the block name
  57096. */
  57097. constructor(name: string);
  57098. /**
  57099. * Gets the current class name
  57100. * @returns the class name
  57101. */
  57102. getClassName(): string;
  57103. /**
  57104. * Gets the input component
  57105. */
  57106. readonly input: NodeMaterialConnectionPoint;
  57107. /**
  57108. * Gets the source min input component
  57109. */
  57110. readonly sourceMin: NodeMaterialConnectionPoint;
  57111. /**
  57112. * Gets the source max input component
  57113. */
  57114. readonly sourceMax: NodeMaterialConnectionPoint;
  57115. /**
  57116. * Gets the target min input component
  57117. */
  57118. readonly targetMin: NodeMaterialConnectionPoint;
  57119. /**
  57120. * Gets the target max input component
  57121. */
  57122. readonly targetMax: NodeMaterialConnectionPoint;
  57123. /**
  57124. * Gets the output component
  57125. */
  57126. readonly output: NodeMaterialConnectionPoint;
  57127. protected _buildBlock(state: NodeMaterialBuildState): this;
  57128. protected _dumpPropertiesCode(): string;
  57129. serialize(): any;
  57130. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57131. }
  57132. }
  57133. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  57134. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57135. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57136. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57137. /**
  57138. * Block used to normalize a vector
  57139. */
  57140. export class NormalizeBlock extends NodeMaterialBlock {
  57141. /**
  57142. * Creates a new NormalizeBlock
  57143. * @param name defines the block name
  57144. */
  57145. constructor(name: string);
  57146. /**
  57147. * Gets the current class name
  57148. * @returns the class name
  57149. */
  57150. getClassName(): string;
  57151. /**
  57152. * Gets the input component
  57153. */
  57154. readonly input: NodeMaterialConnectionPoint;
  57155. /**
  57156. * Gets the output component
  57157. */
  57158. readonly output: NodeMaterialConnectionPoint;
  57159. protected _buildBlock(state: NodeMaterialBuildState): this;
  57160. }
  57161. }
  57162. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  57163. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57164. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57165. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57166. import { Scene } from "babylonjs/scene";
  57167. /**
  57168. * Operations supported by the Trigonometry block
  57169. */
  57170. export enum TrigonometryBlockOperations {
  57171. /** Cos */
  57172. Cos = 0,
  57173. /** Sin */
  57174. Sin = 1,
  57175. /** Abs */
  57176. Abs = 2,
  57177. /** Exp */
  57178. Exp = 3,
  57179. /** Exp2 */
  57180. Exp2 = 4,
  57181. /** Round */
  57182. Round = 5,
  57183. /** Floor */
  57184. Floor = 6,
  57185. /** Ceiling */
  57186. Ceiling = 7,
  57187. /** Square root */
  57188. Sqrt = 8,
  57189. /** Log */
  57190. Log = 9,
  57191. /** Tangent */
  57192. Tan = 10,
  57193. /** Arc tangent */
  57194. ArcTan = 11,
  57195. /** Arc cosinus */
  57196. ArcCos = 12,
  57197. /** Arc sinus */
  57198. ArcSin = 13,
  57199. /** Fraction */
  57200. Fract = 14,
  57201. /** Sign */
  57202. Sign = 15,
  57203. /** To radians (from degrees) */
  57204. Radians = 16,
  57205. /** To degrees (from radians) */
  57206. Degrees = 17
  57207. }
  57208. /**
  57209. * Block used to apply trigonometry operation to floats
  57210. */
  57211. export class TrigonometryBlock extends NodeMaterialBlock {
  57212. /**
  57213. * Gets or sets the operation applied by the block
  57214. */
  57215. operation: TrigonometryBlockOperations;
  57216. /**
  57217. * Creates a new TrigonometryBlock
  57218. * @param name defines the block name
  57219. */
  57220. constructor(name: string);
  57221. /**
  57222. * Gets the current class name
  57223. * @returns the class name
  57224. */
  57225. getClassName(): string;
  57226. /**
  57227. * Gets the input component
  57228. */
  57229. readonly input: NodeMaterialConnectionPoint;
  57230. /**
  57231. * Gets the output component
  57232. */
  57233. readonly output: NodeMaterialConnectionPoint;
  57234. protected _buildBlock(state: NodeMaterialBuildState): this;
  57235. serialize(): any;
  57236. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57237. }
  57238. }
  57239. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  57240. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57241. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57242. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57243. /**
  57244. * Block used to create a Color3/4 out of individual inputs (one for each component)
  57245. */
  57246. export class ColorMergerBlock extends NodeMaterialBlock {
  57247. /**
  57248. * Create a new ColorMergerBlock
  57249. * @param name defines the block name
  57250. */
  57251. constructor(name: string);
  57252. /**
  57253. * Gets the current class name
  57254. * @returns the class name
  57255. */
  57256. getClassName(): string;
  57257. /**
  57258. * Gets the r component (input)
  57259. */
  57260. readonly r: NodeMaterialConnectionPoint;
  57261. /**
  57262. * Gets the g component (input)
  57263. */
  57264. readonly g: NodeMaterialConnectionPoint;
  57265. /**
  57266. * Gets the b component (input)
  57267. */
  57268. readonly b: NodeMaterialConnectionPoint;
  57269. /**
  57270. * Gets the a component (input)
  57271. */
  57272. readonly a: NodeMaterialConnectionPoint;
  57273. /**
  57274. * Gets the rgba component (output)
  57275. */
  57276. readonly rgba: NodeMaterialConnectionPoint;
  57277. /**
  57278. * Gets the rgb component (output)
  57279. */
  57280. readonly rgb: NodeMaterialConnectionPoint;
  57281. protected _buildBlock(state: NodeMaterialBuildState): this;
  57282. }
  57283. }
  57284. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  57285. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57286. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57287. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57288. /**
  57289. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  57290. */
  57291. export class VectorMergerBlock extends NodeMaterialBlock {
  57292. /**
  57293. * Create a new VectorMergerBlock
  57294. * @param name defines the block name
  57295. */
  57296. constructor(name: string);
  57297. /**
  57298. * Gets the current class name
  57299. * @returns the class name
  57300. */
  57301. getClassName(): string;
  57302. /**
  57303. * Gets the x component (input)
  57304. */
  57305. readonly x: NodeMaterialConnectionPoint;
  57306. /**
  57307. * Gets the y component (input)
  57308. */
  57309. readonly y: NodeMaterialConnectionPoint;
  57310. /**
  57311. * Gets the z component (input)
  57312. */
  57313. readonly z: NodeMaterialConnectionPoint;
  57314. /**
  57315. * Gets the w component (input)
  57316. */
  57317. readonly w: NodeMaterialConnectionPoint;
  57318. /**
  57319. * Gets the xyzw component (output)
  57320. */
  57321. readonly xyzw: NodeMaterialConnectionPoint;
  57322. /**
  57323. * Gets the xyz component (output)
  57324. */
  57325. readonly xyz: NodeMaterialConnectionPoint;
  57326. /**
  57327. * Gets the xy component (output)
  57328. */
  57329. readonly xy: NodeMaterialConnectionPoint;
  57330. protected _buildBlock(state: NodeMaterialBuildState): this;
  57331. }
  57332. }
  57333. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  57334. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57335. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57336. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57337. /**
  57338. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  57339. */
  57340. export class ColorSplitterBlock extends NodeMaterialBlock {
  57341. /**
  57342. * Create a new ColorSplitterBlock
  57343. * @param name defines the block name
  57344. */
  57345. constructor(name: string);
  57346. /**
  57347. * Gets the current class name
  57348. * @returns the class name
  57349. */
  57350. getClassName(): string;
  57351. /**
  57352. * Gets the rgba component (input)
  57353. */
  57354. readonly rgba: NodeMaterialConnectionPoint;
  57355. /**
  57356. * Gets the rgb component (input)
  57357. */
  57358. readonly rgbIn: NodeMaterialConnectionPoint;
  57359. /**
  57360. * Gets the rgb component (output)
  57361. */
  57362. readonly rgbOut: NodeMaterialConnectionPoint;
  57363. /**
  57364. * Gets the r component (output)
  57365. */
  57366. readonly r: NodeMaterialConnectionPoint;
  57367. /**
  57368. * Gets the g component (output)
  57369. */
  57370. readonly g: NodeMaterialConnectionPoint;
  57371. /**
  57372. * Gets the b component (output)
  57373. */
  57374. readonly b: NodeMaterialConnectionPoint;
  57375. /**
  57376. * Gets the a component (output)
  57377. */
  57378. readonly a: NodeMaterialConnectionPoint;
  57379. protected _inputRename(name: string): string;
  57380. protected _outputRename(name: string): string;
  57381. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57382. }
  57383. }
  57384. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  57385. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57386. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57387. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57388. /**
  57389. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  57390. */
  57391. export class VectorSplitterBlock extends NodeMaterialBlock {
  57392. /**
  57393. * Create a new VectorSplitterBlock
  57394. * @param name defines the block name
  57395. */
  57396. constructor(name: string);
  57397. /**
  57398. * Gets the current class name
  57399. * @returns the class name
  57400. */
  57401. getClassName(): string;
  57402. /**
  57403. * Gets the xyzw component (input)
  57404. */
  57405. readonly xyzw: NodeMaterialConnectionPoint;
  57406. /**
  57407. * Gets the xyz component (input)
  57408. */
  57409. readonly xyzIn: NodeMaterialConnectionPoint;
  57410. /**
  57411. * Gets the xy component (input)
  57412. */
  57413. readonly xyIn: NodeMaterialConnectionPoint;
  57414. /**
  57415. * Gets the xyz component (output)
  57416. */
  57417. readonly xyzOut: NodeMaterialConnectionPoint;
  57418. /**
  57419. * Gets the xy component (output)
  57420. */
  57421. readonly xyOut: NodeMaterialConnectionPoint;
  57422. /**
  57423. * Gets the x component (output)
  57424. */
  57425. readonly x: NodeMaterialConnectionPoint;
  57426. /**
  57427. * Gets the y component (output)
  57428. */
  57429. readonly y: NodeMaterialConnectionPoint;
  57430. /**
  57431. * Gets the z component (output)
  57432. */
  57433. readonly z: NodeMaterialConnectionPoint;
  57434. /**
  57435. * Gets the w component (output)
  57436. */
  57437. readonly w: NodeMaterialConnectionPoint;
  57438. protected _inputRename(name: string): string;
  57439. protected _outputRename(name: string): string;
  57440. protected _buildBlock(state: NodeMaterialBuildState): this;
  57441. }
  57442. }
  57443. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  57444. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57445. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57446. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57447. /**
  57448. * Block used to lerp between 2 values
  57449. */
  57450. export class LerpBlock extends NodeMaterialBlock {
  57451. /**
  57452. * Creates a new LerpBlock
  57453. * @param name defines the block name
  57454. */
  57455. constructor(name: string);
  57456. /**
  57457. * Gets the current class name
  57458. * @returns the class name
  57459. */
  57460. getClassName(): string;
  57461. /**
  57462. * Gets the left operand input component
  57463. */
  57464. readonly left: NodeMaterialConnectionPoint;
  57465. /**
  57466. * Gets the right operand input component
  57467. */
  57468. readonly right: NodeMaterialConnectionPoint;
  57469. /**
  57470. * Gets the gradient operand input component
  57471. */
  57472. readonly gradient: NodeMaterialConnectionPoint;
  57473. /**
  57474. * Gets the output component
  57475. */
  57476. readonly output: NodeMaterialConnectionPoint;
  57477. protected _buildBlock(state: NodeMaterialBuildState): this;
  57478. }
  57479. }
  57480. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  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 divide 2 vectors
  57486. */
  57487. export class DivideBlock extends NodeMaterialBlock {
  57488. /**
  57489. * Creates a new DivideBlock
  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 output component
  57508. */
  57509. readonly output: NodeMaterialConnectionPoint;
  57510. protected _buildBlock(state: NodeMaterialBuildState): this;
  57511. }
  57512. }
  57513. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  57514. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57515. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57516. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57517. /**
  57518. * Block used to subtract 2 vectors
  57519. */
  57520. export class SubtractBlock extends NodeMaterialBlock {
  57521. /**
  57522. * Creates a new SubtractBlock
  57523. * @param name defines the block name
  57524. */
  57525. constructor(name: string);
  57526. /**
  57527. * Gets the current class name
  57528. * @returns the class name
  57529. */
  57530. getClassName(): string;
  57531. /**
  57532. * Gets the left operand input component
  57533. */
  57534. readonly left: NodeMaterialConnectionPoint;
  57535. /**
  57536. * Gets the right operand input component
  57537. */
  57538. readonly right: NodeMaterialConnectionPoint;
  57539. /**
  57540. * Gets the output component
  57541. */
  57542. readonly output: NodeMaterialConnectionPoint;
  57543. protected _buildBlock(state: NodeMaterialBuildState): this;
  57544. }
  57545. }
  57546. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  57547. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57548. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57549. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57550. /**
  57551. * Block used to step a value
  57552. */
  57553. export class StepBlock extends NodeMaterialBlock {
  57554. /**
  57555. * Creates a new StepBlock
  57556. * @param name defines the block name
  57557. */
  57558. constructor(name: string);
  57559. /**
  57560. * Gets the current class name
  57561. * @returns the class name
  57562. */
  57563. getClassName(): string;
  57564. /**
  57565. * Gets the value operand input component
  57566. */
  57567. readonly value: NodeMaterialConnectionPoint;
  57568. /**
  57569. * Gets the edge operand input component
  57570. */
  57571. readonly edge: NodeMaterialConnectionPoint;
  57572. /**
  57573. * Gets the output component
  57574. */
  57575. readonly output: NodeMaterialConnectionPoint;
  57576. protected _buildBlock(state: NodeMaterialBuildState): this;
  57577. }
  57578. }
  57579. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  57580. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57581. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57582. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57583. /**
  57584. * Block used to get the opposite (1 - x) of a value
  57585. */
  57586. export class OneMinusBlock extends NodeMaterialBlock {
  57587. /**
  57588. * Creates a new OneMinusBlock
  57589. * @param name defines the block name
  57590. */
  57591. constructor(name: string);
  57592. /**
  57593. * Gets the current class name
  57594. * @returns the class name
  57595. */
  57596. getClassName(): string;
  57597. /**
  57598. * Gets the input component
  57599. */
  57600. readonly input: NodeMaterialConnectionPoint;
  57601. /**
  57602. * Gets the output component
  57603. */
  57604. readonly output: NodeMaterialConnectionPoint;
  57605. protected _buildBlock(state: NodeMaterialBuildState): this;
  57606. }
  57607. }
  57608. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  57609. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57610. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57611. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57612. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  57613. /**
  57614. * Block used to get the view direction
  57615. */
  57616. export class ViewDirectionBlock extends NodeMaterialBlock {
  57617. /**
  57618. * Creates a new ViewDirectionBlock
  57619. * @param name defines the block name
  57620. */
  57621. constructor(name: string);
  57622. /**
  57623. * Gets the current class name
  57624. * @returns the class name
  57625. */
  57626. getClassName(): string;
  57627. /**
  57628. * Gets the world position component
  57629. */
  57630. readonly worldPosition: NodeMaterialConnectionPoint;
  57631. /**
  57632. * Gets the camera position component
  57633. */
  57634. readonly cameraPosition: NodeMaterialConnectionPoint;
  57635. /**
  57636. * Gets the output component
  57637. */
  57638. readonly output: NodeMaterialConnectionPoint;
  57639. autoConfigure(material: NodeMaterial): void;
  57640. protected _buildBlock(state: NodeMaterialBuildState): this;
  57641. }
  57642. }
  57643. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  57644. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57645. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57646. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57647. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  57648. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  57649. /**
  57650. * Block used to compute fresnel value
  57651. */
  57652. export class FresnelBlock extends NodeMaterialBlock {
  57653. /**
  57654. * Create a new FresnelBlock
  57655. * @param name defines the block name
  57656. */
  57657. constructor(name: string);
  57658. /**
  57659. * Gets the current class name
  57660. * @returns the class name
  57661. */
  57662. getClassName(): string;
  57663. /**
  57664. * Gets the world normal input component
  57665. */
  57666. readonly worldNormal: NodeMaterialConnectionPoint;
  57667. /**
  57668. * Gets the view direction input component
  57669. */
  57670. readonly viewDirection: NodeMaterialConnectionPoint;
  57671. /**
  57672. * Gets the bias input component
  57673. */
  57674. readonly bias: NodeMaterialConnectionPoint;
  57675. /**
  57676. * Gets the camera (or eye) position component
  57677. */
  57678. readonly power: NodeMaterialConnectionPoint;
  57679. /**
  57680. * Gets the fresnel output component
  57681. */
  57682. readonly fresnel: NodeMaterialConnectionPoint;
  57683. autoConfigure(material: NodeMaterial): void;
  57684. protected _buildBlock(state: NodeMaterialBuildState): this;
  57685. }
  57686. }
  57687. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  57688. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57689. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57690. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57691. /**
  57692. * Block used to get the max of 2 values
  57693. */
  57694. export class MaxBlock extends NodeMaterialBlock {
  57695. /**
  57696. * Creates a new MaxBlock
  57697. * @param name defines the block name
  57698. */
  57699. constructor(name: string);
  57700. /**
  57701. * Gets the current class name
  57702. * @returns the class name
  57703. */
  57704. getClassName(): string;
  57705. /**
  57706. * Gets the left operand input component
  57707. */
  57708. readonly left: NodeMaterialConnectionPoint;
  57709. /**
  57710. * Gets the right operand input component
  57711. */
  57712. readonly right: NodeMaterialConnectionPoint;
  57713. /**
  57714. * Gets the output component
  57715. */
  57716. readonly output: NodeMaterialConnectionPoint;
  57717. protected _buildBlock(state: NodeMaterialBuildState): this;
  57718. }
  57719. }
  57720. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  57721. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57722. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57723. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57724. /**
  57725. * Block used to get the min of 2 values
  57726. */
  57727. export class MinBlock extends NodeMaterialBlock {
  57728. /**
  57729. * Creates a new MinBlock
  57730. * @param name defines the block name
  57731. */
  57732. constructor(name: string);
  57733. /**
  57734. * Gets the current class name
  57735. * @returns the class name
  57736. */
  57737. getClassName(): string;
  57738. /**
  57739. * Gets the left operand input component
  57740. */
  57741. readonly left: NodeMaterialConnectionPoint;
  57742. /**
  57743. * Gets the right operand input component
  57744. */
  57745. readonly right: NodeMaterialConnectionPoint;
  57746. /**
  57747. * Gets the output component
  57748. */
  57749. readonly output: NodeMaterialConnectionPoint;
  57750. protected _buildBlock(state: NodeMaterialBuildState): this;
  57751. }
  57752. }
  57753. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  57754. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57755. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57756. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57757. /**
  57758. * Block used to get the distance between 2 values
  57759. */
  57760. export class DistanceBlock extends NodeMaterialBlock {
  57761. /**
  57762. * Creates a new DistanceBlock
  57763. * @param name defines the block name
  57764. */
  57765. constructor(name: string);
  57766. /**
  57767. * Gets the current class name
  57768. * @returns the class name
  57769. */
  57770. getClassName(): string;
  57771. /**
  57772. * Gets the left operand input component
  57773. */
  57774. readonly left: NodeMaterialConnectionPoint;
  57775. /**
  57776. * Gets the right operand input component
  57777. */
  57778. readonly right: NodeMaterialConnectionPoint;
  57779. /**
  57780. * Gets the output component
  57781. */
  57782. readonly output: NodeMaterialConnectionPoint;
  57783. protected _buildBlock(state: NodeMaterialBuildState): this;
  57784. }
  57785. }
  57786. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  57787. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57788. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57789. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57790. /**
  57791. * Block used to get the length of a vector
  57792. */
  57793. export class LengthBlock extends NodeMaterialBlock {
  57794. /**
  57795. * Creates a new LengthBlock
  57796. * @param name defines the block name
  57797. */
  57798. constructor(name: string);
  57799. /**
  57800. * Gets the current class name
  57801. * @returns the class name
  57802. */
  57803. getClassName(): string;
  57804. /**
  57805. * Gets the value input component
  57806. */
  57807. readonly value: NodeMaterialConnectionPoint;
  57808. /**
  57809. * Gets the output component
  57810. */
  57811. readonly output: NodeMaterialConnectionPoint;
  57812. protected _buildBlock(state: NodeMaterialBuildState): this;
  57813. }
  57814. }
  57815. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  57816. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57817. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57818. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57819. /**
  57820. * Block used to get negative version of a value (i.e. x * -1)
  57821. */
  57822. export class NegateBlock extends NodeMaterialBlock {
  57823. /**
  57824. * Creates a new NegateBlock
  57825. * @param name defines the block name
  57826. */
  57827. constructor(name: string);
  57828. /**
  57829. * Gets the current class name
  57830. * @returns the class name
  57831. */
  57832. getClassName(): string;
  57833. /**
  57834. * Gets the value input component
  57835. */
  57836. readonly value: NodeMaterialConnectionPoint;
  57837. /**
  57838. * Gets the output component
  57839. */
  57840. readonly output: NodeMaterialConnectionPoint;
  57841. protected _buildBlock(state: NodeMaterialBuildState): this;
  57842. }
  57843. }
  57844. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  57845. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57846. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57847. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57848. /**
  57849. * Block used to get the value of the first parameter raised to the power of the second
  57850. */
  57851. export class PowBlock extends NodeMaterialBlock {
  57852. /**
  57853. * Creates a new PowBlock
  57854. * @param name defines the block name
  57855. */
  57856. constructor(name: string);
  57857. /**
  57858. * Gets the current class name
  57859. * @returns the class name
  57860. */
  57861. getClassName(): string;
  57862. /**
  57863. * Gets the value operand input component
  57864. */
  57865. readonly value: NodeMaterialConnectionPoint;
  57866. /**
  57867. * Gets the power operand input component
  57868. */
  57869. readonly power: NodeMaterialConnectionPoint;
  57870. /**
  57871. * Gets the output component
  57872. */
  57873. readonly output: NodeMaterialConnectionPoint;
  57874. protected _buildBlock(state: NodeMaterialBuildState): this;
  57875. }
  57876. }
  57877. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  57878. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57879. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57880. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57881. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57882. /**
  57883. * Block used to get a random number
  57884. */
  57885. export class RandomNumberBlock extends NodeMaterialBlock {
  57886. /**
  57887. * Creates a new RandomNumberBlock
  57888. * @param name defines the block name
  57889. */
  57890. constructor(name: string);
  57891. /**
  57892. * Gets the current class name
  57893. * @returns the class name
  57894. */
  57895. getClassName(): string;
  57896. /**
  57897. * Gets the seed input component
  57898. */
  57899. readonly seed: NodeMaterialConnectionPoint;
  57900. /**
  57901. * Gets the output component
  57902. */
  57903. readonly output: NodeMaterialConnectionPoint;
  57904. protected _buildBlock(state: NodeMaterialBuildState): this;
  57905. }
  57906. }
  57907. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  57908. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57909. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57910. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57911. /**
  57912. * Block used to compute arc tangent of 2 values
  57913. */
  57914. export class ArcTan2Block extends NodeMaterialBlock {
  57915. /**
  57916. * Creates a new ArcTan2Block
  57917. * @param name defines the block name
  57918. */
  57919. constructor(name: string);
  57920. /**
  57921. * Gets the current class name
  57922. * @returns the class name
  57923. */
  57924. getClassName(): string;
  57925. /**
  57926. * Gets the x operand input component
  57927. */
  57928. readonly x: NodeMaterialConnectionPoint;
  57929. /**
  57930. * Gets the y operand input component
  57931. */
  57932. readonly y: NodeMaterialConnectionPoint;
  57933. /**
  57934. * Gets the output component
  57935. */
  57936. readonly output: NodeMaterialConnectionPoint;
  57937. protected _buildBlock(state: NodeMaterialBuildState): this;
  57938. }
  57939. }
  57940. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  57941. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57942. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57943. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57944. /**
  57945. * Block used to smooth step a value
  57946. */
  57947. export class SmoothStepBlock extends NodeMaterialBlock {
  57948. /**
  57949. * Creates a new SmoothStepBlock
  57950. * @param name defines the block name
  57951. */
  57952. constructor(name: string);
  57953. /**
  57954. * Gets the current class name
  57955. * @returns the class name
  57956. */
  57957. getClassName(): string;
  57958. /**
  57959. * Gets the value operand input component
  57960. */
  57961. readonly value: NodeMaterialConnectionPoint;
  57962. /**
  57963. * Gets the first edge operand input component
  57964. */
  57965. readonly edge0: NodeMaterialConnectionPoint;
  57966. /**
  57967. * Gets the second edge operand input component
  57968. */
  57969. readonly edge1: 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/reciprocalBlock" {
  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 get the reciprocal (1 / x) of a value
  57983. */
  57984. export class ReciprocalBlock extends NodeMaterialBlock {
  57985. /**
  57986. * Creates a new ReciprocalBlock
  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 input component
  57997. */
  57998. readonly input: NodeMaterialConnectionPoint;
  57999. /**
  58000. * Gets the output component
  58001. */
  58002. readonly output: NodeMaterialConnectionPoint;
  58003. protected _buildBlock(state: NodeMaterialBuildState): this;
  58004. }
  58005. }
  58006. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  58007. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58008. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58009. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58010. /**
  58011. * Block used to replace a color by another one
  58012. */
  58013. export class ReplaceColorBlock extends NodeMaterialBlock {
  58014. /**
  58015. * Creates a new ReplaceColorBlock
  58016. * @param name defines the block name
  58017. */
  58018. constructor(name: string);
  58019. /**
  58020. * Gets the current class name
  58021. * @returns the class name
  58022. */
  58023. getClassName(): string;
  58024. /**
  58025. * Gets the value input component
  58026. */
  58027. readonly value: NodeMaterialConnectionPoint;
  58028. /**
  58029. * Gets the reference input component
  58030. */
  58031. readonly reference: NodeMaterialConnectionPoint;
  58032. /**
  58033. * Gets the distance input component
  58034. */
  58035. readonly distance: NodeMaterialConnectionPoint;
  58036. /**
  58037. * Gets the replacement input component
  58038. */
  58039. readonly replacement: NodeMaterialConnectionPoint;
  58040. /**
  58041. * Gets the output component
  58042. */
  58043. readonly output: NodeMaterialConnectionPoint;
  58044. protected _buildBlock(state: NodeMaterialBuildState): this;
  58045. }
  58046. }
  58047. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  58048. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58049. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58050. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58051. /**
  58052. * Block used to posterize a value
  58053. * @see https://en.wikipedia.org/wiki/Posterization
  58054. */
  58055. export class PosterizeBlock extends NodeMaterialBlock {
  58056. /**
  58057. * Creates a new PosterizeBlock
  58058. * @param name defines the block name
  58059. */
  58060. constructor(name: string);
  58061. /**
  58062. * Gets the current class name
  58063. * @returns the class name
  58064. */
  58065. getClassName(): string;
  58066. /**
  58067. * Gets the value input component
  58068. */
  58069. readonly value: NodeMaterialConnectionPoint;
  58070. /**
  58071. * Gets the steps input component
  58072. */
  58073. readonly steps: NodeMaterialConnectionPoint;
  58074. /**
  58075. * Gets the output component
  58076. */
  58077. readonly output: NodeMaterialConnectionPoint;
  58078. protected _buildBlock(state: NodeMaterialBuildState): this;
  58079. }
  58080. }
  58081. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  58082. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58083. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58084. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58085. import { Scene } from "babylonjs/scene";
  58086. /**
  58087. * Operations supported by the Wave block
  58088. */
  58089. export enum WaveBlockKind {
  58090. /** SawTooth */
  58091. SawTooth = 0,
  58092. /** Square */
  58093. Square = 1,
  58094. /** Triangle */
  58095. Triangle = 2
  58096. }
  58097. /**
  58098. * Block used to apply wave operation to floats
  58099. */
  58100. export class WaveBlock extends NodeMaterialBlock {
  58101. /**
  58102. * Gets or sets the kibnd of wave to be applied by the block
  58103. */
  58104. kind: WaveBlockKind;
  58105. /**
  58106. * Creates a new WaveBlock
  58107. * @param name defines the block name
  58108. */
  58109. constructor(name: string);
  58110. /**
  58111. * Gets the current class name
  58112. * @returns the class name
  58113. */
  58114. getClassName(): string;
  58115. /**
  58116. * Gets the input component
  58117. */
  58118. readonly input: NodeMaterialConnectionPoint;
  58119. /**
  58120. * Gets the output component
  58121. */
  58122. readonly output: NodeMaterialConnectionPoint;
  58123. protected _buildBlock(state: NodeMaterialBuildState): this;
  58124. serialize(): any;
  58125. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58126. }
  58127. }
  58128. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  58129. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58130. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58131. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58132. import { Color3 } from "babylonjs/Maths/math.color";
  58133. import { Scene } from "babylonjs/scene";
  58134. /**
  58135. * Class used to store a color step for the GradientBlock
  58136. */
  58137. export class GradientBlockColorStep {
  58138. /**
  58139. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  58140. */
  58141. step: number;
  58142. /**
  58143. * Gets or sets the color associated with this step
  58144. */
  58145. color: Color3;
  58146. /**
  58147. * Creates a new GradientBlockColorStep
  58148. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  58149. * @param color defines the color associated with this step
  58150. */
  58151. constructor(
  58152. /**
  58153. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  58154. */
  58155. step: number,
  58156. /**
  58157. * Gets or sets the color associated with this step
  58158. */
  58159. color: Color3);
  58160. }
  58161. /**
  58162. * Block used to return a color from a gradient based on an input value between 0 and 1
  58163. */
  58164. export class GradientBlock extends NodeMaterialBlock {
  58165. /**
  58166. * Gets or sets the list of color steps
  58167. */
  58168. colorSteps: GradientBlockColorStep[];
  58169. /**
  58170. * Creates a new GradientBlock
  58171. * @param name defines the block name
  58172. */
  58173. constructor(name: string);
  58174. /**
  58175. * Gets the current class name
  58176. * @returns the class name
  58177. */
  58178. getClassName(): string;
  58179. /**
  58180. * Gets the gradient input component
  58181. */
  58182. readonly gradient: NodeMaterialConnectionPoint;
  58183. /**
  58184. * Gets the output component
  58185. */
  58186. readonly output: NodeMaterialConnectionPoint;
  58187. private _writeColorConstant;
  58188. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58189. serialize(): any;
  58190. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58191. protected _dumpPropertiesCode(): string;
  58192. }
  58193. }
  58194. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  58195. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58196. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58197. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58198. /**
  58199. * Block used to normalize lerp between 2 values
  58200. */
  58201. export class NLerpBlock extends NodeMaterialBlock {
  58202. /**
  58203. * Creates a new NLerpBlock
  58204. * @param name defines the block name
  58205. */
  58206. constructor(name: string);
  58207. /**
  58208. * Gets the current class name
  58209. * @returns the class name
  58210. */
  58211. getClassName(): string;
  58212. /**
  58213. * Gets the left operand input component
  58214. */
  58215. readonly left: NodeMaterialConnectionPoint;
  58216. /**
  58217. * Gets the right operand input component
  58218. */
  58219. readonly right: NodeMaterialConnectionPoint;
  58220. /**
  58221. * Gets the gradient operand input component
  58222. */
  58223. readonly gradient: NodeMaterialConnectionPoint;
  58224. /**
  58225. * Gets the output component
  58226. */
  58227. readonly output: NodeMaterialConnectionPoint;
  58228. protected _buildBlock(state: NodeMaterialBuildState): this;
  58229. }
  58230. }
  58231. declare module "babylonjs/Materials/Node/Blocks/index" {
  58232. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  58233. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  58234. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  58235. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  58236. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  58237. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  58238. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  58239. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  58240. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  58241. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  58242. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  58243. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  58244. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  58245. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  58246. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  58247. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  58248. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  58249. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  58250. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  58251. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  58252. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  58253. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  58254. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  58255. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  58256. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  58257. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  58258. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  58259. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  58260. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  58261. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  58262. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  58263. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  58264. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  58265. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  58266. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  58267. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  58268. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  58269. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  58270. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  58271. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  58272. }
  58273. declare module "babylonjs/Materials/Node/Optimizers/index" {
  58274. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  58275. }
  58276. declare module "babylonjs/Materials/Node/index" {
  58277. export * from "babylonjs/Materials/Node/Enums/index";
  58278. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58279. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  58280. export * from "babylonjs/Materials/Node/nodeMaterial";
  58281. export * from "babylonjs/Materials/Node/Blocks/index";
  58282. export * from "babylonjs/Materials/Node/Optimizers/index";
  58283. }
  58284. declare module "babylonjs/Materials/effectRenderer" {
  58285. import { Nullable } from "babylonjs/types";
  58286. import { Texture } from "babylonjs/Materials/Textures/texture";
  58287. import { Engine } from "babylonjs/Engines/engine";
  58288. import { Viewport } from "babylonjs/Maths/math.viewport";
  58289. import { Observable } from "babylonjs/Misc/observable";
  58290. import { Effect } from "babylonjs/Materials/effect";
  58291. import "babylonjs/Shaders/postprocess.vertex";
  58292. /**
  58293. * Effect Render Options
  58294. */
  58295. export interface IEffectRendererOptions {
  58296. /**
  58297. * Defines the vertices positions.
  58298. */
  58299. positions?: number[];
  58300. /**
  58301. * Defines the indices.
  58302. */
  58303. indices?: number[];
  58304. }
  58305. /**
  58306. * Helper class to render one or more effects
  58307. */
  58308. export class EffectRenderer {
  58309. private engine;
  58310. private static _DefaultOptions;
  58311. private _vertexBuffers;
  58312. private _indexBuffer;
  58313. private _ringBufferIndex;
  58314. private _ringScreenBuffer;
  58315. private _fullscreenViewport;
  58316. private _getNextFrameBuffer;
  58317. /**
  58318. * Creates an effect renderer
  58319. * @param engine the engine to use for rendering
  58320. * @param options defines the options of the effect renderer
  58321. */
  58322. constructor(engine: Engine, options?: IEffectRendererOptions);
  58323. /**
  58324. * Sets the current viewport in normalized coordinates 0-1
  58325. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  58326. */
  58327. setViewport(viewport?: Viewport): void;
  58328. /**
  58329. * Binds the embedded attributes buffer to the effect.
  58330. * @param effect Defines the effect to bind the attributes for
  58331. */
  58332. bindBuffers(effect: Effect): void;
  58333. /**
  58334. * Sets the current effect wrapper to use during draw.
  58335. * The effect needs to be ready before calling this api.
  58336. * This also sets the default full screen position attribute.
  58337. * @param effectWrapper Defines the effect to draw with
  58338. */
  58339. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  58340. /**
  58341. * Draws a full screen quad.
  58342. */
  58343. draw(): void;
  58344. /**
  58345. * renders one or more effects to a specified texture
  58346. * @param effectWrappers list of effects to renderer
  58347. * @param outputTexture texture to draw to, if null it will render to the screen
  58348. */
  58349. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  58350. /**
  58351. * Disposes of the effect renderer
  58352. */
  58353. dispose(): void;
  58354. }
  58355. /**
  58356. * Options to create an EffectWrapper
  58357. */
  58358. interface EffectWrapperCreationOptions {
  58359. /**
  58360. * Engine to use to create the effect
  58361. */
  58362. engine: Engine;
  58363. /**
  58364. * Fragment shader for the effect
  58365. */
  58366. fragmentShader: string;
  58367. /**
  58368. * Vertex shader for the effect
  58369. */
  58370. vertexShader?: string;
  58371. /**
  58372. * Attributes to use in the shader
  58373. */
  58374. attributeNames?: Array<string>;
  58375. /**
  58376. * Uniforms to use in the shader
  58377. */
  58378. uniformNames?: Array<string>;
  58379. /**
  58380. * Texture sampler names to use in the shader
  58381. */
  58382. samplerNames?: Array<string>;
  58383. /**
  58384. * The friendly name of the effect displayed in Spector.
  58385. */
  58386. name?: string;
  58387. }
  58388. /**
  58389. * Wraps an effect to be used for rendering
  58390. */
  58391. export class EffectWrapper {
  58392. /**
  58393. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  58394. */
  58395. onApplyObservable: Observable<{}>;
  58396. /**
  58397. * The underlying effect
  58398. */
  58399. effect: Effect;
  58400. /**
  58401. * Creates an effect to be renderer
  58402. * @param creationOptions options to create the effect
  58403. */
  58404. constructor(creationOptions: EffectWrapperCreationOptions);
  58405. /**
  58406. * Disposes of the effect wrapper
  58407. */
  58408. dispose(): void;
  58409. }
  58410. }
  58411. declare module "babylonjs/Materials/index" {
  58412. export * from "babylonjs/Materials/Background/index";
  58413. export * from "babylonjs/Materials/colorCurves";
  58414. export * from "babylonjs/Materials/iEffectFallbacks";
  58415. export * from "babylonjs/Materials/effectFallbacks";
  58416. export * from "babylonjs/Materials/effect";
  58417. export * from "babylonjs/Materials/fresnelParameters";
  58418. export * from "babylonjs/Materials/imageProcessingConfiguration";
  58419. export * from "babylonjs/Materials/material";
  58420. export * from "babylonjs/Materials/materialDefines";
  58421. export * from "babylonjs/Materials/materialHelper";
  58422. export * from "babylonjs/Materials/multiMaterial";
  58423. export * from "babylonjs/Materials/PBR/index";
  58424. export * from "babylonjs/Materials/pushMaterial";
  58425. export * from "babylonjs/Materials/shaderMaterial";
  58426. export * from "babylonjs/Materials/standardMaterial";
  58427. export * from "babylonjs/Materials/Textures/index";
  58428. export * from "babylonjs/Materials/uniformBuffer";
  58429. export * from "babylonjs/Materials/materialFlags";
  58430. export * from "babylonjs/Materials/Node/index";
  58431. export * from "babylonjs/Materials/effectRenderer";
  58432. }
  58433. declare module "babylonjs/Maths/index" {
  58434. export * from "babylonjs/Maths/math.scalar";
  58435. export * from "babylonjs/Maths/math";
  58436. export * from "babylonjs/Maths/sphericalPolynomial";
  58437. }
  58438. declare module "babylonjs/Misc/workerPool" {
  58439. import { IDisposable } from "babylonjs/scene";
  58440. /**
  58441. * Helper class to push actions to a pool of workers.
  58442. */
  58443. export class WorkerPool implements IDisposable {
  58444. private _workerInfos;
  58445. private _pendingActions;
  58446. /**
  58447. * Constructor
  58448. * @param workers Array of workers to use for actions
  58449. */
  58450. constructor(workers: Array<Worker>);
  58451. /**
  58452. * Terminates all workers and clears any pending actions.
  58453. */
  58454. dispose(): void;
  58455. /**
  58456. * Pushes an action to the worker pool. If all the workers are active, the action will be
  58457. * pended until a worker has completed its action.
  58458. * @param action The action to perform. Call onComplete when the action is complete.
  58459. */
  58460. push(action: (worker: Worker, onComplete: () => void) => void): void;
  58461. private _execute;
  58462. }
  58463. }
  58464. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  58465. import { IDisposable } from "babylonjs/scene";
  58466. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  58467. /**
  58468. * Configuration for Draco compression
  58469. */
  58470. export interface IDracoCompressionConfiguration {
  58471. /**
  58472. * Configuration for the decoder.
  58473. */
  58474. decoder: {
  58475. /**
  58476. * The url to the WebAssembly module.
  58477. */
  58478. wasmUrl?: string;
  58479. /**
  58480. * The url to the WebAssembly binary.
  58481. */
  58482. wasmBinaryUrl?: string;
  58483. /**
  58484. * The url to the fallback JavaScript module.
  58485. */
  58486. fallbackUrl?: string;
  58487. };
  58488. }
  58489. /**
  58490. * Draco compression (https://google.github.io/draco/)
  58491. *
  58492. * This class wraps the Draco module.
  58493. *
  58494. * **Encoder**
  58495. *
  58496. * The encoder is not currently implemented.
  58497. *
  58498. * **Decoder**
  58499. *
  58500. * 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.
  58501. *
  58502. * To update the configuration, use the following code:
  58503. * ```javascript
  58504. * DracoCompression.Configuration = {
  58505. * decoder: {
  58506. * wasmUrl: "<url to the WebAssembly library>",
  58507. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  58508. * fallbackUrl: "<url to the fallback JavaScript library>",
  58509. * }
  58510. * };
  58511. * ```
  58512. *
  58513. * 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.
  58514. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  58515. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  58516. *
  58517. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  58518. * ```javascript
  58519. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  58520. * ```
  58521. *
  58522. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  58523. */
  58524. export class DracoCompression implements IDisposable {
  58525. private _workerPoolPromise?;
  58526. private _decoderModulePromise?;
  58527. /**
  58528. * The configuration. Defaults to the following urls:
  58529. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  58530. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  58531. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  58532. */
  58533. static Configuration: IDracoCompressionConfiguration;
  58534. /**
  58535. * Returns true if the decoder configuration is available.
  58536. */
  58537. static readonly DecoderAvailable: boolean;
  58538. /**
  58539. * Default number of workers to create when creating the draco compression object.
  58540. */
  58541. static DefaultNumWorkers: number;
  58542. private static GetDefaultNumWorkers;
  58543. private static _Default;
  58544. /**
  58545. * Default instance for the draco compression object.
  58546. */
  58547. static readonly Default: DracoCompression;
  58548. /**
  58549. * Constructor
  58550. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  58551. */
  58552. constructor(numWorkers?: number);
  58553. /**
  58554. * Stop all async operations and release resources.
  58555. */
  58556. dispose(): void;
  58557. /**
  58558. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  58559. * @returns a promise that resolves when ready
  58560. */
  58561. whenReadyAsync(): Promise<void>;
  58562. /**
  58563. * Decode Draco compressed mesh data to vertex data.
  58564. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  58565. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  58566. * @returns A promise that resolves with the decoded vertex data
  58567. */
  58568. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  58569. [kind: string]: number;
  58570. }): Promise<VertexData>;
  58571. }
  58572. }
  58573. declare module "babylonjs/Meshes/Compression/index" {
  58574. export * from "babylonjs/Meshes/Compression/dracoCompression";
  58575. }
  58576. declare module "babylonjs/Meshes/csg" {
  58577. import { Nullable } from "babylonjs/types";
  58578. import { Scene } from "babylonjs/scene";
  58579. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  58580. import { Mesh } from "babylonjs/Meshes/mesh";
  58581. import { Material } from "babylonjs/Materials/material";
  58582. /**
  58583. * Class for building Constructive Solid Geometry
  58584. */
  58585. export class CSG {
  58586. private polygons;
  58587. /**
  58588. * The world matrix
  58589. */
  58590. matrix: Matrix;
  58591. /**
  58592. * Stores the position
  58593. */
  58594. position: Vector3;
  58595. /**
  58596. * Stores the rotation
  58597. */
  58598. rotation: Vector3;
  58599. /**
  58600. * Stores the rotation quaternion
  58601. */
  58602. rotationQuaternion: Nullable<Quaternion>;
  58603. /**
  58604. * Stores the scaling vector
  58605. */
  58606. scaling: Vector3;
  58607. /**
  58608. * Convert the Mesh to CSG
  58609. * @param mesh The Mesh to convert to CSG
  58610. * @returns A new CSG from the Mesh
  58611. */
  58612. static FromMesh(mesh: Mesh): CSG;
  58613. /**
  58614. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  58615. * @param polygons Polygons used to construct a CSG solid
  58616. */
  58617. private static FromPolygons;
  58618. /**
  58619. * Clones, or makes a deep copy, of the CSG
  58620. * @returns A new CSG
  58621. */
  58622. clone(): CSG;
  58623. /**
  58624. * Unions this CSG with another CSG
  58625. * @param csg The CSG to union against this CSG
  58626. * @returns The unioned CSG
  58627. */
  58628. union(csg: CSG): CSG;
  58629. /**
  58630. * Unions this CSG with another CSG in place
  58631. * @param csg The CSG to union against this CSG
  58632. */
  58633. unionInPlace(csg: CSG): void;
  58634. /**
  58635. * Subtracts this CSG with another CSG
  58636. * @param csg The CSG to subtract against this CSG
  58637. * @returns A new CSG
  58638. */
  58639. subtract(csg: CSG): CSG;
  58640. /**
  58641. * Subtracts this CSG with another CSG in place
  58642. * @param csg The CSG to subtact against this CSG
  58643. */
  58644. subtractInPlace(csg: CSG): void;
  58645. /**
  58646. * Intersect this CSG with another CSG
  58647. * @param csg The CSG to intersect against this CSG
  58648. * @returns A new CSG
  58649. */
  58650. intersect(csg: CSG): CSG;
  58651. /**
  58652. * Intersects this CSG with another CSG in place
  58653. * @param csg The CSG to intersect against this CSG
  58654. */
  58655. intersectInPlace(csg: CSG): void;
  58656. /**
  58657. * Return a new CSG solid with solid and empty space switched. This solid is
  58658. * not modified.
  58659. * @returns A new CSG solid with solid and empty space switched
  58660. */
  58661. inverse(): CSG;
  58662. /**
  58663. * Inverses the CSG in place
  58664. */
  58665. inverseInPlace(): void;
  58666. /**
  58667. * This is used to keep meshes transformations so they can be restored
  58668. * when we build back a Babylon Mesh
  58669. * NB : All CSG operations are performed in world coordinates
  58670. * @param csg The CSG to copy the transform attributes from
  58671. * @returns This CSG
  58672. */
  58673. copyTransformAttributes(csg: CSG): CSG;
  58674. /**
  58675. * Build Raw mesh from CSG
  58676. * Coordinates here are in world space
  58677. * @param name The name of the mesh geometry
  58678. * @param scene The Scene
  58679. * @param keepSubMeshes Specifies if the submeshes should be kept
  58680. * @returns A new Mesh
  58681. */
  58682. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  58683. /**
  58684. * Build Mesh from CSG taking material and transforms into account
  58685. * @param name The name of the Mesh
  58686. * @param material The material of the Mesh
  58687. * @param scene The Scene
  58688. * @param keepSubMeshes Specifies if submeshes should be kept
  58689. * @returns The new Mesh
  58690. */
  58691. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  58692. }
  58693. }
  58694. declare module "babylonjs/Meshes/trailMesh" {
  58695. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58696. import { Mesh } from "babylonjs/Meshes/mesh";
  58697. import { Scene } from "babylonjs/scene";
  58698. /**
  58699. * Class used to create a trail following a mesh
  58700. */
  58701. export class TrailMesh extends Mesh {
  58702. private _generator;
  58703. private _autoStart;
  58704. private _running;
  58705. private _diameter;
  58706. private _length;
  58707. private _sectionPolygonPointsCount;
  58708. private _sectionVectors;
  58709. private _sectionNormalVectors;
  58710. private _beforeRenderObserver;
  58711. /**
  58712. * @constructor
  58713. * @param name The value used by scene.getMeshByName() to do a lookup.
  58714. * @param generator The mesh to generate a trail.
  58715. * @param scene The scene to add this mesh to.
  58716. * @param diameter Diameter of trailing mesh. Default is 1.
  58717. * @param length Length of trailing mesh. Default is 60.
  58718. * @param autoStart Automatically start trailing mesh. Default true.
  58719. */
  58720. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  58721. /**
  58722. * "TrailMesh"
  58723. * @returns "TrailMesh"
  58724. */
  58725. getClassName(): string;
  58726. private _createMesh;
  58727. /**
  58728. * Start trailing mesh.
  58729. */
  58730. start(): void;
  58731. /**
  58732. * Stop trailing mesh.
  58733. */
  58734. stop(): void;
  58735. /**
  58736. * Update trailing mesh geometry.
  58737. */
  58738. update(): void;
  58739. /**
  58740. * Returns a new TrailMesh object.
  58741. * @param name is a string, the name given to the new mesh
  58742. * @param newGenerator use new generator object for cloned trail mesh
  58743. * @returns a new mesh
  58744. */
  58745. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  58746. /**
  58747. * Serializes this trail mesh
  58748. * @param serializationObject object to write serialization to
  58749. */
  58750. serialize(serializationObject: any): void;
  58751. /**
  58752. * Parses a serialized trail mesh
  58753. * @param parsedMesh the serialized mesh
  58754. * @param scene the scene to create the trail mesh in
  58755. * @returns the created trail mesh
  58756. */
  58757. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  58758. }
  58759. }
  58760. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  58761. import { Nullable } from "babylonjs/types";
  58762. import { Scene } from "babylonjs/scene";
  58763. import { Vector4 } from "babylonjs/Maths/math.vector";
  58764. import { Color4 } from "babylonjs/Maths/math.color";
  58765. import { Mesh } from "babylonjs/Meshes/mesh";
  58766. /**
  58767. * Class containing static functions to help procedurally build meshes
  58768. */
  58769. export class TiledBoxBuilder {
  58770. /**
  58771. * Creates a box mesh
  58772. * 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)
  58773. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58774. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58775. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58776. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58777. * @param name defines the name of the mesh
  58778. * @param options defines the options used to create the mesh
  58779. * @param scene defines the hosting scene
  58780. * @returns the box mesh
  58781. */
  58782. static CreateTiledBox(name: string, options: {
  58783. pattern?: number;
  58784. width?: number;
  58785. height?: number;
  58786. depth?: number;
  58787. tileSize?: number;
  58788. tileWidth?: number;
  58789. tileHeight?: number;
  58790. alignHorizontal?: number;
  58791. alignVertical?: number;
  58792. faceUV?: Vector4[];
  58793. faceColors?: Color4[];
  58794. sideOrientation?: number;
  58795. updatable?: boolean;
  58796. }, scene?: Nullable<Scene>): Mesh;
  58797. }
  58798. }
  58799. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  58800. import { Vector4 } from "babylonjs/Maths/math.vector";
  58801. import { Mesh } from "babylonjs/Meshes/mesh";
  58802. /**
  58803. * Class containing static functions to help procedurally build meshes
  58804. */
  58805. export class TorusKnotBuilder {
  58806. /**
  58807. * Creates a torus knot mesh
  58808. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  58809. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  58810. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  58811. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  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 torus knot mesh
  58819. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  58820. */
  58821. static CreateTorusKnot(name: string, options: {
  58822. radius?: number;
  58823. tube?: number;
  58824. radialSegments?: number;
  58825. tubularSegments?: number;
  58826. p?: number;
  58827. q?: number;
  58828. updatable?: boolean;
  58829. sideOrientation?: number;
  58830. frontUVs?: Vector4;
  58831. backUVs?: Vector4;
  58832. }, scene: any): Mesh;
  58833. }
  58834. }
  58835. declare module "babylonjs/Meshes/polygonMesh" {
  58836. import { Scene } from "babylonjs/scene";
  58837. import { Vector2 } from "babylonjs/Maths/math.vector";
  58838. import { Mesh } from "babylonjs/Meshes/mesh";
  58839. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  58840. import { Path2 } from "babylonjs/Maths/math.path";
  58841. /**
  58842. * Polygon
  58843. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  58844. */
  58845. export class Polygon {
  58846. /**
  58847. * Creates a rectangle
  58848. * @param xmin bottom X coord
  58849. * @param ymin bottom Y coord
  58850. * @param xmax top X coord
  58851. * @param ymax top Y coord
  58852. * @returns points that make the resulting rectation
  58853. */
  58854. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  58855. /**
  58856. * Creates a circle
  58857. * @param radius radius of circle
  58858. * @param cx scale in x
  58859. * @param cy scale in y
  58860. * @param numberOfSides number of sides that make up the circle
  58861. * @returns points that make the resulting circle
  58862. */
  58863. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  58864. /**
  58865. * Creates a polygon from input string
  58866. * @param input Input polygon data
  58867. * @returns the parsed points
  58868. */
  58869. static Parse(input: string): Vector2[];
  58870. /**
  58871. * Starts building a polygon from x and y coordinates
  58872. * @param x x coordinate
  58873. * @param y y coordinate
  58874. * @returns the started path2
  58875. */
  58876. static StartingAt(x: number, y: number): Path2;
  58877. }
  58878. /**
  58879. * Builds a polygon
  58880. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  58881. */
  58882. export class PolygonMeshBuilder {
  58883. private _points;
  58884. private _outlinepoints;
  58885. private _holes;
  58886. private _name;
  58887. private _scene;
  58888. private _epoints;
  58889. private _eholes;
  58890. private _addToepoint;
  58891. /**
  58892. * Babylon reference to the earcut plugin.
  58893. */
  58894. bjsEarcut: any;
  58895. /**
  58896. * Creates a PolygonMeshBuilder
  58897. * @param name name of the builder
  58898. * @param contours Path of the polygon
  58899. * @param scene scene to add to when creating the mesh
  58900. * @param earcutInjection can be used to inject your own earcut reference
  58901. */
  58902. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  58903. /**
  58904. * Adds a whole within the polygon
  58905. * @param hole Array of points defining the hole
  58906. * @returns this
  58907. */
  58908. addHole(hole: Vector2[]): PolygonMeshBuilder;
  58909. /**
  58910. * Creates the polygon
  58911. * @param updatable If the mesh should be updatable
  58912. * @param depth The depth of the mesh created
  58913. * @returns the created mesh
  58914. */
  58915. build(updatable?: boolean, depth?: number): Mesh;
  58916. /**
  58917. * Creates the polygon
  58918. * @param depth The depth of the mesh created
  58919. * @returns the created VertexData
  58920. */
  58921. buildVertexData(depth?: number): VertexData;
  58922. /**
  58923. * Adds a side to the polygon
  58924. * @param positions points that make the polygon
  58925. * @param normals normals of the polygon
  58926. * @param uvs uvs of the polygon
  58927. * @param indices indices of the polygon
  58928. * @param bounds bounds of the polygon
  58929. * @param points points of the polygon
  58930. * @param depth depth of the polygon
  58931. * @param flip flip of the polygon
  58932. */
  58933. private addSide;
  58934. }
  58935. }
  58936. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  58937. import { Scene } from "babylonjs/scene";
  58938. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  58939. import { Color4 } from "babylonjs/Maths/math.color";
  58940. import { Mesh } from "babylonjs/Meshes/mesh";
  58941. import { Nullable } from "babylonjs/types";
  58942. /**
  58943. * Class containing static functions to help procedurally build meshes
  58944. */
  58945. export class PolygonBuilder {
  58946. /**
  58947. * Creates a polygon mesh
  58948. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  58949. * * 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
  58950. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  58951. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58952. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  58953. * * Remember you can only change the shape positions, not their number when updating a polygon
  58954. * @param name defines the name of the mesh
  58955. * @param options defines the options used to create the mesh
  58956. * @param scene defines the hosting scene
  58957. * @param earcutInjection can be used to inject your own earcut reference
  58958. * @returns the polygon mesh
  58959. */
  58960. static CreatePolygon(name: string, options: {
  58961. shape: Vector3[];
  58962. holes?: Vector3[][];
  58963. depth?: number;
  58964. faceUV?: Vector4[];
  58965. faceColors?: Color4[];
  58966. updatable?: boolean;
  58967. sideOrientation?: number;
  58968. frontUVs?: Vector4;
  58969. backUVs?: Vector4;
  58970. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58971. /**
  58972. * Creates an extruded polygon mesh, with depth in the Y direction.
  58973. * * 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)
  58974. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58975. * @param name defines the name of the mesh
  58976. * @param options defines the options used to create the mesh
  58977. * @param scene defines the hosting scene
  58978. * @param earcutInjection can be used to inject your own earcut reference
  58979. * @returns the polygon mesh
  58980. */
  58981. static ExtrudePolygon(name: string, options: {
  58982. shape: Vector3[];
  58983. holes?: Vector3[][];
  58984. depth?: number;
  58985. faceUV?: Vector4[];
  58986. faceColors?: Color4[];
  58987. updatable?: boolean;
  58988. sideOrientation?: number;
  58989. frontUVs?: Vector4;
  58990. backUVs?: Vector4;
  58991. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58992. }
  58993. }
  58994. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  58995. import { Scene } from "babylonjs/scene";
  58996. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  58997. import { Mesh } from "babylonjs/Meshes/mesh";
  58998. import { Nullable } from "babylonjs/types";
  58999. /**
  59000. * Class containing static functions to help procedurally build meshes
  59001. */
  59002. export class LatheBuilder {
  59003. /**
  59004. * Creates lathe mesh.
  59005. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  59006. * * 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
  59007. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  59008. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  59009. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  59010. * * 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
  59011. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  59012. * * 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
  59013. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59014. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59015. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59016. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59017. * @param name defines the name of the mesh
  59018. * @param options defines the options used to create the mesh
  59019. * @param scene defines the hosting scene
  59020. * @returns the lathe mesh
  59021. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  59022. */
  59023. static CreateLathe(name: string, options: {
  59024. shape: Vector3[];
  59025. radius?: number;
  59026. tessellation?: number;
  59027. clip?: number;
  59028. arc?: number;
  59029. closed?: boolean;
  59030. updatable?: boolean;
  59031. sideOrientation?: number;
  59032. frontUVs?: Vector4;
  59033. backUVs?: Vector4;
  59034. cap?: number;
  59035. invertUV?: boolean;
  59036. }, scene?: Nullable<Scene>): Mesh;
  59037. }
  59038. }
  59039. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  59040. import { Nullable } from "babylonjs/types";
  59041. import { Scene } from "babylonjs/scene";
  59042. import { Vector4 } from "babylonjs/Maths/math.vector";
  59043. import { Mesh } from "babylonjs/Meshes/mesh";
  59044. /**
  59045. * Class containing static functions to help procedurally build meshes
  59046. */
  59047. export class TiledPlaneBuilder {
  59048. /**
  59049. * Creates a tiled plane mesh
  59050. * * The parameter `pattern` will, depending on value, do nothing or
  59051. * * * flip (reflect about central vertical) alternate tiles across and up
  59052. * * * flip every tile on alternate rows
  59053. * * * rotate (180 degs) alternate tiles across and up
  59054. * * * rotate every tile on alternate rows
  59055. * * * flip and rotate alternate tiles across and up
  59056. * * * flip and rotate every tile on alternate rows
  59057. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  59058. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  59059. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59060. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59061. * * 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)
  59062. * * 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)
  59063. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  59064. * @param name defines the name of the mesh
  59065. * @param options defines the options used to create the mesh
  59066. * @param scene defines the hosting scene
  59067. * @returns the box mesh
  59068. */
  59069. static CreateTiledPlane(name: string, options: {
  59070. pattern?: number;
  59071. tileSize?: number;
  59072. tileWidth?: number;
  59073. tileHeight?: number;
  59074. size?: number;
  59075. width?: number;
  59076. height?: number;
  59077. alignHorizontal?: number;
  59078. alignVertical?: number;
  59079. sideOrientation?: number;
  59080. frontUVs?: Vector4;
  59081. backUVs?: Vector4;
  59082. updatable?: boolean;
  59083. }, scene?: Nullable<Scene>): Mesh;
  59084. }
  59085. }
  59086. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  59087. import { Nullable } from "babylonjs/types";
  59088. import { Scene } from "babylonjs/scene";
  59089. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  59090. import { Mesh } from "babylonjs/Meshes/mesh";
  59091. /**
  59092. * Class containing static functions to help procedurally build meshes
  59093. */
  59094. export class TubeBuilder {
  59095. /**
  59096. * Creates a tube mesh.
  59097. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59098. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  59099. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  59100. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  59101. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  59102. * * 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)
  59103. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  59104. * * 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
  59105. * * 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
  59106. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59107. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59108. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59109. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59110. * @param name defines the name of the mesh
  59111. * @param options defines the options used to create the mesh
  59112. * @param scene defines the hosting scene
  59113. * @returns the tube mesh
  59114. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59115. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  59116. */
  59117. static CreateTube(name: string, options: {
  59118. path: Vector3[];
  59119. radius?: number;
  59120. tessellation?: number;
  59121. radiusFunction?: {
  59122. (i: number, distance: number): number;
  59123. };
  59124. cap?: number;
  59125. arc?: number;
  59126. updatable?: boolean;
  59127. sideOrientation?: number;
  59128. frontUVs?: Vector4;
  59129. backUVs?: Vector4;
  59130. instance?: Mesh;
  59131. invertUV?: boolean;
  59132. }, scene?: Nullable<Scene>): Mesh;
  59133. }
  59134. }
  59135. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  59136. import { Scene } from "babylonjs/scene";
  59137. import { Vector4 } from "babylonjs/Maths/math.vector";
  59138. import { Mesh } from "babylonjs/Meshes/mesh";
  59139. import { Nullable } from "babylonjs/types";
  59140. /**
  59141. * Class containing static functions to help procedurally build meshes
  59142. */
  59143. export class IcoSphereBuilder {
  59144. /**
  59145. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  59146. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  59147. * * 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`)
  59148. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  59149. * * 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
  59150. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59151. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59152. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59153. * @param name defines the name of the mesh
  59154. * @param options defines the options used to create the mesh
  59155. * @param scene defines the hosting scene
  59156. * @returns the icosahedron mesh
  59157. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  59158. */
  59159. static CreateIcoSphere(name: string, options: {
  59160. radius?: number;
  59161. radiusX?: number;
  59162. radiusY?: number;
  59163. radiusZ?: number;
  59164. flat?: boolean;
  59165. subdivisions?: number;
  59166. sideOrientation?: number;
  59167. frontUVs?: Vector4;
  59168. backUVs?: Vector4;
  59169. updatable?: boolean;
  59170. }, scene?: Nullable<Scene>): Mesh;
  59171. }
  59172. }
  59173. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  59174. import { Vector3 } from "babylonjs/Maths/math.vector";
  59175. import { Mesh } from "babylonjs/Meshes/mesh";
  59176. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59177. /**
  59178. * Class containing static functions to help procedurally build meshes
  59179. */
  59180. export class DecalBuilder {
  59181. /**
  59182. * Creates a decal mesh.
  59183. * 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
  59184. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  59185. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  59186. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  59187. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  59188. * @param name defines the name of the mesh
  59189. * @param sourceMesh defines the mesh where the decal must be applied
  59190. * @param options defines the options used to create the mesh
  59191. * @param scene defines the hosting scene
  59192. * @returns the decal mesh
  59193. * @see https://doc.babylonjs.com/how_to/decals
  59194. */
  59195. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  59196. position?: Vector3;
  59197. normal?: Vector3;
  59198. size?: Vector3;
  59199. angle?: number;
  59200. }): Mesh;
  59201. }
  59202. }
  59203. declare module "babylonjs/Meshes/meshBuilder" {
  59204. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  59205. import { Nullable } from "babylonjs/types";
  59206. import { Scene } from "babylonjs/scene";
  59207. import { Mesh } from "babylonjs/Meshes/mesh";
  59208. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  59209. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  59210. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59211. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  59212. import { Plane } from "babylonjs/Maths/math.plane";
  59213. /**
  59214. * Class containing static functions to help procedurally build meshes
  59215. */
  59216. export class MeshBuilder {
  59217. /**
  59218. * Creates a box mesh
  59219. * * The parameter `size` sets the size (float) of each box side (default 1)
  59220. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  59221. * * 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)
  59222. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59223. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59224. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59225. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59226. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  59227. * @param name defines the name of the mesh
  59228. * @param options defines the options used to create the mesh
  59229. * @param scene defines the hosting scene
  59230. * @returns the box mesh
  59231. */
  59232. static CreateBox(name: string, options: {
  59233. size?: number;
  59234. width?: number;
  59235. height?: number;
  59236. depth?: number;
  59237. faceUV?: Vector4[];
  59238. faceColors?: Color4[];
  59239. sideOrientation?: number;
  59240. frontUVs?: Vector4;
  59241. backUVs?: Vector4;
  59242. updatable?: boolean;
  59243. }, scene?: Nullable<Scene>): Mesh;
  59244. /**
  59245. * Creates a tiled box mesh
  59246. * * faceTiles sets the pattern, tile size and number of tiles for a face
  59247. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59248. * @param name defines the name of the mesh
  59249. * @param options defines the options used to create the mesh
  59250. * @param scene defines the hosting scene
  59251. * @returns the tiled box mesh
  59252. */
  59253. static CreateTiledBox(name: string, options: {
  59254. pattern?: number;
  59255. size?: number;
  59256. width?: number;
  59257. height?: number;
  59258. depth: number;
  59259. tileSize?: number;
  59260. tileWidth?: number;
  59261. tileHeight?: number;
  59262. faceUV?: Vector4[];
  59263. faceColors?: Color4[];
  59264. alignHorizontal?: number;
  59265. alignVertical?: number;
  59266. sideOrientation?: number;
  59267. updatable?: boolean;
  59268. }, scene?: Nullable<Scene>): Mesh;
  59269. /**
  59270. * Creates a sphere mesh
  59271. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  59272. * * 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`)
  59273. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  59274. * * 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
  59275. * * 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)
  59276. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59277. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59278. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59279. * @param name defines the name of the mesh
  59280. * @param options defines the options used to create the mesh
  59281. * @param scene defines the hosting scene
  59282. * @returns the sphere mesh
  59283. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  59284. */
  59285. static CreateSphere(name: string, options: {
  59286. segments?: number;
  59287. diameter?: number;
  59288. diameterX?: number;
  59289. diameterY?: number;
  59290. diameterZ?: number;
  59291. arc?: number;
  59292. slice?: number;
  59293. sideOrientation?: number;
  59294. frontUVs?: Vector4;
  59295. backUVs?: Vector4;
  59296. updatable?: boolean;
  59297. }, scene?: Nullable<Scene>): Mesh;
  59298. /**
  59299. * Creates a plane polygonal mesh. By default, this is a disc
  59300. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  59301. * * 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
  59302. * * 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
  59303. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59304. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59305. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59306. * @param name defines the name of the mesh
  59307. * @param options defines the options used to create the mesh
  59308. * @param scene defines the hosting scene
  59309. * @returns the plane polygonal mesh
  59310. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  59311. */
  59312. static CreateDisc(name: string, options: {
  59313. radius?: number;
  59314. tessellation?: number;
  59315. arc?: number;
  59316. updatable?: boolean;
  59317. sideOrientation?: number;
  59318. frontUVs?: Vector4;
  59319. backUVs?: Vector4;
  59320. }, scene?: Nullable<Scene>): Mesh;
  59321. /**
  59322. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  59323. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  59324. * * 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`)
  59325. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  59326. * * 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
  59327. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59328. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59329. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59330. * @param name defines the name of the mesh
  59331. * @param options defines the options used to create the mesh
  59332. * @param scene defines the hosting scene
  59333. * @returns the icosahedron mesh
  59334. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  59335. */
  59336. static CreateIcoSphere(name: string, options: {
  59337. radius?: number;
  59338. radiusX?: number;
  59339. radiusY?: number;
  59340. radiusZ?: number;
  59341. flat?: boolean;
  59342. subdivisions?: number;
  59343. sideOrientation?: number;
  59344. frontUVs?: Vector4;
  59345. backUVs?: Vector4;
  59346. updatable?: boolean;
  59347. }, scene?: Nullable<Scene>): Mesh;
  59348. /**
  59349. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59350. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  59351. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  59352. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  59353. * * 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
  59354. * * 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
  59355. * * 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
  59356. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59357. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59358. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59359. * * 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
  59360. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  59361. * * 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
  59362. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  59363. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59364. * @param name defines the name of the mesh
  59365. * @param options defines the options used to create the mesh
  59366. * @param scene defines the hosting scene
  59367. * @returns the ribbon mesh
  59368. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  59369. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59370. */
  59371. static CreateRibbon(name: string, options: {
  59372. pathArray: Vector3[][];
  59373. closeArray?: boolean;
  59374. closePath?: boolean;
  59375. offset?: number;
  59376. updatable?: boolean;
  59377. sideOrientation?: number;
  59378. frontUVs?: Vector4;
  59379. backUVs?: Vector4;
  59380. instance?: Mesh;
  59381. invertUV?: boolean;
  59382. uvs?: Vector2[];
  59383. colors?: Color4[];
  59384. }, scene?: Nullable<Scene>): Mesh;
  59385. /**
  59386. * Creates a cylinder or a cone mesh
  59387. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  59388. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  59389. * * 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.
  59390. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  59391. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  59392. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  59393. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  59394. * * 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).
  59395. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  59396. * * 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).
  59397. * * 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
  59398. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  59399. * * 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
  59400. * * 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.
  59401. * * If `enclose` is false, a ring surface is one element.
  59402. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  59403. * * 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
  59404. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59405. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59406. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59407. * @param name defines the name of the mesh
  59408. * @param options defines the options used to create the mesh
  59409. * @param scene defines the hosting scene
  59410. * @returns the cylinder mesh
  59411. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  59412. */
  59413. static CreateCylinder(name: string, options: {
  59414. height?: number;
  59415. diameterTop?: number;
  59416. diameterBottom?: number;
  59417. diameter?: number;
  59418. tessellation?: number;
  59419. subdivisions?: number;
  59420. arc?: number;
  59421. faceColors?: Color4[];
  59422. faceUV?: Vector4[];
  59423. updatable?: boolean;
  59424. hasRings?: boolean;
  59425. enclose?: boolean;
  59426. cap?: number;
  59427. sideOrientation?: number;
  59428. frontUVs?: Vector4;
  59429. backUVs?: Vector4;
  59430. }, scene?: Nullable<Scene>): Mesh;
  59431. /**
  59432. * Creates a torus mesh
  59433. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  59434. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  59435. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  59436. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59437. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59438. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59439. * @param name defines the name of the mesh
  59440. * @param options defines the options used to create the mesh
  59441. * @param scene defines the hosting scene
  59442. * @returns the torus mesh
  59443. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  59444. */
  59445. static CreateTorus(name: string, options: {
  59446. diameter?: number;
  59447. thickness?: number;
  59448. tessellation?: number;
  59449. updatable?: boolean;
  59450. sideOrientation?: number;
  59451. frontUVs?: Vector4;
  59452. backUVs?: Vector4;
  59453. }, scene?: Nullable<Scene>): Mesh;
  59454. /**
  59455. * Creates a torus knot mesh
  59456. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  59457. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  59458. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  59459. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  59460. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59461. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59462. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59463. * @param name defines the name of the mesh
  59464. * @param options defines the options used to create the mesh
  59465. * @param scene defines the hosting scene
  59466. * @returns the torus knot mesh
  59467. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  59468. */
  59469. static CreateTorusKnot(name: string, options: {
  59470. radius?: number;
  59471. tube?: number;
  59472. radialSegments?: number;
  59473. tubularSegments?: number;
  59474. p?: number;
  59475. q?: number;
  59476. updatable?: boolean;
  59477. sideOrientation?: number;
  59478. frontUVs?: Vector4;
  59479. backUVs?: Vector4;
  59480. }, scene?: Nullable<Scene>): Mesh;
  59481. /**
  59482. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  59483. * * 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
  59484. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  59485. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  59486. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  59487. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  59488. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  59489. * * 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
  59490. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  59491. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59492. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  59493. * @param name defines the name of the new line system
  59494. * @param options defines the options used to create the line system
  59495. * @param scene defines the hosting scene
  59496. * @returns a new line system mesh
  59497. */
  59498. static CreateLineSystem(name: string, options: {
  59499. lines: Vector3[][];
  59500. updatable?: boolean;
  59501. instance?: Nullable<LinesMesh>;
  59502. colors?: Nullable<Color4[][]>;
  59503. useVertexAlpha?: boolean;
  59504. }, scene: Nullable<Scene>): LinesMesh;
  59505. /**
  59506. * Creates a line mesh
  59507. * 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
  59508. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  59509. * * The parameter `points` is an array successive Vector3
  59510. * * 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
  59511. * * The optional parameter `colors` is an array of successive Color4, one per line point
  59512. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  59513. * * When updating an instance, remember that only point positions can change, not the number of points
  59514. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59515. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  59516. * @param name defines the name of the new line system
  59517. * @param options defines the options used to create the line system
  59518. * @param scene defines the hosting scene
  59519. * @returns a new line mesh
  59520. */
  59521. static CreateLines(name: string, options: {
  59522. points: Vector3[];
  59523. updatable?: boolean;
  59524. instance?: Nullable<LinesMesh>;
  59525. colors?: Color4[];
  59526. useVertexAlpha?: boolean;
  59527. }, scene?: Nullable<Scene>): LinesMesh;
  59528. /**
  59529. * Creates a dashed line mesh
  59530. * * 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
  59531. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  59532. * * The parameter `points` is an array successive Vector3
  59533. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  59534. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  59535. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  59536. * * 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
  59537. * * When updating an instance, remember that only point positions can change, not the number of points
  59538. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59539. * @param name defines the name of the mesh
  59540. * @param options defines the options used to create the mesh
  59541. * @param scene defines the hosting scene
  59542. * @returns the dashed line mesh
  59543. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  59544. */
  59545. static CreateDashedLines(name: string, options: {
  59546. points: Vector3[];
  59547. dashSize?: number;
  59548. gapSize?: number;
  59549. dashNb?: number;
  59550. updatable?: boolean;
  59551. instance?: LinesMesh;
  59552. }, scene?: Nullable<Scene>): LinesMesh;
  59553. /**
  59554. * 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.
  59555. * * 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.
  59556. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59557. * * 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.
  59558. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  59559. * * 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
  59560. * * 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
  59561. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  59562. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59563. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59564. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  59565. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59566. * @param name defines the name of the mesh
  59567. * @param options defines the options used to create the mesh
  59568. * @param scene defines the hosting scene
  59569. * @returns the extruded shape mesh
  59570. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59571. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59572. */
  59573. static ExtrudeShape(name: string, options: {
  59574. shape: Vector3[];
  59575. path: Vector3[];
  59576. scale?: number;
  59577. rotation?: number;
  59578. cap?: number;
  59579. updatable?: boolean;
  59580. sideOrientation?: number;
  59581. frontUVs?: Vector4;
  59582. backUVs?: Vector4;
  59583. instance?: Mesh;
  59584. invertUV?: boolean;
  59585. }, scene?: Nullable<Scene>): Mesh;
  59586. /**
  59587. * Creates an custom extruded shape mesh.
  59588. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  59589. * * 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.
  59590. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59591. * * 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
  59592. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  59593. * * 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
  59594. * * It must returns a float value that will be the scale value applied to the shape on each path point
  59595. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  59596. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  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 custom extruded shape mesh
  59608. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  59609. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59610. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59611. */
  59612. static ExtrudeShapeCustom(name: string, options: {
  59613. shape: Vector3[];
  59614. path: Vector3[];
  59615. scaleFunction?: any;
  59616. rotationFunction?: any;
  59617. ribbonCloseArray?: boolean;
  59618. ribbonClosePath?: boolean;
  59619. cap?: number;
  59620. updatable?: boolean;
  59621. sideOrientation?: number;
  59622. frontUVs?: Vector4;
  59623. backUVs?: Vector4;
  59624. instance?: Mesh;
  59625. invertUV?: boolean;
  59626. }, scene?: Nullable<Scene>): Mesh;
  59627. /**
  59628. * Creates lathe mesh.
  59629. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  59630. * * 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
  59631. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  59632. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  59633. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  59634. * * 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
  59635. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  59636. * * 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
  59637. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59638. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59639. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59640. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59641. * @param name defines the name of the mesh
  59642. * @param options defines the options used to create the mesh
  59643. * @param scene defines the hosting scene
  59644. * @returns the lathe mesh
  59645. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  59646. */
  59647. static CreateLathe(name: string, options: {
  59648. shape: Vector3[];
  59649. radius?: number;
  59650. tessellation?: number;
  59651. clip?: number;
  59652. arc?: number;
  59653. closed?: boolean;
  59654. updatable?: boolean;
  59655. sideOrientation?: number;
  59656. frontUVs?: Vector4;
  59657. backUVs?: Vector4;
  59658. cap?: number;
  59659. invertUV?: boolean;
  59660. }, scene?: Nullable<Scene>): Mesh;
  59661. /**
  59662. * Creates a tiled plane mesh
  59663. * * You can set a limited pattern arrangement with the tiles
  59664. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59665. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59666. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59667. * @param name defines the name of the mesh
  59668. * @param options defines the options used to create the mesh
  59669. * @param scene defines the hosting scene
  59670. * @returns the plane mesh
  59671. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  59672. */
  59673. static CreateTiledPlane(name: string, options: {
  59674. pattern?: number;
  59675. tileSize?: number;
  59676. tileWidth?: number;
  59677. tileHeight?: number;
  59678. size?: number;
  59679. width?: number;
  59680. height?: number;
  59681. alignHorizontal?: number;
  59682. alignVertical?: number;
  59683. sideOrientation?: number;
  59684. frontUVs?: Vector4;
  59685. backUVs?: Vector4;
  59686. updatable?: boolean;
  59687. }, scene?: Nullable<Scene>): Mesh;
  59688. /**
  59689. * Creates a plane mesh
  59690. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  59691. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  59692. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  59693. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59694. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59695. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59696. * @param name defines the name of the mesh
  59697. * @param options defines the options used to create the mesh
  59698. * @param scene defines the hosting scene
  59699. * @returns the plane mesh
  59700. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  59701. */
  59702. static CreatePlane(name: string, options: {
  59703. size?: number;
  59704. width?: number;
  59705. height?: number;
  59706. sideOrientation?: number;
  59707. frontUVs?: Vector4;
  59708. backUVs?: Vector4;
  59709. updatable?: boolean;
  59710. sourcePlane?: Plane;
  59711. }, scene?: Nullable<Scene>): Mesh;
  59712. /**
  59713. * Creates a ground mesh
  59714. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  59715. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  59716. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59717. * @param name defines the name of the mesh
  59718. * @param options defines the options used to create the mesh
  59719. * @param scene defines the hosting scene
  59720. * @returns the ground mesh
  59721. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  59722. */
  59723. static CreateGround(name: string, options: {
  59724. width?: number;
  59725. height?: number;
  59726. subdivisions?: number;
  59727. subdivisionsX?: number;
  59728. subdivisionsY?: number;
  59729. updatable?: boolean;
  59730. }, scene?: Nullable<Scene>): Mesh;
  59731. /**
  59732. * Creates a tiled ground mesh
  59733. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  59734. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  59735. * * 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
  59736. * * 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
  59737. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59738. * @param name defines the name of the mesh
  59739. * @param options defines the options used to create the mesh
  59740. * @param scene defines the hosting scene
  59741. * @returns the tiled ground mesh
  59742. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  59743. */
  59744. static CreateTiledGround(name: string, options: {
  59745. xmin: number;
  59746. zmin: number;
  59747. xmax: number;
  59748. zmax: number;
  59749. subdivisions?: {
  59750. w: number;
  59751. h: number;
  59752. };
  59753. precision?: {
  59754. w: number;
  59755. h: number;
  59756. };
  59757. updatable?: boolean;
  59758. }, scene?: Nullable<Scene>): Mesh;
  59759. /**
  59760. * Creates a ground mesh from a height map
  59761. * * The parameter `url` sets the URL of the height map image resource.
  59762. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  59763. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  59764. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  59765. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  59766. * * 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.
  59767. * * 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).
  59768. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  59769. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59770. * @param name defines the name of the mesh
  59771. * @param url defines the url to the height map
  59772. * @param options defines the options used to create the mesh
  59773. * @param scene defines the hosting scene
  59774. * @returns the ground mesh
  59775. * @see https://doc.babylonjs.com/babylon101/height_map
  59776. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  59777. */
  59778. static CreateGroundFromHeightMap(name: string, url: string, options: {
  59779. width?: number;
  59780. height?: number;
  59781. subdivisions?: number;
  59782. minHeight?: number;
  59783. maxHeight?: number;
  59784. colorFilter?: Color3;
  59785. alphaFilter?: number;
  59786. updatable?: boolean;
  59787. onReady?: (mesh: GroundMesh) => void;
  59788. }, scene?: Nullable<Scene>): GroundMesh;
  59789. /**
  59790. * Creates a polygon mesh
  59791. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  59792. * * 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
  59793. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59794. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59795. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  59796. * * Remember you can only change the shape positions, not their number when updating a polygon
  59797. * @param name defines the name of the mesh
  59798. * @param options defines the options used to create the mesh
  59799. * @param scene defines the hosting scene
  59800. * @param earcutInjection can be used to inject your own earcut reference
  59801. * @returns the polygon mesh
  59802. */
  59803. static CreatePolygon(name: string, options: {
  59804. shape: Vector3[];
  59805. holes?: Vector3[][];
  59806. depth?: number;
  59807. faceUV?: Vector4[];
  59808. faceColors?: Color4[];
  59809. updatable?: boolean;
  59810. sideOrientation?: number;
  59811. frontUVs?: Vector4;
  59812. backUVs?: Vector4;
  59813. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59814. /**
  59815. * Creates an extruded polygon mesh, with depth in the Y direction.
  59816. * * 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)
  59817. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59818. * @param name defines the name of the mesh
  59819. * @param options defines the options used to create the mesh
  59820. * @param scene defines the hosting scene
  59821. * @param earcutInjection can be used to inject your own earcut reference
  59822. * @returns the polygon mesh
  59823. */
  59824. static ExtrudePolygon(name: string, options: {
  59825. shape: Vector3[];
  59826. holes?: Vector3[][];
  59827. depth?: number;
  59828. faceUV?: Vector4[];
  59829. faceColors?: Color4[];
  59830. updatable?: boolean;
  59831. sideOrientation?: number;
  59832. frontUVs?: Vector4;
  59833. backUVs?: Vector4;
  59834. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59835. /**
  59836. * Creates a tube mesh.
  59837. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59838. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  59839. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  59840. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  59841. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  59842. * * 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)
  59843. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  59844. * * 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
  59845. * * 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
  59846. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59847. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59848. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59849. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59850. * @param name defines the name of the mesh
  59851. * @param options defines the options used to create the mesh
  59852. * @param scene defines the hosting scene
  59853. * @returns the tube mesh
  59854. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59855. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  59856. */
  59857. static CreateTube(name: string, options: {
  59858. path: Vector3[];
  59859. radius?: number;
  59860. tessellation?: number;
  59861. radiusFunction?: {
  59862. (i: number, distance: number): number;
  59863. };
  59864. cap?: number;
  59865. arc?: number;
  59866. updatable?: boolean;
  59867. sideOrientation?: number;
  59868. frontUVs?: Vector4;
  59869. backUVs?: Vector4;
  59870. instance?: Mesh;
  59871. invertUV?: boolean;
  59872. }, scene?: Nullable<Scene>): Mesh;
  59873. /**
  59874. * Creates a polyhedron mesh
  59875. * * 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
  59876. * * The parameter `size` (positive float, default 1) sets the polygon size
  59877. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  59878. * * 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`
  59879. * * 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
  59880. * * 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)`)
  59881. * * 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
  59882. * * 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
  59883. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59884. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59885. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59886. * @param name defines the name of the mesh
  59887. * @param options defines the options used to create the mesh
  59888. * @param scene defines the hosting scene
  59889. * @returns the polyhedron mesh
  59890. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  59891. */
  59892. static CreatePolyhedron(name: string, options: {
  59893. type?: number;
  59894. size?: number;
  59895. sizeX?: number;
  59896. sizeY?: number;
  59897. sizeZ?: number;
  59898. custom?: any;
  59899. faceUV?: Vector4[];
  59900. faceColors?: Color4[];
  59901. flat?: boolean;
  59902. updatable?: boolean;
  59903. sideOrientation?: number;
  59904. frontUVs?: Vector4;
  59905. backUVs?: Vector4;
  59906. }, scene?: Nullable<Scene>): Mesh;
  59907. /**
  59908. * Creates a decal mesh.
  59909. * 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
  59910. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  59911. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  59912. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  59913. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  59914. * @param name defines the name of the mesh
  59915. * @param sourceMesh defines the mesh where the decal must be applied
  59916. * @param options defines the options used to create the mesh
  59917. * @param scene defines the hosting scene
  59918. * @returns the decal mesh
  59919. * @see https://doc.babylonjs.com/how_to/decals
  59920. */
  59921. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  59922. position?: Vector3;
  59923. normal?: Vector3;
  59924. size?: Vector3;
  59925. angle?: number;
  59926. }): Mesh;
  59927. }
  59928. }
  59929. declare module "babylonjs/Meshes/meshSimplification" {
  59930. import { Mesh } from "babylonjs/Meshes/mesh";
  59931. /**
  59932. * A simplifier interface for future simplification implementations
  59933. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59934. */
  59935. export interface ISimplifier {
  59936. /**
  59937. * Simplification of a given mesh according to the given settings.
  59938. * Since this requires computation, it is assumed that the function runs async.
  59939. * @param settings The settings of the simplification, including quality and distance
  59940. * @param successCallback A callback that will be called after the mesh was simplified.
  59941. * @param errorCallback in case of an error, this callback will be called. optional.
  59942. */
  59943. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  59944. }
  59945. /**
  59946. * Expected simplification settings.
  59947. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  59948. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59949. */
  59950. export interface ISimplificationSettings {
  59951. /**
  59952. * Gets or sets the expected quality
  59953. */
  59954. quality: number;
  59955. /**
  59956. * Gets or sets the distance when this optimized version should be used
  59957. */
  59958. distance: number;
  59959. /**
  59960. * Gets an already optimized mesh
  59961. */
  59962. optimizeMesh?: boolean;
  59963. }
  59964. /**
  59965. * Class used to specify simplification options
  59966. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59967. */
  59968. export class SimplificationSettings implements ISimplificationSettings {
  59969. /** expected quality */
  59970. quality: number;
  59971. /** distance when this optimized version should be used */
  59972. distance: number;
  59973. /** already optimized mesh */
  59974. optimizeMesh?: boolean | undefined;
  59975. /**
  59976. * Creates a SimplificationSettings
  59977. * @param quality expected quality
  59978. * @param distance distance when this optimized version should be used
  59979. * @param optimizeMesh already optimized mesh
  59980. */
  59981. constructor(
  59982. /** expected quality */
  59983. quality: number,
  59984. /** distance when this optimized version should be used */
  59985. distance: number,
  59986. /** already optimized mesh */
  59987. optimizeMesh?: boolean | undefined);
  59988. }
  59989. /**
  59990. * Interface used to define a simplification task
  59991. */
  59992. export interface ISimplificationTask {
  59993. /**
  59994. * Array of settings
  59995. */
  59996. settings: Array<ISimplificationSettings>;
  59997. /**
  59998. * Simplification type
  59999. */
  60000. simplificationType: SimplificationType;
  60001. /**
  60002. * Mesh to simplify
  60003. */
  60004. mesh: Mesh;
  60005. /**
  60006. * Callback called on success
  60007. */
  60008. successCallback?: () => void;
  60009. /**
  60010. * Defines if parallel processing can be used
  60011. */
  60012. parallelProcessing: boolean;
  60013. }
  60014. /**
  60015. * Queue used to order the simplification tasks
  60016. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60017. */
  60018. export class SimplificationQueue {
  60019. private _simplificationArray;
  60020. /**
  60021. * Gets a boolean indicating that the process is still running
  60022. */
  60023. running: boolean;
  60024. /**
  60025. * Creates a new queue
  60026. */
  60027. constructor();
  60028. /**
  60029. * Adds a new simplification task
  60030. * @param task defines a task to add
  60031. */
  60032. addTask(task: ISimplificationTask): void;
  60033. /**
  60034. * Execute next task
  60035. */
  60036. executeNext(): void;
  60037. /**
  60038. * Execute a simplification task
  60039. * @param task defines the task to run
  60040. */
  60041. runSimplification(task: ISimplificationTask): void;
  60042. private getSimplifier;
  60043. }
  60044. /**
  60045. * The implemented types of simplification
  60046. * At the moment only Quadratic Error Decimation is implemented
  60047. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60048. */
  60049. export enum SimplificationType {
  60050. /** Quadratic error decimation */
  60051. QUADRATIC = 0
  60052. }
  60053. }
  60054. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  60055. import { Scene } from "babylonjs/scene";
  60056. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  60057. import { ISceneComponent } from "babylonjs/sceneComponent";
  60058. module "babylonjs/scene" {
  60059. interface Scene {
  60060. /** @hidden (Backing field) */
  60061. _simplificationQueue: SimplificationQueue;
  60062. /**
  60063. * Gets or sets the simplification queue attached to the scene
  60064. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60065. */
  60066. simplificationQueue: SimplificationQueue;
  60067. }
  60068. }
  60069. module "babylonjs/Meshes/mesh" {
  60070. interface Mesh {
  60071. /**
  60072. * Simplify the mesh according to the given array of settings.
  60073. * Function will return immediately and will simplify async
  60074. * @param settings a collection of simplification settings
  60075. * @param parallelProcessing should all levels calculate parallel or one after the other
  60076. * @param simplificationType the type of simplification to run
  60077. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  60078. * @returns the current mesh
  60079. */
  60080. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  60081. }
  60082. }
  60083. /**
  60084. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  60085. * created in a scene
  60086. */
  60087. export class SimplicationQueueSceneComponent implements ISceneComponent {
  60088. /**
  60089. * The component name helpfull to identify the component in the list of scene components.
  60090. */
  60091. readonly name: string;
  60092. /**
  60093. * The scene the component belongs to.
  60094. */
  60095. scene: Scene;
  60096. /**
  60097. * Creates a new instance of the component for the given scene
  60098. * @param scene Defines the scene to register the component in
  60099. */
  60100. constructor(scene: Scene);
  60101. /**
  60102. * Registers the component in a given scene
  60103. */
  60104. register(): void;
  60105. /**
  60106. * Rebuilds the elements related to this component in case of
  60107. * context lost for instance.
  60108. */
  60109. rebuild(): void;
  60110. /**
  60111. * Disposes the component and the associated ressources
  60112. */
  60113. dispose(): void;
  60114. private _beforeCameraUpdate;
  60115. }
  60116. }
  60117. declare module "babylonjs/Meshes/Builders/index" {
  60118. export * from "babylonjs/Meshes/Builders/boxBuilder";
  60119. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  60120. export * from "babylonjs/Meshes/Builders/discBuilder";
  60121. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  60122. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  60123. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  60124. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  60125. export * from "babylonjs/Meshes/Builders/torusBuilder";
  60126. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  60127. export * from "babylonjs/Meshes/Builders/linesBuilder";
  60128. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  60129. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  60130. export * from "babylonjs/Meshes/Builders/latheBuilder";
  60131. export * from "babylonjs/Meshes/Builders/planeBuilder";
  60132. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  60133. export * from "babylonjs/Meshes/Builders/groundBuilder";
  60134. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  60135. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  60136. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  60137. export * from "babylonjs/Meshes/Builders/decalBuilder";
  60138. }
  60139. declare module "babylonjs/Meshes/index" {
  60140. export * from "babylonjs/Meshes/abstractMesh";
  60141. export * from "babylonjs/Meshes/buffer";
  60142. export * from "babylonjs/Meshes/Compression/index";
  60143. export * from "babylonjs/Meshes/csg";
  60144. export * from "babylonjs/Meshes/geometry";
  60145. export * from "babylonjs/Meshes/groundMesh";
  60146. export * from "babylonjs/Meshes/trailMesh";
  60147. export * from "babylonjs/Meshes/instancedMesh";
  60148. export * from "babylonjs/Meshes/linesMesh";
  60149. export * from "babylonjs/Meshes/mesh";
  60150. export * from "babylonjs/Meshes/mesh.vertexData";
  60151. export * from "babylonjs/Meshes/meshBuilder";
  60152. export * from "babylonjs/Meshes/meshSimplification";
  60153. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  60154. export * from "babylonjs/Meshes/polygonMesh";
  60155. export * from "babylonjs/Meshes/subMesh";
  60156. export * from "babylonjs/Meshes/meshLODLevel";
  60157. export * from "babylonjs/Meshes/transformNode";
  60158. export * from "babylonjs/Meshes/Builders/index";
  60159. export * from "babylonjs/Meshes/dataBuffer";
  60160. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  60161. }
  60162. declare module "babylonjs/Morph/index" {
  60163. export * from "babylonjs/Morph/morphTarget";
  60164. export * from "babylonjs/Morph/morphTargetManager";
  60165. }
  60166. declare module "babylonjs/Navigation/INavigationEngine" {
  60167. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60168. import { Vector3 } from "babylonjs/Maths/math";
  60169. import { Mesh } from "babylonjs/Meshes/mesh";
  60170. import { Scene } from "babylonjs/scene";
  60171. /**
  60172. * Navigation plugin interface to add navigation constrained by a navigation mesh
  60173. */
  60174. export interface INavigationEnginePlugin {
  60175. /**
  60176. * plugin name
  60177. */
  60178. name: string;
  60179. /**
  60180. * Creates a navigation mesh
  60181. * @param meshes array of all the geometry used to compute the navigatio mesh
  60182. * @param parameters bunch of parameters used to filter geometry
  60183. */
  60184. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  60185. /**
  60186. * Create a navigation mesh debug mesh
  60187. * @param scene is where the mesh will be added
  60188. * @returns debug display mesh
  60189. */
  60190. createDebugNavMesh(scene: Scene): Mesh;
  60191. /**
  60192. * Get a navigation mesh constrained position, closest to the parameter position
  60193. * @param position world position
  60194. * @returns the closest point to position constrained by the navigation mesh
  60195. */
  60196. getClosestPoint(position: Vector3): Vector3;
  60197. /**
  60198. * Get a navigation mesh constrained position, within a particular radius
  60199. * @param position world position
  60200. * @param maxRadius the maximum distance to the constrained world position
  60201. * @returns the closest point to position constrained by the navigation mesh
  60202. */
  60203. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  60204. /**
  60205. * Compute the final position from a segment made of destination-position
  60206. * @param position world position
  60207. * @param destination world position
  60208. * @returns the resulting point along the navmesh
  60209. */
  60210. moveAlong(position: Vector3, destination: Vector3): Vector3;
  60211. /**
  60212. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  60213. * @param start world position
  60214. * @param end world position
  60215. * @returns array containing world position composing the path
  60216. */
  60217. computePath(start: Vector3, end: Vector3): Vector3[];
  60218. /**
  60219. * If this plugin is supported
  60220. * @returns true if plugin is supported
  60221. */
  60222. isSupported(): boolean;
  60223. /**
  60224. * Create a new Crowd so you can add agents
  60225. * @param maxAgents the maximum agent count in the crowd
  60226. * @param maxAgentRadius the maximum radius an agent can have
  60227. * @param scene to attach the crowd to
  60228. * @returns the crowd you can add agents to
  60229. */
  60230. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  60231. /**
  60232. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60233. * The queries will try to find a solution within those bounds
  60234. * default is (1,1,1)
  60235. * @param extent x,y,z value that define the extent around the queries point of reference
  60236. */
  60237. setDefaultQueryExtent(extent: Vector3): void;
  60238. /**
  60239. * Get the Bounding box extent specified by setDefaultQueryExtent
  60240. * @returns the box extent values
  60241. */
  60242. getDefaultQueryExtent(): Vector3;
  60243. /**
  60244. * Release all resources
  60245. */
  60246. dispose(): void;
  60247. }
  60248. /**
  60249. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  60250. */
  60251. export interface ICrowd {
  60252. /**
  60253. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  60254. * You can attach anything to that node. The node position is updated in the scene update tick.
  60255. * @param pos world position that will be constrained by the navigation mesh
  60256. * @param parameters agent parameters
  60257. * @param transform hooked to the agent that will be update by the scene
  60258. * @returns agent index
  60259. */
  60260. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  60261. /**
  60262. * Returns the agent position in world space
  60263. * @param index agent index returned by addAgent
  60264. * @returns world space position
  60265. */
  60266. getAgentPosition(index: number): Vector3;
  60267. /**
  60268. * Gets the agent velocity in world space
  60269. * @param index agent index returned by addAgent
  60270. * @returns world space velocity
  60271. */
  60272. getAgentVelocity(index: number): Vector3;
  60273. /**
  60274. * remove a particular agent previously created
  60275. * @param index agent index returned by addAgent
  60276. */
  60277. removeAgent(index: number): void;
  60278. /**
  60279. * get the list of all agents attached to this crowd
  60280. * @returns list of agent indices
  60281. */
  60282. getAgents(): number[];
  60283. /**
  60284. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  60285. * @param deltaTime in seconds
  60286. */
  60287. update(deltaTime: number): void;
  60288. /**
  60289. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  60290. * @param index agent index returned by addAgent
  60291. * @param destination targeted world position
  60292. */
  60293. agentGoto(index: number, destination: Vector3): void;
  60294. /**
  60295. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60296. * The queries will try to find a solution within those bounds
  60297. * default is (1,1,1)
  60298. * @param extent x,y,z value that define the extent around the queries point of reference
  60299. */
  60300. setDefaultQueryExtent(extent: Vector3): void;
  60301. /**
  60302. * Get the Bounding box extent specified by setDefaultQueryExtent
  60303. * @returns the box extent values
  60304. */
  60305. getDefaultQueryExtent(): Vector3;
  60306. /**
  60307. * Release all resources
  60308. */
  60309. dispose(): void;
  60310. }
  60311. /**
  60312. * Configures an agent
  60313. */
  60314. export interface IAgentParameters {
  60315. /**
  60316. * Agent radius. [Limit: >= 0]
  60317. */
  60318. radius: number;
  60319. /**
  60320. * Agent height. [Limit: > 0]
  60321. */
  60322. height: number;
  60323. /**
  60324. * Maximum allowed acceleration. [Limit: >= 0]
  60325. */
  60326. maxAcceleration: number;
  60327. /**
  60328. * Maximum allowed speed. [Limit: >= 0]
  60329. */
  60330. maxSpeed: number;
  60331. /**
  60332. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  60333. */
  60334. collisionQueryRange: number;
  60335. /**
  60336. * The path visibility optimization range. [Limit: > 0]
  60337. */
  60338. pathOptimizationRange: number;
  60339. /**
  60340. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  60341. */
  60342. separationWeight: number;
  60343. }
  60344. /**
  60345. * Configures the navigation mesh creation
  60346. */
  60347. export interface INavMeshParameters {
  60348. /**
  60349. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  60350. */
  60351. cs: number;
  60352. /**
  60353. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  60354. */
  60355. ch: number;
  60356. /**
  60357. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  60358. */
  60359. walkableSlopeAngle: number;
  60360. /**
  60361. * Minimum floor to 'ceiling' height that will still allow the floor area to
  60362. * be considered walkable. [Limit: >= 3] [Units: vx]
  60363. */
  60364. walkableHeight: number;
  60365. /**
  60366. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  60367. */
  60368. walkableClimb: number;
  60369. /**
  60370. * The distance to erode/shrink the walkable area of the heightfield away from
  60371. * obstructions. [Limit: >=0] [Units: vx]
  60372. */
  60373. walkableRadius: number;
  60374. /**
  60375. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  60376. */
  60377. maxEdgeLen: number;
  60378. /**
  60379. * The maximum distance a simplfied contour's border edges should deviate
  60380. * the original raw contour. [Limit: >=0] [Units: vx]
  60381. */
  60382. maxSimplificationError: number;
  60383. /**
  60384. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  60385. */
  60386. minRegionArea: number;
  60387. /**
  60388. * Any regions with a span count smaller than this value will, if possible,
  60389. * be merged with larger regions. [Limit: >=0] [Units: vx]
  60390. */
  60391. mergeRegionArea: number;
  60392. /**
  60393. * The maximum number of vertices allowed for polygons generated during the
  60394. * contour to polygon conversion process. [Limit: >= 3]
  60395. */
  60396. maxVertsPerPoly: number;
  60397. /**
  60398. * Sets the sampling distance to use when generating the detail mesh.
  60399. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  60400. */
  60401. detailSampleDist: number;
  60402. /**
  60403. * The maximum distance the detail mesh surface should deviate from heightfield
  60404. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  60405. */
  60406. detailSampleMaxError: number;
  60407. }
  60408. }
  60409. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  60410. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  60411. import { Mesh } from "babylonjs/Meshes/mesh";
  60412. import { Scene } from "babylonjs/scene";
  60413. import { Vector3 } from "babylonjs/Maths/math";
  60414. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60415. /**
  60416. * RecastJS navigation plugin
  60417. */
  60418. export class RecastJSPlugin implements INavigationEnginePlugin {
  60419. /**
  60420. * Reference to the Recast library
  60421. */
  60422. bjsRECAST: any;
  60423. /**
  60424. * plugin name
  60425. */
  60426. name: string;
  60427. /**
  60428. * the first navmesh created. We might extend this to support multiple navmeshes
  60429. */
  60430. navMesh: any;
  60431. /**
  60432. * Initializes the recastJS plugin
  60433. * @param recastInjection can be used to inject your own recast reference
  60434. */
  60435. constructor(recastInjection?: any);
  60436. /**
  60437. * Creates a navigation mesh
  60438. * @param meshes array of all the geometry used to compute the navigatio mesh
  60439. * @param parameters bunch of parameters used to filter geometry
  60440. */
  60441. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  60442. /**
  60443. * Create a navigation mesh debug mesh
  60444. * @param scene is where the mesh will be added
  60445. * @returns debug display mesh
  60446. */
  60447. createDebugNavMesh(scene: Scene): Mesh;
  60448. /**
  60449. * Get a navigation mesh constrained position, closest to the parameter position
  60450. * @param position world position
  60451. * @returns the closest point to position constrained by the navigation mesh
  60452. */
  60453. getClosestPoint(position: Vector3): Vector3;
  60454. /**
  60455. * Get a navigation mesh constrained position, within a particular radius
  60456. * @param position world position
  60457. * @param maxRadius the maximum distance to the constrained world position
  60458. * @returns the closest point to position constrained by the navigation mesh
  60459. */
  60460. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  60461. /**
  60462. * Compute the final position from a segment made of destination-position
  60463. * @param position world position
  60464. * @param destination world position
  60465. * @returns the resulting point along the navmesh
  60466. */
  60467. moveAlong(position: Vector3, destination: Vector3): Vector3;
  60468. /**
  60469. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  60470. * @param start world position
  60471. * @param end world position
  60472. * @returns array containing world position composing the path
  60473. */
  60474. computePath(start: Vector3, end: Vector3): Vector3[];
  60475. /**
  60476. * Create a new Crowd so you can add agents
  60477. * @param maxAgents the maximum agent count in the crowd
  60478. * @param maxAgentRadius the maximum radius an agent can have
  60479. * @param scene to attach the crowd to
  60480. * @returns the crowd you can add agents to
  60481. */
  60482. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  60483. /**
  60484. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60485. * The queries will try to find a solution within those bounds
  60486. * default is (1,1,1)
  60487. * @param extent x,y,z value that define the extent around the queries point of reference
  60488. */
  60489. setDefaultQueryExtent(extent: Vector3): void;
  60490. /**
  60491. * Get the Bounding box extent specified by setDefaultQueryExtent
  60492. * @returns the box extent values
  60493. */
  60494. getDefaultQueryExtent(): Vector3;
  60495. /**
  60496. * Disposes
  60497. */
  60498. dispose(): void;
  60499. /**
  60500. * If this plugin is supported
  60501. * @returns true if plugin is supported
  60502. */
  60503. isSupported(): boolean;
  60504. }
  60505. /**
  60506. * Recast detour crowd implementation
  60507. */
  60508. export class RecastJSCrowd implements ICrowd {
  60509. /**
  60510. * Recast/detour plugin
  60511. */
  60512. bjsRECASTPlugin: RecastJSPlugin;
  60513. /**
  60514. * Link to the detour crowd
  60515. */
  60516. recastCrowd: any;
  60517. /**
  60518. * One transform per agent
  60519. */
  60520. transforms: TransformNode[];
  60521. /**
  60522. * All agents created
  60523. */
  60524. agents: number[];
  60525. /**
  60526. * Link to the scene is kept to unregister the crowd from the scene
  60527. */
  60528. private _scene;
  60529. /**
  60530. * Observer for crowd updates
  60531. */
  60532. private _onBeforeAnimationsObserver;
  60533. /**
  60534. * Constructor
  60535. * @param plugin recastJS plugin
  60536. * @param maxAgents the maximum agent count in the crowd
  60537. * @param maxAgentRadius the maximum radius an agent can have
  60538. * @param scene to attach the crowd to
  60539. * @returns the crowd you can add agents to
  60540. */
  60541. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  60542. /**
  60543. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  60544. * You can attach anything to that node. The node position is updated in the scene update tick.
  60545. * @param pos world position that will be constrained by the navigation mesh
  60546. * @param parameters agent parameters
  60547. * @param transform hooked to the agent that will be update by the scene
  60548. * @returns agent index
  60549. */
  60550. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  60551. /**
  60552. * Returns the agent position in world space
  60553. * @param index agent index returned by addAgent
  60554. * @returns world space position
  60555. */
  60556. getAgentPosition(index: number): Vector3;
  60557. /**
  60558. * Returns the agent velocity in world space
  60559. * @param index agent index returned by addAgent
  60560. * @returns world space velocity
  60561. */
  60562. getAgentVelocity(index: number): Vector3;
  60563. /**
  60564. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  60565. * @param index agent index returned by addAgent
  60566. * @param destination targeted world position
  60567. */
  60568. agentGoto(index: number, destination: Vector3): void;
  60569. /**
  60570. * remove a particular agent previously created
  60571. * @param index agent index returned by addAgent
  60572. */
  60573. removeAgent(index: number): void;
  60574. /**
  60575. * get the list of all agents attached to this crowd
  60576. * @returns list of agent indices
  60577. */
  60578. getAgents(): number[];
  60579. /**
  60580. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  60581. * @param deltaTime in seconds
  60582. */
  60583. update(deltaTime: number): void;
  60584. /**
  60585. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60586. * The queries will try to find a solution within those bounds
  60587. * default is (1,1,1)
  60588. * @param extent x,y,z value that define the extent around the queries point of reference
  60589. */
  60590. setDefaultQueryExtent(extent: Vector3): void;
  60591. /**
  60592. * Get the Bounding box extent specified by setDefaultQueryExtent
  60593. * @returns the box extent values
  60594. */
  60595. getDefaultQueryExtent(): Vector3;
  60596. /**
  60597. * Release all resources
  60598. */
  60599. dispose(): void;
  60600. }
  60601. }
  60602. declare module "babylonjs/Navigation/Plugins/index" {
  60603. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  60604. }
  60605. declare module "babylonjs/Navigation/index" {
  60606. export * from "babylonjs/Navigation/INavigationEngine";
  60607. export * from "babylonjs/Navigation/Plugins/index";
  60608. }
  60609. declare module "babylonjs/Offline/database" {
  60610. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  60611. /**
  60612. * Class used to enable access to IndexedDB
  60613. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  60614. */
  60615. export class Database implements IOfflineProvider {
  60616. private _callbackManifestChecked;
  60617. private _currentSceneUrl;
  60618. private _db;
  60619. private _enableSceneOffline;
  60620. private _enableTexturesOffline;
  60621. private _manifestVersionFound;
  60622. private _mustUpdateRessources;
  60623. private _hasReachedQuota;
  60624. private _isSupported;
  60625. private _idbFactory;
  60626. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  60627. private static IsUASupportingBlobStorage;
  60628. /**
  60629. * Gets a boolean indicating if Database storate is enabled (off by default)
  60630. */
  60631. static IDBStorageEnabled: boolean;
  60632. /**
  60633. * Gets a boolean indicating if scene must be saved in the database
  60634. */
  60635. readonly enableSceneOffline: boolean;
  60636. /**
  60637. * Gets a boolean indicating if textures must be saved in the database
  60638. */
  60639. readonly enableTexturesOffline: boolean;
  60640. /**
  60641. * Creates a new Database
  60642. * @param urlToScene defines the url to load the scene
  60643. * @param callbackManifestChecked defines the callback to use when manifest is checked
  60644. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  60645. */
  60646. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  60647. private static _ParseURL;
  60648. private static _ReturnFullUrlLocation;
  60649. private _checkManifestFile;
  60650. /**
  60651. * Open the database and make it available
  60652. * @param successCallback defines the callback to call on success
  60653. * @param errorCallback defines the callback to call on error
  60654. */
  60655. open(successCallback: () => void, errorCallback: () => void): void;
  60656. /**
  60657. * Loads an image from the database
  60658. * @param url defines the url to load from
  60659. * @param image defines the target DOM image
  60660. */
  60661. loadImage(url: string, image: HTMLImageElement): void;
  60662. private _loadImageFromDBAsync;
  60663. private _saveImageIntoDBAsync;
  60664. private _checkVersionFromDB;
  60665. private _loadVersionFromDBAsync;
  60666. private _saveVersionIntoDBAsync;
  60667. /**
  60668. * Loads a file from database
  60669. * @param url defines the URL to load from
  60670. * @param sceneLoaded defines a callback to call on success
  60671. * @param progressCallBack defines a callback to call when progress changed
  60672. * @param errorCallback defines a callback to call on error
  60673. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  60674. */
  60675. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  60676. private _loadFileAsync;
  60677. private _saveFileAsync;
  60678. /**
  60679. * Validates if xhr data is correct
  60680. * @param xhr defines the request to validate
  60681. * @param dataType defines the expected data type
  60682. * @returns true if data is correct
  60683. */
  60684. private static _ValidateXHRData;
  60685. }
  60686. }
  60687. declare module "babylonjs/Offline/index" {
  60688. export * from "babylonjs/Offline/database";
  60689. export * from "babylonjs/Offline/IOfflineProvider";
  60690. }
  60691. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  60692. /** @hidden */
  60693. export var gpuUpdateParticlesPixelShader: {
  60694. name: string;
  60695. shader: string;
  60696. };
  60697. }
  60698. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  60699. /** @hidden */
  60700. export var gpuUpdateParticlesVertexShader: {
  60701. name: string;
  60702. shader: string;
  60703. };
  60704. }
  60705. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  60706. /** @hidden */
  60707. export var clipPlaneFragmentDeclaration2: {
  60708. name: string;
  60709. shader: string;
  60710. };
  60711. }
  60712. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  60713. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  60714. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  60715. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60716. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  60717. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  60718. /** @hidden */
  60719. export var gpuRenderParticlesPixelShader: {
  60720. name: string;
  60721. shader: string;
  60722. };
  60723. }
  60724. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  60725. /** @hidden */
  60726. export var clipPlaneVertexDeclaration2: {
  60727. name: string;
  60728. shader: string;
  60729. };
  60730. }
  60731. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  60732. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  60733. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  60734. /** @hidden */
  60735. export var gpuRenderParticlesVertexShader: {
  60736. name: string;
  60737. shader: string;
  60738. };
  60739. }
  60740. declare module "babylonjs/Particles/gpuParticleSystem" {
  60741. import { Nullable } from "babylonjs/types";
  60742. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  60743. import { Observable } from "babylonjs/Misc/observable";
  60744. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  60745. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  60746. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  60747. import { Scene, IDisposable } from "babylonjs/scene";
  60748. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  60749. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  60750. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  60751. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  60752. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  60753. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  60754. /**
  60755. * This represents a GPU particle system in Babylon
  60756. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  60757. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  60758. */
  60759. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  60760. /**
  60761. * The layer mask we are rendering the particles through.
  60762. */
  60763. layerMask: number;
  60764. private _capacity;
  60765. private _activeCount;
  60766. private _currentActiveCount;
  60767. private _accumulatedCount;
  60768. private _renderEffect;
  60769. private _updateEffect;
  60770. private _buffer0;
  60771. private _buffer1;
  60772. private _spriteBuffer;
  60773. private _updateVAO;
  60774. private _renderVAO;
  60775. private _targetIndex;
  60776. private _sourceBuffer;
  60777. private _targetBuffer;
  60778. private _engine;
  60779. private _currentRenderId;
  60780. private _started;
  60781. private _stopped;
  60782. private _timeDelta;
  60783. private _randomTexture;
  60784. private _randomTexture2;
  60785. private _attributesStrideSize;
  60786. private _updateEffectOptions;
  60787. private _randomTextureSize;
  60788. private _actualFrame;
  60789. private readonly _rawTextureWidth;
  60790. /**
  60791. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  60792. */
  60793. static readonly IsSupported: boolean;
  60794. /**
  60795. * An event triggered when the system is disposed.
  60796. */
  60797. onDisposeObservable: Observable<GPUParticleSystem>;
  60798. /**
  60799. * Gets the maximum number of particles active at the same time.
  60800. * @returns The max number of active particles.
  60801. */
  60802. getCapacity(): number;
  60803. /**
  60804. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  60805. * to override the particles.
  60806. */
  60807. forceDepthWrite: boolean;
  60808. /**
  60809. * Gets or set the number of active particles
  60810. */
  60811. activeParticleCount: number;
  60812. private _preWarmDone;
  60813. /**
  60814. * Is this system ready to be used/rendered
  60815. * @return true if the system is ready
  60816. */
  60817. isReady(): boolean;
  60818. /**
  60819. * Gets if the system has been started. (Note: this will still be true after stop is called)
  60820. * @returns True if it has been started, otherwise false.
  60821. */
  60822. isStarted(): boolean;
  60823. /**
  60824. * Starts the particle system and begins to emit
  60825. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  60826. */
  60827. start(delay?: number): void;
  60828. /**
  60829. * Stops the particle system.
  60830. */
  60831. stop(): void;
  60832. /**
  60833. * Remove all active particles
  60834. */
  60835. reset(): void;
  60836. /**
  60837. * Returns the string "GPUParticleSystem"
  60838. * @returns a string containing the class name
  60839. */
  60840. getClassName(): string;
  60841. private _colorGradientsTexture;
  60842. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  60843. /**
  60844. * Adds a new color gradient
  60845. * @param gradient defines the gradient to use (between 0 and 1)
  60846. * @param color1 defines the color to affect to the specified gradient
  60847. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  60848. * @returns the current particle system
  60849. */
  60850. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  60851. /**
  60852. * Remove a specific color gradient
  60853. * @param gradient defines the gradient to remove
  60854. * @returns the current particle system
  60855. */
  60856. removeColorGradient(gradient: number): GPUParticleSystem;
  60857. private _angularSpeedGradientsTexture;
  60858. private _sizeGradientsTexture;
  60859. private _velocityGradientsTexture;
  60860. private _limitVelocityGradientsTexture;
  60861. private _dragGradientsTexture;
  60862. private _addFactorGradient;
  60863. /**
  60864. * Adds a new size gradient
  60865. * @param gradient defines the gradient to use (between 0 and 1)
  60866. * @param factor defines the size factor to affect to the specified gradient
  60867. * @returns the current particle system
  60868. */
  60869. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  60870. /**
  60871. * Remove a specific size gradient
  60872. * @param gradient defines the gradient to remove
  60873. * @returns the current particle system
  60874. */
  60875. removeSizeGradient(gradient: number): GPUParticleSystem;
  60876. /**
  60877. * Adds a new angular speed gradient
  60878. * @param gradient defines the gradient to use (between 0 and 1)
  60879. * @param factor defines the angular speed to affect to the specified gradient
  60880. * @returns the current particle system
  60881. */
  60882. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  60883. /**
  60884. * Remove a specific angular speed gradient
  60885. * @param gradient defines the gradient to remove
  60886. * @returns the current particle system
  60887. */
  60888. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  60889. /**
  60890. * Adds a new velocity gradient
  60891. * @param gradient defines the gradient to use (between 0 and 1)
  60892. * @param factor defines the velocity to affect to the specified gradient
  60893. * @returns the current particle system
  60894. */
  60895. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  60896. /**
  60897. * Remove a specific velocity gradient
  60898. * @param gradient defines the gradient to remove
  60899. * @returns the current particle system
  60900. */
  60901. removeVelocityGradient(gradient: number): GPUParticleSystem;
  60902. /**
  60903. * Adds a new limit velocity gradient
  60904. * @param gradient defines the gradient to use (between 0 and 1)
  60905. * @param factor defines the limit velocity value to affect to the specified gradient
  60906. * @returns the current particle system
  60907. */
  60908. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  60909. /**
  60910. * Remove a specific limit velocity gradient
  60911. * @param gradient defines the gradient to remove
  60912. * @returns the current particle system
  60913. */
  60914. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  60915. /**
  60916. * Adds a new drag gradient
  60917. * @param gradient defines the gradient to use (between 0 and 1)
  60918. * @param factor defines the drag value to affect to the specified gradient
  60919. * @returns the current particle system
  60920. */
  60921. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  60922. /**
  60923. * Remove a specific drag gradient
  60924. * @param gradient defines the gradient to remove
  60925. * @returns the current particle system
  60926. */
  60927. removeDragGradient(gradient: number): GPUParticleSystem;
  60928. /**
  60929. * Not supported by GPUParticleSystem
  60930. * @param gradient defines the gradient to use (between 0 and 1)
  60931. * @param factor defines the emit rate value to affect to the specified gradient
  60932. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  60933. * @returns the current particle system
  60934. */
  60935. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  60936. /**
  60937. * Not supported by GPUParticleSystem
  60938. * @param gradient defines the gradient to remove
  60939. * @returns the current particle system
  60940. */
  60941. removeEmitRateGradient(gradient: number): IParticleSystem;
  60942. /**
  60943. * Not supported by GPUParticleSystem
  60944. * @param gradient defines the gradient to use (between 0 and 1)
  60945. * @param factor defines the start size value to affect to the specified gradient
  60946. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  60947. * @returns the current particle system
  60948. */
  60949. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  60950. /**
  60951. * Not supported by GPUParticleSystem
  60952. * @param gradient defines the gradient to remove
  60953. * @returns the current particle system
  60954. */
  60955. removeStartSizeGradient(gradient: number): IParticleSystem;
  60956. /**
  60957. * Not supported by GPUParticleSystem
  60958. * @param gradient defines the gradient to use (between 0 and 1)
  60959. * @param min defines the color remap minimal range
  60960. * @param max defines the color remap maximal range
  60961. * @returns the current particle system
  60962. */
  60963. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  60964. /**
  60965. * Not supported by GPUParticleSystem
  60966. * @param gradient defines the gradient to remove
  60967. * @returns the current particle system
  60968. */
  60969. removeColorRemapGradient(): IParticleSystem;
  60970. /**
  60971. * Not supported by GPUParticleSystem
  60972. * @param gradient defines the gradient to use (between 0 and 1)
  60973. * @param min defines the alpha remap minimal range
  60974. * @param max defines the alpha remap maximal range
  60975. * @returns the current particle system
  60976. */
  60977. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  60978. /**
  60979. * Not supported by GPUParticleSystem
  60980. * @param gradient defines the gradient to remove
  60981. * @returns the current particle system
  60982. */
  60983. removeAlphaRemapGradient(): IParticleSystem;
  60984. /**
  60985. * Not supported by GPUParticleSystem
  60986. * @param gradient defines the gradient to use (between 0 and 1)
  60987. * @param color defines the color to affect to the specified gradient
  60988. * @returns the current particle system
  60989. */
  60990. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  60991. /**
  60992. * Not supported by GPUParticleSystem
  60993. * @param gradient defines the gradient to remove
  60994. * @returns the current particle system
  60995. */
  60996. removeRampGradient(): IParticleSystem;
  60997. /**
  60998. * Not supported by GPUParticleSystem
  60999. * @returns the list of ramp gradients
  61000. */
  61001. getRampGradients(): Nullable<Array<Color3Gradient>>;
  61002. /**
  61003. * Not supported by GPUParticleSystem
  61004. * Gets or sets a boolean indicating that ramp gradients must be used
  61005. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  61006. */
  61007. useRampGradients: boolean;
  61008. /**
  61009. * Not supported by GPUParticleSystem
  61010. * @param gradient defines the gradient to use (between 0 and 1)
  61011. * @param factor defines the life time factor to affect to the specified gradient
  61012. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  61013. * @returns the current particle system
  61014. */
  61015. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  61016. /**
  61017. * Not supported by GPUParticleSystem
  61018. * @param gradient defines the gradient to remove
  61019. * @returns the current particle system
  61020. */
  61021. removeLifeTimeGradient(gradient: number): IParticleSystem;
  61022. /**
  61023. * Instantiates a GPU particle system.
  61024. * 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.
  61025. * @param name The name of the particle system
  61026. * @param options The options used to create the system
  61027. * @param scene The scene the particle system belongs to
  61028. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  61029. */
  61030. constructor(name: string, options: Partial<{
  61031. capacity: number;
  61032. randomTextureSize: number;
  61033. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  61034. protected _reset(): void;
  61035. private _createUpdateVAO;
  61036. private _createRenderVAO;
  61037. private _initialize;
  61038. /** @hidden */
  61039. _recreateUpdateEffect(): void;
  61040. /** @hidden */
  61041. _recreateRenderEffect(): void;
  61042. /**
  61043. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  61044. * @param preWarm defines if we are in the pre-warmimg phase
  61045. */
  61046. animate(preWarm?: boolean): void;
  61047. private _createFactorGradientTexture;
  61048. private _createSizeGradientTexture;
  61049. private _createAngularSpeedGradientTexture;
  61050. private _createVelocityGradientTexture;
  61051. private _createLimitVelocityGradientTexture;
  61052. private _createDragGradientTexture;
  61053. private _createColorGradientTexture;
  61054. /**
  61055. * Renders the particle system in its current state
  61056. * @param preWarm defines if the system should only update the particles but not render them
  61057. * @returns the current number of particles
  61058. */
  61059. render(preWarm?: boolean): number;
  61060. /**
  61061. * Rebuilds the particle system
  61062. */
  61063. rebuild(): void;
  61064. private _releaseBuffers;
  61065. private _releaseVAOs;
  61066. /**
  61067. * Disposes the particle system and free the associated resources
  61068. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  61069. */
  61070. dispose(disposeTexture?: boolean): void;
  61071. /**
  61072. * Clones the particle system.
  61073. * @param name The name of the cloned object
  61074. * @param newEmitter The new emitter to use
  61075. * @returns the cloned particle system
  61076. */
  61077. clone(name: string, newEmitter: any): GPUParticleSystem;
  61078. /**
  61079. * Serializes the particle system to a JSON object.
  61080. * @returns the JSON object
  61081. */
  61082. serialize(): any;
  61083. /**
  61084. * Parses a JSON object to create a GPU particle system.
  61085. * @param parsedParticleSystem The JSON object to parse
  61086. * @param scene The scene to create the particle system in
  61087. * @param rootUrl The root url to use to load external dependencies like texture
  61088. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  61089. * @returns the parsed GPU particle system
  61090. */
  61091. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  61092. }
  61093. }
  61094. declare module "babylonjs/Particles/particleSystemSet" {
  61095. import { Nullable } from "babylonjs/types";
  61096. import { Color3 } from "babylonjs/Maths/math.color";
  61097. import { TransformNode } from "babylonjs/Meshes/transformNode";
  61098. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61099. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61100. import { Scene, IDisposable } from "babylonjs/scene";
  61101. /**
  61102. * Represents a set of particle systems working together to create a specific effect
  61103. */
  61104. export class ParticleSystemSet implements IDisposable {
  61105. private _emitterCreationOptions;
  61106. private _emitterNode;
  61107. /**
  61108. * Gets the particle system list
  61109. */
  61110. systems: IParticleSystem[];
  61111. /**
  61112. * Gets the emitter node used with this set
  61113. */
  61114. readonly emitterNode: Nullable<TransformNode>;
  61115. /**
  61116. * Creates a new emitter mesh as a sphere
  61117. * @param options defines the options used to create the sphere
  61118. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  61119. * @param scene defines the hosting scene
  61120. */
  61121. setEmitterAsSphere(options: {
  61122. diameter: number;
  61123. segments: number;
  61124. color: Color3;
  61125. }, renderingGroupId: number, scene: Scene): void;
  61126. /**
  61127. * Starts all particle systems of the set
  61128. * @param emitter defines an optional mesh to use as emitter for the particle systems
  61129. */
  61130. start(emitter?: AbstractMesh): void;
  61131. /**
  61132. * Release all associated resources
  61133. */
  61134. dispose(): void;
  61135. /**
  61136. * Serialize the set into a JSON compatible object
  61137. * @returns a JSON compatible representation of the set
  61138. */
  61139. serialize(): any;
  61140. /**
  61141. * Parse a new ParticleSystemSet from a serialized source
  61142. * @param data defines a JSON compatible representation of the set
  61143. * @param scene defines the hosting scene
  61144. * @param gpu defines if we want GPU particles or CPU particles
  61145. * @returns a new ParticleSystemSet
  61146. */
  61147. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  61148. }
  61149. }
  61150. declare module "babylonjs/Particles/particleHelper" {
  61151. import { Nullable } from "babylonjs/types";
  61152. import { Scene } from "babylonjs/scene";
  61153. import { Vector3 } from "babylonjs/Maths/math.vector";
  61154. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61155. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61156. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  61157. /**
  61158. * This class is made for on one-liner static method to help creating particle system set.
  61159. */
  61160. export class ParticleHelper {
  61161. /**
  61162. * Gets or sets base Assets URL
  61163. */
  61164. static BaseAssetsUrl: string;
  61165. /**
  61166. * Create a default particle system that you can tweak
  61167. * @param emitter defines the emitter to use
  61168. * @param capacity defines the system capacity (default is 500 particles)
  61169. * @param scene defines the hosting scene
  61170. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  61171. * @returns the new Particle system
  61172. */
  61173. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  61174. /**
  61175. * This is the main static method (one-liner) of this helper to create different particle systems
  61176. * @param type This string represents the type to the particle system to create
  61177. * @param scene The scene where the particle system should live
  61178. * @param gpu If the system will use gpu
  61179. * @returns the ParticleSystemSet created
  61180. */
  61181. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  61182. /**
  61183. * Static function used to export a particle system to a ParticleSystemSet variable.
  61184. * Please note that the emitter shape is not exported
  61185. * @param systems defines the particle systems to export
  61186. * @returns the created particle system set
  61187. */
  61188. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  61189. }
  61190. }
  61191. declare module "babylonjs/Particles/particleSystemComponent" {
  61192. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61193. import { Effect } from "babylonjs/Materials/effect";
  61194. import "babylonjs/Shaders/particles.vertex";
  61195. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  61196. module "babylonjs/Engines/engine" {
  61197. interface Engine {
  61198. /**
  61199. * Create an effect to use with particle systems.
  61200. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  61201. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  61202. * @param uniformsNames defines a list of attribute names
  61203. * @param samplers defines an array of string used to represent textures
  61204. * @param defines defines the string containing the defines to use to compile the shaders
  61205. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  61206. * @param onCompiled defines a function to call when the effect creation is successful
  61207. * @param onError defines a function to call when the effect creation has failed
  61208. * @returns the new Effect
  61209. */
  61210. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  61211. }
  61212. }
  61213. module "babylonjs/Meshes/mesh" {
  61214. interface Mesh {
  61215. /**
  61216. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  61217. * @returns an array of IParticleSystem
  61218. */
  61219. getEmittedParticleSystems(): IParticleSystem[];
  61220. /**
  61221. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  61222. * @returns an array of IParticleSystem
  61223. */
  61224. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  61225. }
  61226. }
  61227. /**
  61228. * @hidden
  61229. */
  61230. export var _IDoNeedToBeInTheBuild: number;
  61231. }
  61232. declare module "babylonjs/Particles/index" {
  61233. export * from "babylonjs/Particles/baseParticleSystem";
  61234. export * from "babylonjs/Particles/EmitterTypes/index";
  61235. export * from "babylonjs/Particles/gpuParticleSystem";
  61236. export * from "babylonjs/Particles/IParticleSystem";
  61237. export * from "babylonjs/Particles/particle";
  61238. export * from "babylonjs/Particles/particleHelper";
  61239. export * from "babylonjs/Particles/particleSystem";
  61240. export * from "babylonjs/Particles/particleSystemComponent";
  61241. export * from "babylonjs/Particles/particleSystemSet";
  61242. export * from "babylonjs/Particles/solidParticle";
  61243. export * from "babylonjs/Particles/solidParticleSystem";
  61244. export * from "babylonjs/Particles/subEmitter";
  61245. }
  61246. declare module "babylonjs/Physics/physicsEngineComponent" {
  61247. import { Nullable } from "babylonjs/types";
  61248. import { Observable, Observer } from "babylonjs/Misc/observable";
  61249. import { Vector3 } from "babylonjs/Maths/math.vector";
  61250. import { Mesh } from "babylonjs/Meshes/mesh";
  61251. import { ISceneComponent } from "babylonjs/sceneComponent";
  61252. import { Scene } from "babylonjs/scene";
  61253. import { Node } from "babylonjs/node";
  61254. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  61255. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  61256. module "babylonjs/scene" {
  61257. interface Scene {
  61258. /** @hidden (Backing field) */
  61259. _physicsEngine: Nullable<IPhysicsEngine>;
  61260. /**
  61261. * Gets the current physics engine
  61262. * @returns a IPhysicsEngine or null if none attached
  61263. */
  61264. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  61265. /**
  61266. * Enables physics to the current scene
  61267. * @param gravity defines the scene's gravity for the physics engine
  61268. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  61269. * @return a boolean indicating if the physics engine was initialized
  61270. */
  61271. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  61272. /**
  61273. * Disables and disposes the physics engine associated with the scene
  61274. */
  61275. disablePhysicsEngine(): void;
  61276. /**
  61277. * Gets a boolean indicating if there is an active physics engine
  61278. * @returns a boolean indicating if there is an active physics engine
  61279. */
  61280. isPhysicsEnabled(): boolean;
  61281. /**
  61282. * Deletes a physics compound impostor
  61283. * @param compound defines the compound to delete
  61284. */
  61285. deleteCompoundImpostor(compound: any): void;
  61286. /**
  61287. * An event triggered when physic simulation is about to be run
  61288. */
  61289. onBeforePhysicsObservable: Observable<Scene>;
  61290. /**
  61291. * An event triggered when physic simulation has been done
  61292. */
  61293. onAfterPhysicsObservable: Observable<Scene>;
  61294. }
  61295. }
  61296. module "babylonjs/Meshes/abstractMesh" {
  61297. interface AbstractMesh {
  61298. /** @hidden */
  61299. _physicsImpostor: Nullable<PhysicsImpostor>;
  61300. /**
  61301. * Gets or sets impostor used for physic simulation
  61302. * @see http://doc.babylonjs.com/features/physics_engine
  61303. */
  61304. physicsImpostor: Nullable<PhysicsImpostor>;
  61305. /**
  61306. * Gets the current physics impostor
  61307. * @see http://doc.babylonjs.com/features/physics_engine
  61308. * @returns a physics impostor or null
  61309. */
  61310. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  61311. /** Apply a physic impulse to the mesh
  61312. * @param force defines the force to apply
  61313. * @param contactPoint defines where to apply the force
  61314. * @returns the current mesh
  61315. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  61316. */
  61317. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  61318. /**
  61319. * Creates a physic joint between two meshes
  61320. * @param otherMesh defines the other mesh to use
  61321. * @param pivot1 defines the pivot to use on this mesh
  61322. * @param pivot2 defines the pivot to use on the other mesh
  61323. * @param options defines additional options (can be plugin dependent)
  61324. * @returns the current mesh
  61325. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  61326. */
  61327. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  61328. /** @hidden */
  61329. _disposePhysicsObserver: Nullable<Observer<Node>>;
  61330. }
  61331. }
  61332. /**
  61333. * Defines the physics engine scene component responsible to manage a physics engine
  61334. */
  61335. export class PhysicsEngineSceneComponent implements ISceneComponent {
  61336. /**
  61337. * The component name helpful to identify the component in the list of scene components.
  61338. */
  61339. readonly name: string;
  61340. /**
  61341. * The scene the component belongs to.
  61342. */
  61343. scene: Scene;
  61344. /**
  61345. * Creates a new instance of the component for the given scene
  61346. * @param scene Defines the scene to register the component in
  61347. */
  61348. constructor(scene: Scene);
  61349. /**
  61350. * Registers the component in a given scene
  61351. */
  61352. register(): void;
  61353. /**
  61354. * Rebuilds the elements related to this component in case of
  61355. * context lost for instance.
  61356. */
  61357. rebuild(): void;
  61358. /**
  61359. * Disposes the component and the associated ressources
  61360. */
  61361. dispose(): void;
  61362. }
  61363. }
  61364. declare module "babylonjs/Physics/physicsHelper" {
  61365. import { Nullable } from "babylonjs/types";
  61366. import { Vector3 } from "babylonjs/Maths/math.vector";
  61367. import { Mesh } from "babylonjs/Meshes/mesh";
  61368. import { Scene } from "babylonjs/scene";
  61369. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  61370. /**
  61371. * A helper for physics simulations
  61372. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61373. */
  61374. export class PhysicsHelper {
  61375. private _scene;
  61376. private _physicsEngine;
  61377. /**
  61378. * Initializes the Physics helper
  61379. * @param scene Babylon.js scene
  61380. */
  61381. constructor(scene: Scene);
  61382. /**
  61383. * Applies a radial explosion impulse
  61384. * @param origin the origin of the explosion
  61385. * @param radiusOrEventOptions the radius or the options of radial explosion
  61386. * @param strength the explosion strength
  61387. * @param falloff possible options: Constant & Linear. Defaults to Constant
  61388. * @returns A physics radial explosion event, or null
  61389. */
  61390. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  61391. /**
  61392. * Applies a radial explosion force
  61393. * @param origin the origin of the explosion
  61394. * @param radiusOrEventOptions the radius or the options of radial explosion
  61395. * @param strength the explosion strength
  61396. * @param falloff possible options: Constant & Linear. Defaults to Constant
  61397. * @returns A physics radial explosion event, or null
  61398. */
  61399. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  61400. /**
  61401. * Creates a gravitational field
  61402. * @param origin the origin of the explosion
  61403. * @param radiusOrEventOptions the radius or the options of radial explosion
  61404. * @param strength the explosion strength
  61405. * @param falloff possible options: Constant & Linear. Defaults to Constant
  61406. * @returns A physics gravitational field event, or null
  61407. */
  61408. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  61409. /**
  61410. * Creates a physics updraft event
  61411. * @param origin the origin of the updraft
  61412. * @param radiusOrEventOptions the radius or the options of the updraft
  61413. * @param strength the strength of the updraft
  61414. * @param height the height of the updraft
  61415. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  61416. * @returns A physics updraft event, or null
  61417. */
  61418. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  61419. /**
  61420. * Creates a physics vortex event
  61421. * @param origin the of the vortex
  61422. * @param radiusOrEventOptions the radius or the options of the vortex
  61423. * @param strength the strength of the vortex
  61424. * @param height the height of the vortex
  61425. * @returns a Physics vortex event, or null
  61426. * A physics vortex event or null
  61427. */
  61428. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  61429. }
  61430. /**
  61431. * Represents a physics radial explosion event
  61432. */
  61433. class PhysicsRadialExplosionEvent {
  61434. private _scene;
  61435. private _options;
  61436. private _sphere;
  61437. private _dataFetched;
  61438. /**
  61439. * Initializes a radial explosioin event
  61440. * @param _scene BabylonJS scene
  61441. * @param _options The options for the vortex event
  61442. */
  61443. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  61444. /**
  61445. * Returns the data related to the radial explosion event (sphere).
  61446. * @returns The radial explosion event data
  61447. */
  61448. getData(): PhysicsRadialExplosionEventData;
  61449. /**
  61450. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  61451. * @param impostor A physics imposter
  61452. * @param origin the origin of the explosion
  61453. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  61454. */
  61455. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  61456. /**
  61457. * Triggers affecterd impostors callbacks
  61458. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  61459. */
  61460. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  61461. /**
  61462. * Disposes the sphere.
  61463. * @param force Specifies if the sphere should be disposed by force
  61464. */
  61465. dispose(force?: boolean): void;
  61466. /*** Helpers ***/
  61467. private _prepareSphere;
  61468. private _intersectsWithSphere;
  61469. }
  61470. /**
  61471. * Represents a gravitational field event
  61472. */
  61473. class PhysicsGravitationalFieldEvent {
  61474. private _physicsHelper;
  61475. private _scene;
  61476. private _origin;
  61477. private _options;
  61478. private _tickCallback;
  61479. private _sphere;
  61480. private _dataFetched;
  61481. /**
  61482. * Initializes the physics gravitational field event
  61483. * @param _physicsHelper A physics helper
  61484. * @param _scene BabylonJS scene
  61485. * @param _origin The origin position of the gravitational field event
  61486. * @param _options The options for the vortex event
  61487. */
  61488. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  61489. /**
  61490. * Returns the data related to the gravitational field event (sphere).
  61491. * @returns A gravitational field event
  61492. */
  61493. getData(): PhysicsGravitationalFieldEventData;
  61494. /**
  61495. * Enables the gravitational field.
  61496. */
  61497. enable(): void;
  61498. /**
  61499. * Disables the gravitational field.
  61500. */
  61501. disable(): void;
  61502. /**
  61503. * Disposes the sphere.
  61504. * @param force The force to dispose from the gravitational field event
  61505. */
  61506. dispose(force?: boolean): void;
  61507. private _tick;
  61508. }
  61509. /**
  61510. * Represents a physics updraft event
  61511. */
  61512. class PhysicsUpdraftEvent {
  61513. private _scene;
  61514. private _origin;
  61515. private _options;
  61516. private _physicsEngine;
  61517. private _originTop;
  61518. private _originDirection;
  61519. private _tickCallback;
  61520. private _cylinder;
  61521. private _cylinderPosition;
  61522. private _dataFetched;
  61523. /**
  61524. * Initializes the physics updraft event
  61525. * @param _scene BabylonJS scene
  61526. * @param _origin The origin position of the updraft
  61527. * @param _options The options for the updraft event
  61528. */
  61529. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  61530. /**
  61531. * Returns the data related to the updraft event (cylinder).
  61532. * @returns A physics updraft event
  61533. */
  61534. getData(): PhysicsUpdraftEventData;
  61535. /**
  61536. * Enables the updraft.
  61537. */
  61538. enable(): void;
  61539. /**
  61540. * Disables the updraft.
  61541. */
  61542. disable(): void;
  61543. /**
  61544. * Disposes the cylinder.
  61545. * @param force Specifies if the updraft should be disposed by force
  61546. */
  61547. dispose(force?: boolean): void;
  61548. private getImpostorHitData;
  61549. private _tick;
  61550. /*** Helpers ***/
  61551. private _prepareCylinder;
  61552. private _intersectsWithCylinder;
  61553. }
  61554. /**
  61555. * Represents a physics vortex event
  61556. */
  61557. class PhysicsVortexEvent {
  61558. private _scene;
  61559. private _origin;
  61560. private _options;
  61561. private _physicsEngine;
  61562. private _originTop;
  61563. private _tickCallback;
  61564. private _cylinder;
  61565. private _cylinderPosition;
  61566. private _dataFetched;
  61567. /**
  61568. * Initializes the physics vortex event
  61569. * @param _scene The BabylonJS scene
  61570. * @param _origin The origin position of the vortex
  61571. * @param _options The options for the vortex event
  61572. */
  61573. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  61574. /**
  61575. * Returns the data related to the vortex event (cylinder).
  61576. * @returns The physics vortex event data
  61577. */
  61578. getData(): PhysicsVortexEventData;
  61579. /**
  61580. * Enables the vortex.
  61581. */
  61582. enable(): void;
  61583. /**
  61584. * Disables the cortex.
  61585. */
  61586. disable(): void;
  61587. /**
  61588. * Disposes the sphere.
  61589. * @param force
  61590. */
  61591. dispose(force?: boolean): void;
  61592. private getImpostorHitData;
  61593. private _tick;
  61594. /*** Helpers ***/
  61595. private _prepareCylinder;
  61596. private _intersectsWithCylinder;
  61597. }
  61598. /**
  61599. * Options fot the radial explosion event
  61600. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61601. */
  61602. export class PhysicsRadialExplosionEventOptions {
  61603. /**
  61604. * The radius of the sphere for the radial explosion.
  61605. */
  61606. radius: number;
  61607. /**
  61608. * The strenth of the explosion.
  61609. */
  61610. strength: number;
  61611. /**
  61612. * The strenght of the force in correspondence to the distance of the affected object
  61613. */
  61614. falloff: PhysicsRadialImpulseFalloff;
  61615. /**
  61616. * Sphere options for the radial explosion.
  61617. */
  61618. sphere: {
  61619. segments: number;
  61620. diameter: number;
  61621. };
  61622. /**
  61623. * Sphere options for the radial explosion.
  61624. */
  61625. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  61626. }
  61627. /**
  61628. * Options fot the updraft event
  61629. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61630. */
  61631. export class PhysicsUpdraftEventOptions {
  61632. /**
  61633. * The radius of the cylinder for the vortex
  61634. */
  61635. radius: number;
  61636. /**
  61637. * The strenth of the updraft.
  61638. */
  61639. strength: number;
  61640. /**
  61641. * The height of the cylinder for the updraft.
  61642. */
  61643. height: number;
  61644. /**
  61645. * The mode for the the updraft.
  61646. */
  61647. updraftMode: PhysicsUpdraftMode;
  61648. }
  61649. /**
  61650. * Options fot the vortex event
  61651. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61652. */
  61653. export class PhysicsVortexEventOptions {
  61654. /**
  61655. * The radius of the cylinder for the vortex
  61656. */
  61657. radius: number;
  61658. /**
  61659. * The strenth of the vortex.
  61660. */
  61661. strength: number;
  61662. /**
  61663. * The height of the cylinder for the vortex.
  61664. */
  61665. height: number;
  61666. /**
  61667. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  61668. */
  61669. centripetalForceThreshold: number;
  61670. /**
  61671. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  61672. */
  61673. centripetalForceMultiplier: number;
  61674. /**
  61675. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  61676. */
  61677. centrifugalForceMultiplier: number;
  61678. /**
  61679. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  61680. */
  61681. updraftForceMultiplier: number;
  61682. }
  61683. /**
  61684. * The strenght of the force in correspondence to the distance of the affected object
  61685. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61686. */
  61687. export enum PhysicsRadialImpulseFalloff {
  61688. /** Defines that impulse is constant in strength across it's whole radius */
  61689. Constant = 0,
  61690. /** Defines that impulse gets weaker if it's further from the origin */
  61691. Linear = 1
  61692. }
  61693. /**
  61694. * The strength of the force in correspondence to the distance of the affected object
  61695. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61696. */
  61697. export enum PhysicsUpdraftMode {
  61698. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  61699. Center = 0,
  61700. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  61701. Perpendicular = 1
  61702. }
  61703. /**
  61704. * Interface for a physics hit data
  61705. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61706. */
  61707. export interface PhysicsHitData {
  61708. /**
  61709. * The force applied at the contact point
  61710. */
  61711. force: Vector3;
  61712. /**
  61713. * The contact point
  61714. */
  61715. contactPoint: Vector3;
  61716. /**
  61717. * The distance from the origin to the contact point
  61718. */
  61719. distanceFromOrigin: number;
  61720. }
  61721. /**
  61722. * Interface for radial explosion event data
  61723. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61724. */
  61725. export interface PhysicsRadialExplosionEventData {
  61726. /**
  61727. * A sphere used for the radial explosion event
  61728. */
  61729. sphere: Mesh;
  61730. }
  61731. /**
  61732. * Interface for gravitational field event data
  61733. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61734. */
  61735. export interface PhysicsGravitationalFieldEventData {
  61736. /**
  61737. * A sphere mesh used for the gravitational field event
  61738. */
  61739. sphere: Mesh;
  61740. }
  61741. /**
  61742. * Interface for updraft event data
  61743. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61744. */
  61745. export interface PhysicsUpdraftEventData {
  61746. /**
  61747. * A cylinder used for the updraft event
  61748. */
  61749. cylinder: Mesh;
  61750. }
  61751. /**
  61752. * Interface for vortex event data
  61753. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61754. */
  61755. export interface PhysicsVortexEventData {
  61756. /**
  61757. * A cylinder used for the vortex event
  61758. */
  61759. cylinder: Mesh;
  61760. }
  61761. /**
  61762. * Interface for an affected physics impostor
  61763. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61764. */
  61765. export interface PhysicsAffectedImpostorWithData {
  61766. /**
  61767. * The impostor affected by the effect
  61768. */
  61769. impostor: PhysicsImpostor;
  61770. /**
  61771. * The data about the hit/horce from the explosion
  61772. */
  61773. hitData: PhysicsHitData;
  61774. }
  61775. }
  61776. declare module "babylonjs/Physics/Plugins/index" {
  61777. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  61778. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  61779. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  61780. }
  61781. declare module "babylonjs/Physics/index" {
  61782. export * from "babylonjs/Physics/IPhysicsEngine";
  61783. export * from "babylonjs/Physics/physicsEngine";
  61784. export * from "babylonjs/Physics/physicsEngineComponent";
  61785. export * from "babylonjs/Physics/physicsHelper";
  61786. export * from "babylonjs/Physics/physicsImpostor";
  61787. export * from "babylonjs/Physics/physicsJoint";
  61788. export * from "babylonjs/Physics/Plugins/index";
  61789. }
  61790. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  61791. /** @hidden */
  61792. export var blackAndWhitePixelShader: {
  61793. name: string;
  61794. shader: string;
  61795. };
  61796. }
  61797. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  61798. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61799. import { Camera } from "babylonjs/Cameras/camera";
  61800. import { Engine } from "babylonjs/Engines/engine";
  61801. import "babylonjs/Shaders/blackAndWhite.fragment";
  61802. /**
  61803. * Post process used to render in black and white
  61804. */
  61805. export class BlackAndWhitePostProcess extends PostProcess {
  61806. /**
  61807. * Linear about to convert he result to black and white (default: 1)
  61808. */
  61809. degree: number;
  61810. /**
  61811. * Creates a black and white post process
  61812. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  61813. * @param name The name of the effect.
  61814. * @param options The required width/height ratio to downsize to before computing the render pass.
  61815. * @param camera The camera to apply the render pass to.
  61816. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61817. * @param engine The engine which the post process will be applied. (default: current engine)
  61818. * @param reusable If the post process can be reused on the same frame. (default: false)
  61819. */
  61820. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61821. }
  61822. }
  61823. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  61824. import { Nullable } from "babylonjs/types";
  61825. import { Camera } from "babylonjs/Cameras/camera";
  61826. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61827. import { Engine } from "babylonjs/Engines/engine";
  61828. /**
  61829. * This represents a set of one or more post processes in Babylon.
  61830. * A post process can be used to apply a shader to a texture after it is rendered.
  61831. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  61832. */
  61833. export class PostProcessRenderEffect {
  61834. private _postProcesses;
  61835. private _getPostProcesses;
  61836. private _singleInstance;
  61837. private _cameras;
  61838. private _indicesForCamera;
  61839. /**
  61840. * Name of the effect
  61841. * @hidden
  61842. */
  61843. _name: string;
  61844. /**
  61845. * Instantiates a post process render effect.
  61846. * A post process can be used to apply a shader to a texture after it is rendered.
  61847. * @param engine The engine the effect is tied to
  61848. * @param name The name of the effect
  61849. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  61850. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  61851. */
  61852. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  61853. /**
  61854. * Checks if all the post processes in the effect are supported.
  61855. */
  61856. readonly isSupported: boolean;
  61857. /**
  61858. * Updates the current state of the effect
  61859. * @hidden
  61860. */
  61861. _update(): void;
  61862. /**
  61863. * Attaches the effect on cameras
  61864. * @param cameras The camera to attach to.
  61865. * @hidden
  61866. */
  61867. _attachCameras(cameras: Camera): void;
  61868. /**
  61869. * Attaches the effect on cameras
  61870. * @param cameras The camera to attach to.
  61871. * @hidden
  61872. */
  61873. _attachCameras(cameras: Camera[]): void;
  61874. /**
  61875. * Detaches the effect on cameras
  61876. * @param cameras The camera to detatch from.
  61877. * @hidden
  61878. */
  61879. _detachCameras(cameras: Camera): void;
  61880. /**
  61881. * Detatches the effect on cameras
  61882. * @param cameras The camera to detatch from.
  61883. * @hidden
  61884. */
  61885. _detachCameras(cameras: Camera[]): void;
  61886. /**
  61887. * Enables the effect on given cameras
  61888. * @param cameras The camera to enable.
  61889. * @hidden
  61890. */
  61891. _enable(cameras: Camera): void;
  61892. /**
  61893. * Enables the effect on given cameras
  61894. * @param cameras The camera to enable.
  61895. * @hidden
  61896. */
  61897. _enable(cameras: Nullable<Camera[]>): void;
  61898. /**
  61899. * Disables the effect on the given cameras
  61900. * @param cameras The camera to disable.
  61901. * @hidden
  61902. */
  61903. _disable(cameras: Camera): void;
  61904. /**
  61905. * Disables the effect on the given cameras
  61906. * @param cameras The camera to disable.
  61907. * @hidden
  61908. */
  61909. _disable(cameras: Nullable<Camera[]>): void;
  61910. /**
  61911. * Gets a list of the post processes contained in the effect.
  61912. * @param camera The camera to get the post processes on.
  61913. * @returns The list of the post processes in the effect.
  61914. */
  61915. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  61916. }
  61917. }
  61918. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  61919. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61920. /** @hidden */
  61921. export var extractHighlightsPixelShader: {
  61922. name: string;
  61923. shader: string;
  61924. };
  61925. }
  61926. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  61927. import { Nullable } from "babylonjs/types";
  61928. import { Camera } from "babylonjs/Cameras/camera";
  61929. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61930. import { Engine } from "babylonjs/Engines/engine";
  61931. import "babylonjs/Shaders/extractHighlights.fragment";
  61932. /**
  61933. * 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.
  61934. */
  61935. export class ExtractHighlightsPostProcess extends PostProcess {
  61936. /**
  61937. * The luminance threshold, pixels below this value will be set to black.
  61938. */
  61939. threshold: number;
  61940. /** @hidden */
  61941. _exposure: number;
  61942. /**
  61943. * Post process which has the input texture to be used when performing highlight extraction
  61944. * @hidden
  61945. */
  61946. _inputPostProcess: Nullable<PostProcess>;
  61947. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61948. }
  61949. }
  61950. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  61951. /** @hidden */
  61952. export var bloomMergePixelShader: {
  61953. name: string;
  61954. shader: string;
  61955. };
  61956. }
  61957. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  61958. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61959. import { Nullable } from "babylonjs/types";
  61960. import { Engine } from "babylonjs/Engines/engine";
  61961. import { Camera } from "babylonjs/Cameras/camera";
  61962. import "babylonjs/Shaders/bloomMerge.fragment";
  61963. /**
  61964. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  61965. */
  61966. export class BloomMergePostProcess extends PostProcess {
  61967. /** Weight of the bloom to be added to the original input. */
  61968. weight: number;
  61969. /**
  61970. * Creates a new instance of @see BloomMergePostProcess
  61971. * @param name The name of the effect.
  61972. * @param originalFromInput Post process which's input will be used for the merge.
  61973. * @param blurred Blurred highlights post process which's output will be used.
  61974. * @param weight Weight of the bloom to be added to the original input.
  61975. * @param options The required width/height ratio to downsize to before computing the render pass.
  61976. * @param camera The camera to apply the render pass to.
  61977. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61978. * @param engine The engine which the post process will be applied. (default: current engine)
  61979. * @param reusable If the post process can be reused on the same frame. (default: false)
  61980. * @param textureType Type of textures used when performing the post process. (default: 0)
  61981. * @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)
  61982. */
  61983. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  61984. /** Weight of the bloom to be added to the original input. */
  61985. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61986. }
  61987. }
  61988. declare module "babylonjs/PostProcesses/bloomEffect" {
  61989. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  61990. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61991. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  61992. import { Camera } from "babylonjs/Cameras/camera";
  61993. import { Scene } from "babylonjs/scene";
  61994. /**
  61995. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  61996. */
  61997. export class BloomEffect extends PostProcessRenderEffect {
  61998. private bloomScale;
  61999. /**
  62000. * @hidden Internal
  62001. */
  62002. _effects: Array<PostProcess>;
  62003. /**
  62004. * @hidden Internal
  62005. */
  62006. _downscale: ExtractHighlightsPostProcess;
  62007. private _blurX;
  62008. private _blurY;
  62009. private _merge;
  62010. /**
  62011. * The luminance threshold to find bright areas of the image to bloom.
  62012. */
  62013. threshold: number;
  62014. /**
  62015. * The strength of the bloom.
  62016. */
  62017. weight: number;
  62018. /**
  62019. * Specifies the size of the bloom blur kernel, relative to the final output size
  62020. */
  62021. kernel: number;
  62022. /**
  62023. * Creates a new instance of @see BloomEffect
  62024. * @param scene The scene the effect belongs to.
  62025. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  62026. * @param bloomKernel The size of the kernel to be used when applying the blur.
  62027. * @param bloomWeight The the strength of bloom.
  62028. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  62029. * @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)
  62030. */
  62031. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  62032. /**
  62033. * Disposes each of the internal effects for a given camera.
  62034. * @param camera The camera to dispose the effect on.
  62035. */
  62036. disposeEffects(camera: Camera): void;
  62037. /**
  62038. * @hidden Internal
  62039. */
  62040. _updateEffects(): void;
  62041. /**
  62042. * Internal
  62043. * @returns if all the contained post processes are ready.
  62044. * @hidden
  62045. */
  62046. _isReady(): boolean;
  62047. }
  62048. }
  62049. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  62050. /** @hidden */
  62051. export var chromaticAberrationPixelShader: {
  62052. name: string;
  62053. shader: string;
  62054. };
  62055. }
  62056. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  62057. import { Vector2 } from "babylonjs/Maths/math.vector";
  62058. import { Nullable } from "babylonjs/types";
  62059. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62060. import { Camera } from "babylonjs/Cameras/camera";
  62061. import { Engine } from "babylonjs/Engines/engine";
  62062. import "babylonjs/Shaders/chromaticAberration.fragment";
  62063. /**
  62064. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  62065. */
  62066. export class ChromaticAberrationPostProcess extends PostProcess {
  62067. /**
  62068. * The amount of seperation of rgb channels (default: 30)
  62069. */
  62070. aberrationAmount: number;
  62071. /**
  62072. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  62073. */
  62074. radialIntensity: number;
  62075. /**
  62076. * 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))
  62077. */
  62078. direction: Vector2;
  62079. /**
  62080. * 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))
  62081. */
  62082. centerPosition: Vector2;
  62083. /**
  62084. * Creates a new instance ChromaticAberrationPostProcess
  62085. * @param name The name of the effect.
  62086. * @param screenWidth The width of the screen to apply the effect on.
  62087. * @param screenHeight The height of the screen to apply the effect on.
  62088. * @param options The required width/height ratio to downsize to before computing the render pass.
  62089. * @param camera The camera to apply the render pass to.
  62090. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62091. * @param engine The engine which the post process will be applied. (default: current engine)
  62092. * @param reusable If the post process can be reused on the same frame. (default: false)
  62093. * @param textureType Type of textures used when performing the post process. (default: 0)
  62094. * @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)
  62095. */
  62096. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62097. }
  62098. }
  62099. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  62100. /** @hidden */
  62101. export var circleOfConfusionPixelShader: {
  62102. name: string;
  62103. shader: string;
  62104. };
  62105. }
  62106. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  62107. import { Nullable } from "babylonjs/types";
  62108. import { Engine } from "babylonjs/Engines/engine";
  62109. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62110. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62111. import { Camera } from "babylonjs/Cameras/camera";
  62112. import "babylonjs/Shaders/circleOfConfusion.fragment";
  62113. /**
  62114. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  62115. */
  62116. export class CircleOfConfusionPostProcess extends PostProcess {
  62117. /**
  62118. * 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.
  62119. */
  62120. lensSize: number;
  62121. /**
  62122. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  62123. */
  62124. fStop: number;
  62125. /**
  62126. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  62127. */
  62128. focusDistance: number;
  62129. /**
  62130. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  62131. */
  62132. focalLength: number;
  62133. private _depthTexture;
  62134. /**
  62135. * Creates a new instance CircleOfConfusionPostProcess
  62136. * @param name The name of the effect.
  62137. * @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.
  62138. * @param options The required width/height ratio to downsize to before computing the render pass.
  62139. * @param camera The camera to apply the render pass to.
  62140. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62141. * @param engine The engine which the post process will be applied. (default: current engine)
  62142. * @param reusable If the post process can be reused on the same frame. (default: false)
  62143. * @param textureType Type of textures used when performing the post process. (default: 0)
  62144. * @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)
  62145. */
  62146. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62147. /**
  62148. * 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.
  62149. */
  62150. depthTexture: RenderTargetTexture;
  62151. }
  62152. }
  62153. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  62154. /** @hidden */
  62155. export var colorCorrectionPixelShader: {
  62156. name: string;
  62157. shader: string;
  62158. };
  62159. }
  62160. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  62161. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62162. import { Engine } from "babylonjs/Engines/engine";
  62163. import { Camera } from "babylonjs/Cameras/camera";
  62164. import "babylonjs/Shaders/colorCorrection.fragment";
  62165. /**
  62166. *
  62167. * This post-process allows the modification of rendered colors by using
  62168. * a 'look-up table' (LUT). This effect is also called Color Grading.
  62169. *
  62170. * The object needs to be provided an url to a texture containing the color
  62171. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  62172. * Use an image editing software to tweak the LUT to match your needs.
  62173. *
  62174. * For an example of a color LUT, see here:
  62175. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  62176. * For explanations on color grading, see here:
  62177. * @see http://udn.epicgames.com/Three/ColorGrading.html
  62178. *
  62179. */
  62180. export class ColorCorrectionPostProcess extends PostProcess {
  62181. private _colorTableTexture;
  62182. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62183. }
  62184. }
  62185. declare module "babylonjs/Shaders/convolution.fragment" {
  62186. /** @hidden */
  62187. export var convolutionPixelShader: {
  62188. name: string;
  62189. shader: string;
  62190. };
  62191. }
  62192. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  62193. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62194. import { Nullable } from "babylonjs/types";
  62195. import { Camera } from "babylonjs/Cameras/camera";
  62196. import { Engine } from "babylonjs/Engines/engine";
  62197. import "babylonjs/Shaders/convolution.fragment";
  62198. /**
  62199. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  62200. * input texture to perform effects such as edge detection or sharpening
  62201. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  62202. */
  62203. export class ConvolutionPostProcess extends PostProcess {
  62204. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  62205. kernel: number[];
  62206. /**
  62207. * Creates a new instance ConvolutionPostProcess
  62208. * @param name The name of the effect.
  62209. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  62210. * @param options The required width/height ratio to downsize to before computing the render pass.
  62211. * @param camera The camera to apply the render pass to.
  62212. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62213. * @param engine The engine which the post process will be applied. (default: current engine)
  62214. * @param reusable If the post process can be reused on the same frame. (default: false)
  62215. * @param textureType Type of textures used when performing the post process. (default: 0)
  62216. */
  62217. constructor(name: string,
  62218. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  62219. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  62220. /**
  62221. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62222. */
  62223. static EdgeDetect0Kernel: number[];
  62224. /**
  62225. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62226. */
  62227. static EdgeDetect1Kernel: number[];
  62228. /**
  62229. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62230. */
  62231. static EdgeDetect2Kernel: number[];
  62232. /**
  62233. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62234. */
  62235. static SharpenKernel: number[];
  62236. /**
  62237. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62238. */
  62239. static EmbossKernel: number[];
  62240. /**
  62241. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62242. */
  62243. static GaussianKernel: number[];
  62244. }
  62245. }
  62246. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  62247. import { Nullable } from "babylonjs/types";
  62248. import { Vector2 } from "babylonjs/Maths/math.vector";
  62249. import { Camera } from "babylonjs/Cameras/camera";
  62250. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62251. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  62252. import { Engine } from "babylonjs/Engines/engine";
  62253. import { Scene } from "babylonjs/scene";
  62254. /**
  62255. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  62256. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  62257. * based on samples that have a large difference in distance than the center pixel.
  62258. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  62259. */
  62260. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  62261. direction: Vector2;
  62262. /**
  62263. * Creates a new instance CircleOfConfusionPostProcess
  62264. * @param name The name of the effect.
  62265. * @param scene The scene the effect belongs to.
  62266. * @param direction The direction the blur should be applied.
  62267. * @param kernel The size of the kernel used to blur.
  62268. * @param options The required width/height ratio to downsize to before computing the render pass.
  62269. * @param camera The camera to apply the render pass to.
  62270. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  62271. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  62272. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62273. * @param engine The engine which the post process will be applied. (default: current engine)
  62274. * @param reusable If the post process can be reused on the same frame. (default: false)
  62275. * @param textureType Type of textures used when performing the post process. (default: 0)
  62276. * @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)
  62277. */
  62278. 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);
  62279. }
  62280. }
  62281. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  62282. /** @hidden */
  62283. export var depthOfFieldMergePixelShader: {
  62284. name: string;
  62285. shader: string;
  62286. };
  62287. }
  62288. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  62289. import { Nullable } from "babylonjs/types";
  62290. import { Camera } from "babylonjs/Cameras/camera";
  62291. import { Effect } from "babylonjs/Materials/effect";
  62292. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62293. import { Engine } from "babylonjs/Engines/engine";
  62294. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  62295. /**
  62296. * Options to be set when merging outputs from the default pipeline.
  62297. */
  62298. export class DepthOfFieldMergePostProcessOptions {
  62299. /**
  62300. * The original image to merge on top of
  62301. */
  62302. originalFromInput: PostProcess;
  62303. /**
  62304. * Parameters to perform the merge of the depth of field effect
  62305. */
  62306. depthOfField?: {
  62307. circleOfConfusion: PostProcess;
  62308. blurSteps: Array<PostProcess>;
  62309. };
  62310. /**
  62311. * Parameters to perform the merge of bloom effect
  62312. */
  62313. bloom?: {
  62314. blurred: PostProcess;
  62315. weight: number;
  62316. };
  62317. }
  62318. /**
  62319. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  62320. */
  62321. export class DepthOfFieldMergePostProcess extends PostProcess {
  62322. private blurSteps;
  62323. /**
  62324. * Creates a new instance of DepthOfFieldMergePostProcess
  62325. * @param name The name of the effect.
  62326. * @param originalFromInput Post process which's input will be used for the merge.
  62327. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  62328. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  62329. * @param options The required width/height ratio to downsize to before computing the render pass.
  62330. * @param camera The camera to apply the render pass to.
  62331. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62332. * @param engine The engine which the post process will be applied. (default: current engine)
  62333. * @param reusable If the post process can be reused on the same frame. (default: false)
  62334. * @param textureType Type of textures used when performing the post process. (default: 0)
  62335. * @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)
  62336. */
  62337. 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);
  62338. /**
  62339. * Updates the effect with the current post process compile time values and recompiles the shader.
  62340. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  62341. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  62342. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  62343. * @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
  62344. * @param onCompiled Called when the shader has been compiled.
  62345. * @param onError Called if there is an error when compiling a shader.
  62346. */
  62347. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  62348. }
  62349. }
  62350. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  62351. import { Nullable } from "babylonjs/types";
  62352. import { Camera } from "babylonjs/Cameras/camera";
  62353. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62354. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62355. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  62356. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  62357. import { Scene } from "babylonjs/scene";
  62358. /**
  62359. * Specifies the level of max blur that should be applied when using the depth of field effect
  62360. */
  62361. export enum DepthOfFieldEffectBlurLevel {
  62362. /**
  62363. * Subtle blur
  62364. */
  62365. Low = 0,
  62366. /**
  62367. * Medium blur
  62368. */
  62369. Medium = 1,
  62370. /**
  62371. * Large blur
  62372. */
  62373. High = 2
  62374. }
  62375. /**
  62376. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  62377. */
  62378. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  62379. private _circleOfConfusion;
  62380. /**
  62381. * @hidden Internal, blurs from high to low
  62382. */
  62383. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  62384. private _depthOfFieldBlurY;
  62385. private _dofMerge;
  62386. /**
  62387. * @hidden Internal post processes in depth of field effect
  62388. */
  62389. _effects: Array<PostProcess>;
  62390. /**
  62391. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  62392. */
  62393. focalLength: number;
  62394. /**
  62395. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  62396. */
  62397. fStop: number;
  62398. /**
  62399. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  62400. */
  62401. focusDistance: number;
  62402. /**
  62403. * 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.
  62404. */
  62405. lensSize: number;
  62406. /**
  62407. * Creates a new instance DepthOfFieldEffect
  62408. * @param scene The scene the effect belongs to.
  62409. * @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.
  62410. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  62411. * @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)
  62412. */
  62413. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  62414. /**
  62415. * Get the current class name of the current effet
  62416. * @returns "DepthOfFieldEffect"
  62417. */
  62418. getClassName(): string;
  62419. /**
  62420. * 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.
  62421. */
  62422. depthTexture: RenderTargetTexture;
  62423. /**
  62424. * Disposes each of the internal effects for a given camera.
  62425. * @param camera The camera to dispose the effect on.
  62426. */
  62427. disposeEffects(camera: Camera): void;
  62428. /**
  62429. * @hidden Internal
  62430. */
  62431. _updateEffects(): void;
  62432. /**
  62433. * Internal
  62434. * @returns if all the contained post processes are ready.
  62435. * @hidden
  62436. */
  62437. _isReady(): boolean;
  62438. }
  62439. }
  62440. declare module "babylonjs/Shaders/displayPass.fragment" {
  62441. /** @hidden */
  62442. export var displayPassPixelShader: {
  62443. name: string;
  62444. shader: string;
  62445. };
  62446. }
  62447. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  62448. import { Nullable } from "babylonjs/types";
  62449. import { Camera } from "babylonjs/Cameras/camera";
  62450. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62451. import { Engine } from "babylonjs/Engines/engine";
  62452. import "babylonjs/Shaders/displayPass.fragment";
  62453. /**
  62454. * DisplayPassPostProcess which produces an output the same as it's input
  62455. */
  62456. export class DisplayPassPostProcess extends PostProcess {
  62457. /**
  62458. * Creates the DisplayPassPostProcess
  62459. * @param name The name of the effect.
  62460. * @param options The required width/height ratio to downsize to before computing the render pass.
  62461. * @param camera The camera to apply the render pass to.
  62462. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62463. * @param engine The engine which the post process will be applied. (default: current engine)
  62464. * @param reusable If the post process can be reused on the same frame. (default: false)
  62465. */
  62466. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62467. }
  62468. }
  62469. declare module "babylonjs/Shaders/filter.fragment" {
  62470. /** @hidden */
  62471. export var filterPixelShader: {
  62472. name: string;
  62473. shader: string;
  62474. };
  62475. }
  62476. declare module "babylonjs/PostProcesses/filterPostProcess" {
  62477. import { Nullable } from "babylonjs/types";
  62478. import { Matrix } from "babylonjs/Maths/math.vector";
  62479. import { Camera } from "babylonjs/Cameras/camera";
  62480. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62481. import { Engine } from "babylonjs/Engines/engine";
  62482. import "babylonjs/Shaders/filter.fragment";
  62483. /**
  62484. * Applies a kernel filter to the image
  62485. */
  62486. export class FilterPostProcess extends PostProcess {
  62487. /** The matrix to be applied to the image */
  62488. kernelMatrix: Matrix;
  62489. /**
  62490. *
  62491. * @param name The name of the effect.
  62492. * @param kernelMatrix The matrix to be applied to the image
  62493. * @param options The required width/height ratio to downsize to before computing the render pass.
  62494. * @param camera The camera to apply the render pass to.
  62495. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62496. * @param engine The engine which the post process will be applied. (default: current engine)
  62497. * @param reusable If the post process can be reused on the same frame. (default: false)
  62498. */
  62499. constructor(name: string,
  62500. /** The matrix to be applied to the image */
  62501. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62502. }
  62503. }
  62504. declare module "babylonjs/Shaders/fxaa.fragment" {
  62505. /** @hidden */
  62506. export var fxaaPixelShader: {
  62507. name: string;
  62508. shader: string;
  62509. };
  62510. }
  62511. declare module "babylonjs/Shaders/fxaa.vertex" {
  62512. /** @hidden */
  62513. export var fxaaVertexShader: {
  62514. name: string;
  62515. shader: string;
  62516. };
  62517. }
  62518. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  62519. import { Nullable } from "babylonjs/types";
  62520. import { Camera } from "babylonjs/Cameras/camera";
  62521. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62522. import { Engine } from "babylonjs/Engines/engine";
  62523. import "babylonjs/Shaders/fxaa.fragment";
  62524. import "babylonjs/Shaders/fxaa.vertex";
  62525. /**
  62526. * Fxaa post process
  62527. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  62528. */
  62529. export class FxaaPostProcess extends PostProcess {
  62530. /** @hidden */
  62531. texelWidth: number;
  62532. /** @hidden */
  62533. texelHeight: number;
  62534. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  62535. private _getDefines;
  62536. }
  62537. }
  62538. declare module "babylonjs/Shaders/grain.fragment" {
  62539. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62540. /** @hidden */
  62541. export var grainPixelShader: {
  62542. name: string;
  62543. shader: string;
  62544. };
  62545. }
  62546. declare module "babylonjs/PostProcesses/grainPostProcess" {
  62547. import { Nullable } from "babylonjs/types";
  62548. import { Camera } from "babylonjs/Cameras/camera";
  62549. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62550. import { Engine } from "babylonjs/Engines/engine";
  62551. import "babylonjs/Shaders/grain.fragment";
  62552. /**
  62553. * The GrainPostProcess adds noise to the image at mid luminance levels
  62554. */
  62555. export class GrainPostProcess extends PostProcess {
  62556. /**
  62557. * The intensity of the grain added (default: 30)
  62558. */
  62559. intensity: number;
  62560. /**
  62561. * If the grain should be randomized on every frame
  62562. */
  62563. animated: boolean;
  62564. /**
  62565. * Creates a new instance of @see GrainPostProcess
  62566. * @param name The name of the effect.
  62567. * @param options The required width/height ratio to downsize to before computing the render pass.
  62568. * @param camera The camera to apply the render pass to.
  62569. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62570. * @param engine The engine which the post process will be applied. (default: current engine)
  62571. * @param reusable If the post process can be reused on the same frame. (default: false)
  62572. * @param textureType Type of textures used when performing the post process. (default: 0)
  62573. * @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)
  62574. */
  62575. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62576. }
  62577. }
  62578. declare module "babylonjs/Shaders/highlights.fragment" {
  62579. /** @hidden */
  62580. export var highlightsPixelShader: {
  62581. name: string;
  62582. shader: string;
  62583. };
  62584. }
  62585. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  62586. import { Nullable } from "babylonjs/types";
  62587. import { Camera } from "babylonjs/Cameras/camera";
  62588. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62589. import { Engine } from "babylonjs/Engines/engine";
  62590. import "babylonjs/Shaders/highlights.fragment";
  62591. /**
  62592. * Extracts highlights from the image
  62593. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  62594. */
  62595. export class HighlightsPostProcess extends PostProcess {
  62596. /**
  62597. * Extracts highlights from the image
  62598. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  62599. * @param name The name of the effect.
  62600. * @param options The required width/height ratio to downsize to before computing the render pass.
  62601. * @param camera The camera to apply the render pass to.
  62602. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62603. * @param engine The engine which the post process will be applied. (default: current engine)
  62604. * @param reusable If the post process can be reused on the same frame. (default: false)
  62605. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  62606. */
  62607. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  62608. }
  62609. }
  62610. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  62611. /** @hidden */
  62612. export var mrtFragmentDeclaration: {
  62613. name: string;
  62614. shader: string;
  62615. };
  62616. }
  62617. declare module "babylonjs/Shaders/geometry.fragment" {
  62618. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  62619. /** @hidden */
  62620. export var geometryPixelShader: {
  62621. name: string;
  62622. shader: string;
  62623. };
  62624. }
  62625. declare module "babylonjs/Shaders/geometry.vertex" {
  62626. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  62627. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  62628. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  62629. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  62630. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  62631. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  62632. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  62633. /** @hidden */
  62634. export var geometryVertexShader: {
  62635. name: string;
  62636. shader: string;
  62637. };
  62638. }
  62639. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  62640. import { Matrix } from "babylonjs/Maths/math.vector";
  62641. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62642. import { Mesh } from "babylonjs/Meshes/mesh";
  62643. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  62644. import { Effect } from "babylonjs/Materials/effect";
  62645. import { Scene } from "babylonjs/scene";
  62646. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62647. import "babylonjs/Shaders/geometry.fragment";
  62648. import "babylonjs/Shaders/geometry.vertex";
  62649. /** @hidden */
  62650. interface ISavedTransformationMatrix {
  62651. world: Matrix;
  62652. viewProjection: Matrix;
  62653. }
  62654. /**
  62655. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  62656. */
  62657. export class GeometryBufferRenderer {
  62658. /**
  62659. * Constant used to retrieve the position texture index in the G-Buffer textures array
  62660. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  62661. */
  62662. static readonly POSITION_TEXTURE_TYPE: number;
  62663. /**
  62664. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  62665. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  62666. */
  62667. static readonly VELOCITY_TEXTURE_TYPE: number;
  62668. /**
  62669. * Dictionary used to store the previous transformation matrices of each rendered mesh
  62670. * in order to compute objects velocities when enableVelocity is set to "true"
  62671. * @hidden
  62672. */
  62673. _previousTransformationMatrices: {
  62674. [index: number]: ISavedTransformationMatrix;
  62675. };
  62676. /**
  62677. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  62678. * in order to compute objects velocities when enableVelocity is set to "true"
  62679. * @hidden
  62680. */
  62681. _previousBonesTransformationMatrices: {
  62682. [index: number]: Float32Array;
  62683. };
  62684. /**
  62685. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  62686. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  62687. */
  62688. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  62689. private _scene;
  62690. private _multiRenderTarget;
  62691. private _ratio;
  62692. private _enablePosition;
  62693. private _enableVelocity;
  62694. private _positionIndex;
  62695. private _velocityIndex;
  62696. protected _effect: Effect;
  62697. protected _cachedDefines: string;
  62698. /**
  62699. * Set the render list (meshes to be rendered) used in the G buffer.
  62700. */
  62701. renderList: Mesh[];
  62702. /**
  62703. * Gets wether or not G buffer are supported by the running hardware.
  62704. * This requires draw buffer supports
  62705. */
  62706. readonly isSupported: boolean;
  62707. /**
  62708. * Returns the index of the given texture type in the G-Buffer textures array
  62709. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  62710. * @returns the index of the given texture type in the G-Buffer textures array
  62711. */
  62712. getTextureIndex(textureType: number): number;
  62713. /**
  62714. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  62715. */
  62716. /**
  62717. * Sets whether or not objects positions are enabled for the G buffer.
  62718. */
  62719. enablePosition: boolean;
  62720. /**
  62721. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  62722. */
  62723. /**
  62724. * Sets wether or not objects velocities are enabled for the G buffer.
  62725. */
  62726. enableVelocity: boolean;
  62727. /**
  62728. * Gets the scene associated with the buffer.
  62729. */
  62730. readonly scene: Scene;
  62731. /**
  62732. * Gets the ratio used by the buffer during its creation.
  62733. * How big is the buffer related to the main canvas.
  62734. */
  62735. readonly ratio: number;
  62736. /** @hidden */
  62737. static _SceneComponentInitialization: (scene: Scene) => void;
  62738. /**
  62739. * Creates a new G Buffer for the scene
  62740. * @param scene The scene the buffer belongs to
  62741. * @param ratio How big is the buffer related to the main canvas.
  62742. */
  62743. constructor(scene: Scene, ratio?: number);
  62744. /**
  62745. * Checks wether everything is ready to render a submesh to the G buffer.
  62746. * @param subMesh the submesh to check readiness for
  62747. * @param useInstances is the mesh drawn using instance or not
  62748. * @returns true if ready otherwise false
  62749. */
  62750. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62751. /**
  62752. * Gets the current underlying G Buffer.
  62753. * @returns the buffer
  62754. */
  62755. getGBuffer(): MultiRenderTarget;
  62756. /**
  62757. * Gets the number of samples used to render the buffer (anti aliasing).
  62758. */
  62759. /**
  62760. * Sets the number of samples used to render the buffer (anti aliasing).
  62761. */
  62762. samples: number;
  62763. /**
  62764. * Disposes the renderer and frees up associated resources.
  62765. */
  62766. dispose(): void;
  62767. protected _createRenderTargets(): void;
  62768. private _copyBonesTransformationMatrices;
  62769. }
  62770. }
  62771. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  62772. import { Nullable } from "babylonjs/types";
  62773. import { Scene } from "babylonjs/scene";
  62774. import { ISceneComponent } from "babylonjs/sceneComponent";
  62775. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  62776. module "babylonjs/scene" {
  62777. interface Scene {
  62778. /** @hidden (Backing field) */
  62779. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  62780. /**
  62781. * Gets or Sets the current geometry buffer associated to the scene.
  62782. */
  62783. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  62784. /**
  62785. * Enables a GeometryBufferRender and associates it with the scene
  62786. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  62787. * @returns the GeometryBufferRenderer
  62788. */
  62789. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  62790. /**
  62791. * Disables the GeometryBufferRender associated with the scene
  62792. */
  62793. disableGeometryBufferRenderer(): void;
  62794. }
  62795. }
  62796. /**
  62797. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  62798. * in several rendering techniques.
  62799. */
  62800. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  62801. /**
  62802. * The component name helpful to identify the component in the list of scene components.
  62803. */
  62804. readonly name: string;
  62805. /**
  62806. * The scene the component belongs to.
  62807. */
  62808. scene: Scene;
  62809. /**
  62810. * Creates a new instance of the component for the given scene
  62811. * @param scene Defines the scene to register the component in
  62812. */
  62813. constructor(scene: Scene);
  62814. /**
  62815. * Registers the component in a given scene
  62816. */
  62817. register(): void;
  62818. /**
  62819. * Rebuilds the elements related to this component in case of
  62820. * context lost for instance.
  62821. */
  62822. rebuild(): void;
  62823. /**
  62824. * Disposes the component and the associated ressources
  62825. */
  62826. dispose(): void;
  62827. private _gatherRenderTargets;
  62828. }
  62829. }
  62830. declare module "babylonjs/Shaders/motionBlur.fragment" {
  62831. /** @hidden */
  62832. export var motionBlurPixelShader: {
  62833. name: string;
  62834. shader: string;
  62835. };
  62836. }
  62837. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  62838. import { Nullable } from "babylonjs/types";
  62839. import { Camera } from "babylonjs/Cameras/camera";
  62840. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62841. import { Scene } from "babylonjs/scene";
  62842. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62843. import "babylonjs/Animations/animatable";
  62844. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  62845. import "babylonjs/Shaders/motionBlur.fragment";
  62846. import { Engine } from "babylonjs/Engines/engine";
  62847. /**
  62848. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  62849. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  62850. * As an example, all you have to do is to create the post-process:
  62851. * var mb = new BABYLON.MotionBlurPostProcess(
  62852. * 'mb', // The name of the effect.
  62853. * scene, // The scene containing the objects to blur according to their velocity.
  62854. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  62855. * camera // The camera to apply the render pass to.
  62856. * );
  62857. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  62858. */
  62859. export class MotionBlurPostProcess extends PostProcess {
  62860. /**
  62861. * Defines how much the image is blurred by the movement. Default value is equal to 1
  62862. */
  62863. motionStrength: number;
  62864. /**
  62865. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  62866. */
  62867. /**
  62868. * Sets the number of iterations to be used for motion blur quality
  62869. */
  62870. motionBlurSamples: number;
  62871. private _motionBlurSamples;
  62872. private _geometryBufferRenderer;
  62873. /**
  62874. * Creates a new instance MotionBlurPostProcess
  62875. * @param name The name of the effect.
  62876. * @param scene The scene containing the objects to blur according to their velocity.
  62877. * @param options The required width/height ratio to downsize to before computing the render pass.
  62878. * @param camera The camera to apply the render pass to.
  62879. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62880. * @param engine The engine which the post process will be applied. (default: current engine)
  62881. * @param reusable If the post process can be reused on the same frame. (default: false)
  62882. * @param textureType Type of textures used when performing the post process. (default: 0)
  62883. * @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)
  62884. */
  62885. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62886. /**
  62887. * Excludes the given skinned mesh from computing bones velocities.
  62888. * 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.
  62889. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  62890. */
  62891. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  62892. /**
  62893. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  62894. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  62895. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  62896. */
  62897. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  62898. /**
  62899. * Disposes the post process.
  62900. * @param camera The camera to dispose the post process on.
  62901. */
  62902. dispose(camera?: Camera): void;
  62903. }
  62904. }
  62905. declare module "babylonjs/Shaders/refraction.fragment" {
  62906. /** @hidden */
  62907. export var refractionPixelShader: {
  62908. name: string;
  62909. shader: string;
  62910. };
  62911. }
  62912. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  62913. import { Color3 } from "babylonjs/Maths/math.color";
  62914. import { Camera } from "babylonjs/Cameras/camera";
  62915. import { Texture } from "babylonjs/Materials/Textures/texture";
  62916. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62917. import { Engine } from "babylonjs/Engines/engine";
  62918. import "babylonjs/Shaders/refraction.fragment";
  62919. /**
  62920. * Post process which applies a refractin texture
  62921. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  62922. */
  62923. export class RefractionPostProcess extends PostProcess {
  62924. /** the base color of the refraction (used to taint the rendering) */
  62925. color: Color3;
  62926. /** simulated refraction depth */
  62927. depth: number;
  62928. /** the coefficient of the base color (0 to remove base color tainting) */
  62929. colorLevel: number;
  62930. private _refTexture;
  62931. private _ownRefractionTexture;
  62932. /**
  62933. * Gets or sets the refraction texture
  62934. * Please note that you are responsible for disposing the texture if you set it manually
  62935. */
  62936. refractionTexture: Texture;
  62937. /**
  62938. * Initializes the RefractionPostProcess
  62939. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  62940. * @param name The name of the effect.
  62941. * @param refractionTextureUrl Url of the refraction texture to use
  62942. * @param color the base color of the refraction (used to taint the rendering)
  62943. * @param depth simulated refraction depth
  62944. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  62945. * @param camera The camera to apply the render pass to.
  62946. * @param options The required width/height ratio to downsize to before computing the render pass.
  62947. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62948. * @param engine The engine which the post process will be applied. (default: current engine)
  62949. * @param reusable If the post process can be reused on the same frame. (default: false)
  62950. */
  62951. constructor(name: string, refractionTextureUrl: string,
  62952. /** the base color of the refraction (used to taint the rendering) */
  62953. color: Color3,
  62954. /** simulated refraction depth */
  62955. depth: number,
  62956. /** the coefficient of the base color (0 to remove base color tainting) */
  62957. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62958. /**
  62959. * Disposes of the post process
  62960. * @param camera Camera to dispose post process on
  62961. */
  62962. dispose(camera: Camera): void;
  62963. }
  62964. }
  62965. declare module "babylonjs/Shaders/sharpen.fragment" {
  62966. /** @hidden */
  62967. export var sharpenPixelShader: {
  62968. name: string;
  62969. shader: string;
  62970. };
  62971. }
  62972. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  62973. import { Nullable } from "babylonjs/types";
  62974. import { Camera } from "babylonjs/Cameras/camera";
  62975. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62976. import "babylonjs/Shaders/sharpen.fragment";
  62977. import { Engine } from "babylonjs/Engines/engine";
  62978. /**
  62979. * The SharpenPostProcess applies a sharpen kernel to every pixel
  62980. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  62981. */
  62982. export class SharpenPostProcess extends PostProcess {
  62983. /**
  62984. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  62985. */
  62986. colorAmount: number;
  62987. /**
  62988. * How much sharpness should be applied (default: 0.3)
  62989. */
  62990. edgeAmount: number;
  62991. /**
  62992. * Creates a new instance ConvolutionPostProcess
  62993. * @param name The name of the effect.
  62994. * @param options The required width/height ratio to downsize to before computing the render pass.
  62995. * @param camera The camera to apply the render pass to.
  62996. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62997. * @param engine The engine which the post process will be applied. (default: current engine)
  62998. * @param reusable If the post process can be reused on the same frame. (default: false)
  62999. * @param textureType Type of textures used when performing the post process. (default: 0)
  63000. * @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)
  63001. */
  63002. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63003. }
  63004. }
  63005. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  63006. import { Nullable } from "babylonjs/types";
  63007. import { Camera } from "babylonjs/Cameras/camera";
  63008. import { Engine } from "babylonjs/Engines/engine";
  63009. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  63010. import { IInspectable } from "babylonjs/Misc/iInspectable";
  63011. /**
  63012. * PostProcessRenderPipeline
  63013. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63014. */
  63015. export class PostProcessRenderPipeline {
  63016. private engine;
  63017. private _renderEffects;
  63018. private _renderEffectsForIsolatedPass;
  63019. /**
  63020. * List of inspectable custom properties (used by the Inspector)
  63021. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  63022. */
  63023. inspectableCustomProperties: IInspectable[];
  63024. /**
  63025. * @hidden
  63026. */
  63027. protected _cameras: Camera[];
  63028. /** @hidden */
  63029. _name: string;
  63030. /**
  63031. * Gets pipeline name
  63032. */
  63033. readonly name: string;
  63034. /**
  63035. * Initializes a PostProcessRenderPipeline
  63036. * @param engine engine to add the pipeline to
  63037. * @param name name of the pipeline
  63038. */
  63039. constructor(engine: Engine, name: string);
  63040. /**
  63041. * Gets the class name
  63042. * @returns "PostProcessRenderPipeline"
  63043. */
  63044. getClassName(): string;
  63045. /**
  63046. * If all the render effects in the pipeline are supported
  63047. */
  63048. readonly isSupported: boolean;
  63049. /**
  63050. * Adds an effect to the pipeline
  63051. * @param renderEffect the effect to add
  63052. */
  63053. addEffect(renderEffect: PostProcessRenderEffect): void;
  63054. /** @hidden */
  63055. _rebuild(): void;
  63056. /** @hidden */
  63057. _enableEffect(renderEffectName: string, cameras: Camera): void;
  63058. /** @hidden */
  63059. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  63060. /** @hidden */
  63061. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  63062. /** @hidden */
  63063. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  63064. /** @hidden */
  63065. _attachCameras(cameras: Camera, unique: boolean): void;
  63066. /** @hidden */
  63067. _attachCameras(cameras: Camera[], unique: boolean): void;
  63068. /** @hidden */
  63069. _detachCameras(cameras: Camera): void;
  63070. /** @hidden */
  63071. _detachCameras(cameras: Nullable<Camera[]>): void;
  63072. /** @hidden */
  63073. _update(): void;
  63074. /** @hidden */
  63075. _reset(): void;
  63076. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  63077. /**
  63078. * Disposes of the pipeline
  63079. */
  63080. dispose(): void;
  63081. }
  63082. }
  63083. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  63084. import { Camera } from "babylonjs/Cameras/camera";
  63085. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63086. /**
  63087. * PostProcessRenderPipelineManager class
  63088. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63089. */
  63090. export class PostProcessRenderPipelineManager {
  63091. private _renderPipelines;
  63092. /**
  63093. * Initializes a PostProcessRenderPipelineManager
  63094. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63095. */
  63096. constructor();
  63097. /**
  63098. * Gets the list of supported render pipelines
  63099. */
  63100. readonly supportedPipelines: PostProcessRenderPipeline[];
  63101. /**
  63102. * Adds a pipeline to the manager
  63103. * @param renderPipeline The pipeline to add
  63104. */
  63105. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  63106. /**
  63107. * Attaches a camera to the pipeline
  63108. * @param renderPipelineName The name of the pipeline to attach to
  63109. * @param cameras the camera to attach
  63110. * @param unique if the camera can be attached multiple times to the pipeline
  63111. */
  63112. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  63113. /**
  63114. * Detaches a camera from the pipeline
  63115. * @param renderPipelineName The name of the pipeline to detach from
  63116. * @param cameras the camera to detach
  63117. */
  63118. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  63119. /**
  63120. * Enables an effect by name on a pipeline
  63121. * @param renderPipelineName the name of the pipeline to enable the effect in
  63122. * @param renderEffectName the name of the effect to enable
  63123. * @param cameras the cameras that the effect should be enabled on
  63124. */
  63125. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  63126. /**
  63127. * Disables an effect by name on a pipeline
  63128. * @param renderPipelineName the name of the pipeline to disable the effect in
  63129. * @param renderEffectName the name of the effect to disable
  63130. * @param cameras the cameras that the effect should be disabled on
  63131. */
  63132. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  63133. /**
  63134. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  63135. */
  63136. update(): void;
  63137. /** @hidden */
  63138. _rebuild(): void;
  63139. /**
  63140. * Disposes of the manager and pipelines
  63141. */
  63142. dispose(): void;
  63143. }
  63144. }
  63145. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  63146. import { ISceneComponent } from "babylonjs/sceneComponent";
  63147. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  63148. import { Scene } from "babylonjs/scene";
  63149. module "babylonjs/scene" {
  63150. interface Scene {
  63151. /** @hidden (Backing field) */
  63152. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  63153. /**
  63154. * Gets the postprocess render pipeline manager
  63155. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63156. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  63157. */
  63158. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  63159. }
  63160. }
  63161. /**
  63162. * Defines the Render Pipeline scene component responsible to rendering pipelines
  63163. */
  63164. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  63165. /**
  63166. * The component name helpfull to identify the component in the list of scene components.
  63167. */
  63168. readonly name: string;
  63169. /**
  63170. * The scene the component belongs to.
  63171. */
  63172. scene: Scene;
  63173. /**
  63174. * Creates a new instance of the component for the given scene
  63175. * @param scene Defines the scene to register the component in
  63176. */
  63177. constructor(scene: Scene);
  63178. /**
  63179. * Registers the component in a given scene
  63180. */
  63181. register(): void;
  63182. /**
  63183. * Rebuilds the elements related to this component in case of
  63184. * context lost for instance.
  63185. */
  63186. rebuild(): void;
  63187. /**
  63188. * Disposes the component and the associated ressources
  63189. */
  63190. dispose(): void;
  63191. private _gatherRenderTargets;
  63192. }
  63193. }
  63194. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  63195. import { Nullable } from "babylonjs/types";
  63196. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  63197. import { Camera } from "babylonjs/Cameras/camera";
  63198. import { IDisposable } from "babylonjs/scene";
  63199. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  63200. import { Scene } from "babylonjs/scene";
  63201. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  63202. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  63203. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  63204. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  63205. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  63206. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63207. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  63208. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63209. import { Animation } from "babylonjs/Animations/animation";
  63210. /**
  63211. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  63212. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  63213. */
  63214. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  63215. private _scene;
  63216. private _camerasToBeAttached;
  63217. /**
  63218. * ID of the sharpen post process,
  63219. */
  63220. private readonly SharpenPostProcessId;
  63221. /**
  63222. * @ignore
  63223. * ID of the image processing post process;
  63224. */
  63225. readonly ImageProcessingPostProcessId: string;
  63226. /**
  63227. * @ignore
  63228. * ID of the Fast Approximate Anti-Aliasing post process;
  63229. */
  63230. readonly FxaaPostProcessId: string;
  63231. /**
  63232. * ID of the chromatic aberration post process,
  63233. */
  63234. private readonly ChromaticAberrationPostProcessId;
  63235. /**
  63236. * ID of the grain post process
  63237. */
  63238. private readonly GrainPostProcessId;
  63239. /**
  63240. * Sharpen post process which will apply a sharpen convolution to enhance edges
  63241. */
  63242. sharpen: SharpenPostProcess;
  63243. private _sharpenEffect;
  63244. private bloom;
  63245. /**
  63246. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  63247. */
  63248. depthOfField: DepthOfFieldEffect;
  63249. /**
  63250. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  63251. */
  63252. fxaa: FxaaPostProcess;
  63253. /**
  63254. * Image post processing pass used to perform operations such as tone mapping or color grading.
  63255. */
  63256. imageProcessing: ImageProcessingPostProcess;
  63257. /**
  63258. * Chromatic aberration post process which will shift rgb colors in the image
  63259. */
  63260. chromaticAberration: ChromaticAberrationPostProcess;
  63261. private _chromaticAberrationEffect;
  63262. /**
  63263. * Grain post process which add noise to the image
  63264. */
  63265. grain: GrainPostProcess;
  63266. private _grainEffect;
  63267. /**
  63268. * Glow post process which adds a glow to emissive areas of the image
  63269. */
  63270. private _glowLayer;
  63271. /**
  63272. * Animations which can be used to tweak settings over a period of time
  63273. */
  63274. animations: Animation[];
  63275. private _imageProcessingConfigurationObserver;
  63276. private _sharpenEnabled;
  63277. private _bloomEnabled;
  63278. private _depthOfFieldEnabled;
  63279. private _depthOfFieldBlurLevel;
  63280. private _fxaaEnabled;
  63281. private _imageProcessingEnabled;
  63282. private _defaultPipelineTextureType;
  63283. private _bloomScale;
  63284. private _chromaticAberrationEnabled;
  63285. private _grainEnabled;
  63286. private _buildAllowed;
  63287. /**
  63288. * Gets active scene
  63289. */
  63290. readonly scene: Scene;
  63291. /**
  63292. * Enable or disable the sharpen process from the pipeline
  63293. */
  63294. sharpenEnabled: boolean;
  63295. private _resizeObserver;
  63296. private _hardwareScaleLevel;
  63297. private _bloomKernel;
  63298. /**
  63299. * Specifies the size of the bloom blur kernel, relative to the final output size
  63300. */
  63301. bloomKernel: number;
  63302. /**
  63303. * Specifies the weight of the bloom in the final rendering
  63304. */
  63305. private _bloomWeight;
  63306. /**
  63307. * Specifies the luma threshold for the area that will be blurred by the bloom
  63308. */
  63309. private _bloomThreshold;
  63310. private _hdr;
  63311. /**
  63312. * The strength of the bloom.
  63313. */
  63314. bloomWeight: number;
  63315. /**
  63316. * The strength of the bloom.
  63317. */
  63318. bloomThreshold: number;
  63319. /**
  63320. * The scale of the bloom, lower value will provide better performance.
  63321. */
  63322. bloomScale: number;
  63323. /**
  63324. * Enable or disable the bloom from the pipeline
  63325. */
  63326. bloomEnabled: boolean;
  63327. private _rebuildBloom;
  63328. /**
  63329. * If the depth of field is enabled.
  63330. */
  63331. depthOfFieldEnabled: boolean;
  63332. /**
  63333. * Blur level of the depth of field effect. (Higher blur will effect performance)
  63334. */
  63335. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  63336. /**
  63337. * If the anti aliasing is enabled.
  63338. */
  63339. fxaaEnabled: boolean;
  63340. private _samples;
  63341. /**
  63342. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  63343. */
  63344. samples: number;
  63345. /**
  63346. * If image processing is enabled.
  63347. */
  63348. imageProcessingEnabled: boolean;
  63349. /**
  63350. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  63351. */
  63352. glowLayerEnabled: boolean;
  63353. /**
  63354. * Gets the glow layer (or null if not defined)
  63355. */
  63356. readonly glowLayer: Nullable<GlowLayer>;
  63357. /**
  63358. * Enable or disable the chromaticAberration process from the pipeline
  63359. */
  63360. chromaticAberrationEnabled: boolean;
  63361. /**
  63362. * Enable or disable the grain process from the pipeline
  63363. */
  63364. grainEnabled: boolean;
  63365. /**
  63366. * @constructor
  63367. * @param name - The rendering pipeline name (default: "")
  63368. * @param hdr - If high dynamic range textures should be used (default: true)
  63369. * @param scene - The scene linked to this pipeline (default: the last created scene)
  63370. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  63371. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  63372. */
  63373. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  63374. /**
  63375. * Get the class name
  63376. * @returns "DefaultRenderingPipeline"
  63377. */
  63378. getClassName(): string;
  63379. /**
  63380. * Force the compilation of the entire pipeline.
  63381. */
  63382. prepare(): void;
  63383. private _hasCleared;
  63384. private _prevPostProcess;
  63385. private _prevPrevPostProcess;
  63386. private _setAutoClearAndTextureSharing;
  63387. private _depthOfFieldSceneObserver;
  63388. private _buildPipeline;
  63389. private _disposePostProcesses;
  63390. /**
  63391. * Adds a camera to the pipeline
  63392. * @param camera the camera to be added
  63393. */
  63394. addCamera(camera: Camera): void;
  63395. /**
  63396. * Removes a camera from the pipeline
  63397. * @param camera the camera to remove
  63398. */
  63399. removeCamera(camera: Camera): void;
  63400. /**
  63401. * Dispose of the pipeline and stop all post processes
  63402. */
  63403. dispose(): void;
  63404. /**
  63405. * Serialize the rendering pipeline (Used when exporting)
  63406. * @returns the serialized object
  63407. */
  63408. serialize(): any;
  63409. /**
  63410. * Parse the serialized pipeline
  63411. * @param source Source pipeline.
  63412. * @param scene The scene to load the pipeline to.
  63413. * @param rootUrl The URL of the serialized pipeline.
  63414. * @returns An instantiated pipeline from the serialized object.
  63415. */
  63416. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  63417. }
  63418. }
  63419. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  63420. /** @hidden */
  63421. export var lensHighlightsPixelShader: {
  63422. name: string;
  63423. shader: string;
  63424. };
  63425. }
  63426. declare module "babylonjs/Shaders/depthOfField.fragment" {
  63427. /** @hidden */
  63428. export var depthOfFieldPixelShader: {
  63429. name: string;
  63430. shader: string;
  63431. };
  63432. }
  63433. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  63434. import { Camera } from "babylonjs/Cameras/camera";
  63435. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63436. import { Scene } from "babylonjs/scene";
  63437. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63438. import "babylonjs/Shaders/chromaticAberration.fragment";
  63439. import "babylonjs/Shaders/lensHighlights.fragment";
  63440. import "babylonjs/Shaders/depthOfField.fragment";
  63441. /**
  63442. * BABYLON.JS Chromatic Aberration GLSL Shader
  63443. * Author: Olivier Guyot
  63444. * Separates very slightly R, G and B colors on the edges of the screen
  63445. * Inspired by Francois Tarlier & Martins Upitis
  63446. */
  63447. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  63448. /**
  63449. * @ignore
  63450. * The chromatic aberration PostProcess id in the pipeline
  63451. */
  63452. LensChromaticAberrationEffect: string;
  63453. /**
  63454. * @ignore
  63455. * The highlights enhancing PostProcess id in the pipeline
  63456. */
  63457. HighlightsEnhancingEffect: string;
  63458. /**
  63459. * @ignore
  63460. * The depth-of-field PostProcess id in the pipeline
  63461. */
  63462. LensDepthOfFieldEffect: string;
  63463. private _scene;
  63464. private _depthTexture;
  63465. private _grainTexture;
  63466. private _chromaticAberrationPostProcess;
  63467. private _highlightsPostProcess;
  63468. private _depthOfFieldPostProcess;
  63469. private _edgeBlur;
  63470. private _grainAmount;
  63471. private _chromaticAberration;
  63472. private _distortion;
  63473. private _highlightsGain;
  63474. private _highlightsThreshold;
  63475. private _dofDistance;
  63476. private _dofAperture;
  63477. private _dofDarken;
  63478. private _dofPentagon;
  63479. private _blurNoise;
  63480. /**
  63481. * @constructor
  63482. *
  63483. * Effect parameters are as follow:
  63484. * {
  63485. * chromatic_aberration: number; // from 0 to x (1 for realism)
  63486. * edge_blur: number; // from 0 to x (1 for realism)
  63487. * distortion: number; // from 0 to x (1 for realism)
  63488. * grain_amount: number; // from 0 to 1
  63489. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  63490. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  63491. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  63492. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  63493. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  63494. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  63495. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  63496. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  63497. * }
  63498. * Note: if an effect parameter is unset, effect is disabled
  63499. *
  63500. * @param name The rendering pipeline name
  63501. * @param parameters - An object containing all parameters (see above)
  63502. * @param scene The scene linked to this pipeline
  63503. * @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)
  63504. * @param cameras The array of cameras that the rendering pipeline will be attached to
  63505. */
  63506. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  63507. /**
  63508. * Get the class name
  63509. * @returns "LensRenderingPipeline"
  63510. */
  63511. getClassName(): string;
  63512. /**
  63513. * Gets associated scene
  63514. */
  63515. readonly scene: Scene;
  63516. /**
  63517. * Gets or sets the edge blur
  63518. */
  63519. edgeBlur: number;
  63520. /**
  63521. * Gets or sets the grain amount
  63522. */
  63523. grainAmount: number;
  63524. /**
  63525. * Gets or sets the chromatic aberration amount
  63526. */
  63527. chromaticAberration: number;
  63528. /**
  63529. * Gets or sets the depth of field aperture
  63530. */
  63531. dofAperture: number;
  63532. /**
  63533. * Gets or sets the edge distortion
  63534. */
  63535. edgeDistortion: number;
  63536. /**
  63537. * Gets or sets the depth of field distortion
  63538. */
  63539. dofDistortion: number;
  63540. /**
  63541. * Gets or sets the darken out of focus amount
  63542. */
  63543. darkenOutOfFocus: number;
  63544. /**
  63545. * Gets or sets a boolean indicating if blur noise is enabled
  63546. */
  63547. blurNoise: boolean;
  63548. /**
  63549. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  63550. */
  63551. pentagonBokeh: boolean;
  63552. /**
  63553. * Gets or sets the highlight grain amount
  63554. */
  63555. highlightsGain: number;
  63556. /**
  63557. * Gets or sets the highlight threshold
  63558. */
  63559. highlightsThreshold: number;
  63560. /**
  63561. * Sets the amount of blur at the edges
  63562. * @param amount blur amount
  63563. */
  63564. setEdgeBlur(amount: number): void;
  63565. /**
  63566. * Sets edge blur to 0
  63567. */
  63568. disableEdgeBlur(): void;
  63569. /**
  63570. * Sets the amout of grain
  63571. * @param amount Amount of grain
  63572. */
  63573. setGrainAmount(amount: number): void;
  63574. /**
  63575. * Set grain amount to 0
  63576. */
  63577. disableGrain(): void;
  63578. /**
  63579. * Sets the chromatic aberration amount
  63580. * @param amount amount of chromatic aberration
  63581. */
  63582. setChromaticAberration(amount: number): void;
  63583. /**
  63584. * Sets chromatic aberration amount to 0
  63585. */
  63586. disableChromaticAberration(): void;
  63587. /**
  63588. * Sets the EdgeDistortion amount
  63589. * @param amount amount of EdgeDistortion
  63590. */
  63591. setEdgeDistortion(amount: number): void;
  63592. /**
  63593. * Sets edge distortion to 0
  63594. */
  63595. disableEdgeDistortion(): void;
  63596. /**
  63597. * Sets the FocusDistance amount
  63598. * @param amount amount of FocusDistance
  63599. */
  63600. setFocusDistance(amount: number): void;
  63601. /**
  63602. * Disables depth of field
  63603. */
  63604. disableDepthOfField(): void;
  63605. /**
  63606. * Sets the Aperture amount
  63607. * @param amount amount of Aperture
  63608. */
  63609. setAperture(amount: number): void;
  63610. /**
  63611. * Sets the DarkenOutOfFocus amount
  63612. * @param amount amount of DarkenOutOfFocus
  63613. */
  63614. setDarkenOutOfFocus(amount: number): void;
  63615. private _pentagonBokehIsEnabled;
  63616. /**
  63617. * Creates a pentagon bokeh effect
  63618. */
  63619. enablePentagonBokeh(): void;
  63620. /**
  63621. * Disables the pentagon bokeh effect
  63622. */
  63623. disablePentagonBokeh(): void;
  63624. /**
  63625. * Enables noise blur
  63626. */
  63627. enableNoiseBlur(): void;
  63628. /**
  63629. * Disables noise blur
  63630. */
  63631. disableNoiseBlur(): void;
  63632. /**
  63633. * Sets the HighlightsGain amount
  63634. * @param amount amount of HighlightsGain
  63635. */
  63636. setHighlightsGain(amount: number): void;
  63637. /**
  63638. * Sets the HighlightsThreshold amount
  63639. * @param amount amount of HighlightsThreshold
  63640. */
  63641. setHighlightsThreshold(amount: number): void;
  63642. /**
  63643. * Disables highlights
  63644. */
  63645. disableHighlights(): void;
  63646. /**
  63647. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  63648. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  63649. */
  63650. dispose(disableDepthRender?: boolean): void;
  63651. private _createChromaticAberrationPostProcess;
  63652. private _createHighlightsPostProcess;
  63653. private _createDepthOfFieldPostProcess;
  63654. private _createGrainTexture;
  63655. }
  63656. }
  63657. declare module "babylonjs/Shaders/ssao2.fragment" {
  63658. /** @hidden */
  63659. export var ssao2PixelShader: {
  63660. name: string;
  63661. shader: string;
  63662. };
  63663. }
  63664. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  63665. /** @hidden */
  63666. export var ssaoCombinePixelShader: {
  63667. name: string;
  63668. shader: string;
  63669. };
  63670. }
  63671. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  63672. import { Camera } from "babylonjs/Cameras/camera";
  63673. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63674. import { Scene } from "babylonjs/scene";
  63675. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63676. import "babylonjs/Shaders/ssao2.fragment";
  63677. import "babylonjs/Shaders/ssaoCombine.fragment";
  63678. /**
  63679. * Render pipeline to produce ssao effect
  63680. */
  63681. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  63682. /**
  63683. * @ignore
  63684. * The PassPostProcess id in the pipeline that contains the original scene color
  63685. */
  63686. SSAOOriginalSceneColorEffect: string;
  63687. /**
  63688. * @ignore
  63689. * The SSAO PostProcess id in the pipeline
  63690. */
  63691. SSAORenderEffect: string;
  63692. /**
  63693. * @ignore
  63694. * The horizontal blur PostProcess id in the pipeline
  63695. */
  63696. SSAOBlurHRenderEffect: string;
  63697. /**
  63698. * @ignore
  63699. * The vertical blur PostProcess id in the pipeline
  63700. */
  63701. SSAOBlurVRenderEffect: string;
  63702. /**
  63703. * @ignore
  63704. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  63705. */
  63706. SSAOCombineRenderEffect: string;
  63707. /**
  63708. * The output strength of the SSAO post-process. Default value is 1.0.
  63709. */
  63710. totalStrength: number;
  63711. /**
  63712. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  63713. */
  63714. maxZ: number;
  63715. /**
  63716. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  63717. */
  63718. minZAspect: number;
  63719. private _samples;
  63720. /**
  63721. * Number of samples used for the SSAO calculations. Default value is 8
  63722. */
  63723. samples: number;
  63724. private _textureSamples;
  63725. /**
  63726. * Number of samples to use for antialiasing
  63727. */
  63728. textureSamples: number;
  63729. /**
  63730. * Ratio object used for SSAO ratio and blur ratio
  63731. */
  63732. private _ratio;
  63733. /**
  63734. * Dynamically generated sphere sampler.
  63735. */
  63736. private _sampleSphere;
  63737. /**
  63738. * Blur filter offsets
  63739. */
  63740. private _samplerOffsets;
  63741. private _expensiveBlur;
  63742. /**
  63743. * If bilateral blur should be used
  63744. */
  63745. expensiveBlur: boolean;
  63746. /**
  63747. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  63748. */
  63749. radius: number;
  63750. /**
  63751. * The base color of the SSAO post-process
  63752. * The final result is "base + ssao" between [0, 1]
  63753. */
  63754. base: number;
  63755. /**
  63756. * Support test.
  63757. */
  63758. static readonly IsSupported: boolean;
  63759. private _scene;
  63760. private _depthTexture;
  63761. private _normalTexture;
  63762. private _randomTexture;
  63763. private _originalColorPostProcess;
  63764. private _ssaoPostProcess;
  63765. private _blurHPostProcess;
  63766. private _blurVPostProcess;
  63767. private _ssaoCombinePostProcess;
  63768. private _firstUpdate;
  63769. /**
  63770. * Gets active scene
  63771. */
  63772. readonly scene: Scene;
  63773. /**
  63774. * @constructor
  63775. * @param name The rendering pipeline name
  63776. * @param scene The scene linked to this pipeline
  63777. * @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 }
  63778. * @param cameras The array of cameras that the rendering pipeline will be attached to
  63779. */
  63780. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  63781. /**
  63782. * Get the class name
  63783. * @returns "SSAO2RenderingPipeline"
  63784. */
  63785. getClassName(): string;
  63786. /**
  63787. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  63788. */
  63789. dispose(disableGeometryBufferRenderer?: boolean): void;
  63790. private _createBlurPostProcess;
  63791. /** @hidden */
  63792. _rebuild(): void;
  63793. private _bits;
  63794. private _radicalInverse_VdC;
  63795. private _hammersley;
  63796. private _hemisphereSample_uniform;
  63797. private _generateHemisphere;
  63798. private _createSSAOPostProcess;
  63799. private _createSSAOCombinePostProcess;
  63800. private _createRandomTexture;
  63801. /**
  63802. * Serialize the rendering pipeline (Used when exporting)
  63803. * @returns the serialized object
  63804. */
  63805. serialize(): any;
  63806. /**
  63807. * Parse the serialized pipeline
  63808. * @param source Source pipeline.
  63809. * @param scene The scene to load the pipeline to.
  63810. * @param rootUrl The URL of the serialized pipeline.
  63811. * @returns An instantiated pipeline from the serialized object.
  63812. */
  63813. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  63814. }
  63815. }
  63816. declare module "babylonjs/Shaders/ssao.fragment" {
  63817. /** @hidden */
  63818. export var ssaoPixelShader: {
  63819. name: string;
  63820. shader: string;
  63821. };
  63822. }
  63823. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  63824. import { Camera } from "babylonjs/Cameras/camera";
  63825. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63826. import { Scene } from "babylonjs/scene";
  63827. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63828. import "babylonjs/Shaders/ssao.fragment";
  63829. import "babylonjs/Shaders/ssaoCombine.fragment";
  63830. /**
  63831. * Render pipeline to produce ssao effect
  63832. */
  63833. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  63834. /**
  63835. * @ignore
  63836. * The PassPostProcess id in the pipeline that contains the original scene color
  63837. */
  63838. SSAOOriginalSceneColorEffect: string;
  63839. /**
  63840. * @ignore
  63841. * The SSAO PostProcess id in the pipeline
  63842. */
  63843. SSAORenderEffect: string;
  63844. /**
  63845. * @ignore
  63846. * The horizontal blur PostProcess id in the pipeline
  63847. */
  63848. SSAOBlurHRenderEffect: string;
  63849. /**
  63850. * @ignore
  63851. * The vertical blur PostProcess id in the pipeline
  63852. */
  63853. SSAOBlurVRenderEffect: string;
  63854. /**
  63855. * @ignore
  63856. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  63857. */
  63858. SSAOCombineRenderEffect: string;
  63859. /**
  63860. * The output strength of the SSAO post-process. Default value is 1.0.
  63861. */
  63862. totalStrength: number;
  63863. /**
  63864. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  63865. */
  63866. radius: number;
  63867. /**
  63868. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  63869. * Must not be equal to fallOff and superior to fallOff.
  63870. * Default value is 0.0075
  63871. */
  63872. area: number;
  63873. /**
  63874. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  63875. * Must not be equal to area and inferior to area.
  63876. * Default value is 0.000001
  63877. */
  63878. fallOff: number;
  63879. /**
  63880. * The base color of the SSAO post-process
  63881. * The final result is "base + ssao" between [0, 1]
  63882. */
  63883. base: number;
  63884. private _scene;
  63885. private _depthTexture;
  63886. private _randomTexture;
  63887. private _originalColorPostProcess;
  63888. private _ssaoPostProcess;
  63889. private _blurHPostProcess;
  63890. private _blurVPostProcess;
  63891. private _ssaoCombinePostProcess;
  63892. private _firstUpdate;
  63893. /**
  63894. * Gets active scene
  63895. */
  63896. readonly scene: Scene;
  63897. /**
  63898. * @constructor
  63899. * @param name - The rendering pipeline name
  63900. * @param scene - The scene linked to this pipeline
  63901. * @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 }
  63902. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  63903. */
  63904. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  63905. /**
  63906. * Get the class name
  63907. * @returns "SSAORenderingPipeline"
  63908. */
  63909. getClassName(): string;
  63910. /**
  63911. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  63912. */
  63913. dispose(disableDepthRender?: boolean): void;
  63914. private _createBlurPostProcess;
  63915. /** @hidden */
  63916. _rebuild(): void;
  63917. private _createSSAOPostProcess;
  63918. private _createSSAOCombinePostProcess;
  63919. private _createRandomTexture;
  63920. }
  63921. }
  63922. declare module "babylonjs/Shaders/standard.fragment" {
  63923. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  63924. /** @hidden */
  63925. export var standardPixelShader: {
  63926. name: string;
  63927. shader: string;
  63928. };
  63929. }
  63930. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  63931. import { Nullable } from "babylonjs/types";
  63932. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  63933. import { Camera } from "babylonjs/Cameras/camera";
  63934. import { Texture } from "babylonjs/Materials/Textures/texture";
  63935. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63936. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63937. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  63938. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  63939. import { IDisposable } from "babylonjs/scene";
  63940. import { SpotLight } from "babylonjs/Lights/spotLight";
  63941. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  63942. import { Scene } from "babylonjs/scene";
  63943. import { Animation } from "babylonjs/Animations/animation";
  63944. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63945. import "babylonjs/Shaders/standard.fragment";
  63946. /**
  63947. * Standard rendering pipeline
  63948. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  63949. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  63950. */
  63951. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  63952. /**
  63953. * Public members
  63954. */
  63955. /**
  63956. * Post-process which contains the original scene color before the pipeline applies all the effects
  63957. */
  63958. originalPostProcess: Nullable<PostProcess>;
  63959. /**
  63960. * Post-process used to down scale an image x4
  63961. */
  63962. downSampleX4PostProcess: Nullable<PostProcess>;
  63963. /**
  63964. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  63965. */
  63966. brightPassPostProcess: Nullable<PostProcess>;
  63967. /**
  63968. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  63969. */
  63970. blurHPostProcesses: PostProcess[];
  63971. /**
  63972. * Post-process array storing all the vertical blur post-processes used by the pipeline
  63973. */
  63974. blurVPostProcesses: PostProcess[];
  63975. /**
  63976. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  63977. */
  63978. textureAdderPostProcess: Nullable<PostProcess>;
  63979. /**
  63980. * Post-process used to create volumetric lighting effect
  63981. */
  63982. volumetricLightPostProcess: Nullable<PostProcess>;
  63983. /**
  63984. * Post-process used to smooth the previous volumetric light post-process on the X axis
  63985. */
  63986. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  63987. /**
  63988. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  63989. */
  63990. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  63991. /**
  63992. * Post-process used to merge the volumetric light effect and the real scene color
  63993. */
  63994. volumetricLightMergePostProces: Nullable<PostProcess>;
  63995. /**
  63996. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  63997. */
  63998. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  63999. /**
  64000. * Base post-process used to calculate the average luminance of the final image for HDR
  64001. */
  64002. luminancePostProcess: Nullable<PostProcess>;
  64003. /**
  64004. * Post-processes used to create down sample post-processes in order to get
  64005. * the average luminance of the final image for HDR
  64006. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  64007. */
  64008. luminanceDownSamplePostProcesses: PostProcess[];
  64009. /**
  64010. * Post-process used to create a HDR effect (light adaptation)
  64011. */
  64012. hdrPostProcess: Nullable<PostProcess>;
  64013. /**
  64014. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  64015. */
  64016. textureAdderFinalPostProcess: Nullable<PostProcess>;
  64017. /**
  64018. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  64019. */
  64020. lensFlareFinalPostProcess: Nullable<PostProcess>;
  64021. /**
  64022. * Post-process used to merge the final HDR post-process and the real scene color
  64023. */
  64024. hdrFinalPostProcess: Nullable<PostProcess>;
  64025. /**
  64026. * Post-process used to create a lens flare effect
  64027. */
  64028. lensFlarePostProcess: Nullable<PostProcess>;
  64029. /**
  64030. * Post-process that merges the result of the lens flare post-process and the real scene color
  64031. */
  64032. lensFlareComposePostProcess: Nullable<PostProcess>;
  64033. /**
  64034. * Post-process used to create a motion blur effect
  64035. */
  64036. motionBlurPostProcess: Nullable<PostProcess>;
  64037. /**
  64038. * Post-process used to create a depth of field effect
  64039. */
  64040. depthOfFieldPostProcess: Nullable<PostProcess>;
  64041. /**
  64042. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  64043. */
  64044. fxaaPostProcess: Nullable<FxaaPostProcess>;
  64045. /**
  64046. * Represents the brightness threshold in order to configure the illuminated surfaces
  64047. */
  64048. brightThreshold: number;
  64049. /**
  64050. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  64051. */
  64052. blurWidth: number;
  64053. /**
  64054. * Sets if the blur for highlighted surfaces must be only horizontal
  64055. */
  64056. horizontalBlur: boolean;
  64057. /**
  64058. * Gets the overall exposure used by the pipeline
  64059. */
  64060. /**
  64061. * Sets the overall exposure used by the pipeline
  64062. */
  64063. exposure: number;
  64064. /**
  64065. * Texture used typically to simulate "dirty" on camera lens
  64066. */
  64067. lensTexture: Nullable<Texture>;
  64068. /**
  64069. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  64070. */
  64071. volumetricLightCoefficient: number;
  64072. /**
  64073. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  64074. */
  64075. volumetricLightPower: number;
  64076. /**
  64077. * Used the set the blur intensity to smooth the volumetric lights
  64078. */
  64079. volumetricLightBlurScale: number;
  64080. /**
  64081. * Light (spot or directional) used to generate the volumetric lights rays
  64082. * The source light must have a shadow generate so the pipeline can get its
  64083. * depth map
  64084. */
  64085. sourceLight: Nullable<SpotLight | DirectionalLight>;
  64086. /**
  64087. * For eye adaptation, represents the minimum luminance the eye can see
  64088. */
  64089. hdrMinimumLuminance: number;
  64090. /**
  64091. * For eye adaptation, represents the decrease luminance speed
  64092. */
  64093. hdrDecreaseRate: number;
  64094. /**
  64095. * For eye adaptation, represents the increase luminance speed
  64096. */
  64097. hdrIncreaseRate: number;
  64098. /**
  64099. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  64100. */
  64101. /**
  64102. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  64103. */
  64104. hdrAutoExposure: boolean;
  64105. /**
  64106. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  64107. */
  64108. lensColorTexture: Nullable<Texture>;
  64109. /**
  64110. * The overall strengh for the lens flare effect
  64111. */
  64112. lensFlareStrength: number;
  64113. /**
  64114. * Dispersion coefficient for lens flare ghosts
  64115. */
  64116. lensFlareGhostDispersal: number;
  64117. /**
  64118. * Main lens flare halo width
  64119. */
  64120. lensFlareHaloWidth: number;
  64121. /**
  64122. * Based on the lens distortion effect, defines how much the lens flare result
  64123. * is distorted
  64124. */
  64125. lensFlareDistortionStrength: number;
  64126. /**
  64127. * Configures the blur intensity used for for lens flare (halo)
  64128. */
  64129. lensFlareBlurWidth: number;
  64130. /**
  64131. * Lens star texture must be used to simulate rays on the flares and is available
  64132. * in the documentation
  64133. */
  64134. lensStarTexture: Nullable<Texture>;
  64135. /**
  64136. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  64137. * flare effect by taking account of the dirt texture
  64138. */
  64139. lensFlareDirtTexture: Nullable<Texture>;
  64140. /**
  64141. * Represents the focal length for the depth of field effect
  64142. */
  64143. depthOfFieldDistance: number;
  64144. /**
  64145. * Represents the blur intensity for the blurred part of the depth of field effect
  64146. */
  64147. depthOfFieldBlurWidth: number;
  64148. /**
  64149. * Gets how much the image is blurred by the movement while using the motion blur post-process
  64150. */
  64151. /**
  64152. * Sets how much the image is blurred by the movement while using the motion blur post-process
  64153. */
  64154. motionStrength: number;
  64155. /**
  64156. * Gets wether or not the motion blur post-process is object based or screen based.
  64157. */
  64158. /**
  64159. * Sets wether or not the motion blur post-process should be object based or screen based
  64160. */
  64161. objectBasedMotionBlur: boolean;
  64162. /**
  64163. * List of animations for the pipeline (IAnimatable implementation)
  64164. */
  64165. animations: Animation[];
  64166. /**
  64167. * Private members
  64168. */
  64169. private _scene;
  64170. private _currentDepthOfFieldSource;
  64171. private _basePostProcess;
  64172. private _fixedExposure;
  64173. private _currentExposure;
  64174. private _hdrAutoExposure;
  64175. private _hdrCurrentLuminance;
  64176. private _motionStrength;
  64177. private _isObjectBasedMotionBlur;
  64178. private _floatTextureType;
  64179. private _camerasToBeAttached;
  64180. private _ratio;
  64181. private _bloomEnabled;
  64182. private _depthOfFieldEnabled;
  64183. private _vlsEnabled;
  64184. private _lensFlareEnabled;
  64185. private _hdrEnabled;
  64186. private _motionBlurEnabled;
  64187. private _fxaaEnabled;
  64188. private _motionBlurSamples;
  64189. private _volumetricLightStepsCount;
  64190. private _samples;
  64191. /**
  64192. * @ignore
  64193. * Specifies if the bloom pipeline is enabled
  64194. */
  64195. BloomEnabled: boolean;
  64196. /**
  64197. * @ignore
  64198. * Specifies if the depth of field pipeline is enabed
  64199. */
  64200. DepthOfFieldEnabled: boolean;
  64201. /**
  64202. * @ignore
  64203. * Specifies if the lens flare pipeline is enabed
  64204. */
  64205. LensFlareEnabled: boolean;
  64206. /**
  64207. * @ignore
  64208. * Specifies if the HDR pipeline is enabled
  64209. */
  64210. HDREnabled: boolean;
  64211. /**
  64212. * @ignore
  64213. * Specifies if the volumetric lights scattering effect is enabled
  64214. */
  64215. VLSEnabled: boolean;
  64216. /**
  64217. * @ignore
  64218. * Specifies if the motion blur effect is enabled
  64219. */
  64220. MotionBlurEnabled: boolean;
  64221. /**
  64222. * Specifies if anti-aliasing is enabled
  64223. */
  64224. fxaaEnabled: boolean;
  64225. /**
  64226. * Specifies the number of steps used to calculate the volumetric lights
  64227. * Typically in interval [50, 200]
  64228. */
  64229. volumetricLightStepsCount: number;
  64230. /**
  64231. * Specifies the number of samples used for the motion blur effect
  64232. * Typically in interval [16, 64]
  64233. */
  64234. motionBlurSamples: number;
  64235. /**
  64236. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  64237. */
  64238. samples: number;
  64239. /**
  64240. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  64241. * @constructor
  64242. * @param name The rendering pipeline name
  64243. * @param scene The scene linked to this pipeline
  64244. * @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)
  64245. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  64246. * @param cameras The array of cameras that the rendering pipeline will be attached to
  64247. */
  64248. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  64249. private _buildPipeline;
  64250. private _createDownSampleX4PostProcess;
  64251. private _createBrightPassPostProcess;
  64252. private _createBlurPostProcesses;
  64253. private _createTextureAdderPostProcess;
  64254. private _createVolumetricLightPostProcess;
  64255. private _createLuminancePostProcesses;
  64256. private _createHdrPostProcess;
  64257. private _createLensFlarePostProcess;
  64258. private _createDepthOfFieldPostProcess;
  64259. private _createMotionBlurPostProcess;
  64260. private _getDepthTexture;
  64261. private _disposePostProcesses;
  64262. /**
  64263. * Dispose of the pipeline and stop all post processes
  64264. */
  64265. dispose(): void;
  64266. /**
  64267. * Serialize the rendering pipeline (Used when exporting)
  64268. * @returns the serialized object
  64269. */
  64270. serialize(): any;
  64271. /**
  64272. * Parse the serialized pipeline
  64273. * @param source Source pipeline.
  64274. * @param scene The scene to load the pipeline to.
  64275. * @param rootUrl The URL of the serialized pipeline.
  64276. * @returns An instantiated pipeline from the serialized object.
  64277. */
  64278. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  64279. /**
  64280. * Luminance steps
  64281. */
  64282. static LuminanceSteps: number;
  64283. }
  64284. }
  64285. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  64286. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  64287. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  64288. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  64289. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  64290. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  64291. }
  64292. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  64293. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  64294. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  64295. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64296. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  64297. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64298. }
  64299. declare module "babylonjs/Shaders/tonemap.fragment" {
  64300. /** @hidden */
  64301. export var tonemapPixelShader: {
  64302. name: string;
  64303. shader: string;
  64304. };
  64305. }
  64306. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  64307. import { Camera } from "babylonjs/Cameras/camera";
  64308. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  64309. import "babylonjs/Shaders/tonemap.fragment";
  64310. import { Engine } from "babylonjs/Engines/engine";
  64311. /** Defines operator used for tonemapping */
  64312. export enum TonemappingOperator {
  64313. /** Hable */
  64314. Hable = 0,
  64315. /** Reinhard */
  64316. Reinhard = 1,
  64317. /** HejiDawson */
  64318. HejiDawson = 2,
  64319. /** Photographic */
  64320. Photographic = 3
  64321. }
  64322. /**
  64323. * Defines a post process to apply tone mapping
  64324. */
  64325. export class TonemapPostProcess extends PostProcess {
  64326. private _operator;
  64327. /** Defines the required exposure adjustement */
  64328. exposureAdjustment: number;
  64329. /**
  64330. * Creates a new TonemapPostProcess
  64331. * @param name defines the name of the postprocess
  64332. * @param _operator defines the operator to use
  64333. * @param exposureAdjustment defines the required exposure adjustement
  64334. * @param camera defines the camera to use (can be null)
  64335. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  64336. * @param engine defines the hosting engine (can be ignore if camera is set)
  64337. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  64338. */
  64339. constructor(name: string, _operator: TonemappingOperator,
  64340. /** Defines the required exposure adjustement */
  64341. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  64342. }
  64343. }
  64344. declare module "babylonjs/Shaders/depth.vertex" {
  64345. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  64346. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  64347. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  64348. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  64349. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  64350. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  64351. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  64352. /** @hidden */
  64353. export var depthVertexShader: {
  64354. name: string;
  64355. shader: string;
  64356. };
  64357. }
  64358. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  64359. /** @hidden */
  64360. export var volumetricLightScatteringPixelShader: {
  64361. name: string;
  64362. shader: string;
  64363. };
  64364. }
  64365. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  64366. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  64367. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  64368. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  64369. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  64370. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  64371. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  64372. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  64373. /** @hidden */
  64374. export var volumetricLightScatteringPassVertexShader: {
  64375. name: string;
  64376. shader: string;
  64377. };
  64378. }
  64379. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  64380. /** @hidden */
  64381. export var volumetricLightScatteringPassPixelShader: {
  64382. name: string;
  64383. shader: string;
  64384. };
  64385. }
  64386. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  64387. import { Vector3 } from "babylonjs/Maths/math.vector";
  64388. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64389. import { Mesh } from "babylonjs/Meshes/mesh";
  64390. import { Camera } from "babylonjs/Cameras/camera";
  64391. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64392. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  64393. import { Scene } from "babylonjs/scene";
  64394. import "babylonjs/Meshes/Builders/planeBuilder";
  64395. import "babylonjs/Shaders/depth.vertex";
  64396. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  64397. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  64398. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  64399. import { Engine } from "babylonjs/Engines/engine";
  64400. /**
  64401. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  64402. */
  64403. export class VolumetricLightScatteringPostProcess extends PostProcess {
  64404. private _volumetricLightScatteringPass;
  64405. private _volumetricLightScatteringRTT;
  64406. private _viewPort;
  64407. private _screenCoordinates;
  64408. private _cachedDefines;
  64409. /**
  64410. * If not undefined, the mesh position is computed from the attached node position
  64411. */
  64412. attachedNode: {
  64413. position: Vector3;
  64414. };
  64415. /**
  64416. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  64417. */
  64418. customMeshPosition: Vector3;
  64419. /**
  64420. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  64421. */
  64422. useCustomMeshPosition: boolean;
  64423. /**
  64424. * If the post-process should inverse the light scattering direction
  64425. */
  64426. invert: boolean;
  64427. /**
  64428. * The internal mesh used by the post-process
  64429. */
  64430. mesh: Mesh;
  64431. /**
  64432. * @hidden
  64433. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  64434. */
  64435. useDiffuseColor: boolean;
  64436. /**
  64437. * Array containing the excluded meshes not rendered in the internal pass
  64438. */
  64439. excludedMeshes: AbstractMesh[];
  64440. /**
  64441. * Controls the overall intensity of the post-process
  64442. */
  64443. exposure: number;
  64444. /**
  64445. * Dissipates each sample's contribution in range [0, 1]
  64446. */
  64447. decay: number;
  64448. /**
  64449. * Controls the overall intensity of each sample
  64450. */
  64451. weight: number;
  64452. /**
  64453. * Controls the density of each sample
  64454. */
  64455. density: number;
  64456. /**
  64457. * @constructor
  64458. * @param name The post-process name
  64459. * @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)
  64460. * @param camera The camera that the post-process will be attached to
  64461. * @param mesh The mesh used to create the light scattering
  64462. * @param samples The post-process quality, default 100
  64463. * @param samplingModeThe post-process filtering mode
  64464. * @param engine The babylon engine
  64465. * @param reusable If the post-process is reusable
  64466. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  64467. */
  64468. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  64469. /**
  64470. * Returns the string "VolumetricLightScatteringPostProcess"
  64471. * @returns "VolumetricLightScatteringPostProcess"
  64472. */
  64473. getClassName(): string;
  64474. private _isReady;
  64475. /**
  64476. * Sets the new light position for light scattering effect
  64477. * @param position The new custom light position
  64478. */
  64479. setCustomMeshPosition(position: Vector3): void;
  64480. /**
  64481. * Returns the light position for light scattering effect
  64482. * @return Vector3 The custom light position
  64483. */
  64484. getCustomMeshPosition(): Vector3;
  64485. /**
  64486. * Disposes the internal assets and detaches the post-process from the camera
  64487. */
  64488. dispose(camera: Camera): void;
  64489. /**
  64490. * Returns the render target texture used by the post-process
  64491. * @return the render target texture used by the post-process
  64492. */
  64493. getPass(): RenderTargetTexture;
  64494. private _meshExcluded;
  64495. private _createPass;
  64496. private _updateMeshScreenCoordinates;
  64497. /**
  64498. * Creates a default mesh for the Volumeric Light Scattering post-process
  64499. * @param name The mesh name
  64500. * @param scene The scene where to create the mesh
  64501. * @return the default mesh
  64502. */
  64503. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  64504. }
  64505. }
  64506. declare module "babylonjs/PostProcesses/index" {
  64507. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  64508. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  64509. export * from "babylonjs/PostProcesses/bloomEffect";
  64510. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  64511. export * from "babylonjs/PostProcesses/blurPostProcess";
  64512. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  64513. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  64514. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  64515. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  64516. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  64517. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  64518. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  64519. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  64520. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  64521. export * from "babylonjs/PostProcesses/filterPostProcess";
  64522. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  64523. export * from "babylonjs/PostProcesses/grainPostProcess";
  64524. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  64525. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  64526. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  64527. export * from "babylonjs/PostProcesses/passPostProcess";
  64528. export * from "babylonjs/PostProcesses/postProcess";
  64529. export * from "babylonjs/PostProcesses/postProcessManager";
  64530. export * from "babylonjs/PostProcesses/refractionPostProcess";
  64531. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  64532. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  64533. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  64534. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  64535. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  64536. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  64537. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  64538. }
  64539. declare module "babylonjs/Probes/index" {
  64540. export * from "babylonjs/Probes/reflectionProbe";
  64541. }
  64542. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  64543. import { Scene } from "babylonjs/scene";
  64544. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64545. import { SmartArray } from "babylonjs/Misc/smartArray";
  64546. import { ISceneComponent } from "babylonjs/sceneComponent";
  64547. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  64548. import "babylonjs/Meshes/Builders/boxBuilder";
  64549. import "babylonjs/Shaders/color.fragment";
  64550. import "babylonjs/Shaders/color.vertex";
  64551. import { Color3 } from "babylonjs/Maths/math.color";
  64552. module "babylonjs/scene" {
  64553. interface Scene {
  64554. /** @hidden (Backing field) */
  64555. _boundingBoxRenderer: BoundingBoxRenderer;
  64556. /** @hidden (Backing field) */
  64557. _forceShowBoundingBoxes: boolean;
  64558. /**
  64559. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  64560. */
  64561. forceShowBoundingBoxes: boolean;
  64562. /**
  64563. * Gets the bounding box renderer associated with the scene
  64564. * @returns a BoundingBoxRenderer
  64565. */
  64566. getBoundingBoxRenderer(): BoundingBoxRenderer;
  64567. }
  64568. }
  64569. module "babylonjs/Meshes/abstractMesh" {
  64570. interface AbstractMesh {
  64571. /** @hidden (Backing field) */
  64572. _showBoundingBox: boolean;
  64573. /**
  64574. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  64575. */
  64576. showBoundingBox: boolean;
  64577. }
  64578. }
  64579. /**
  64580. * Component responsible of rendering the bounding box of the meshes in a scene.
  64581. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  64582. */
  64583. export class BoundingBoxRenderer implements ISceneComponent {
  64584. /**
  64585. * The component name helpfull to identify the component in the list of scene components.
  64586. */
  64587. readonly name: string;
  64588. /**
  64589. * The scene the component belongs to.
  64590. */
  64591. scene: Scene;
  64592. /**
  64593. * Color of the bounding box lines placed in front of an object
  64594. */
  64595. frontColor: Color3;
  64596. /**
  64597. * Color of the bounding box lines placed behind an object
  64598. */
  64599. backColor: Color3;
  64600. /**
  64601. * Defines if the renderer should show the back lines or not
  64602. */
  64603. showBackLines: boolean;
  64604. /**
  64605. * @hidden
  64606. */
  64607. renderList: SmartArray<BoundingBox>;
  64608. private _colorShader;
  64609. private _vertexBuffers;
  64610. private _indexBuffer;
  64611. private _fillIndexBuffer;
  64612. private _fillIndexData;
  64613. /**
  64614. * Instantiates a new bounding box renderer in a scene.
  64615. * @param scene the scene the renderer renders in
  64616. */
  64617. constructor(scene: Scene);
  64618. /**
  64619. * Registers the component in a given scene
  64620. */
  64621. register(): void;
  64622. private _evaluateSubMesh;
  64623. private _activeMesh;
  64624. private _prepareRessources;
  64625. private _createIndexBuffer;
  64626. /**
  64627. * Rebuilds the elements related to this component in case of
  64628. * context lost for instance.
  64629. */
  64630. rebuild(): void;
  64631. /**
  64632. * @hidden
  64633. */
  64634. reset(): void;
  64635. /**
  64636. * Render the bounding boxes of a specific rendering group
  64637. * @param renderingGroupId defines the rendering group to render
  64638. */
  64639. render(renderingGroupId: number): void;
  64640. /**
  64641. * In case of occlusion queries, we can render the occlusion bounding box through this method
  64642. * @param mesh Define the mesh to render the occlusion bounding box for
  64643. */
  64644. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  64645. /**
  64646. * Dispose and release the resources attached to this renderer.
  64647. */
  64648. dispose(): void;
  64649. }
  64650. }
  64651. declare module "babylonjs/Shaders/depth.fragment" {
  64652. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  64653. /** @hidden */
  64654. export var depthPixelShader: {
  64655. name: string;
  64656. shader: string;
  64657. };
  64658. }
  64659. declare module "babylonjs/Rendering/depthRenderer" {
  64660. import { Nullable } from "babylonjs/types";
  64661. import { SubMesh } from "babylonjs/Meshes/subMesh";
  64662. import { Scene } from "babylonjs/scene";
  64663. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64664. import { Camera } from "babylonjs/Cameras/camera";
  64665. import "babylonjs/Shaders/depth.fragment";
  64666. import "babylonjs/Shaders/depth.vertex";
  64667. /**
  64668. * This represents a depth renderer in Babylon.
  64669. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  64670. */
  64671. export class DepthRenderer {
  64672. private _scene;
  64673. private _depthMap;
  64674. private _effect;
  64675. private readonly _storeNonLinearDepth;
  64676. private readonly _clearColor;
  64677. /** Get if the depth renderer is using packed depth or not */
  64678. readonly isPacked: boolean;
  64679. private _cachedDefines;
  64680. private _camera;
  64681. /**
  64682. * Specifiess that the depth renderer will only be used within
  64683. * the camera it is created for.
  64684. * This can help forcing its rendering during the camera processing.
  64685. */
  64686. useOnlyInActiveCamera: boolean;
  64687. /** @hidden */
  64688. static _SceneComponentInitialization: (scene: Scene) => void;
  64689. /**
  64690. * Instantiates a depth renderer
  64691. * @param scene The scene the renderer belongs to
  64692. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  64693. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  64694. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  64695. */
  64696. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  64697. /**
  64698. * Creates the depth rendering effect and checks if the effect is ready.
  64699. * @param subMesh The submesh to be used to render the depth map of
  64700. * @param useInstances If multiple world instances should be used
  64701. * @returns if the depth renderer is ready to render the depth map
  64702. */
  64703. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64704. /**
  64705. * Gets the texture which the depth map will be written to.
  64706. * @returns The depth map texture
  64707. */
  64708. getDepthMap(): RenderTargetTexture;
  64709. /**
  64710. * Disposes of the depth renderer.
  64711. */
  64712. dispose(): void;
  64713. }
  64714. }
  64715. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  64716. import { Nullable } from "babylonjs/types";
  64717. import { Scene } from "babylonjs/scene";
  64718. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  64719. import { Camera } from "babylonjs/Cameras/camera";
  64720. import { ISceneComponent } from "babylonjs/sceneComponent";
  64721. module "babylonjs/scene" {
  64722. interface Scene {
  64723. /** @hidden (Backing field) */
  64724. _depthRenderer: {
  64725. [id: string]: DepthRenderer;
  64726. };
  64727. /**
  64728. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  64729. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  64730. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  64731. * @returns the created depth renderer
  64732. */
  64733. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  64734. /**
  64735. * Disables a depth renderer for a given camera
  64736. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  64737. */
  64738. disableDepthRenderer(camera?: Nullable<Camera>): void;
  64739. }
  64740. }
  64741. /**
  64742. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  64743. * in several rendering techniques.
  64744. */
  64745. export class DepthRendererSceneComponent implements ISceneComponent {
  64746. /**
  64747. * The component name helpfull to identify the component in the list of scene components.
  64748. */
  64749. readonly name: string;
  64750. /**
  64751. * The scene the component belongs to.
  64752. */
  64753. scene: Scene;
  64754. /**
  64755. * Creates a new instance of the component for the given scene
  64756. * @param scene Defines the scene to register the component in
  64757. */
  64758. constructor(scene: Scene);
  64759. /**
  64760. * Registers the component in a given scene
  64761. */
  64762. register(): void;
  64763. /**
  64764. * Rebuilds the elements related to this component in case of
  64765. * context lost for instance.
  64766. */
  64767. rebuild(): void;
  64768. /**
  64769. * Disposes the component and the associated ressources
  64770. */
  64771. dispose(): void;
  64772. private _gatherRenderTargets;
  64773. private _gatherActiveCameraRenderTargets;
  64774. }
  64775. }
  64776. declare module "babylonjs/Shaders/outline.fragment" {
  64777. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  64778. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  64779. /** @hidden */
  64780. export var outlinePixelShader: {
  64781. name: string;
  64782. shader: string;
  64783. };
  64784. }
  64785. declare module "babylonjs/Shaders/outline.vertex" {
  64786. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  64787. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  64788. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  64789. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  64790. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  64791. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  64792. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  64793. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  64794. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  64795. /** @hidden */
  64796. export var outlineVertexShader: {
  64797. name: string;
  64798. shader: string;
  64799. };
  64800. }
  64801. declare module "babylonjs/Rendering/outlineRenderer" {
  64802. import { SubMesh } from "babylonjs/Meshes/subMesh";
  64803. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  64804. import { Scene } from "babylonjs/scene";
  64805. import { ISceneComponent } from "babylonjs/sceneComponent";
  64806. import "babylonjs/Shaders/outline.fragment";
  64807. import "babylonjs/Shaders/outline.vertex";
  64808. module "babylonjs/scene" {
  64809. interface Scene {
  64810. /** @hidden */
  64811. _outlineRenderer: OutlineRenderer;
  64812. /**
  64813. * Gets the outline renderer associated with the scene
  64814. * @returns a OutlineRenderer
  64815. */
  64816. getOutlineRenderer(): OutlineRenderer;
  64817. }
  64818. }
  64819. module "babylonjs/Meshes/abstractMesh" {
  64820. interface AbstractMesh {
  64821. /** @hidden (Backing field) */
  64822. _renderOutline: boolean;
  64823. /**
  64824. * Gets or sets a boolean indicating if the outline must be rendered as well
  64825. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  64826. */
  64827. renderOutline: boolean;
  64828. /** @hidden (Backing field) */
  64829. _renderOverlay: boolean;
  64830. /**
  64831. * Gets or sets a boolean indicating if the overlay must be rendered as well
  64832. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  64833. */
  64834. renderOverlay: boolean;
  64835. }
  64836. }
  64837. /**
  64838. * This class is responsible to draw bothe outline/overlay of meshes.
  64839. * It should not be used directly but through the available method on mesh.
  64840. */
  64841. export class OutlineRenderer implements ISceneComponent {
  64842. /**
  64843. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  64844. */
  64845. private static _StencilReference;
  64846. /**
  64847. * The name of the component. Each component must have a unique name.
  64848. */
  64849. name: string;
  64850. /**
  64851. * The scene the component belongs to.
  64852. */
  64853. scene: Scene;
  64854. /**
  64855. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  64856. */
  64857. zOffset: number;
  64858. private _engine;
  64859. private _effect;
  64860. private _cachedDefines;
  64861. private _savedDepthWrite;
  64862. /**
  64863. * Instantiates a new outline renderer. (There could be only one per scene).
  64864. * @param scene Defines the scene it belongs to
  64865. */
  64866. constructor(scene: Scene);
  64867. /**
  64868. * Register the component to one instance of a scene.
  64869. */
  64870. register(): void;
  64871. /**
  64872. * Rebuilds the elements related to this component in case of
  64873. * context lost for instance.
  64874. */
  64875. rebuild(): void;
  64876. /**
  64877. * Disposes the component and the associated ressources.
  64878. */
  64879. dispose(): void;
  64880. /**
  64881. * Renders the outline in the canvas.
  64882. * @param subMesh Defines the sumesh to render
  64883. * @param batch Defines the batch of meshes in case of instances
  64884. * @param useOverlay Defines if the rendering is for the overlay or the outline
  64885. */
  64886. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  64887. /**
  64888. * Returns whether or not the outline renderer is ready for a given submesh.
  64889. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  64890. * @param subMesh Defines the submesh to check readyness for
  64891. * @param useInstances Defines wheter wee are trying to render instances or not
  64892. * @returns true if ready otherwise false
  64893. */
  64894. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64895. private _beforeRenderingMesh;
  64896. private _afterRenderingMesh;
  64897. }
  64898. }
  64899. declare module "babylonjs/Rendering/index" {
  64900. export * from "babylonjs/Rendering/boundingBoxRenderer";
  64901. export * from "babylonjs/Rendering/depthRenderer";
  64902. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  64903. export * from "babylonjs/Rendering/edgesRenderer";
  64904. export * from "babylonjs/Rendering/geometryBufferRenderer";
  64905. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  64906. export * from "babylonjs/Rendering/outlineRenderer";
  64907. export * from "babylonjs/Rendering/renderingGroup";
  64908. export * from "babylonjs/Rendering/renderingManager";
  64909. export * from "babylonjs/Rendering/utilityLayerRenderer";
  64910. }
  64911. declare module "babylonjs/Sprites/spritePackedManager" {
  64912. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  64913. import { Scene } from "babylonjs/scene";
  64914. /**
  64915. * Class used to manage multiple sprites of different sizes on the same spritesheet
  64916. * @see http://doc.babylonjs.com/babylon101/sprites
  64917. */
  64918. export class SpritePackedManager extends SpriteManager {
  64919. /** defines the packed manager's name */
  64920. name: string;
  64921. /**
  64922. * Creates a new sprite manager from a packed sprite sheet
  64923. * @param name defines the manager's name
  64924. * @param imgUrl defines the sprite sheet url
  64925. * @param capacity defines the maximum allowed number of sprites
  64926. * @param scene defines the hosting scene
  64927. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  64928. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  64929. * @param samplingMode defines the smapling mode to use with spritesheet
  64930. * @param fromPacked set to true; do not alter
  64931. */
  64932. constructor(
  64933. /** defines the packed manager's name */
  64934. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  64935. }
  64936. }
  64937. declare module "babylonjs/Sprites/index" {
  64938. export * from "babylonjs/Sprites/sprite";
  64939. export * from "babylonjs/Sprites/spriteManager";
  64940. export * from "babylonjs/Sprites/spritePackedManager";
  64941. export * from "babylonjs/Sprites/spriteSceneComponent";
  64942. }
  64943. declare module "babylonjs/States/index" {
  64944. export * from "babylonjs/States/alphaCullingState";
  64945. export * from "babylonjs/States/depthCullingState";
  64946. export * from "babylonjs/States/stencilState";
  64947. }
  64948. declare module "babylonjs/Misc/assetsManager" {
  64949. import { Scene } from "babylonjs/scene";
  64950. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64951. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  64952. import { Skeleton } from "babylonjs/Bones/skeleton";
  64953. import { Observable } from "babylonjs/Misc/observable";
  64954. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64955. import { Texture } from "babylonjs/Materials/Textures/texture";
  64956. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  64957. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  64958. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  64959. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  64960. /**
  64961. * Defines the list of states available for a task inside a AssetsManager
  64962. */
  64963. export enum AssetTaskState {
  64964. /**
  64965. * Initialization
  64966. */
  64967. INIT = 0,
  64968. /**
  64969. * Running
  64970. */
  64971. RUNNING = 1,
  64972. /**
  64973. * Done
  64974. */
  64975. DONE = 2,
  64976. /**
  64977. * Error
  64978. */
  64979. ERROR = 3
  64980. }
  64981. /**
  64982. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  64983. */
  64984. export abstract class AbstractAssetTask {
  64985. /**
  64986. * Task name
  64987. */ name: string;
  64988. /**
  64989. * Callback called when the task is successful
  64990. */
  64991. onSuccess: (task: any) => void;
  64992. /**
  64993. * Callback called when the task is not successful
  64994. */
  64995. onError: (task: any, message?: string, exception?: any) => void;
  64996. /**
  64997. * Creates a new AssetsManager
  64998. * @param name defines the name of the task
  64999. */
  65000. constructor(
  65001. /**
  65002. * Task name
  65003. */ name: string);
  65004. private _isCompleted;
  65005. private _taskState;
  65006. private _errorObject;
  65007. /**
  65008. * Get if the task is completed
  65009. */
  65010. readonly isCompleted: boolean;
  65011. /**
  65012. * Gets the current state of the task
  65013. */
  65014. readonly taskState: AssetTaskState;
  65015. /**
  65016. * Gets the current error object (if task is in error)
  65017. */
  65018. readonly errorObject: {
  65019. message?: string;
  65020. exception?: any;
  65021. };
  65022. /**
  65023. * Internal only
  65024. * @hidden
  65025. */
  65026. _setErrorObject(message?: string, exception?: any): void;
  65027. /**
  65028. * Execute the current task
  65029. * @param scene defines the scene where you want your assets to be loaded
  65030. * @param onSuccess is a callback called when the task is successfully executed
  65031. * @param onError is a callback called if an error occurs
  65032. */
  65033. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65034. /**
  65035. * Execute the current task
  65036. * @param scene defines the scene where you want your assets to be loaded
  65037. * @param onSuccess is a callback called when the task is successfully executed
  65038. * @param onError is a callback called if an error occurs
  65039. */
  65040. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65041. /**
  65042. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  65043. * This can be used with failed tasks that have the reason for failure fixed.
  65044. */
  65045. reset(): void;
  65046. private onErrorCallback;
  65047. private onDoneCallback;
  65048. }
  65049. /**
  65050. * Define the interface used by progress events raised during assets loading
  65051. */
  65052. export interface IAssetsProgressEvent {
  65053. /**
  65054. * Defines the number of remaining tasks to process
  65055. */
  65056. remainingCount: number;
  65057. /**
  65058. * Defines the total number of tasks
  65059. */
  65060. totalCount: number;
  65061. /**
  65062. * Defines the task that was just processed
  65063. */
  65064. task: AbstractAssetTask;
  65065. }
  65066. /**
  65067. * Class used to share progress information about assets loading
  65068. */
  65069. export class AssetsProgressEvent implements IAssetsProgressEvent {
  65070. /**
  65071. * Defines the number of remaining tasks to process
  65072. */
  65073. remainingCount: number;
  65074. /**
  65075. * Defines the total number of tasks
  65076. */
  65077. totalCount: number;
  65078. /**
  65079. * Defines the task that was just processed
  65080. */
  65081. task: AbstractAssetTask;
  65082. /**
  65083. * Creates a AssetsProgressEvent
  65084. * @param remainingCount defines the number of remaining tasks to process
  65085. * @param totalCount defines the total number of tasks
  65086. * @param task defines the task that was just processed
  65087. */
  65088. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  65089. }
  65090. /**
  65091. * Define a task used by AssetsManager to load meshes
  65092. */
  65093. export class MeshAssetTask extends AbstractAssetTask {
  65094. /**
  65095. * Defines the name of the task
  65096. */
  65097. name: string;
  65098. /**
  65099. * Defines the list of mesh's names you want to load
  65100. */
  65101. meshesNames: any;
  65102. /**
  65103. * Defines the root url to use as a base to load your meshes and associated resources
  65104. */
  65105. rootUrl: string;
  65106. /**
  65107. * Defines the filename of the scene to load from
  65108. */
  65109. sceneFilename: string;
  65110. /**
  65111. * Gets the list of loaded meshes
  65112. */
  65113. loadedMeshes: Array<AbstractMesh>;
  65114. /**
  65115. * Gets the list of loaded particle systems
  65116. */
  65117. loadedParticleSystems: Array<IParticleSystem>;
  65118. /**
  65119. * Gets the list of loaded skeletons
  65120. */
  65121. loadedSkeletons: Array<Skeleton>;
  65122. /**
  65123. * Gets the list of loaded animation groups
  65124. */
  65125. loadedAnimationGroups: Array<AnimationGroup>;
  65126. /**
  65127. * Callback called when the task is successful
  65128. */
  65129. onSuccess: (task: MeshAssetTask) => void;
  65130. /**
  65131. * Callback called when the task is successful
  65132. */
  65133. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  65134. /**
  65135. * Creates a new MeshAssetTask
  65136. * @param name defines the name of the task
  65137. * @param meshesNames defines the list of mesh's names you want to load
  65138. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  65139. * @param sceneFilename defines the filename of the scene to load from
  65140. */
  65141. constructor(
  65142. /**
  65143. * Defines the name of the task
  65144. */
  65145. name: string,
  65146. /**
  65147. * Defines the list of mesh's names you want to load
  65148. */
  65149. meshesNames: any,
  65150. /**
  65151. * Defines the root url to use as a base to load your meshes and associated resources
  65152. */
  65153. rootUrl: string,
  65154. /**
  65155. * Defines the filename of the scene to load from
  65156. */
  65157. sceneFilename: string);
  65158. /**
  65159. * Execute the current task
  65160. * @param scene defines the scene where you want your assets to be loaded
  65161. * @param onSuccess is a callback called when the task is successfully executed
  65162. * @param onError is a callback called if an error occurs
  65163. */
  65164. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65165. }
  65166. /**
  65167. * Define a task used by AssetsManager to load text content
  65168. */
  65169. export class TextFileAssetTask extends AbstractAssetTask {
  65170. /**
  65171. * Defines the name of the task
  65172. */
  65173. name: string;
  65174. /**
  65175. * Defines the location of the file to load
  65176. */
  65177. url: string;
  65178. /**
  65179. * Gets the loaded text string
  65180. */
  65181. text: string;
  65182. /**
  65183. * Callback called when the task is successful
  65184. */
  65185. onSuccess: (task: TextFileAssetTask) => void;
  65186. /**
  65187. * Callback called when the task is successful
  65188. */
  65189. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  65190. /**
  65191. * Creates a new TextFileAssetTask object
  65192. * @param name defines the name of the task
  65193. * @param url defines the location of the file to load
  65194. */
  65195. constructor(
  65196. /**
  65197. * Defines the name of the task
  65198. */
  65199. name: string,
  65200. /**
  65201. * Defines the location of the file to load
  65202. */
  65203. url: string);
  65204. /**
  65205. * Execute the current task
  65206. * @param scene defines the scene where you want your assets to be loaded
  65207. * @param onSuccess is a callback called when the task is successfully executed
  65208. * @param onError is a callback called if an error occurs
  65209. */
  65210. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65211. }
  65212. /**
  65213. * Define a task used by AssetsManager to load binary data
  65214. */
  65215. export class BinaryFileAssetTask extends AbstractAssetTask {
  65216. /**
  65217. * Defines the name of the task
  65218. */
  65219. name: string;
  65220. /**
  65221. * Defines the location of the file to load
  65222. */
  65223. url: string;
  65224. /**
  65225. * Gets the lodaded data (as an array buffer)
  65226. */
  65227. data: ArrayBuffer;
  65228. /**
  65229. * Callback called when the task is successful
  65230. */
  65231. onSuccess: (task: BinaryFileAssetTask) => void;
  65232. /**
  65233. * Callback called when the task is successful
  65234. */
  65235. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  65236. /**
  65237. * Creates a new BinaryFileAssetTask object
  65238. * @param name defines the name of the new task
  65239. * @param url defines the location of the file to load
  65240. */
  65241. constructor(
  65242. /**
  65243. * Defines the name of the task
  65244. */
  65245. name: string,
  65246. /**
  65247. * Defines the location of the file to load
  65248. */
  65249. url: string);
  65250. /**
  65251. * Execute the current task
  65252. * @param scene defines the scene where you want your assets to be loaded
  65253. * @param onSuccess is a callback called when the task is successfully executed
  65254. * @param onError is a callback called if an error occurs
  65255. */
  65256. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65257. }
  65258. /**
  65259. * Define a task used by AssetsManager to load images
  65260. */
  65261. export class ImageAssetTask extends AbstractAssetTask {
  65262. /**
  65263. * Defines the name of the task
  65264. */
  65265. name: string;
  65266. /**
  65267. * Defines the location of the image to load
  65268. */
  65269. url: string;
  65270. /**
  65271. * Gets the loaded images
  65272. */
  65273. image: HTMLImageElement;
  65274. /**
  65275. * Callback called when the task is successful
  65276. */
  65277. onSuccess: (task: ImageAssetTask) => void;
  65278. /**
  65279. * Callback called when the task is successful
  65280. */
  65281. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  65282. /**
  65283. * Creates a new ImageAssetTask
  65284. * @param name defines the name of the task
  65285. * @param url defines the location of the image to load
  65286. */
  65287. constructor(
  65288. /**
  65289. * Defines the name of the task
  65290. */
  65291. name: string,
  65292. /**
  65293. * Defines the location of the image to load
  65294. */
  65295. url: string);
  65296. /**
  65297. * Execute the current task
  65298. * @param scene defines the scene where you want your assets to be loaded
  65299. * @param onSuccess is a callback called when the task is successfully executed
  65300. * @param onError is a callback called if an error occurs
  65301. */
  65302. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65303. }
  65304. /**
  65305. * Defines the interface used by texture loading tasks
  65306. */
  65307. export interface ITextureAssetTask<TEX extends BaseTexture> {
  65308. /**
  65309. * Gets the loaded texture
  65310. */
  65311. texture: TEX;
  65312. }
  65313. /**
  65314. * Define a task used by AssetsManager to load 2D textures
  65315. */
  65316. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  65317. /**
  65318. * Defines the name of the task
  65319. */
  65320. name: string;
  65321. /**
  65322. * Defines the location of the file to load
  65323. */
  65324. url: string;
  65325. /**
  65326. * Defines if mipmap should not be generated (default is false)
  65327. */
  65328. noMipmap?: boolean | undefined;
  65329. /**
  65330. * Defines if texture must be inverted on Y axis (default is false)
  65331. */
  65332. invertY?: boolean | undefined;
  65333. /**
  65334. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  65335. */
  65336. samplingMode: number;
  65337. /**
  65338. * Gets the loaded texture
  65339. */
  65340. texture: Texture;
  65341. /**
  65342. * Callback called when the task is successful
  65343. */
  65344. onSuccess: (task: TextureAssetTask) => void;
  65345. /**
  65346. * Callback called when the task is successful
  65347. */
  65348. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  65349. /**
  65350. * Creates a new TextureAssetTask object
  65351. * @param name defines the name of the task
  65352. * @param url defines the location of the file to load
  65353. * @param noMipmap defines if mipmap should not be generated (default is false)
  65354. * @param invertY defines if texture must be inverted on Y axis (default is false)
  65355. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  65356. */
  65357. constructor(
  65358. /**
  65359. * Defines the name of the task
  65360. */
  65361. name: string,
  65362. /**
  65363. * Defines the location of the file to load
  65364. */
  65365. url: string,
  65366. /**
  65367. * Defines if mipmap should not be generated (default is false)
  65368. */
  65369. noMipmap?: boolean | undefined,
  65370. /**
  65371. * Defines if texture must be inverted on Y axis (default is false)
  65372. */
  65373. invertY?: boolean | undefined,
  65374. /**
  65375. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  65376. */
  65377. samplingMode?: number);
  65378. /**
  65379. * Execute the current task
  65380. * @param scene defines the scene where you want your assets to be loaded
  65381. * @param onSuccess is a callback called when the task is successfully executed
  65382. * @param onError is a callback called if an error occurs
  65383. */
  65384. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65385. }
  65386. /**
  65387. * Define a task used by AssetsManager to load cube textures
  65388. */
  65389. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  65390. /**
  65391. * Defines the name of the task
  65392. */
  65393. name: string;
  65394. /**
  65395. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  65396. */
  65397. url: string;
  65398. /**
  65399. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  65400. */
  65401. extensions?: string[] | undefined;
  65402. /**
  65403. * Defines if mipmaps should not be generated (default is false)
  65404. */
  65405. noMipmap?: boolean | undefined;
  65406. /**
  65407. * Defines the explicit list of files (undefined by default)
  65408. */
  65409. files?: string[] | undefined;
  65410. /**
  65411. * Gets the loaded texture
  65412. */
  65413. texture: CubeTexture;
  65414. /**
  65415. * Callback called when the task is successful
  65416. */
  65417. onSuccess: (task: CubeTextureAssetTask) => void;
  65418. /**
  65419. * Callback called when the task is successful
  65420. */
  65421. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  65422. /**
  65423. * Creates a new CubeTextureAssetTask
  65424. * @param name defines the name of the task
  65425. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  65426. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  65427. * @param noMipmap defines if mipmaps should not be generated (default is false)
  65428. * @param files defines the explicit list of files (undefined by default)
  65429. */
  65430. constructor(
  65431. /**
  65432. * Defines the name of the task
  65433. */
  65434. name: string,
  65435. /**
  65436. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  65437. */
  65438. url: string,
  65439. /**
  65440. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  65441. */
  65442. extensions?: string[] | undefined,
  65443. /**
  65444. * Defines if mipmaps should not be generated (default is false)
  65445. */
  65446. noMipmap?: boolean | undefined,
  65447. /**
  65448. * Defines the explicit list of files (undefined by default)
  65449. */
  65450. files?: string[] | undefined);
  65451. /**
  65452. * Execute the current task
  65453. * @param scene defines the scene where you want your assets to be loaded
  65454. * @param onSuccess is a callback called when the task is successfully executed
  65455. * @param onError is a callback called if an error occurs
  65456. */
  65457. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65458. }
  65459. /**
  65460. * Define a task used by AssetsManager to load HDR cube textures
  65461. */
  65462. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  65463. /**
  65464. * Defines the name of the task
  65465. */
  65466. name: string;
  65467. /**
  65468. * Defines the location of the file to load
  65469. */
  65470. url: string;
  65471. /**
  65472. * Defines the desired size (the more it increases the longer the generation will be)
  65473. */
  65474. size: number;
  65475. /**
  65476. * Defines if mipmaps should not be generated (default is false)
  65477. */
  65478. noMipmap: boolean;
  65479. /**
  65480. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  65481. */
  65482. generateHarmonics: boolean;
  65483. /**
  65484. * 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)
  65485. */
  65486. gammaSpace: boolean;
  65487. /**
  65488. * Internal Use Only
  65489. */
  65490. reserved: boolean;
  65491. /**
  65492. * Gets the loaded texture
  65493. */
  65494. texture: HDRCubeTexture;
  65495. /**
  65496. * Callback called when the task is successful
  65497. */
  65498. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  65499. /**
  65500. * Callback called when the task is successful
  65501. */
  65502. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  65503. /**
  65504. * Creates a new HDRCubeTextureAssetTask object
  65505. * @param name defines the name of the task
  65506. * @param url defines the location of the file to load
  65507. * @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.
  65508. * @param noMipmap defines if mipmaps should not be generated (default is false)
  65509. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  65510. * @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)
  65511. * @param reserved Internal use only
  65512. */
  65513. constructor(
  65514. /**
  65515. * Defines the name of the task
  65516. */
  65517. name: string,
  65518. /**
  65519. * Defines the location of the file to load
  65520. */
  65521. url: string,
  65522. /**
  65523. * Defines the desired size (the more it increases the longer the generation will be)
  65524. */
  65525. size: number,
  65526. /**
  65527. * Defines if mipmaps should not be generated (default is false)
  65528. */
  65529. noMipmap?: boolean,
  65530. /**
  65531. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  65532. */
  65533. generateHarmonics?: boolean,
  65534. /**
  65535. * 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)
  65536. */
  65537. gammaSpace?: boolean,
  65538. /**
  65539. * Internal Use Only
  65540. */
  65541. reserved?: boolean);
  65542. /**
  65543. * Execute the current task
  65544. * @param scene defines the scene where you want your assets to be loaded
  65545. * @param onSuccess is a callback called when the task is successfully executed
  65546. * @param onError is a callback called if an error occurs
  65547. */
  65548. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65549. }
  65550. /**
  65551. * Define a task used by AssetsManager to load Equirectangular cube textures
  65552. */
  65553. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  65554. /**
  65555. * Defines the name of the task
  65556. */
  65557. name: string;
  65558. /**
  65559. * Defines the location of the file to load
  65560. */
  65561. url: string;
  65562. /**
  65563. * Defines the desired size (the more it increases the longer the generation will be)
  65564. */
  65565. size: number;
  65566. /**
  65567. * Defines if mipmaps should not be generated (default is false)
  65568. */
  65569. noMipmap: boolean;
  65570. /**
  65571. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  65572. * but the standard material would require them in Gamma space) (default is true)
  65573. */
  65574. gammaSpace: boolean;
  65575. /**
  65576. * Gets the loaded texture
  65577. */
  65578. texture: EquiRectangularCubeTexture;
  65579. /**
  65580. * Callback called when the task is successful
  65581. */
  65582. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  65583. /**
  65584. * Callback called when the task is successful
  65585. */
  65586. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  65587. /**
  65588. * Creates a new EquiRectangularCubeTextureAssetTask object
  65589. * @param name defines the name of the task
  65590. * @param url defines the location of the file to load
  65591. * @param size defines the desired size (the more it increases the longer the generation will be)
  65592. * If the size is omitted this implies you are using a preprocessed cubemap.
  65593. * @param noMipmap defines if mipmaps should not be generated (default is false)
  65594. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  65595. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  65596. * (default is true)
  65597. */
  65598. constructor(
  65599. /**
  65600. * Defines the name of the task
  65601. */
  65602. name: string,
  65603. /**
  65604. * Defines the location of the file to load
  65605. */
  65606. url: string,
  65607. /**
  65608. * Defines the desired size (the more it increases the longer the generation will be)
  65609. */
  65610. size: number,
  65611. /**
  65612. * Defines if mipmaps should not be generated (default is false)
  65613. */
  65614. noMipmap?: boolean,
  65615. /**
  65616. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  65617. * but the standard material would require them in Gamma space) (default is true)
  65618. */
  65619. gammaSpace?: boolean);
  65620. /**
  65621. * Execute the current task
  65622. * @param scene defines the scene where you want your assets to be loaded
  65623. * @param onSuccess is a callback called when the task is successfully executed
  65624. * @param onError is a callback called if an error occurs
  65625. */
  65626. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65627. }
  65628. /**
  65629. * This class can be used to easily import assets into a scene
  65630. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  65631. */
  65632. export class AssetsManager {
  65633. private _scene;
  65634. private _isLoading;
  65635. protected _tasks: AbstractAssetTask[];
  65636. protected _waitingTasksCount: number;
  65637. protected _totalTasksCount: number;
  65638. /**
  65639. * Callback called when all tasks are processed
  65640. */
  65641. onFinish: (tasks: AbstractAssetTask[]) => void;
  65642. /**
  65643. * Callback called when a task is successful
  65644. */
  65645. onTaskSuccess: (task: AbstractAssetTask) => void;
  65646. /**
  65647. * Callback called when a task had an error
  65648. */
  65649. onTaskError: (task: AbstractAssetTask) => void;
  65650. /**
  65651. * Callback called when a task is done (whatever the result is)
  65652. */
  65653. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  65654. /**
  65655. * Observable called when all tasks are processed
  65656. */
  65657. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  65658. /**
  65659. * Observable called when a task had an error
  65660. */
  65661. onTaskErrorObservable: Observable<AbstractAssetTask>;
  65662. /**
  65663. * Observable called when all tasks were executed
  65664. */
  65665. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  65666. /**
  65667. * Observable called when a task is done (whatever the result is)
  65668. */
  65669. onProgressObservable: Observable<IAssetsProgressEvent>;
  65670. /**
  65671. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  65672. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  65673. */
  65674. useDefaultLoadingScreen: boolean;
  65675. /**
  65676. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  65677. * when all assets have been downloaded.
  65678. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  65679. */
  65680. autoHideLoadingUI: boolean;
  65681. /**
  65682. * Creates a new AssetsManager
  65683. * @param scene defines the scene to work on
  65684. */
  65685. constructor(scene: Scene);
  65686. /**
  65687. * Add a MeshAssetTask to the list of active tasks
  65688. * @param taskName defines the name of the new task
  65689. * @param meshesNames defines the name of meshes to load
  65690. * @param rootUrl defines the root url to use to locate files
  65691. * @param sceneFilename defines the filename of the scene file
  65692. * @returns a new MeshAssetTask object
  65693. */
  65694. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  65695. /**
  65696. * Add a TextFileAssetTask to the list of active tasks
  65697. * @param taskName defines the name of the new task
  65698. * @param url defines the url of the file to load
  65699. * @returns a new TextFileAssetTask object
  65700. */
  65701. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  65702. /**
  65703. * Add a BinaryFileAssetTask to the list of active tasks
  65704. * @param taskName defines the name of the new task
  65705. * @param url defines the url of the file to load
  65706. * @returns a new BinaryFileAssetTask object
  65707. */
  65708. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  65709. /**
  65710. * Add a ImageAssetTask to the list of active tasks
  65711. * @param taskName defines the name of the new task
  65712. * @param url defines the url of the file to load
  65713. * @returns a new ImageAssetTask object
  65714. */
  65715. addImageTask(taskName: string, url: string): ImageAssetTask;
  65716. /**
  65717. * Add a TextureAssetTask to the list of active tasks
  65718. * @param taskName defines the name of the new task
  65719. * @param url defines the url of the file to load
  65720. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65721. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  65722. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  65723. * @returns a new TextureAssetTask object
  65724. */
  65725. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  65726. /**
  65727. * Add a CubeTextureAssetTask to the list of active tasks
  65728. * @param taskName defines the name of the new task
  65729. * @param url defines the url of the file to load
  65730. * @param extensions defines the extension to use to load the cube map (can be null)
  65731. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65732. * @param files defines the list of files to load (can be null)
  65733. * @returns a new CubeTextureAssetTask object
  65734. */
  65735. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  65736. /**
  65737. *
  65738. * Add a HDRCubeTextureAssetTask to the list of active tasks
  65739. * @param taskName defines the name of the new task
  65740. * @param url defines the url of the file to load
  65741. * @param size defines the size you want for the cubemap (can be null)
  65742. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65743. * @param generateHarmonics defines if you want to automatically generate (true by default)
  65744. * @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)
  65745. * @param reserved Internal use only
  65746. * @returns a new HDRCubeTextureAssetTask object
  65747. */
  65748. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  65749. /**
  65750. *
  65751. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  65752. * @param taskName defines the name of the new task
  65753. * @param url defines the url of the file to load
  65754. * @param size defines the size you want for the cubemap (can be null)
  65755. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65756. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  65757. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  65758. * @returns a new EquiRectangularCubeTextureAssetTask object
  65759. */
  65760. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  65761. /**
  65762. * Remove a task from the assets manager.
  65763. * @param task the task to remove
  65764. */
  65765. removeTask(task: AbstractAssetTask): void;
  65766. private _decreaseWaitingTasksCount;
  65767. private _runTask;
  65768. /**
  65769. * Reset the AssetsManager and remove all tasks
  65770. * @return the current instance of the AssetsManager
  65771. */
  65772. reset(): AssetsManager;
  65773. /**
  65774. * Start the loading process
  65775. * @return the current instance of the AssetsManager
  65776. */
  65777. load(): AssetsManager;
  65778. /**
  65779. * Start the loading process as an async operation
  65780. * @return a promise returning the list of failed tasks
  65781. */
  65782. loadAsync(): Promise<void>;
  65783. }
  65784. }
  65785. declare module "babylonjs/Misc/deferred" {
  65786. /**
  65787. * Wrapper class for promise with external resolve and reject.
  65788. */
  65789. export class Deferred<T> {
  65790. /**
  65791. * The promise associated with this deferred object.
  65792. */
  65793. readonly promise: Promise<T>;
  65794. private _resolve;
  65795. private _reject;
  65796. /**
  65797. * The resolve method of the promise associated with this deferred object.
  65798. */
  65799. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  65800. /**
  65801. * The reject method of the promise associated with this deferred object.
  65802. */
  65803. readonly reject: (reason?: any) => void;
  65804. /**
  65805. * Constructor for this deferred object.
  65806. */
  65807. constructor();
  65808. }
  65809. }
  65810. declare module "babylonjs/Misc/meshExploder" {
  65811. import { Mesh } from "babylonjs/Meshes/mesh";
  65812. /**
  65813. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  65814. */
  65815. export class MeshExploder {
  65816. private _centerMesh;
  65817. private _meshes;
  65818. private _meshesOrigins;
  65819. private _toCenterVectors;
  65820. private _scaledDirection;
  65821. private _newPosition;
  65822. private _centerPosition;
  65823. /**
  65824. * Explodes meshes from a center mesh.
  65825. * @param meshes The meshes to explode.
  65826. * @param centerMesh The mesh to be center of explosion.
  65827. */
  65828. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  65829. private _setCenterMesh;
  65830. /**
  65831. * Get class name
  65832. * @returns "MeshExploder"
  65833. */
  65834. getClassName(): string;
  65835. /**
  65836. * "Exploded meshes"
  65837. * @returns Array of meshes with the centerMesh at index 0.
  65838. */
  65839. getMeshes(): Array<Mesh>;
  65840. /**
  65841. * Explodes meshes giving a specific direction
  65842. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  65843. */
  65844. explode(direction?: number): void;
  65845. }
  65846. }
  65847. declare module "babylonjs/Misc/filesInput" {
  65848. import { Engine } from "babylonjs/Engines/engine";
  65849. import { Scene } from "babylonjs/scene";
  65850. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  65851. /**
  65852. * Class used to help managing file picking and drag'n'drop
  65853. */
  65854. export class FilesInput {
  65855. /**
  65856. * List of files ready to be loaded
  65857. */
  65858. static readonly FilesToLoad: {
  65859. [key: string]: File;
  65860. };
  65861. /**
  65862. * Callback called when a file is processed
  65863. */
  65864. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  65865. private _engine;
  65866. private _currentScene;
  65867. private _sceneLoadedCallback;
  65868. private _progressCallback;
  65869. private _additionalRenderLoopLogicCallback;
  65870. private _textureLoadingCallback;
  65871. private _startingProcessingFilesCallback;
  65872. private _onReloadCallback;
  65873. private _errorCallback;
  65874. private _elementToMonitor;
  65875. private _sceneFileToLoad;
  65876. private _filesToLoad;
  65877. /**
  65878. * Creates a new FilesInput
  65879. * @param engine defines the rendering engine
  65880. * @param scene defines the hosting scene
  65881. * @param sceneLoadedCallback callback called when scene is loaded
  65882. * @param progressCallback callback called to track progress
  65883. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  65884. * @param textureLoadingCallback callback called when a texture is loading
  65885. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  65886. * @param onReloadCallback callback called when a reload is requested
  65887. * @param errorCallback callback call if an error occurs
  65888. */
  65889. 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);
  65890. private _dragEnterHandler;
  65891. private _dragOverHandler;
  65892. private _dropHandler;
  65893. /**
  65894. * Calls this function to listen to drag'n'drop events on a specific DOM element
  65895. * @param elementToMonitor defines the DOM element to track
  65896. */
  65897. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  65898. /**
  65899. * Release all associated resources
  65900. */
  65901. dispose(): void;
  65902. private renderFunction;
  65903. private drag;
  65904. private drop;
  65905. private _traverseFolder;
  65906. private _processFiles;
  65907. /**
  65908. * Load files from a drop event
  65909. * @param event defines the drop event to use as source
  65910. */
  65911. loadFiles(event: any): void;
  65912. private _processReload;
  65913. /**
  65914. * Reload the current scene from the loaded files
  65915. */
  65916. reload(): void;
  65917. }
  65918. }
  65919. declare module "babylonjs/Misc/HighDynamicRange/index" {
  65920. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  65921. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  65922. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  65923. }
  65924. declare module "babylonjs/Misc/sceneOptimizer" {
  65925. import { Scene, IDisposable } from "babylonjs/scene";
  65926. import { Observable } from "babylonjs/Misc/observable";
  65927. /**
  65928. * Defines the root class used to create scene optimization to use with SceneOptimizer
  65929. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65930. */
  65931. export class SceneOptimization {
  65932. /**
  65933. * Defines the priority of this optimization (0 by default which means first in the list)
  65934. */
  65935. priority: number;
  65936. /**
  65937. * Gets a string describing the action executed by the current optimization
  65938. * @returns description string
  65939. */
  65940. getDescription(): string;
  65941. /**
  65942. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65943. * @param scene defines the current scene where to apply this optimization
  65944. * @param optimizer defines the current optimizer
  65945. * @returns true if everything that can be done was applied
  65946. */
  65947. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65948. /**
  65949. * Creates the SceneOptimization object
  65950. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  65951. * @param desc defines the description associated with the optimization
  65952. */
  65953. constructor(
  65954. /**
  65955. * Defines the priority of this optimization (0 by default which means first in the list)
  65956. */
  65957. priority?: number);
  65958. }
  65959. /**
  65960. * Defines an optimization used to reduce the size of render target textures
  65961. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65962. */
  65963. export class TextureOptimization extends SceneOptimization {
  65964. /**
  65965. * Defines the priority of this optimization (0 by default which means first in the list)
  65966. */
  65967. priority: number;
  65968. /**
  65969. * 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
  65970. */
  65971. maximumSize: number;
  65972. /**
  65973. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  65974. */
  65975. step: number;
  65976. /**
  65977. * Gets a string describing the action executed by the current optimization
  65978. * @returns description string
  65979. */
  65980. getDescription(): string;
  65981. /**
  65982. * Creates the TextureOptimization object
  65983. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  65984. * @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
  65985. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  65986. */
  65987. constructor(
  65988. /**
  65989. * Defines the priority of this optimization (0 by default which means first in the list)
  65990. */
  65991. priority?: number,
  65992. /**
  65993. * 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
  65994. */
  65995. maximumSize?: number,
  65996. /**
  65997. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  65998. */
  65999. step?: number);
  66000. /**
  66001. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66002. * @param scene defines the current scene where to apply this optimization
  66003. * @param optimizer defines the current optimizer
  66004. * @returns true if everything that can be done was applied
  66005. */
  66006. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66007. }
  66008. /**
  66009. * Defines an optimization used to increase or decrease the rendering resolution
  66010. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66011. */
  66012. export class HardwareScalingOptimization extends SceneOptimization {
  66013. /**
  66014. * Defines the priority of this optimization (0 by default which means first in the list)
  66015. */
  66016. priority: number;
  66017. /**
  66018. * Defines the maximum scale to use (2 by default)
  66019. */
  66020. maximumScale: number;
  66021. /**
  66022. * Defines the step to use between two passes (0.5 by default)
  66023. */
  66024. step: number;
  66025. private _currentScale;
  66026. private _directionOffset;
  66027. /**
  66028. * Gets a string describing the action executed by the current optimization
  66029. * @return description string
  66030. */
  66031. getDescription(): string;
  66032. /**
  66033. * Creates the HardwareScalingOptimization object
  66034. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66035. * @param maximumScale defines the maximum scale to use (2 by default)
  66036. * @param step defines the step to use between two passes (0.5 by default)
  66037. */
  66038. constructor(
  66039. /**
  66040. * Defines the priority of this optimization (0 by default which means first in the list)
  66041. */
  66042. priority?: number,
  66043. /**
  66044. * Defines the maximum scale to use (2 by default)
  66045. */
  66046. maximumScale?: number,
  66047. /**
  66048. * Defines the step to use between two passes (0.5 by default)
  66049. */
  66050. step?: number);
  66051. /**
  66052. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66053. * @param scene defines the current scene where to apply this optimization
  66054. * @param optimizer defines the current optimizer
  66055. * @returns true if everything that can be done was applied
  66056. */
  66057. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66058. }
  66059. /**
  66060. * Defines an optimization used to remove shadows
  66061. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66062. */
  66063. export class ShadowsOptimization extends SceneOptimization {
  66064. /**
  66065. * Gets a string describing the action executed by the current optimization
  66066. * @return description string
  66067. */
  66068. getDescription(): string;
  66069. /**
  66070. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66071. * @param scene defines the current scene where to apply this optimization
  66072. * @param optimizer defines the current optimizer
  66073. * @returns true if everything that can be done was applied
  66074. */
  66075. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66076. }
  66077. /**
  66078. * Defines an optimization used to turn post-processes off
  66079. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66080. */
  66081. export class PostProcessesOptimization extends SceneOptimization {
  66082. /**
  66083. * Gets a string describing the action executed by the current optimization
  66084. * @return description string
  66085. */
  66086. getDescription(): string;
  66087. /**
  66088. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66089. * @param scene defines the current scene where to apply this optimization
  66090. * @param optimizer defines the current optimizer
  66091. * @returns true if everything that can be done was applied
  66092. */
  66093. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66094. }
  66095. /**
  66096. * Defines an optimization used to turn lens flares off
  66097. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66098. */
  66099. export class LensFlaresOptimization extends SceneOptimization {
  66100. /**
  66101. * Gets a string describing the action executed by the current optimization
  66102. * @return description string
  66103. */
  66104. getDescription(): string;
  66105. /**
  66106. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66107. * @param scene defines the current scene where to apply this optimization
  66108. * @param optimizer defines the current optimizer
  66109. * @returns true if everything that can be done was applied
  66110. */
  66111. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66112. }
  66113. /**
  66114. * Defines an optimization based on user defined callback.
  66115. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66116. */
  66117. export class CustomOptimization extends SceneOptimization {
  66118. /**
  66119. * Callback called to apply the custom optimization.
  66120. */
  66121. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  66122. /**
  66123. * Callback called to get custom description
  66124. */
  66125. onGetDescription: () => string;
  66126. /**
  66127. * Gets a string describing the action executed by the current optimization
  66128. * @returns description string
  66129. */
  66130. getDescription(): string;
  66131. /**
  66132. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66133. * @param scene defines the current scene where to apply this optimization
  66134. * @param optimizer defines the current optimizer
  66135. * @returns true if everything that can be done was applied
  66136. */
  66137. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66138. }
  66139. /**
  66140. * Defines an optimization used to turn particles off
  66141. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66142. */
  66143. export class ParticlesOptimization extends SceneOptimization {
  66144. /**
  66145. * Gets a string describing the action executed by the current optimization
  66146. * @return description string
  66147. */
  66148. getDescription(): string;
  66149. /**
  66150. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66151. * @param scene defines the current scene where to apply this optimization
  66152. * @param optimizer defines the current optimizer
  66153. * @returns true if everything that can be done was applied
  66154. */
  66155. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66156. }
  66157. /**
  66158. * Defines an optimization used to turn render targets off
  66159. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66160. */
  66161. export class RenderTargetsOptimization extends SceneOptimization {
  66162. /**
  66163. * Gets a string describing the action executed by the current optimization
  66164. * @return description string
  66165. */
  66166. getDescription(): string;
  66167. /**
  66168. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66169. * @param scene defines the current scene where to apply this optimization
  66170. * @param optimizer defines the current optimizer
  66171. * @returns true if everything that can be done was applied
  66172. */
  66173. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66174. }
  66175. /**
  66176. * Defines an optimization used to merge meshes with compatible materials
  66177. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66178. */
  66179. export class MergeMeshesOptimization extends SceneOptimization {
  66180. private static _UpdateSelectionTree;
  66181. /**
  66182. * Gets or sets a boolean which defines if optimization octree has to be updated
  66183. */
  66184. /**
  66185. * Gets or sets a boolean which defines if optimization octree has to be updated
  66186. */
  66187. static UpdateSelectionTree: boolean;
  66188. /**
  66189. * Gets a string describing the action executed by the current optimization
  66190. * @return description string
  66191. */
  66192. getDescription(): string;
  66193. private _canBeMerged;
  66194. /**
  66195. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66196. * @param scene defines the current scene where to apply this optimization
  66197. * @param optimizer defines the current optimizer
  66198. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  66199. * @returns true if everything that can be done was applied
  66200. */
  66201. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  66202. }
  66203. /**
  66204. * Defines a list of options used by SceneOptimizer
  66205. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66206. */
  66207. export class SceneOptimizerOptions {
  66208. /**
  66209. * Defines the target frame rate to reach (60 by default)
  66210. */
  66211. targetFrameRate: number;
  66212. /**
  66213. * Defines the interval between two checkes (2000ms by default)
  66214. */
  66215. trackerDuration: number;
  66216. /**
  66217. * Gets the list of optimizations to apply
  66218. */
  66219. optimizations: SceneOptimization[];
  66220. /**
  66221. * Creates a new list of options used by SceneOptimizer
  66222. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  66223. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  66224. */
  66225. constructor(
  66226. /**
  66227. * Defines the target frame rate to reach (60 by default)
  66228. */
  66229. targetFrameRate?: number,
  66230. /**
  66231. * Defines the interval between two checkes (2000ms by default)
  66232. */
  66233. trackerDuration?: number);
  66234. /**
  66235. * Add a new optimization
  66236. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  66237. * @returns the current SceneOptimizerOptions
  66238. */
  66239. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  66240. /**
  66241. * Add a new custom optimization
  66242. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  66243. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  66244. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66245. * @returns the current SceneOptimizerOptions
  66246. */
  66247. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  66248. /**
  66249. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  66250. * @param targetFrameRate defines the target frame rate (60 by default)
  66251. * @returns a SceneOptimizerOptions object
  66252. */
  66253. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  66254. /**
  66255. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  66256. * @param targetFrameRate defines the target frame rate (60 by default)
  66257. * @returns a SceneOptimizerOptions object
  66258. */
  66259. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  66260. /**
  66261. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  66262. * @param targetFrameRate defines the target frame rate (60 by default)
  66263. * @returns a SceneOptimizerOptions object
  66264. */
  66265. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  66266. }
  66267. /**
  66268. * Class used to run optimizations in order to reach a target frame rate
  66269. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66270. */
  66271. export class SceneOptimizer implements IDisposable {
  66272. private _isRunning;
  66273. private _options;
  66274. private _scene;
  66275. private _currentPriorityLevel;
  66276. private _targetFrameRate;
  66277. private _trackerDuration;
  66278. private _currentFrameRate;
  66279. private _sceneDisposeObserver;
  66280. private _improvementMode;
  66281. /**
  66282. * Defines an observable called when the optimizer reaches the target frame rate
  66283. */
  66284. onSuccessObservable: Observable<SceneOptimizer>;
  66285. /**
  66286. * Defines an observable called when the optimizer enables an optimization
  66287. */
  66288. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  66289. /**
  66290. * Defines an observable called when the optimizer is not able to reach the target frame rate
  66291. */
  66292. onFailureObservable: Observable<SceneOptimizer>;
  66293. /**
  66294. * Gets a boolean indicating if the optimizer is in improvement mode
  66295. */
  66296. readonly isInImprovementMode: boolean;
  66297. /**
  66298. * Gets the current priority level (0 at start)
  66299. */
  66300. readonly currentPriorityLevel: number;
  66301. /**
  66302. * Gets the current frame rate checked by the SceneOptimizer
  66303. */
  66304. readonly currentFrameRate: number;
  66305. /**
  66306. * Gets or sets the current target frame rate (60 by default)
  66307. */
  66308. /**
  66309. * Gets or sets the current target frame rate (60 by default)
  66310. */
  66311. targetFrameRate: number;
  66312. /**
  66313. * Gets or sets the current interval between two checks (every 2000ms by default)
  66314. */
  66315. /**
  66316. * Gets or sets the current interval between two checks (every 2000ms by default)
  66317. */
  66318. trackerDuration: number;
  66319. /**
  66320. * Gets the list of active optimizations
  66321. */
  66322. readonly optimizations: SceneOptimization[];
  66323. /**
  66324. * Creates a new SceneOptimizer
  66325. * @param scene defines the scene to work on
  66326. * @param options defines the options to use with the SceneOptimizer
  66327. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  66328. * @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)
  66329. */
  66330. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  66331. /**
  66332. * Stops the current optimizer
  66333. */
  66334. stop(): void;
  66335. /**
  66336. * Reset the optimizer to initial step (current priority level = 0)
  66337. */
  66338. reset(): void;
  66339. /**
  66340. * Start the optimizer. By default it will try to reach a specific framerate
  66341. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  66342. */
  66343. start(): void;
  66344. private _checkCurrentState;
  66345. /**
  66346. * Release all resources
  66347. */
  66348. dispose(): void;
  66349. /**
  66350. * Helper function to create a SceneOptimizer with one single line of code
  66351. * @param scene defines the scene to work on
  66352. * @param options defines the options to use with the SceneOptimizer
  66353. * @param onSuccess defines a callback to call on success
  66354. * @param onFailure defines a callback to call on failure
  66355. * @returns the new SceneOptimizer object
  66356. */
  66357. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  66358. }
  66359. }
  66360. declare module "babylonjs/Misc/sceneSerializer" {
  66361. import { Scene } from "babylonjs/scene";
  66362. /**
  66363. * Class used to serialize a scene into a string
  66364. */
  66365. export class SceneSerializer {
  66366. /**
  66367. * Clear cache used by a previous serialization
  66368. */
  66369. static ClearCache(): void;
  66370. /**
  66371. * Serialize a scene into a JSON compatible object
  66372. * @param scene defines the scene to serialize
  66373. * @returns a JSON compatible object
  66374. */
  66375. static Serialize(scene: Scene): any;
  66376. /**
  66377. * Serialize a mesh into a JSON compatible object
  66378. * @param toSerialize defines the mesh to serialize
  66379. * @param withParents defines if parents must be serialized as well
  66380. * @param withChildren defines if children must be serialized as well
  66381. * @returns a JSON compatible object
  66382. */
  66383. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  66384. }
  66385. }
  66386. declare module "babylonjs/Misc/textureTools" {
  66387. import { Texture } from "babylonjs/Materials/Textures/texture";
  66388. /**
  66389. * Class used to host texture specific utilities
  66390. */
  66391. export class TextureTools {
  66392. /**
  66393. * Uses the GPU to create a copy texture rescaled at a given size
  66394. * @param texture Texture to copy from
  66395. * @param width defines the desired width
  66396. * @param height defines the desired height
  66397. * @param useBilinearMode defines if bilinear mode has to be used
  66398. * @return the generated texture
  66399. */
  66400. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  66401. }
  66402. }
  66403. declare module "babylonjs/Misc/videoRecorder" {
  66404. import { Nullable } from "babylonjs/types";
  66405. import { Engine } from "babylonjs/Engines/engine";
  66406. /**
  66407. * This represents the different options available for the video capture.
  66408. */
  66409. export interface VideoRecorderOptions {
  66410. /** Defines the mime type of the video. */
  66411. mimeType: string;
  66412. /** Defines the FPS the video should be recorded at. */
  66413. fps: number;
  66414. /** Defines the chunk size for the recording data. */
  66415. recordChunckSize: number;
  66416. /** The audio tracks to attach to the recording. */
  66417. audioTracks?: MediaStreamTrack[];
  66418. }
  66419. /**
  66420. * This can help with recording videos from BabylonJS.
  66421. * This is based on the available WebRTC functionalities of the browser.
  66422. *
  66423. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  66424. */
  66425. export class VideoRecorder {
  66426. private static readonly _defaultOptions;
  66427. /**
  66428. * Returns whether or not the VideoRecorder is available in your browser.
  66429. * @param engine Defines the Babylon Engine.
  66430. * @returns true if supported otherwise false.
  66431. */
  66432. static IsSupported(engine: Engine): boolean;
  66433. private readonly _options;
  66434. private _canvas;
  66435. private _mediaRecorder;
  66436. private _recordedChunks;
  66437. private _fileName;
  66438. private _resolve;
  66439. private _reject;
  66440. /**
  66441. * True when a recording is already in progress.
  66442. */
  66443. readonly isRecording: boolean;
  66444. /**
  66445. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  66446. * @param engine Defines the BabylonJS Engine you wish to record.
  66447. * @param options Defines options that can be used to customize the capture.
  66448. */
  66449. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  66450. /**
  66451. * Stops the current recording before the default capture timeout passed in the startRecording function.
  66452. */
  66453. stopRecording(): void;
  66454. /**
  66455. * Starts recording the canvas for a max duration specified in parameters.
  66456. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  66457. * If null no automatic download will start and you can rely on the promise to get the data back.
  66458. * @param maxDuration Defines the maximum recording time in seconds.
  66459. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  66460. * @return A promise callback at the end of the recording with the video data in Blob.
  66461. */
  66462. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  66463. /**
  66464. * Releases internal resources used during the recording.
  66465. */
  66466. dispose(): void;
  66467. private _handleDataAvailable;
  66468. private _handleError;
  66469. private _handleStop;
  66470. }
  66471. }
  66472. declare module "babylonjs/Misc/screenshotTools" {
  66473. import { Camera } from "babylonjs/Cameras/camera";
  66474. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  66475. import { Engine } from "babylonjs/Engines/engine";
  66476. /**
  66477. * Class containing a set of static utilities functions for screenshots
  66478. */
  66479. export class ScreenshotTools {
  66480. /**
  66481. * Captures a screenshot of the current rendering
  66482. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66483. * @param engine defines the rendering engine
  66484. * @param camera defines the source camera
  66485. * @param size This parameter can be set to a single number or to an object with the
  66486. * following (optional) properties: precision, width, height. If a single number is passed,
  66487. * it will be used for both width and height. If an object is passed, the screenshot size
  66488. * will be derived from the parameters. The precision property is a multiplier allowing
  66489. * rendering at a higher or lower resolution
  66490. * @param successCallback defines the callback receives a single parameter which contains the
  66491. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  66492. * src parameter of an <img> to display it
  66493. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  66494. * Check your browser for supported MIME types
  66495. */
  66496. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  66497. /**
  66498. * Captures a screenshot of the current rendering
  66499. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66500. * @param engine defines the rendering engine
  66501. * @param camera defines the source camera
  66502. * @param size This parameter can be set to a single number or to an object with the
  66503. * following (optional) properties: precision, width, height. If a single number is passed,
  66504. * it will be used for both width and height. If an object is passed, the screenshot size
  66505. * will be derived from the parameters. The precision property is a multiplier allowing
  66506. * rendering at a higher or lower resolution
  66507. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  66508. * Check your browser for supported MIME types
  66509. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  66510. * to the src parameter of an <img> to display it
  66511. */
  66512. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  66513. /**
  66514. * Generates an image screenshot from the specified camera.
  66515. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66516. * @param engine The engine to use for rendering
  66517. * @param camera The camera to use for rendering
  66518. * @param size This parameter can be set to a single number or to an object with the
  66519. * following (optional) properties: precision, width, height. If a single number is passed,
  66520. * it will be used for both width and height. If an object is passed, the screenshot size
  66521. * will be derived from the parameters. The precision property is a multiplier allowing
  66522. * rendering at a higher or lower resolution
  66523. * @param successCallback The callback receives a single parameter which contains the
  66524. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  66525. * src parameter of an <img> to display it
  66526. * @param mimeType The MIME type of the screenshot image (default: image/png).
  66527. * Check your browser for supported MIME types
  66528. * @param samples Texture samples (default: 1)
  66529. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  66530. * @param fileName A name for for the downloaded file.
  66531. */
  66532. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  66533. /**
  66534. * Generates an image screenshot from the specified camera.
  66535. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66536. * @param engine The engine to use for rendering
  66537. * @param camera The camera to use for rendering
  66538. * @param size This parameter can be set to a single number or to an object with the
  66539. * following (optional) properties: precision, width, height. If a single number is passed,
  66540. * it will be used for both width and height. If an object is passed, the screenshot size
  66541. * will be derived from the parameters. The precision property is a multiplier allowing
  66542. * rendering at a higher or lower resolution
  66543. * @param mimeType The MIME type of the screenshot image (default: image/png).
  66544. * Check your browser for supported MIME types
  66545. * @param samples Texture samples (default: 1)
  66546. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  66547. * @param fileName A name for for the downloaded file.
  66548. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  66549. * to the src parameter of an <img> to display it
  66550. */
  66551. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  66552. /**
  66553. * Gets height and width for screenshot size
  66554. * @private
  66555. */
  66556. private static _getScreenshotSize;
  66557. }
  66558. }
  66559. declare module "babylonjs/Misc/index" {
  66560. export * from "babylonjs/Misc/andOrNotEvaluator";
  66561. export * from "babylonjs/Misc/assetsManager";
  66562. export * from "babylonjs/Misc/dds";
  66563. export * from "babylonjs/Misc/decorators";
  66564. export * from "babylonjs/Misc/deferred";
  66565. export * from "babylonjs/Misc/environmentTextureTools";
  66566. export * from "babylonjs/Misc/meshExploder";
  66567. export * from "babylonjs/Misc/filesInput";
  66568. export * from "babylonjs/Misc/HighDynamicRange/index";
  66569. export * from "babylonjs/Misc/khronosTextureContainer";
  66570. export * from "babylonjs/Misc/observable";
  66571. export * from "babylonjs/Misc/performanceMonitor";
  66572. export * from "babylonjs/Misc/promise";
  66573. export * from "babylonjs/Misc/sceneOptimizer";
  66574. export * from "babylonjs/Misc/sceneSerializer";
  66575. export * from "babylonjs/Misc/smartArray";
  66576. export * from "babylonjs/Misc/stringDictionary";
  66577. export * from "babylonjs/Misc/tags";
  66578. export * from "babylonjs/Misc/textureTools";
  66579. export * from "babylonjs/Misc/tga";
  66580. export * from "babylonjs/Misc/tools";
  66581. export * from "babylonjs/Misc/videoRecorder";
  66582. export * from "babylonjs/Misc/virtualJoystick";
  66583. export * from "babylonjs/Misc/workerPool";
  66584. export * from "babylonjs/Misc/logger";
  66585. export * from "babylonjs/Misc/typeStore";
  66586. export * from "babylonjs/Misc/filesInputStore";
  66587. export * from "babylonjs/Misc/deepCopier";
  66588. export * from "babylonjs/Misc/pivotTools";
  66589. export * from "babylonjs/Misc/precisionDate";
  66590. export * from "babylonjs/Misc/screenshotTools";
  66591. export * from "babylonjs/Misc/typeStore";
  66592. export * from "babylonjs/Misc/webRequest";
  66593. export * from "babylonjs/Misc/iInspectable";
  66594. export * from "babylonjs/Misc/brdfTextureTools";
  66595. export * from "babylonjs/Misc/rgbdTextureTools";
  66596. export * from "babylonjs/Misc/gradients";
  66597. export * from "babylonjs/Misc/perfCounter";
  66598. export * from "babylonjs/Misc/fileRequest";
  66599. export * from "babylonjs/Misc/customAnimationFrameRequester";
  66600. export * from "babylonjs/Misc/retryStrategy";
  66601. export * from "babylonjs/Misc/loadFileError";
  66602. export * from "babylonjs/Misc/interfaces/screenshotSize";
  66603. }
  66604. declare module "babylonjs/index" {
  66605. export * from "babylonjs/abstractScene";
  66606. export * from "babylonjs/Actions/index";
  66607. export * from "babylonjs/Animations/index";
  66608. export * from "babylonjs/assetContainer";
  66609. export * from "babylonjs/Audio/index";
  66610. export * from "babylonjs/Behaviors/index";
  66611. export * from "babylonjs/Bones/index";
  66612. export * from "babylonjs/Cameras/index";
  66613. export * from "babylonjs/Collisions/index";
  66614. export * from "babylonjs/Culling/index";
  66615. export * from "babylonjs/Debug/index";
  66616. export * from "babylonjs/Engines/index";
  66617. export * from "babylonjs/Events/index";
  66618. export * from "babylonjs/Gamepads/index";
  66619. export * from "babylonjs/Gizmos/index";
  66620. export * from "babylonjs/Helpers/index";
  66621. export * from "babylonjs/Instrumentation/index";
  66622. export * from "babylonjs/Layers/index";
  66623. export * from "babylonjs/LensFlares/index";
  66624. export * from "babylonjs/Lights/index";
  66625. export * from "babylonjs/Loading/index";
  66626. export * from "babylonjs/Materials/index";
  66627. export * from "babylonjs/Maths/index";
  66628. export * from "babylonjs/Meshes/index";
  66629. export * from "babylonjs/Morph/index";
  66630. export * from "babylonjs/Navigation/index";
  66631. export * from "babylonjs/node";
  66632. export * from "babylonjs/Offline/index";
  66633. export * from "babylonjs/Particles/index";
  66634. export * from "babylonjs/Physics/index";
  66635. export * from "babylonjs/PostProcesses/index";
  66636. export * from "babylonjs/Probes/index";
  66637. export * from "babylonjs/Rendering/index";
  66638. export * from "babylonjs/scene";
  66639. export * from "babylonjs/sceneComponent";
  66640. export * from "babylonjs/Sprites/index";
  66641. export * from "babylonjs/States/index";
  66642. export * from "babylonjs/Misc/index";
  66643. export * from "babylonjs/types";
  66644. }
  66645. declare module "babylonjs/Animations/pathCursor" {
  66646. import { Vector3 } from "babylonjs/Maths/math.vector";
  66647. import { Path2 } from "babylonjs/Maths/math.path";
  66648. /**
  66649. * A cursor which tracks a point on a path
  66650. */
  66651. export class PathCursor {
  66652. private path;
  66653. /**
  66654. * Stores path cursor callbacks for when an onchange event is triggered
  66655. */
  66656. private _onchange;
  66657. /**
  66658. * The value of the path cursor
  66659. */
  66660. value: number;
  66661. /**
  66662. * The animation array of the path cursor
  66663. */
  66664. animations: Animation[];
  66665. /**
  66666. * Initializes the path cursor
  66667. * @param path The path to track
  66668. */
  66669. constructor(path: Path2);
  66670. /**
  66671. * Gets the cursor point on the path
  66672. * @returns A point on the path cursor at the cursor location
  66673. */
  66674. getPoint(): Vector3;
  66675. /**
  66676. * Moves the cursor ahead by the step amount
  66677. * @param step The amount to move the cursor forward
  66678. * @returns This path cursor
  66679. */
  66680. moveAhead(step?: number): PathCursor;
  66681. /**
  66682. * Moves the cursor behind by the step amount
  66683. * @param step The amount to move the cursor back
  66684. * @returns This path cursor
  66685. */
  66686. moveBack(step?: number): PathCursor;
  66687. /**
  66688. * Moves the cursor by the step amount
  66689. * If the step amount is greater than one, an exception is thrown
  66690. * @param step The amount to move the cursor
  66691. * @returns This path cursor
  66692. */
  66693. move(step: number): PathCursor;
  66694. /**
  66695. * Ensures that the value is limited between zero and one
  66696. * @returns This path cursor
  66697. */
  66698. private ensureLimits;
  66699. /**
  66700. * Runs onchange callbacks on change (used by the animation engine)
  66701. * @returns This path cursor
  66702. */
  66703. private raiseOnChange;
  66704. /**
  66705. * Executes a function on change
  66706. * @param f A path cursor onchange callback
  66707. * @returns This path cursor
  66708. */
  66709. onchange(f: (cursor: PathCursor) => void): PathCursor;
  66710. }
  66711. }
  66712. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  66713. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  66714. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  66715. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  66716. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  66717. }
  66718. declare module "babylonjs/Engines/Processors/Expressions/index" {
  66719. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  66720. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  66721. }
  66722. declare module "babylonjs/Engines/Processors/index" {
  66723. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  66724. export * from "babylonjs/Engines/Processors/Expressions/index";
  66725. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  66726. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  66727. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  66728. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  66729. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  66730. export * from "babylonjs/Engines/Processors/shaderProcessor";
  66731. }
  66732. declare module "babylonjs/Legacy/legacy" {
  66733. import * as Babylon from "babylonjs/index";
  66734. export * from "babylonjs/index";
  66735. }
  66736. declare module "babylonjs/Shaders/blur.fragment" {
  66737. /** @hidden */
  66738. export var blurPixelShader: {
  66739. name: string;
  66740. shader: string;
  66741. };
  66742. }
  66743. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  66744. /** @hidden */
  66745. export var pointCloudVertexDeclaration: {
  66746. name: string;
  66747. shader: string;
  66748. };
  66749. }
  66750. declare module "babylonjs" {
  66751. export * from "babylonjs/Legacy/legacy";
  66752. }
  66753. declare module BABYLON {
  66754. /** Alias type for value that can be null */
  66755. export type Nullable<T> = T | null;
  66756. /**
  66757. * Alias type for number that are floats
  66758. * @ignorenaming
  66759. */
  66760. export type float = number;
  66761. /**
  66762. * Alias type for number that are doubles.
  66763. * @ignorenaming
  66764. */
  66765. export type double = number;
  66766. /**
  66767. * Alias type for number that are integer
  66768. * @ignorenaming
  66769. */
  66770. export type int = number;
  66771. /** Alias type for number array or Float32Array */
  66772. export type FloatArray = number[] | Float32Array;
  66773. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  66774. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  66775. /**
  66776. * Alias for types that can be used by a Buffer or VertexBuffer.
  66777. */
  66778. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  66779. /**
  66780. * Alias type for primitive types
  66781. * @ignorenaming
  66782. */
  66783. type Primitive = undefined | null | boolean | string | number | Function;
  66784. /**
  66785. * Type modifier to make all the properties of an object Readonly
  66786. */
  66787. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  66788. /**
  66789. * Type modifier to make all the properties of an object Readonly recursively
  66790. */
  66791. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  66792. /**
  66793. * Type modifier to make object properties readonly.
  66794. */
  66795. export type DeepImmutableObject<T> = {
  66796. readonly [K in keyof T]: DeepImmutable<T[K]>;
  66797. };
  66798. /** @hidden */
  66799. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  66800. }
  66801. }
  66802. declare module BABYLON {
  66803. /**
  66804. * A class serves as a medium between the observable and its observers
  66805. */
  66806. export class EventState {
  66807. /**
  66808. * Create a new EventState
  66809. * @param mask defines the mask associated with this state
  66810. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  66811. * @param target defines the original target of the state
  66812. * @param currentTarget defines the current target of the state
  66813. */
  66814. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  66815. /**
  66816. * Initialize the current event state
  66817. * @param mask defines the mask associated with this state
  66818. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  66819. * @param target defines the original target of the state
  66820. * @param currentTarget defines the current target of the state
  66821. * @returns the current event state
  66822. */
  66823. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  66824. /**
  66825. * An Observer can set this property to true to prevent subsequent observers of being notified
  66826. */
  66827. skipNextObservers: boolean;
  66828. /**
  66829. * Get the mask value that were used to trigger the event corresponding to this EventState object
  66830. */
  66831. mask: number;
  66832. /**
  66833. * The object that originally notified the event
  66834. */
  66835. target?: any;
  66836. /**
  66837. * The current object in the bubbling phase
  66838. */
  66839. currentTarget?: any;
  66840. /**
  66841. * This will be populated with the return value of the last function that was executed.
  66842. * If it is the first function in the callback chain it will be the event data.
  66843. */
  66844. lastReturnValue?: any;
  66845. }
  66846. /**
  66847. * Represent an Observer registered to a given Observable object.
  66848. */
  66849. export class Observer<T> {
  66850. /**
  66851. * Defines the callback to call when the observer is notified
  66852. */
  66853. callback: (eventData: T, eventState: EventState) => void;
  66854. /**
  66855. * Defines the mask of the observer (used to filter notifications)
  66856. */
  66857. mask: number;
  66858. /**
  66859. * Defines the current scope used to restore the JS context
  66860. */
  66861. scope: any;
  66862. /** @hidden */
  66863. _willBeUnregistered: boolean;
  66864. /**
  66865. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  66866. */
  66867. unregisterOnNextCall: boolean;
  66868. /**
  66869. * Creates a new observer
  66870. * @param callback defines the callback to call when the observer is notified
  66871. * @param mask defines the mask of the observer (used to filter notifications)
  66872. * @param scope defines the current scope used to restore the JS context
  66873. */
  66874. constructor(
  66875. /**
  66876. * Defines the callback to call when the observer is notified
  66877. */
  66878. callback: (eventData: T, eventState: EventState) => void,
  66879. /**
  66880. * Defines the mask of the observer (used to filter notifications)
  66881. */
  66882. mask: number,
  66883. /**
  66884. * Defines the current scope used to restore the JS context
  66885. */
  66886. scope?: any);
  66887. }
  66888. /**
  66889. * Represent a list of observers registered to multiple Observables object.
  66890. */
  66891. export class MultiObserver<T> {
  66892. private _observers;
  66893. private _observables;
  66894. /**
  66895. * Release associated resources
  66896. */
  66897. dispose(): void;
  66898. /**
  66899. * Raise a callback when one of the observable will notify
  66900. * @param observables defines a list of observables to watch
  66901. * @param callback defines the callback to call on notification
  66902. * @param mask defines the mask used to filter notifications
  66903. * @param scope defines the current scope used to restore the JS context
  66904. * @returns the new MultiObserver
  66905. */
  66906. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  66907. }
  66908. /**
  66909. * The Observable class is a simple implementation of the Observable pattern.
  66910. *
  66911. * 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.
  66912. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  66913. * 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).
  66914. * 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.
  66915. */
  66916. export class Observable<T> {
  66917. private _observers;
  66918. private _eventState;
  66919. private _onObserverAdded;
  66920. /**
  66921. * Gets the list of observers
  66922. */
  66923. readonly observers: Array<Observer<T>>;
  66924. /**
  66925. * Creates a new observable
  66926. * @param onObserverAdded defines a callback to call when a new observer is added
  66927. */
  66928. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  66929. /**
  66930. * Create a new Observer with the specified callback
  66931. * @param callback the callback that will be executed for that Observer
  66932. * @param mask the mask used to filter observers
  66933. * @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.
  66934. * @param scope optional scope for the callback to be called from
  66935. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  66936. * @returns the new observer created for the callback
  66937. */
  66938. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  66939. /**
  66940. * Create a new Observer with the specified callback and unregisters after the next notification
  66941. * @param callback the callback that will be executed for that Observer
  66942. * @returns the new observer created for the callback
  66943. */
  66944. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  66945. /**
  66946. * Remove an Observer from the Observable object
  66947. * @param observer the instance of the Observer to remove
  66948. * @returns false if it doesn't belong to this Observable
  66949. */
  66950. remove(observer: Nullable<Observer<T>>): boolean;
  66951. /**
  66952. * Remove a callback from the Observable object
  66953. * @param callback the callback to remove
  66954. * @param scope optional scope. If used only the callbacks with this scope will be removed
  66955. * @returns false if it doesn't belong to this Observable
  66956. */
  66957. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  66958. private _deferUnregister;
  66959. private _remove;
  66960. /**
  66961. * Moves the observable to the top of the observer list making it get called first when notified
  66962. * @param observer the observer to move
  66963. */
  66964. makeObserverTopPriority(observer: Observer<T>): void;
  66965. /**
  66966. * Moves the observable to the bottom of the observer list making it get called last when notified
  66967. * @param observer the observer to move
  66968. */
  66969. makeObserverBottomPriority(observer: Observer<T>): void;
  66970. /**
  66971. * Notify all Observers by calling their respective callback with the given data
  66972. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  66973. * @param eventData defines the data to send to all observers
  66974. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  66975. * @param target defines the original target of the state
  66976. * @param currentTarget defines the current target of the state
  66977. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  66978. */
  66979. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  66980. /**
  66981. * Calling this will execute each callback, expecting it to be a promise or return a value.
  66982. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  66983. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  66984. * and it is crucial that all callbacks will be executed.
  66985. * The order of the callbacks is kept, callbacks are not executed parallel.
  66986. *
  66987. * @param eventData The data to be sent to each callback
  66988. * @param mask is used to filter observers defaults to -1
  66989. * @param target defines the callback target (see EventState)
  66990. * @param currentTarget defines he current object in the bubbling phase
  66991. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  66992. */
  66993. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  66994. /**
  66995. * Notify a specific observer
  66996. * @param observer defines the observer to notify
  66997. * @param eventData defines the data to be sent to each callback
  66998. * @param mask is used to filter observers defaults to -1
  66999. */
  67000. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  67001. /**
  67002. * Gets a boolean indicating if the observable has at least one observer
  67003. * @returns true is the Observable has at least one Observer registered
  67004. */
  67005. hasObservers(): boolean;
  67006. /**
  67007. * Clear the list of observers
  67008. */
  67009. clear(): void;
  67010. /**
  67011. * Clone the current observable
  67012. * @returns a new observable
  67013. */
  67014. clone(): Observable<T>;
  67015. /**
  67016. * Does this observable handles observer registered with a given mask
  67017. * @param mask defines the mask to be tested
  67018. * @return whether or not one observer registered with the given mask is handeled
  67019. **/
  67020. hasSpecificMask(mask?: number): boolean;
  67021. }
  67022. }
  67023. declare module BABYLON {
  67024. /**
  67025. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  67026. * Babylon.js
  67027. */
  67028. export class DomManagement {
  67029. /**
  67030. * Checks if the window object exists
  67031. * @returns true if the window object exists
  67032. */
  67033. static IsWindowObjectExist(): boolean;
  67034. /**
  67035. * Checks if the navigator object exists
  67036. * @returns true if the navigator object exists
  67037. */
  67038. static IsNavigatorAvailable(): boolean;
  67039. /**
  67040. * Extracts text content from a DOM element hierarchy
  67041. * @param element defines the root element
  67042. * @returns a string
  67043. */
  67044. static GetDOMTextContent(element: HTMLElement): string;
  67045. }
  67046. }
  67047. declare module BABYLON {
  67048. /**
  67049. * Logger used througouht the application to allow configuration of
  67050. * the log level required for the messages.
  67051. */
  67052. export class Logger {
  67053. /**
  67054. * No log
  67055. */
  67056. static readonly NoneLogLevel: number;
  67057. /**
  67058. * Only message logs
  67059. */
  67060. static readonly MessageLogLevel: number;
  67061. /**
  67062. * Only warning logs
  67063. */
  67064. static readonly WarningLogLevel: number;
  67065. /**
  67066. * Only error logs
  67067. */
  67068. static readonly ErrorLogLevel: number;
  67069. /**
  67070. * All logs
  67071. */
  67072. static readonly AllLogLevel: number;
  67073. private static _LogCache;
  67074. /**
  67075. * Gets a value indicating the number of loading errors
  67076. * @ignorenaming
  67077. */
  67078. static errorsCount: number;
  67079. /**
  67080. * Callback called when a new log is added
  67081. */
  67082. static OnNewCacheEntry: (entry: string) => void;
  67083. private static _AddLogEntry;
  67084. private static _FormatMessage;
  67085. private static _LogDisabled;
  67086. private static _LogEnabled;
  67087. private static _WarnDisabled;
  67088. private static _WarnEnabled;
  67089. private static _ErrorDisabled;
  67090. private static _ErrorEnabled;
  67091. /**
  67092. * Log a message to the console
  67093. */
  67094. static Log: (message: string) => void;
  67095. /**
  67096. * Write a warning message to the console
  67097. */
  67098. static Warn: (message: string) => void;
  67099. /**
  67100. * Write an error message to the console
  67101. */
  67102. static Error: (message: string) => void;
  67103. /**
  67104. * Gets current log cache (list of logs)
  67105. */
  67106. static readonly LogCache: string;
  67107. /**
  67108. * Clears the log cache
  67109. */
  67110. static ClearLogCache(): void;
  67111. /**
  67112. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  67113. */
  67114. static LogLevels: number;
  67115. }
  67116. }
  67117. declare module BABYLON {
  67118. /** @hidden */
  67119. export class _TypeStore {
  67120. /** @hidden */
  67121. static RegisteredTypes: {
  67122. [key: string]: Object;
  67123. };
  67124. /** @hidden */
  67125. static GetClass(fqdn: string): any;
  67126. }
  67127. }
  67128. declare module BABYLON {
  67129. /**
  67130. * Class containing a set of static utilities functions for deep copy.
  67131. */
  67132. export class DeepCopier {
  67133. /**
  67134. * Tries to copy an object by duplicating every property
  67135. * @param source defines the source object
  67136. * @param destination defines the target object
  67137. * @param doNotCopyList defines a list of properties to avoid
  67138. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  67139. */
  67140. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  67141. }
  67142. }
  67143. declare module BABYLON {
  67144. /**
  67145. * Class containing a set of static utilities functions for precision date
  67146. */
  67147. export class PrecisionDate {
  67148. /**
  67149. * Gets either window.performance.now() if supported or Date.now() else
  67150. */
  67151. static readonly Now: number;
  67152. }
  67153. }
  67154. declare module BABYLON {
  67155. /** @hidden */
  67156. export class _DevTools {
  67157. static WarnImport(name: string): string;
  67158. }
  67159. }
  67160. declare module BABYLON {
  67161. /**
  67162. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  67163. */
  67164. export class WebRequest {
  67165. private _xhr;
  67166. /**
  67167. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  67168. * i.e. when loading files, where the server/service expects an Authorization header
  67169. */
  67170. static CustomRequestHeaders: {
  67171. [key: string]: string;
  67172. };
  67173. /**
  67174. * Add callback functions in this array to update all the requests before they get sent to the network
  67175. */
  67176. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  67177. private _injectCustomRequestHeaders;
  67178. /**
  67179. * Gets or sets a function to be called when loading progress changes
  67180. */
  67181. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  67182. /**
  67183. * Returns client's state
  67184. */
  67185. readonly readyState: number;
  67186. /**
  67187. * Returns client's status
  67188. */
  67189. readonly status: number;
  67190. /**
  67191. * Returns client's status as a text
  67192. */
  67193. readonly statusText: string;
  67194. /**
  67195. * Returns client's response
  67196. */
  67197. readonly response: any;
  67198. /**
  67199. * Returns client's response url
  67200. */
  67201. readonly responseURL: string;
  67202. /**
  67203. * Returns client's response as text
  67204. */
  67205. readonly responseText: string;
  67206. /**
  67207. * Gets or sets the expected response type
  67208. */
  67209. responseType: XMLHttpRequestResponseType;
  67210. /** @hidden */
  67211. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  67212. /** @hidden */
  67213. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  67214. /**
  67215. * Cancels any network activity
  67216. */
  67217. abort(): void;
  67218. /**
  67219. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  67220. * @param body defines an optional request body
  67221. */
  67222. send(body?: Document | BodyInit | null): void;
  67223. /**
  67224. * Sets the request method, request URL
  67225. * @param method defines the method to use (GET, POST, etc..)
  67226. * @param url defines the url to connect with
  67227. */
  67228. open(method: string, url: string): void;
  67229. }
  67230. }
  67231. declare module BABYLON {
  67232. /**
  67233. * File request interface
  67234. */
  67235. export interface IFileRequest {
  67236. /**
  67237. * Raised when the request is complete (success or error).
  67238. */
  67239. onCompleteObservable: Observable<IFileRequest>;
  67240. /**
  67241. * Aborts the request for a file.
  67242. */
  67243. abort: () => void;
  67244. }
  67245. }
  67246. declare module BABYLON {
  67247. /**
  67248. * Scalar computation library
  67249. */
  67250. export class Scalar {
  67251. /**
  67252. * Two pi constants convenient for computation.
  67253. */
  67254. static TwoPi: number;
  67255. /**
  67256. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  67257. * @param a number
  67258. * @param b number
  67259. * @param epsilon (default = 1.401298E-45)
  67260. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  67261. */
  67262. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  67263. /**
  67264. * Returns a string : the upper case translation of the number i to hexadecimal.
  67265. * @param i number
  67266. * @returns the upper case translation of the number i to hexadecimal.
  67267. */
  67268. static ToHex(i: number): string;
  67269. /**
  67270. * Returns -1 if value is negative and +1 is value is positive.
  67271. * @param value the value
  67272. * @returns the value itself if it's equal to zero.
  67273. */
  67274. static Sign(value: number): number;
  67275. /**
  67276. * Returns the value itself if it's between min and max.
  67277. * Returns min if the value is lower than min.
  67278. * Returns max if the value is greater than max.
  67279. * @param value the value to clmap
  67280. * @param min the min value to clamp to (default: 0)
  67281. * @param max the max value to clamp to (default: 1)
  67282. * @returns the clamped value
  67283. */
  67284. static Clamp(value: number, min?: number, max?: number): number;
  67285. /**
  67286. * the log2 of value.
  67287. * @param value the value to compute log2 of
  67288. * @returns the log2 of value.
  67289. */
  67290. static Log2(value: number): number;
  67291. /**
  67292. * Loops the value, so that it is never larger than length and never smaller than 0.
  67293. *
  67294. * This is similar to the modulo operator but it works with floating point numbers.
  67295. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  67296. * With t = 5 and length = 2.5, the result would be 0.0.
  67297. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  67298. * @param value the value
  67299. * @param length the length
  67300. * @returns the looped value
  67301. */
  67302. static Repeat(value: number, length: number): number;
  67303. /**
  67304. * Normalize the value between 0.0 and 1.0 using min and max values
  67305. * @param value value to normalize
  67306. * @param min max to normalize between
  67307. * @param max min to normalize between
  67308. * @returns the normalized value
  67309. */
  67310. static Normalize(value: number, min: number, max: number): number;
  67311. /**
  67312. * Denormalize the value from 0.0 and 1.0 using min and max values
  67313. * @param normalized value to denormalize
  67314. * @param min max to denormalize between
  67315. * @param max min to denormalize between
  67316. * @returns the denormalized value
  67317. */
  67318. static Denormalize(normalized: number, min: number, max: number): number;
  67319. /**
  67320. * Calculates the shortest difference between two given angles given in degrees.
  67321. * @param current current angle in degrees
  67322. * @param target target angle in degrees
  67323. * @returns the delta
  67324. */
  67325. static DeltaAngle(current: number, target: number): number;
  67326. /**
  67327. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  67328. * @param tx value
  67329. * @param length length
  67330. * @returns The returned value will move back and forth between 0 and length
  67331. */
  67332. static PingPong(tx: number, length: number): number;
  67333. /**
  67334. * Interpolates between min and max with smoothing at the limits.
  67335. *
  67336. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  67337. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  67338. * @param from from
  67339. * @param to to
  67340. * @param tx value
  67341. * @returns the smooth stepped value
  67342. */
  67343. static SmoothStep(from: number, to: number, tx: number): number;
  67344. /**
  67345. * Moves a value current towards target.
  67346. *
  67347. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  67348. * Negative values of maxDelta pushes the value away from target.
  67349. * @param current current value
  67350. * @param target target value
  67351. * @param maxDelta max distance to move
  67352. * @returns resulting value
  67353. */
  67354. static MoveTowards(current: number, target: number, maxDelta: number): number;
  67355. /**
  67356. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  67357. *
  67358. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  67359. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  67360. * @param current current value
  67361. * @param target target value
  67362. * @param maxDelta max distance to move
  67363. * @returns resulting angle
  67364. */
  67365. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  67366. /**
  67367. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  67368. * @param start start value
  67369. * @param end target value
  67370. * @param amount amount to lerp between
  67371. * @returns the lerped value
  67372. */
  67373. static Lerp(start: number, end: number, amount: number): number;
  67374. /**
  67375. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  67376. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  67377. * @param start start value
  67378. * @param end target value
  67379. * @param amount amount to lerp between
  67380. * @returns the lerped value
  67381. */
  67382. static LerpAngle(start: number, end: number, amount: number): number;
  67383. /**
  67384. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  67385. * @param a start value
  67386. * @param b target value
  67387. * @param value value between a and b
  67388. * @returns the inverseLerp value
  67389. */
  67390. static InverseLerp(a: number, b: number, value: number): number;
  67391. /**
  67392. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  67393. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  67394. * @param value1 spline value
  67395. * @param tangent1 spline value
  67396. * @param value2 spline value
  67397. * @param tangent2 spline value
  67398. * @param amount input value
  67399. * @returns hermite result
  67400. */
  67401. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  67402. /**
  67403. * Returns a random float number between and min and max values
  67404. * @param min min value of random
  67405. * @param max max value of random
  67406. * @returns random value
  67407. */
  67408. static RandomRange(min: number, max: number): number;
  67409. /**
  67410. * This function returns percentage of a number in a given range.
  67411. *
  67412. * RangeToPercent(40,20,60) will return 0.5 (50%)
  67413. * RangeToPercent(34,0,100) will return 0.34 (34%)
  67414. * @param number to convert to percentage
  67415. * @param min min range
  67416. * @param max max range
  67417. * @returns the percentage
  67418. */
  67419. static RangeToPercent(number: number, min: number, max: number): number;
  67420. /**
  67421. * This function returns number that corresponds to the percentage in a given range.
  67422. *
  67423. * PercentToRange(0.34,0,100) will return 34.
  67424. * @param percent to convert to number
  67425. * @param min min range
  67426. * @param max max range
  67427. * @returns the number
  67428. */
  67429. static PercentToRange(percent: number, min: number, max: number): number;
  67430. /**
  67431. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  67432. * @param angle The angle to normalize in radian.
  67433. * @return The converted angle.
  67434. */
  67435. static NormalizeRadians(angle: number): number;
  67436. }
  67437. }
  67438. declare module BABYLON {
  67439. /**
  67440. * Constant used to convert a value to gamma space
  67441. * @ignorenaming
  67442. */
  67443. export const ToGammaSpace: number;
  67444. /**
  67445. * Constant used to convert a value to linear space
  67446. * @ignorenaming
  67447. */
  67448. export const ToLinearSpace = 2.2;
  67449. /**
  67450. * Constant used to define the minimal number value in Babylon.js
  67451. * @ignorenaming
  67452. */
  67453. let Epsilon: number;
  67454. }
  67455. declare module BABYLON {
  67456. /**
  67457. * Class used to represent a viewport on screen
  67458. */
  67459. export class Viewport {
  67460. /** viewport left coordinate */
  67461. x: number;
  67462. /** viewport top coordinate */
  67463. y: number;
  67464. /**viewport width */
  67465. width: number;
  67466. /** viewport height */
  67467. height: number;
  67468. /**
  67469. * Creates a Viewport object located at (x, y) and sized (width, height)
  67470. * @param x defines viewport left coordinate
  67471. * @param y defines viewport top coordinate
  67472. * @param width defines the viewport width
  67473. * @param height defines the viewport height
  67474. */
  67475. constructor(
  67476. /** viewport left coordinate */
  67477. x: number,
  67478. /** viewport top coordinate */
  67479. y: number,
  67480. /**viewport width */
  67481. width: number,
  67482. /** viewport height */
  67483. height: number);
  67484. /**
  67485. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  67486. * @param renderWidth defines the rendering width
  67487. * @param renderHeight defines the rendering height
  67488. * @returns a new Viewport
  67489. */
  67490. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  67491. /**
  67492. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  67493. * @param renderWidth defines the rendering width
  67494. * @param renderHeight defines the rendering height
  67495. * @param ref defines the target viewport
  67496. * @returns the current viewport
  67497. */
  67498. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  67499. /**
  67500. * Returns a new Viewport copied from the current one
  67501. * @returns a new Viewport
  67502. */
  67503. clone(): Viewport;
  67504. }
  67505. }
  67506. declare module BABYLON {
  67507. /**
  67508. * Class containing a set of static utilities functions for arrays.
  67509. */
  67510. export class ArrayTools {
  67511. /**
  67512. * Returns an array of the given size filled with element built from the given constructor and the paramters
  67513. * @param size the number of element to construct and put in the array
  67514. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  67515. * @returns a new array filled with new objects
  67516. */
  67517. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  67518. }
  67519. }
  67520. declare module BABYLON {
  67521. /**
  67522. * @hidden
  67523. */
  67524. export interface IColor4Like {
  67525. r: float;
  67526. g: float;
  67527. b: float;
  67528. a: float;
  67529. }
  67530. /**
  67531. * @hidden
  67532. */
  67533. export interface IColor3Like {
  67534. r: float;
  67535. g: float;
  67536. b: float;
  67537. }
  67538. /**
  67539. * @hidden
  67540. */
  67541. export interface IVector4Like {
  67542. x: float;
  67543. y: float;
  67544. z: float;
  67545. w: float;
  67546. }
  67547. /**
  67548. * @hidden
  67549. */
  67550. export interface IVector3Like {
  67551. x: float;
  67552. y: float;
  67553. z: float;
  67554. }
  67555. /**
  67556. * @hidden
  67557. */
  67558. export interface IVector2Like {
  67559. x: float;
  67560. y: float;
  67561. }
  67562. /**
  67563. * @hidden
  67564. */
  67565. export interface IMatrixLike {
  67566. toArray(): DeepImmutable<Float32Array>;
  67567. updateFlag: int;
  67568. }
  67569. /**
  67570. * @hidden
  67571. */
  67572. export interface IViewportLike {
  67573. x: float;
  67574. y: float;
  67575. width: float;
  67576. height: float;
  67577. }
  67578. /**
  67579. * @hidden
  67580. */
  67581. export interface IPlaneLike {
  67582. normal: IVector3Like;
  67583. d: float;
  67584. normalize(): void;
  67585. }
  67586. }
  67587. declare module BABYLON {
  67588. /**
  67589. * Class representing a vector containing 2 coordinates
  67590. */
  67591. export class Vector2 {
  67592. /** defines the first coordinate */
  67593. x: number;
  67594. /** defines the second coordinate */
  67595. y: number;
  67596. /**
  67597. * Creates a new Vector2 from the given x and y coordinates
  67598. * @param x defines the first coordinate
  67599. * @param y defines the second coordinate
  67600. */
  67601. constructor(
  67602. /** defines the first coordinate */
  67603. x?: number,
  67604. /** defines the second coordinate */
  67605. y?: number);
  67606. /**
  67607. * Gets a string with the Vector2 coordinates
  67608. * @returns a string with the Vector2 coordinates
  67609. */
  67610. toString(): string;
  67611. /**
  67612. * Gets class name
  67613. * @returns the string "Vector2"
  67614. */
  67615. getClassName(): string;
  67616. /**
  67617. * Gets current vector hash code
  67618. * @returns the Vector2 hash code as a number
  67619. */
  67620. getHashCode(): number;
  67621. /**
  67622. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  67623. * @param array defines the source array
  67624. * @param index defines the offset in source array
  67625. * @returns the current Vector2
  67626. */
  67627. toArray(array: FloatArray, index?: number): Vector2;
  67628. /**
  67629. * Copy the current vector to an array
  67630. * @returns a new array with 2 elements: the Vector2 coordinates.
  67631. */
  67632. asArray(): number[];
  67633. /**
  67634. * Sets the Vector2 coordinates with the given Vector2 coordinates
  67635. * @param source defines the source Vector2
  67636. * @returns the current updated Vector2
  67637. */
  67638. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  67639. /**
  67640. * Sets the Vector2 coordinates with the given floats
  67641. * @param x defines the first coordinate
  67642. * @param y defines the second coordinate
  67643. * @returns the current updated Vector2
  67644. */
  67645. copyFromFloats(x: number, y: number): Vector2;
  67646. /**
  67647. * Sets the Vector2 coordinates with the given floats
  67648. * @param x defines the first coordinate
  67649. * @param y defines the second coordinate
  67650. * @returns the current updated Vector2
  67651. */
  67652. set(x: number, y: number): Vector2;
  67653. /**
  67654. * Add another vector with the current one
  67655. * @param otherVector defines the other vector
  67656. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  67657. */
  67658. add(otherVector: DeepImmutable<Vector2>): Vector2;
  67659. /**
  67660. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  67661. * @param otherVector defines the other vector
  67662. * @param result defines the target vector
  67663. * @returns the unmodified current Vector2
  67664. */
  67665. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  67666. /**
  67667. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  67668. * @param otherVector defines the other vector
  67669. * @returns the current updated Vector2
  67670. */
  67671. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  67672. /**
  67673. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  67674. * @param otherVector defines the other vector
  67675. * @returns a new Vector2
  67676. */
  67677. addVector3(otherVector: Vector3): Vector2;
  67678. /**
  67679. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  67680. * @param otherVector defines the other vector
  67681. * @returns a new Vector2
  67682. */
  67683. subtract(otherVector: Vector2): Vector2;
  67684. /**
  67685. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  67686. * @param otherVector defines the other vector
  67687. * @param result defines the target vector
  67688. * @returns the unmodified current Vector2
  67689. */
  67690. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  67691. /**
  67692. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  67693. * @param otherVector defines the other vector
  67694. * @returns the current updated Vector2
  67695. */
  67696. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  67697. /**
  67698. * Multiplies in place the current Vector2 coordinates by the given ones
  67699. * @param otherVector defines the other vector
  67700. * @returns the current updated Vector2
  67701. */
  67702. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  67703. /**
  67704. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  67705. * @param otherVector defines the other vector
  67706. * @returns a new Vector2
  67707. */
  67708. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  67709. /**
  67710. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  67711. * @param otherVector defines the other vector
  67712. * @param result defines the target vector
  67713. * @returns the unmodified current Vector2
  67714. */
  67715. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  67716. /**
  67717. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  67718. * @param x defines the first coordinate
  67719. * @param y defines the second coordinate
  67720. * @returns a new Vector2
  67721. */
  67722. multiplyByFloats(x: number, y: number): Vector2;
  67723. /**
  67724. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  67725. * @param otherVector defines the other vector
  67726. * @returns a new Vector2
  67727. */
  67728. divide(otherVector: Vector2): Vector2;
  67729. /**
  67730. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  67731. * @param otherVector defines the other vector
  67732. * @param result defines the target vector
  67733. * @returns the unmodified current Vector2
  67734. */
  67735. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  67736. /**
  67737. * Divides the current Vector2 coordinates by the given ones
  67738. * @param otherVector defines the other vector
  67739. * @returns the current updated Vector2
  67740. */
  67741. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  67742. /**
  67743. * Gets a new Vector2 with current Vector2 negated coordinates
  67744. * @returns a new Vector2
  67745. */
  67746. negate(): Vector2;
  67747. /**
  67748. * Multiply the Vector2 coordinates by scale
  67749. * @param scale defines the scaling factor
  67750. * @returns the current updated Vector2
  67751. */
  67752. scaleInPlace(scale: number): Vector2;
  67753. /**
  67754. * Returns a new Vector2 scaled by "scale" from the current Vector2
  67755. * @param scale defines the scaling factor
  67756. * @returns a new Vector2
  67757. */
  67758. scale(scale: number): Vector2;
  67759. /**
  67760. * Scale the current Vector2 values by a factor to a given Vector2
  67761. * @param scale defines the scale factor
  67762. * @param result defines the Vector2 object where to store the result
  67763. * @returns the unmodified current Vector2
  67764. */
  67765. scaleToRef(scale: number, result: Vector2): Vector2;
  67766. /**
  67767. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  67768. * @param scale defines the scale factor
  67769. * @param result defines the Vector2 object where to store the result
  67770. * @returns the unmodified current Vector2
  67771. */
  67772. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  67773. /**
  67774. * Gets a boolean if two vectors are equals
  67775. * @param otherVector defines the other vector
  67776. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  67777. */
  67778. equals(otherVector: DeepImmutable<Vector2>): boolean;
  67779. /**
  67780. * Gets a boolean if two vectors are equals (using an epsilon value)
  67781. * @param otherVector defines the other vector
  67782. * @param epsilon defines the minimal distance to consider equality
  67783. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  67784. */
  67785. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  67786. /**
  67787. * Gets a new Vector2 from current Vector2 floored values
  67788. * @returns a new Vector2
  67789. */
  67790. floor(): Vector2;
  67791. /**
  67792. * Gets a new Vector2 from current Vector2 floored values
  67793. * @returns a new Vector2
  67794. */
  67795. fract(): Vector2;
  67796. /**
  67797. * Gets the length of the vector
  67798. * @returns the vector length (float)
  67799. */
  67800. length(): number;
  67801. /**
  67802. * Gets the vector squared length
  67803. * @returns the vector squared length (float)
  67804. */
  67805. lengthSquared(): number;
  67806. /**
  67807. * Normalize the vector
  67808. * @returns the current updated Vector2
  67809. */
  67810. normalize(): Vector2;
  67811. /**
  67812. * Gets a new Vector2 copied from the Vector2
  67813. * @returns a new Vector2
  67814. */
  67815. clone(): Vector2;
  67816. /**
  67817. * Gets a new Vector2(0, 0)
  67818. * @returns a new Vector2
  67819. */
  67820. static Zero(): Vector2;
  67821. /**
  67822. * Gets a new Vector2(1, 1)
  67823. * @returns a new Vector2
  67824. */
  67825. static One(): Vector2;
  67826. /**
  67827. * Gets a new Vector2 set from the given index element of the given array
  67828. * @param array defines the data source
  67829. * @param offset defines the offset in the data source
  67830. * @returns a new Vector2
  67831. */
  67832. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  67833. /**
  67834. * Sets "result" from the given index element of the given array
  67835. * @param array defines the data source
  67836. * @param offset defines the offset in the data source
  67837. * @param result defines the target vector
  67838. */
  67839. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  67840. /**
  67841. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  67842. * @param value1 defines 1st point of control
  67843. * @param value2 defines 2nd point of control
  67844. * @param value3 defines 3rd point of control
  67845. * @param value4 defines 4th point of control
  67846. * @param amount defines the interpolation factor
  67847. * @returns a new Vector2
  67848. */
  67849. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  67850. /**
  67851. * 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".
  67852. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  67853. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  67854. * @param value defines the value to clamp
  67855. * @param min defines the lower limit
  67856. * @param max defines the upper limit
  67857. * @returns a new Vector2
  67858. */
  67859. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  67860. /**
  67861. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  67862. * @param value1 defines the 1st control point
  67863. * @param tangent1 defines the outgoing tangent
  67864. * @param value2 defines the 2nd control point
  67865. * @param tangent2 defines the incoming tangent
  67866. * @param amount defines the interpolation factor
  67867. * @returns a new Vector2
  67868. */
  67869. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  67870. /**
  67871. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  67872. * @param start defines the start vector
  67873. * @param end defines the end vector
  67874. * @param amount defines the interpolation factor
  67875. * @returns a new Vector2
  67876. */
  67877. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  67878. /**
  67879. * Gets the dot product of the vector "left" and the vector "right"
  67880. * @param left defines first vector
  67881. * @param right defines second vector
  67882. * @returns the dot product (float)
  67883. */
  67884. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  67885. /**
  67886. * Returns a new Vector2 equal to the normalized given vector
  67887. * @param vector defines the vector to normalize
  67888. * @returns a new Vector2
  67889. */
  67890. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  67891. /**
  67892. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  67893. * @param left defines 1st vector
  67894. * @param right defines 2nd vector
  67895. * @returns a new Vector2
  67896. */
  67897. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  67898. /**
  67899. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  67900. * @param left defines 1st vector
  67901. * @param right defines 2nd vector
  67902. * @returns a new Vector2
  67903. */
  67904. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  67905. /**
  67906. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  67907. * @param vector defines the vector to transform
  67908. * @param transformation defines the matrix to apply
  67909. * @returns a new Vector2
  67910. */
  67911. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  67912. /**
  67913. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  67914. * @param vector defines the vector to transform
  67915. * @param transformation defines the matrix to apply
  67916. * @param result defines the target vector
  67917. */
  67918. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  67919. /**
  67920. * Determines if a given vector is included in a triangle
  67921. * @param p defines the vector to test
  67922. * @param p0 defines 1st triangle point
  67923. * @param p1 defines 2nd triangle point
  67924. * @param p2 defines 3rd triangle point
  67925. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  67926. */
  67927. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  67928. /**
  67929. * Gets the distance between the vectors "value1" and "value2"
  67930. * @param value1 defines first vector
  67931. * @param value2 defines second vector
  67932. * @returns the distance between vectors
  67933. */
  67934. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  67935. /**
  67936. * Returns the squared distance between the vectors "value1" and "value2"
  67937. * @param value1 defines first vector
  67938. * @param value2 defines second vector
  67939. * @returns the squared distance between vectors
  67940. */
  67941. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  67942. /**
  67943. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  67944. * @param value1 defines first vector
  67945. * @param value2 defines second vector
  67946. * @returns a new Vector2
  67947. */
  67948. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  67949. /**
  67950. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  67951. * @param p defines the middle point
  67952. * @param segA defines one point of the segment
  67953. * @param segB defines the other point of the segment
  67954. * @returns the shortest distance
  67955. */
  67956. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  67957. }
  67958. /**
  67959. * Classed used to store (x,y,z) vector representation
  67960. * A Vector3 is the main object used in 3D geometry
  67961. * It can represent etiher the coordinates of a point the space, either a direction
  67962. * Reminder: js uses a left handed forward facing system
  67963. */
  67964. export class Vector3 {
  67965. /**
  67966. * Defines the first coordinates (on X axis)
  67967. */
  67968. x: number;
  67969. /**
  67970. * Defines the second coordinates (on Y axis)
  67971. */
  67972. y: number;
  67973. /**
  67974. * Defines the third coordinates (on Z axis)
  67975. */
  67976. z: number;
  67977. private static _UpReadOnly;
  67978. private static _ZeroReadOnly;
  67979. /**
  67980. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  67981. * @param x defines the first coordinates (on X axis)
  67982. * @param y defines the second coordinates (on Y axis)
  67983. * @param z defines the third coordinates (on Z axis)
  67984. */
  67985. constructor(
  67986. /**
  67987. * Defines the first coordinates (on X axis)
  67988. */
  67989. x?: number,
  67990. /**
  67991. * Defines the second coordinates (on Y axis)
  67992. */
  67993. y?: number,
  67994. /**
  67995. * Defines the third coordinates (on Z axis)
  67996. */
  67997. z?: number);
  67998. /**
  67999. * Creates a string representation of the Vector3
  68000. * @returns a string with the Vector3 coordinates.
  68001. */
  68002. toString(): string;
  68003. /**
  68004. * Gets the class name
  68005. * @returns the string "Vector3"
  68006. */
  68007. getClassName(): string;
  68008. /**
  68009. * Creates the Vector3 hash code
  68010. * @returns a number which tends to be unique between Vector3 instances
  68011. */
  68012. getHashCode(): number;
  68013. /**
  68014. * Creates an array containing three elements : the coordinates of the Vector3
  68015. * @returns a new array of numbers
  68016. */
  68017. asArray(): number[];
  68018. /**
  68019. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  68020. * @param array defines the destination array
  68021. * @param index defines the offset in the destination array
  68022. * @returns the current Vector3
  68023. */
  68024. toArray(array: FloatArray, index?: number): Vector3;
  68025. /**
  68026. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  68027. * @returns a new Quaternion object, computed from the Vector3 coordinates
  68028. */
  68029. toQuaternion(): Quaternion;
  68030. /**
  68031. * Adds the given vector to the current Vector3
  68032. * @param otherVector defines the second operand
  68033. * @returns the current updated Vector3
  68034. */
  68035. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  68036. /**
  68037. * Adds the given coordinates to the current Vector3
  68038. * @param x defines the x coordinate of the operand
  68039. * @param y defines the y coordinate of the operand
  68040. * @param z defines the z coordinate of the operand
  68041. * @returns the current updated Vector3
  68042. */
  68043. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  68044. /**
  68045. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  68046. * @param otherVector defines the second operand
  68047. * @returns the resulting Vector3
  68048. */
  68049. add(otherVector: DeepImmutable<Vector3>): Vector3;
  68050. /**
  68051. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  68052. * @param otherVector defines the second operand
  68053. * @param result defines the Vector3 object where to store the result
  68054. * @returns the current Vector3
  68055. */
  68056. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  68057. /**
  68058. * Subtract the given vector from the current Vector3
  68059. * @param otherVector defines the second operand
  68060. * @returns the current updated Vector3
  68061. */
  68062. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  68063. /**
  68064. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  68065. * @param otherVector defines the second operand
  68066. * @returns the resulting Vector3
  68067. */
  68068. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  68069. /**
  68070. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  68071. * @param otherVector defines the second operand
  68072. * @param result defines the Vector3 object where to store the result
  68073. * @returns the current Vector3
  68074. */
  68075. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  68076. /**
  68077. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  68078. * @param x defines the x coordinate of the operand
  68079. * @param y defines the y coordinate of the operand
  68080. * @param z defines the z coordinate of the operand
  68081. * @returns the resulting Vector3
  68082. */
  68083. subtractFromFloats(x: number, y: number, z: number): Vector3;
  68084. /**
  68085. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  68086. * @param x defines the x coordinate of the operand
  68087. * @param y defines the y coordinate of the operand
  68088. * @param z defines the z coordinate of the operand
  68089. * @param result defines the Vector3 object where to store the result
  68090. * @returns the current Vector3
  68091. */
  68092. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  68093. /**
  68094. * Gets a new Vector3 set with the current Vector3 negated coordinates
  68095. * @returns a new Vector3
  68096. */
  68097. negate(): Vector3;
  68098. /**
  68099. * Multiplies the Vector3 coordinates by the float "scale"
  68100. * @param scale defines the multiplier factor
  68101. * @returns the current updated Vector3
  68102. */
  68103. scaleInPlace(scale: number): Vector3;
  68104. /**
  68105. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  68106. * @param scale defines the multiplier factor
  68107. * @returns a new Vector3
  68108. */
  68109. scale(scale: number): Vector3;
  68110. /**
  68111. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  68112. * @param scale defines the multiplier factor
  68113. * @param result defines the Vector3 object where to store the result
  68114. * @returns the current Vector3
  68115. */
  68116. scaleToRef(scale: number, result: Vector3): Vector3;
  68117. /**
  68118. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  68119. * @param scale defines the scale factor
  68120. * @param result defines the Vector3 object where to store the result
  68121. * @returns the unmodified current Vector3
  68122. */
  68123. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  68124. /**
  68125. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  68126. * @param otherVector defines the second operand
  68127. * @returns true if both vectors are equals
  68128. */
  68129. equals(otherVector: DeepImmutable<Vector3>): boolean;
  68130. /**
  68131. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  68132. * @param otherVector defines the second operand
  68133. * @param epsilon defines the minimal distance to define values as equals
  68134. * @returns true if both vectors are distant less than epsilon
  68135. */
  68136. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  68137. /**
  68138. * Returns true if the current Vector3 coordinates equals the given floats
  68139. * @param x defines the x coordinate of the operand
  68140. * @param y defines the y coordinate of the operand
  68141. * @param z defines the z coordinate of the operand
  68142. * @returns true if both vectors are equals
  68143. */
  68144. equalsToFloats(x: number, y: number, z: number): boolean;
  68145. /**
  68146. * Multiplies the current Vector3 coordinates by the given ones
  68147. * @param otherVector defines the second operand
  68148. * @returns the current updated Vector3
  68149. */
  68150. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  68151. /**
  68152. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  68153. * @param otherVector defines the second operand
  68154. * @returns the new Vector3
  68155. */
  68156. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  68157. /**
  68158. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  68159. * @param otherVector defines the second operand
  68160. * @param result defines the Vector3 object where to store the result
  68161. * @returns the current Vector3
  68162. */
  68163. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  68164. /**
  68165. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  68166. * @param x defines the x coordinate of the operand
  68167. * @param y defines the y coordinate of the operand
  68168. * @param z defines the z coordinate of the operand
  68169. * @returns the new Vector3
  68170. */
  68171. multiplyByFloats(x: number, y: number, z: number): Vector3;
  68172. /**
  68173. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  68174. * @param otherVector defines the second operand
  68175. * @returns the new Vector3
  68176. */
  68177. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  68178. /**
  68179. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  68180. * @param otherVector defines the second operand
  68181. * @param result defines the Vector3 object where to store the result
  68182. * @returns the current Vector3
  68183. */
  68184. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  68185. /**
  68186. * Divides the current Vector3 coordinates by the given ones.
  68187. * @param otherVector defines the second operand
  68188. * @returns the current updated Vector3
  68189. */
  68190. divideInPlace(otherVector: Vector3): Vector3;
  68191. /**
  68192. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  68193. * @param other defines the second operand
  68194. * @returns the current updated Vector3
  68195. */
  68196. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  68197. /**
  68198. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  68199. * @param other defines the second operand
  68200. * @returns the current updated Vector3
  68201. */
  68202. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  68203. /**
  68204. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  68205. * @param x defines the x coordinate of the operand
  68206. * @param y defines the y coordinate of the operand
  68207. * @param z defines the z coordinate of the operand
  68208. * @returns the current updated Vector3
  68209. */
  68210. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  68211. /**
  68212. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  68213. * @param x defines the x coordinate of the operand
  68214. * @param y defines the y coordinate of the operand
  68215. * @param z defines the z coordinate of the operand
  68216. * @returns the current updated Vector3
  68217. */
  68218. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  68219. /**
  68220. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  68221. * Check if is non uniform within a certain amount of decimal places to account for this
  68222. * @param epsilon the amount the values can differ
  68223. * @returns if the the vector is non uniform to a certain number of decimal places
  68224. */
  68225. isNonUniformWithinEpsilon(epsilon: number): boolean;
  68226. /**
  68227. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  68228. */
  68229. readonly isNonUniform: boolean;
  68230. /**
  68231. * Gets a new Vector3 from current Vector3 floored values
  68232. * @returns a new Vector3
  68233. */
  68234. floor(): Vector3;
  68235. /**
  68236. * Gets a new Vector3 from current Vector3 floored values
  68237. * @returns a new Vector3
  68238. */
  68239. fract(): Vector3;
  68240. /**
  68241. * Gets the length of the Vector3
  68242. * @returns the length of the Vector3
  68243. */
  68244. length(): number;
  68245. /**
  68246. * Gets the squared length of the Vector3
  68247. * @returns squared length of the Vector3
  68248. */
  68249. lengthSquared(): number;
  68250. /**
  68251. * Normalize the current Vector3.
  68252. * Please note that this is an in place operation.
  68253. * @returns the current updated Vector3
  68254. */
  68255. normalize(): Vector3;
  68256. /**
  68257. * Reorders the x y z properties of the vector in place
  68258. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  68259. * @returns the current updated vector
  68260. */
  68261. reorderInPlace(order: string): this;
  68262. /**
  68263. * Rotates the vector around 0,0,0 by a quaternion
  68264. * @param quaternion the rotation quaternion
  68265. * @param result vector to store the result
  68266. * @returns the resulting vector
  68267. */
  68268. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  68269. /**
  68270. * Rotates a vector around a given point
  68271. * @param quaternion the rotation quaternion
  68272. * @param point the point to rotate around
  68273. * @param result vector to store the result
  68274. * @returns the resulting vector
  68275. */
  68276. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  68277. /**
  68278. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  68279. * The cross product is then orthogonal to both current and "other"
  68280. * @param other defines the right operand
  68281. * @returns the cross product
  68282. */
  68283. cross(other: Vector3): Vector3;
  68284. /**
  68285. * Normalize the current Vector3 with the given input length.
  68286. * Please note that this is an in place operation.
  68287. * @param len the length of the vector
  68288. * @returns the current updated Vector3
  68289. */
  68290. normalizeFromLength(len: number): Vector3;
  68291. /**
  68292. * Normalize the current Vector3 to a new vector
  68293. * @returns the new Vector3
  68294. */
  68295. normalizeToNew(): Vector3;
  68296. /**
  68297. * Normalize the current Vector3 to the reference
  68298. * @param reference define the Vector3 to update
  68299. * @returns the updated Vector3
  68300. */
  68301. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  68302. /**
  68303. * Creates a new Vector3 copied from the current Vector3
  68304. * @returns the new Vector3
  68305. */
  68306. clone(): Vector3;
  68307. /**
  68308. * Copies the given vector coordinates to the current Vector3 ones
  68309. * @param source defines the source Vector3
  68310. * @returns the current updated Vector3
  68311. */
  68312. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  68313. /**
  68314. * Copies the given floats to the current Vector3 coordinates
  68315. * @param x defines the x coordinate of the operand
  68316. * @param y defines the y coordinate of the operand
  68317. * @param z defines the z coordinate of the operand
  68318. * @returns the current updated Vector3
  68319. */
  68320. copyFromFloats(x: number, y: number, z: number): Vector3;
  68321. /**
  68322. * Copies the given floats to the current Vector3 coordinates
  68323. * @param x defines the x coordinate of the operand
  68324. * @param y defines the y coordinate of the operand
  68325. * @param z defines the z coordinate of the operand
  68326. * @returns the current updated Vector3
  68327. */
  68328. set(x: number, y: number, z: number): Vector3;
  68329. /**
  68330. * Copies the given float to the current Vector3 coordinates
  68331. * @param v defines the x, y and z coordinates of the operand
  68332. * @returns the current updated Vector3
  68333. */
  68334. setAll(v: number): Vector3;
  68335. /**
  68336. * Get the clip factor between two vectors
  68337. * @param vector0 defines the first operand
  68338. * @param vector1 defines the second operand
  68339. * @param axis defines the axis to use
  68340. * @param size defines the size along the axis
  68341. * @returns the clip factor
  68342. */
  68343. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  68344. /**
  68345. * Get angle between two vectors
  68346. * @param vector0 angle between vector0 and vector1
  68347. * @param vector1 angle between vector0 and vector1
  68348. * @param normal direction of the normal
  68349. * @return the angle between vector0 and vector1
  68350. */
  68351. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  68352. /**
  68353. * Returns a new Vector3 set from the index "offset" of the given array
  68354. * @param array defines the source array
  68355. * @param offset defines the offset in the source array
  68356. * @returns the new Vector3
  68357. */
  68358. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  68359. /**
  68360. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  68361. * This function is deprecated. Use FromArray instead
  68362. * @param array defines the source array
  68363. * @param offset defines the offset in the source array
  68364. * @returns the new Vector3
  68365. */
  68366. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  68367. /**
  68368. * Sets the given vector "result" with the element values from the index "offset" of the given array
  68369. * @param array defines the source array
  68370. * @param offset defines the offset in the source array
  68371. * @param result defines the Vector3 where to store the result
  68372. */
  68373. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  68374. /**
  68375. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  68376. * This function is deprecated. Use FromArrayToRef instead.
  68377. * @param array defines the source array
  68378. * @param offset defines the offset in the source array
  68379. * @param result defines the Vector3 where to store the result
  68380. */
  68381. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  68382. /**
  68383. * Sets the given vector "result" with the given floats.
  68384. * @param x defines the x coordinate of the source
  68385. * @param y defines the y coordinate of the source
  68386. * @param z defines the z coordinate of the source
  68387. * @param result defines the Vector3 where to store the result
  68388. */
  68389. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  68390. /**
  68391. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  68392. * @returns a new empty Vector3
  68393. */
  68394. static Zero(): Vector3;
  68395. /**
  68396. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  68397. * @returns a new unit Vector3
  68398. */
  68399. static One(): Vector3;
  68400. /**
  68401. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  68402. * @returns a new up Vector3
  68403. */
  68404. static Up(): Vector3;
  68405. /**
  68406. * Gets a up Vector3 that must not be updated
  68407. */
  68408. static readonly UpReadOnly: DeepImmutable<Vector3>;
  68409. /**
  68410. * Gets a zero Vector3 that must not be updated
  68411. */
  68412. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  68413. /**
  68414. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  68415. * @returns a new down Vector3
  68416. */
  68417. static Down(): Vector3;
  68418. /**
  68419. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  68420. * @returns a new forward Vector3
  68421. */
  68422. static Forward(): Vector3;
  68423. /**
  68424. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  68425. * @returns a new forward Vector3
  68426. */
  68427. static Backward(): Vector3;
  68428. /**
  68429. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  68430. * @returns a new right Vector3
  68431. */
  68432. static Right(): Vector3;
  68433. /**
  68434. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  68435. * @returns a new left Vector3
  68436. */
  68437. static Left(): Vector3;
  68438. /**
  68439. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  68440. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  68441. * @param vector defines the Vector3 to transform
  68442. * @param transformation defines the transformation matrix
  68443. * @returns the transformed Vector3
  68444. */
  68445. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  68446. /**
  68447. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  68448. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  68449. * @param vector defines the Vector3 to transform
  68450. * @param transformation defines the transformation matrix
  68451. * @param result defines the Vector3 where to store the result
  68452. */
  68453. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  68454. /**
  68455. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  68456. * This method computes tranformed coordinates only, not transformed direction vectors
  68457. * @param x define the x coordinate of the source vector
  68458. * @param y define the y coordinate of the source vector
  68459. * @param z define the z coordinate of the source vector
  68460. * @param transformation defines the transformation matrix
  68461. * @param result defines the Vector3 where to store the result
  68462. */
  68463. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  68464. /**
  68465. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  68466. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  68467. * @param vector defines the Vector3 to transform
  68468. * @param transformation defines the transformation matrix
  68469. * @returns the new Vector3
  68470. */
  68471. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  68472. /**
  68473. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  68474. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  68475. * @param vector defines the Vector3 to transform
  68476. * @param transformation defines the transformation matrix
  68477. * @param result defines the Vector3 where to store the result
  68478. */
  68479. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  68480. /**
  68481. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  68482. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  68483. * @param x define the x coordinate of the source vector
  68484. * @param y define the y coordinate of the source vector
  68485. * @param z define the z coordinate of the source vector
  68486. * @param transformation defines the transformation matrix
  68487. * @param result defines the Vector3 where to store the result
  68488. */
  68489. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  68490. /**
  68491. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  68492. * @param value1 defines the first control point
  68493. * @param value2 defines the second control point
  68494. * @param value3 defines the third control point
  68495. * @param value4 defines the fourth control point
  68496. * @param amount defines the amount on the spline to use
  68497. * @returns the new Vector3
  68498. */
  68499. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  68500. /**
  68501. * 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"
  68502. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  68503. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  68504. * @param value defines the current value
  68505. * @param min defines the lower range value
  68506. * @param max defines the upper range value
  68507. * @returns the new Vector3
  68508. */
  68509. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  68510. /**
  68511. * 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"
  68512. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  68513. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  68514. * @param value defines the current value
  68515. * @param min defines the lower range value
  68516. * @param max defines the upper range value
  68517. * @param result defines the Vector3 where to store the result
  68518. */
  68519. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  68520. /**
  68521. * Checks if a given vector is inside a specific range
  68522. * @param v defines the vector to test
  68523. * @param min defines the minimum range
  68524. * @param max defines the maximum range
  68525. */
  68526. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  68527. /**
  68528. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  68529. * @param value1 defines the first control point
  68530. * @param tangent1 defines the first tangent vector
  68531. * @param value2 defines the second control point
  68532. * @param tangent2 defines the second tangent vector
  68533. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  68534. * @returns the new Vector3
  68535. */
  68536. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  68537. /**
  68538. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  68539. * @param start defines the start value
  68540. * @param end defines the end value
  68541. * @param amount max defines amount between both (between 0 and 1)
  68542. * @returns the new Vector3
  68543. */
  68544. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  68545. /**
  68546. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  68547. * @param start defines the start value
  68548. * @param end defines the end value
  68549. * @param amount max defines amount between both (between 0 and 1)
  68550. * @param result defines the Vector3 where to store the result
  68551. */
  68552. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  68553. /**
  68554. * Returns the dot product (float) between the vectors "left" and "right"
  68555. * @param left defines the left operand
  68556. * @param right defines the right operand
  68557. * @returns the dot product
  68558. */
  68559. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  68560. /**
  68561. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  68562. * The cross product is then orthogonal to both "left" and "right"
  68563. * @param left defines the left operand
  68564. * @param right defines the right operand
  68565. * @returns the cross product
  68566. */
  68567. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  68568. /**
  68569. * Sets the given vector "result" with the cross product of "left" and "right"
  68570. * The cross product is then orthogonal to both "left" and "right"
  68571. * @param left defines the left operand
  68572. * @param right defines the right operand
  68573. * @param result defines the Vector3 where to store the result
  68574. */
  68575. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  68576. /**
  68577. * Returns a new Vector3 as the normalization of the given vector
  68578. * @param vector defines the Vector3 to normalize
  68579. * @returns the new Vector3
  68580. */
  68581. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  68582. /**
  68583. * Sets the given vector "result" with the normalization of the given first vector
  68584. * @param vector defines the Vector3 to normalize
  68585. * @param result defines the Vector3 where to store the result
  68586. */
  68587. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  68588. /**
  68589. * Project a Vector3 onto screen space
  68590. * @param vector defines the Vector3 to project
  68591. * @param world defines the world matrix to use
  68592. * @param transform defines the transform (view x projection) matrix to use
  68593. * @param viewport defines the screen viewport to use
  68594. * @returns the new Vector3
  68595. */
  68596. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  68597. /** @hidden */
  68598. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  68599. /**
  68600. * Unproject from screen space to object space
  68601. * @param source defines the screen space Vector3 to use
  68602. * @param viewportWidth defines the current width of the viewport
  68603. * @param viewportHeight defines the current height of the viewport
  68604. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68605. * @param transform defines the transform (view x projection) matrix to use
  68606. * @returns the new Vector3
  68607. */
  68608. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  68609. /**
  68610. * Unproject from screen space to object space
  68611. * @param source defines the screen space Vector3 to use
  68612. * @param viewportWidth defines the current width of the viewport
  68613. * @param viewportHeight defines the current height of the viewport
  68614. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68615. * @param view defines the view matrix to use
  68616. * @param projection defines the projection matrix to use
  68617. * @returns the new Vector3
  68618. */
  68619. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  68620. /**
  68621. * Unproject from screen space to object space
  68622. * @param source defines the screen space Vector3 to use
  68623. * @param viewportWidth defines the current width of the viewport
  68624. * @param viewportHeight defines the current height of the viewport
  68625. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68626. * @param view defines the view matrix to use
  68627. * @param projection defines the projection matrix to use
  68628. * @param result defines the Vector3 where to store the result
  68629. */
  68630. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  68631. /**
  68632. * Unproject from screen space to object space
  68633. * @param sourceX defines the screen space x coordinate to use
  68634. * @param sourceY defines the screen space y coordinate to use
  68635. * @param sourceZ defines the screen space z coordinate to use
  68636. * @param viewportWidth defines the current width of the viewport
  68637. * @param viewportHeight defines the current height of the viewport
  68638. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68639. * @param view defines the view matrix to use
  68640. * @param projection defines the projection matrix to use
  68641. * @param result defines the Vector3 where to store the result
  68642. */
  68643. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  68644. /**
  68645. * Gets the minimal coordinate values between two Vector3
  68646. * @param left defines the first operand
  68647. * @param right defines the second operand
  68648. * @returns the new Vector3
  68649. */
  68650. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  68651. /**
  68652. * Gets the maximal coordinate values between two Vector3
  68653. * @param left defines the first operand
  68654. * @param right defines the second operand
  68655. * @returns the new Vector3
  68656. */
  68657. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  68658. /**
  68659. * Returns the distance between the vectors "value1" and "value2"
  68660. * @param value1 defines the first operand
  68661. * @param value2 defines the second operand
  68662. * @returns the distance
  68663. */
  68664. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  68665. /**
  68666. * Returns the squared distance between the vectors "value1" and "value2"
  68667. * @param value1 defines the first operand
  68668. * @param value2 defines the second operand
  68669. * @returns the squared distance
  68670. */
  68671. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  68672. /**
  68673. * Returns a new Vector3 located at the center between "value1" and "value2"
  68674. * @param value1 defines the first operand
  68675. * @param value2 defines the second operand
  68676. * @returns the new Vector3
  68677. */
  68678. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  68679. /**
  68680. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  68681. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  68682. * to something in order to rotate it from its local system to the given target system
  68683. * Note: axis1, axis2 and axis3 are normalized during this operation
  68684. * @param axis1 defines the first axis
  68685. * @param axis2 defines the second axis
  68686. * @param axis3 defines the third axis
  68687. * @returns a new Vector3
  68688. */
  68689. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  68690. /**
  68691. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  68692. * @param axis1 defines the first axis
  68693. * @param axis2 defines the second axis
  68694. * @param axis3 defines the third axis
  68695. * @param ref defines the Vector3 where to store the result
  68696. */
  68697. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  68698. }
  68699. /**
  68700. * Vector4 class created for EulerAngle class conversion to Quaternion
  68701. */
  68702. export class Vector4 {
  68703. /** x value of the vector */
  68704. x: number;
  68705. /** y value of the vector */
  68706. y: number;
  68707. /** z value of the vector */
  68708. z: number;
  68709. /** w value of the vector */
  68710. w: number;
  68711. /**
  68712. * Creates a Vector4 object from the given floats.
  68713. * @param x x value of the vector
  68714. * @param y y value of the vector
  68715. * @param z z value of the vector
  68716. * @param w w value of the vector
  68717. */
  68718. constructor(
  68719. /** x value of the vector */
  68720. x: number,
  68721. /** y value of the vector */
  68722. y: number,
  68723. /** z value of the vector */
  68724. z: number,
  68725. /** w value of the vector */
  68726. w: number);
  68727. /**
  68728. * Returns the string with the Vector4 coordinates.
  68729. * @returns a string containing all the vector values
  68730. */
  68731. toString(): string;
  68732. /**
  68733. * Returns the string "Vector4".
  68734. * @returns "Vector4"
  68735. */
  68736. getClassName(): string;
  68737. /**
  68738. * Returns the Vector4 hash code.
  68739. * @returns a unique hash code
  68740. */
  68741. getHashCode(): number;
  68742. /**
  68743. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  68744. * @returns the resulting array
  68745. */
  68746. asArray(): number[];
  68747. /**
  68748. * Populates the given array from the given index with the Vector4 coordinates.
  68749. * @param array array to populate
  68750. * @param index index of the array to start at (default: 0)
  68751. * @returns the Vector4.
  68752. */
  68753. toArray(array: FloatArray, index?: number): Vector4;
  68754. /**
  68755. * Adds the given vector to the current Vector4.
  68756. * @param otherVector the vector to add
  68757. * @returns the updated Vector4.
  68758. */
  68759. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  68760. /**
  68761. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  68762. * @param otherVector the vector to add
  68763. * @returns the resulting vector
  68764. */
  68765. add(otherVector: DeepImmutable<Vector4>): Vector4;
  68766. /**
  68767. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  68768. * @param otherVector the vector to add
  68769. * @param result the vector to store the result
  68770. * @returns the current Vector4.
  68771. */
  68772. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68773. /**
  68774. * Subtract in place the given vector from the current Vector4.
  68775. * @param otherVector the vector to subtract
  68776. * @returns the updated Vector4.
  68777. */
  68778. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  68779. /**
  68780. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  68781. * @param otherVector the vector to add
  68782. * @returns the new vector with the result
  68783. */
  68784. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  68785. /**
  68786. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  68787. * @param otherVector the vector to subtract
  68788. * @param result the vector to store the result
  68789. * @returns the current Vector4.
  68790. */
  68791. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68792. /**
  68793. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  68794. */
  68795. /**
  68796. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  68797. * @param x value to subtract
  68798. * @param y value to subtract
  68799. * @param z value to subtract
  68800. * @param w value to subtract
  68801. * @returns new vector containing the result
  68802. */
  68803. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  68804. /**
  68805. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  68806. * @param x value to subtract
  68807. * @param y value to subtract
  68808. * @param z value to subtract
  68809. * @param w value to subtract
  68810. * @param result the vector to store the result in
  68811. * @returns the current Vector4.
  68812. */
  68813. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  68814. /**
  68815. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  68816. * @returns a new vector with the negated values
  68817. */
  68818. negate(): Vector4;
  68819. /**
  68820. * Multiplies the current Vector4 coordinates by scale (float).
  68821. * @param scale the number to scale with
  68822. * @returns the updated Vector4.
  68823. */
  68824. scaleInPlace(scale: number): Vector4;
  68825. /**
  68826. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  68827. * @param scale the number to scale with
  68828. * @returns a new vector with the result
  68829. */
  68830. scale(scale: number): Vector4;
  68831. /**
  68832. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  68833. * @param scale the number to scale with
  68834. * @param result a vector to store the result in
  68835. * @returns the current Vector4.
  68836. */
  68837. scaleToRef(scale: number, result: Vector4): Vector4;
  68838. /**
  68839. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  68840. * @param scale defines the scale factor
  68841. * @param result defines the Vector4 object where to store the result
  68842. * @returns the unmodified current Vector4
  68843. */
  68844. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  68845. /**
  68846. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  68847. * @param otherVector the vector to compare against
  68848. * @returns true if they are equal
  68849. */
  68850. equals(otherVector: DeepImmutable<Vector4>): boolean;
  68851. /**
  68852. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  68853. * @param otherVector vector to compare against
  68854. * @param epsilon (Default: very small number)
  68855. * @returns true if they are equal
  68856. */
  68857. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  68858. /**
  68859. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  68860. * @param x x value to compare against
  68861. * @param y y value to compare against
  68862. * @param z z value to compare against
  68863. * @param w w value to compare against
  68864. * @returns true if equal
  68865. */
  68866. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  68867. /**
  68868. * Multiplies in place the current Vector4 by the given one.
  68869. * @param otherVector vector to multiple with
  68870. * @returns the updated Vector4.
  68871. */
  68872. multiplyInPlace(otherVector: Vector4): Vector4;
  68873. /**
  68874. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  68875. * @param otherVector vector to multiple with
  68876. * @returns resulting new vector
  68877. */
  68878. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  68879. /**
  68880. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  68881. * @param otherVector vector to multiple with
  68882. * @param result vector to store the result
  68883. * @returns the current Vector4.
  68884. */
  68885. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68886. /**
  68887. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  68888. * @param x x value multiply with
  68889. * @param y y value multiply with
  68890. * @param z z value multiply with
  68891. * @param w w value multiply with
  68892. * @returns resulting new vector
  68893. */
  68894. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  68895. /**
  68896. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  68897. * @param otherVector vector to devide with
  68898. * @returns resulting new vector
  68899. */
  68900. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  68901. /**
  68902. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  68903. * @param otherVector vector to devide with
  68904. * @param result vector to store the result
  68905. * @returns the current Vector4.
  68906. */
  68907. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68908. /**
  68909. * Divides the current Vector3 coordinates by the given ones.
  68910. * @param otherVector vector to devide with
  68911. * @returns the updated Vector3.
  68912. */
  68913. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  68914. /**
  68915. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  68916. * @param other defines the second operand
  68917. * @returns the current updated Vector4
  68918. */
  68919. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  68920. /**
  68921. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  68922. * @param other defines the second operand
  68923. * @returns the current updated Vector4
  68924. */
  68925. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  68926. /**
  68927. * Gets a new Vector4 from current Vector4 floored values
  68928. * @returns a new Vector4
  68929. */
  68930. floor(): Vector4;
  68931. /**
  68932. * Gets a new Vector4 from current Vector3 floored values
  68933. * @returns a new Vector4
  68934. */
  68935. fract(): Vector4;
  68936. /**
  68937. * Returns the Vector4 length (float).
  68938. * @returns the length
  68939. */
  68940. length(): number;
  68941. /**
  68942. * Returns the Vector4 squared length (float).
  68943. * @returns the length squared
  68944. */
  68945. lengthSquared(): number;
  68946. /**
  68947. * Normalizes in place the Vector4.
  68948. * @returns the updated Vector4.
  68949. */
  68950. normalize(): Vector4;
  68951. /**
  68952. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  68953. * @returns this converted to a new vector3
  68954. */
  68955. toVector3(): Vector3;
  68956. /**
  68957. * Returns a new Vector4 copied from the current one.
  68958. * @returns the new cloned vector
  68959. */
  68960. clone(): Vector4;
  68961. /**
  68962. * Updates the current Vector4 with the given one coordinates.
  68963. * @param source the source vector to copy from
  68964. * @returns the updated Vector4.
  68965. */
  68966. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  68967. /**
  68968. * Updates the current Vector4 coordinates with the given floats.
  68969. * @param x float to copy from
  68970. * @param y float to copy from
  68971. * @param z float to copy from
  68972. * @param w float to copy from
  68973. * @returns the updated Vector4.
  68974. */
  68975. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  68976. /**
  68977. * Updates the current Vector4 coordinates with the given floats.
  68978. * @param x float to set from
  68979. * @param y float to set from
  68980. * @param z float to set from
  68981. * @param w float to set from
  68982. * @returns the updated Vector4.
  68983. */
  68984. set(x: number, y: number, z: number, w: number): Vector4;
  68985. /**
  68986. * Copies the given float to the current Vector3 coordinates
  68987. * @param v defines the x, y, z and w coordinates of the operand
  68988. * @returns the current updated Vector3
  68989. */
  68990. setAll(v: number): Vector4;
  68991. /**
  68992. * Returns a new Vector4 set from the starting index of the given array.
  68993. * @param array the array to pull values from
  68994. * @param offset the offset into the array to start at
  68995. * @returns the new vector
  68996. */
  68997. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  68998. /**
  68999. * Updates the given vector "result" from the starting index of the given array.
  69000. * @param array the array to pull values from
  69001. * @param offset the offset into the array to start at
  69002. * @param result the vector to store the result in
  69003. */
  69004. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  69005. /**
  69006. * Updates the given vector "result" from the starting index of the given Float32Array.
  69007. * @param array the array to pull values from
  69008. * @param offset the offset into the array to start at
  69009. * @param result the vector to store the result in
  69010. */
  69011. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  69012. /**
  69013. * Updates the given vector "result" coordinates from the given floats.
  69014. * @param x float to set from
  69015. * @param y float to set from
  69016. * @param z float to set from
  69017. * @param w float to set from
  69018. * @param result the vector to the floats in
  69019. */
  69020. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  69021. /**
  69022. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  69023. * @returns the new vector
  69024. */
  69025. static Zero(): Vector4;
  69026. /**
  69027. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  69028. * @returns the new vector
  69029. */
  69030. static One(): Vector4;
  69031. /**
  69032. * Returns a new normalized Vector4 from the given one.
  69033. * @param vector the vector to normalize
  69034. * @returns the vector
  69035. */
  69036. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  69037. /**
  69038. * Updates the given vector "result" from the normalization of the given one.
  69039. * @param vector the vector to normalize
  69040. * @param result the vector to store the result in
  69041. */
  69042. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  69043. /**
  69044. * Returns a vector with the minimum values from the left and right vectors
  69045. * @param left left vector to minimize
  69046. * @param right right vector to minimize
  69047. * @returns a new vector with the minimum of the left and right vector values
  69048. */
  69049. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  69050. /**
  69051. * Returns a vector with the maximum values from the left and right vectors
  69052. * @param left left vector to maximize
  69053. * @param right right vector to maximize
  69054. * @returns a new vector with the maximum of the left and right vector values
  69055. */
  69056. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  69057. /**
  69058. * Returns the distance (float) between the vectors "value1" and "value2".
  69059. * @param value1 value to calulate the distance between
  69060. * @param value2 value to calulate the distance between
  69061. * @return the distance between the two vectors
  69062. */
  69063. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  69064. /**
  69065. * Returns the squared distance (float) between the vectors "value1" and "value2".
  69066. * @param value1 value to calulate the distance between
  69067. * @param value2 value to calulate the distance between
  69068. * @return the distance between the two vectors squared
  69069. */
  69070. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  69071. /**
  69072. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  69073. * @param value1 value to calulate the center between
  69074. * @param value2 value to calulate the center between
  69075. * @return the center between the two vectors
  69076. */
  69077. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  69078. /**
  69079. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  69080. * This methods computes transformed normalized direction vectors only.
  69081. * @param vector the vector to transform
  69082. * @param transformation the transformation matrix to apply
  69083. * @returns the new vector
  69084. */
  69085. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  69086. /**
  69087. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  69088. * This methods computes transformed normalized direction vectors only.
  69089. * @param vector the vector to transform
  69090. * @param transformation the transformation matrix to apply
  69091. * @param result the vector to store the result in
  69092. */
  69093. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  69094. /**
  69095. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  69096. * This methods computes transformed normalized direction vectors only.
  69097. * @param x value to transform
  69098. * @param y value to transform
  69099. * @param z value to transform
  69100. * @param w value to transform
  69101. * @param transformation the transformation matrix to apply
  69102. * @param result the vector to store the results in
  69103. */
  69104. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  69105. /**
  69106. * Creates a new Vector4 from a Vector3
  69107. * @param source defines the source data
  69108. * @param w defines the 4th component (default is 0)
  69109. * @returns a new Vector4
  69110. */
  69111. static FromVector3(source: Vector3, w?: number): Vector4;
  69112. }
  69113. /**
  69114. * Class used to store quaternion data
  69115. * @see https://en.wikipedia.org/wiki/Quaternion
  69116. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  69117. */
  69118. export class Quaternion {
  69119. /** defines the first component (0 by default) */
  69120. x: number;
  69121. /** defines the second component (0 by default) */
  69122. y: number;
  69123. /** defines the third component (0 by default) */
  69124. z: number;
  69125. /** defines the fourth component (1.0 by default) */
  69126. w: number;
  69127. /**
  69128. * Creates a new Quaternion from the given floats
  69129. * @param x defines the first component (0 by default)
  69130. * @param y defines the second component (0 by default)
  69131. * @param z defines the third component (0 by default)
  69132. * @param w defines the fourth component (1.0 by default)
  69133. */
  69134. constructor(
  69135. /** defines the first component (0 by default) */
  69136. x?: number,
  69137. /** defines the second component (0 by default) */
  69138. y?: number,
  69139. /** defines the third component (0 by default) */
  69140. z?: number,
  69141. /** defines the fourth component (1.0 by default) */
  69142. w?: number);
  69143. /**
  69144. * Gets a string representation for the current quaternion
  69145. * @returns a string with the Quaternion coordinates
  69146. */
  69147. toString(): string;
  69148. /**
  69149. * Gets the class name of the quaternion
  69150. * @returns the string "Quaternion"
  69151. */
  69152. getClassName(): string;
  69153. /**
  69154. * Gets a hash code for this quaternion
  69155. * @returns the quaternion hash code
  69156. */
  69157. getHashCode(): number;
  69158. /**
  69159. * Copy the quaternion to an array
  69160. * @returns a new array populated with 4 elements from the quaternion coordinates
  69161. */
  69162. asArray(): number[];
  69163. /**
  69164. * Check if two quaternions are equals
  69165. * @param otherQuaternion defines the second operand
  69166. * @return true if the current quaternion and the given one coordinates are strictly equals
  69167. */
  69168. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  69169. /**
  69170. * Clone the current quaternion
  69171. * @returns a new quaternion copied from the current one
  69172. */
  69173. clone(): Quaternion;
  69174. /**
  69175. * Copy a quaternion to the current one
  69176. * @param other defines the other quaternion
  69177. * @returns the updated current quaternion
  69178. */
  69179. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  69180. /**
  69181. * Updates the current quaternion with the given float coordinates
  69182. * @param x defines the x coordinate
  69183. * @param y defines the y coordinate
  69184. * @param z defines the z coordinate
  69185. * @param w defines the w coordinate
  69186. * @returns the updated current quaternion
  69187. */
  69188. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  69189. /**
  69190. * Updates the current quaternion from the given float coordinates
  69191. * @param x defines the x coordinate
  69192. * @param y defines the y coordinate
  69193. * @param z defines the z coordinate
  69194. * @param w defines the w coordinate
  69195. * @returns the updated current quaternion
  69196. */
  69197. set(x: number, y: number, z: number, w: number): Quaternion;
  69198. /**
  69199. * Adds two quaternions
  69200. * @param other defines the second operand
  69201. * @returns a new quaternion as the addition result of the given one and the current quaternion
  69202. */
  69203. add(other: DeepImmutable<Quaternion>): Quaternion;
  69204. /**
  69205. * Add a quaternion to the current one
  69206. * @param other defines the quaternion to add
  69207. * @returns the current quaternion
  69208. */
  69209. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  69210. /**
  69211. * Subtract two quaternions
  69212. * @param other defines the second operand
  69213. * @returns a new quaternion as the subtraction result of the given one from the current one
  69214. */
  69215. subtract(other: Quaternion): Quaternion;
  69216. /**
  69217. * Multiplies the current quaternion by a scale factor
  69218. * @param value defines the scale factor
  69219. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  69220. */
  69221. scale(value: number): Quaternion;
  69222. /**
  69223. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  69224. * @param scale defines the scale factor
  69225. * @param result defines the Quaternion object where to store the result
  69226. * @returns the unmodified current quaternion
  69227. */
  69228. scaleToRef(scale: number, result: Quaternion): Quaternion;
  69229. /**
  69230. * Multiplies in place the current quaternion by a scale factor
  69231. * @param value defines the scale factor
  69232. * @returns the current modified quaternion
  69233. */
  69234. scaleInPlace(value: number): Quaternion;
  69235. /**
  69236. * Scale the current quaternion values by a factor and add the result to a given quaternion
  69237. * @param scale defines the scale factor
  69238. * @param result defines the Quaternion object where to store the result
  69239. * @returns the unmodified current quaternion
  69240. */
  69241. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  69242. /**
  69243. * Multiplies two quaternions
  69244. * @param q1 defines the second operand
  69245. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  69246. */
  69247. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  69248. /**
  69249. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  69250. * @param q1 defines the second operand
  69251. * @param result defines the target quaternion
  69252. * @returns the current quaternion
  69253. */
  69254. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  69255. /**
  69256. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  69257. * @param q1 defines the second operand
  69258. * @returns the currentupdated quaternion
  69259. */
  69260. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  69261. /**
  69262. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  69263. * @param ref defines the target quaternion
  69264. * @returns the current quaternion
  69265. */
  69266. conjugateToRef(ref: Quaternion): Quaternion;
  69267. /**
  69268. * Conjugates in place (1-q) the current quaternion
  69269. * @returns the current updated quaternion
  69270. */
  69271. conjugateInPlace(): Quaternion;
  69272. /**
  69273. * Conjugates in place (1-q) the current quaternion
  69274. * @returns a new quaternion
  69275. */
  69276. conjugate(): Quaternion;
  69277. /**
  69278. * Gets length of current quaternion
  69279. * @returns the quaternion length (float)
  69280. */
  69281. length(): number;
  69282. /**
  69283. * Normalize in place the current quaternion
  69284. * @returns the current updated quaternion
  69285. */
  69286. normalize(): Quaternion;
  69287. /**
  69288. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  69289. * @param order is a reserved parameter and is ignore for now
  69290. * @returns a new Vector3 containing the Euler angles
  69291. */
  69292. toEulerAngles(order?: string): Vector3;
  69293. /**
  69294. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  69295. * @param result defines the vector which will be filled with the Euler angles
  69296. * @param order is a reserved parameter and is ignore for now
  69297. * @returns the current unchanged quaternion
  69298. */
  69299. toEulerAnglesToRef(result: Vector3): Quaternion;
  69300. /**
  69301. * Updates the given rotation matrix with the current quaternion values
  69302. * @param result defines the target matrix
  69303. * @returns the current unchanged quaternion
  69304. */
  69305. toRotationMatrix(result: Matrix): Quaternion;
  69306. /**
  69307. * Updates the current quaternion from the given rotation matrix values
  69308. * @param matrix defines the source matrix
  69309. * @returns the current updated quaternion
  69310. */
  69311. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  69312. /**
  69313. * Creates a new quaternion from a rotation matrix
  69314. * @param matrix defines the source matrix
  69315. * @returns a new quaternion created from the given rotation matrix values
  69316. */
  69317. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  69318. /**
  69319. * Updates the given quaternion with the given rotation matrix values
  69320. * @param matrix defines the source matrix
  69321. * @param result defines the target quaternion
  69322. */
  69323. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  69324. /**
  69325. * Returns the dot product (float) between the quaternions "left" and "right"
  69326. * @param left defines the left operand
  69327. * @param right defines the right operand
  69328. * @returns the dot product
  69329. */
  69330. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  69331. /**
  69332. * Checks if the two quaternions are close to each other
  69333. * @param quat0 defines the first quaternion to check
  69334. * @param quat1 defines the second quaternion to check
  69335. * @returns true if the two quaternions are close to each other
  69336. */
  69337. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  69338. /**
  69339. * Creates an empty quaternion
  69340. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  69341. */
  69342. static Zero(): Quaternion;
  69343. /**
  69344. * Inverse a given quaternion
  69345. * @param q defines the source quaternion
  69346. * @returns a new quaternion as the inverted current quaternion
  69347. */
  69348. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  69349. /**
  69350. * Inverse a given quaternion
  69351. * @param q defines the source quaternion
  69352. * @param result the quaternion the result will be stored in
  69353. * @returns the result quaternion
  69354. */
  69355. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  69356. /**
  69357. * Creates an identity quaternion
  69358. * @returns the identity quaternion
  69359. */
  69360. static Identity(): Quaternion;
  69361. /**
  69362. * Gets a boolean indicating if the given quaternion is identity
  69363. * @param quaternion defines the quaternion to check
  69364. * @returns true if the quaternion is identity
  69365. */
  69366. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  69367. /**
  69368. * Creates a quaternion from a rotation around an axis
  69369. * @param axis defines the axis to use
  69370. * @param angle defines the angle to use
  69371. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  69372. */
  69373. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  69374. /**
  69375. * Creates a rotation around an axis and stores it into the given quaternion
  69376. * @param axis defines the axis to use
  69377. * @param angle defines the angle to use
  69378. * @param result defines the target quaternion
  69379. * @returns the target quaternion
  69380. */
  69381. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  69382. /**
  69383. * Creates a new quaternion from data stored into an array
  69384. * @param array defines the data source
  69385. * @param offset defines the offset in the source array where the data starts
  69386. * @returns a new quaternion
  69387. */
  69388. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  69389. /**
  69390. * Create a quaternion from Euler rotation angles
  69391. * @param x Pitch
  69392. * @param y Yaw
  69393. * @param z Roll
  69394. * @returns the new Quaternion
  69395. */
  69396. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  69397. /**
  69398. * Updates a quaternion from Euler rotation angles
  69399. * @param x Pitch
  69400. * @param y Yaw
  69401. * @param z Roll
  69402. * @param result the quaternion to store the result
  69403. * @returns the updated quaternion
  69404. */
  69405. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  69406. /**
  69407. * Create a quaternion from Euler rotation vector
  69408. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  69409. * @returns the new Quaternion
  69410. */
  69411. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  69412. /**
  69413. * Updates a quaternion from Euler rotation vector
  69414. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  69415. * @param result the quaternion to store the result
  69416. * @returns the updated quaternion
  69417. */
  69418. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  69419. /**
  69420. * Creates a new quaternion from the given Euler float angles (y, x, z)
  69421. * @param yaw defines the rotation around Y axis
  69422. * @param pitch defines the rotation around X axis
  69423. * @param roll defines the rotation around Z axis
  69424. * @returns the new quaternion
  69425. */
  69426. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  69427. /**
  69428. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  69429. * @param yaw defines the rotation around Y axis
  69430. * @param pitch defines the rotation around X axis
  69431. * @param roll defines the rotation around Z axis
  69432. * @param result defines the target quaternion
  69433. */
  69434. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  69435. /**
  69436. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  69437. * @param alpha defines the rotation around first axis
  69438. * @param beta defines the rotation around second axis
  69439. * @param gamma defines the rotation around third axis
  69440. * @returns the new quaternion
  69441. */
  69442. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  69443. /**
  69444. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  69445. * @param alpha defines the rotation around first axis
  69446. * @param beta defines the rotation around second axis
  69447. * @param gamma defines the rotation around third axis
  69448. * @param result defines the target quaternion
  69449. */
  69450. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  69451. /**
  69452. * 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)
  69453. * @param axis1 defines the first axis
  69454. * @param axis2 defines the second axis
  69455. * @param axis3 defines the third axis
  69456. * @returns the new quaternion
  69457. */
  69458. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  69459. /**
  69460. * 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
  69461. * @param axis1 defines the first axis
  69462. * @param axis2 defines the second axis
  69463. * @param axis3 defines the third axis
  69464. * @param ref defines the target quaternion
  69465. */
  69466. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  69467. /**
  69468. * Interpolates between two quaternions
  69469. * @param left defines first quaternion
  69470. * @param right defines second quaternion
  69471. * @param amount defines the gradient to use
  69472. * @returns the new interpolated quaternion
  69473. */
  69474. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  69475. /**
  69476. * Interpolates between two quaternions and stores it into a target quaternion
  69477. * @param left defines first quaternion
  69478. * @param right defines second quaternion
  69479. * @param amount defines the gradient to use
  69480. * @param result defines the target quaternion
  69481. */
  69482. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  69483. /**
  69484. * Interpolate between two quaternions using Hermite interpolation
  69485. * @param value1 defines first quaternion
  69486. * @param tangent1 defines the incoming tangent
  69487. * @param value2 defines second quaternion
  69488. * @param tangent2 defines the outgoing tangent
  69489. * @param amount defines the target quaternion
  69490. * @returns the new interpolated quaternion
  69491. */
  69492. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  69493. }
  69494. /**
  69495. * Class used to store matrix data (4x4)
  69496. */
  69497. export class Matrix {
  69498. private static _updateFlagSeed;
  69499. private static _identityReadOnly;
  69500. private _isIdentity;
  69501. private _isIdentityDirty;
  69502. private _isIdentity3x2;
  69503. private _isIdentity3x2Dirty;
  69504. /**
  69505. * Gets the update flag of the matrix which is an unique number for the matrix.
  69506. * It will be incremented every time the matrix data change.
  69507. * You can use it to speed the comparison between two versions of the same matrix.
  69508. */
  69509. updateFlag: number;
  69510. private readonly _m;
  69511. /**
  69512. * Gets the internal data of the matrix
  69513. */
  69514. readonly m: DeepImmutable<Float32Array>;
  69515. /** @hidden */
  69516. _markAsUpdated(): void;
  69517. /** @hidden */
  69518. private _updateIdentityStatus;
  69519. /**
  69520. * Creates an empty matrix (filled with zeros)
  69521. */
  69522. constructor();
  69523. /**
  69524. * Check if the current matrix is identity
  69525. * @returns true is the matrix is the identity matrix
  69526. */
  69527. isIdentity(): boolean;
  69528. /**
  69529. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  69530. * @returns true is the matrix is the identity matrix
  69531. */
  69532. isIdentityAs3x2(): boolean;
  69533. /**
  69534. * Gets the determinant of the matrix
  69535. * @returns the matrix determinant
  69536. */
  69537. determinant(): number;
  69538. /**
  69539. * Returns the matrix as a Float32Array
  69540. * @returns the matrix underlying array
  69541. */
  69542. toArray(): DeepImmutable<Float32Array>;
  69543. /**
  69544. * Returns the matrix as a Float32Array
  69545. * @returns the matrix underlying array.
  69546. */
  69547. asArray(): DeepImmutable<Float32Array>;
  69548. /**
  69549. * Inverts the current matrix in place
  69550. * @returns the current inverted matrix
  69551. */
  69552. invert(): Matrix;
  69553. /**
  69554. * Sets all the matrix elements to zero
  69555. * @returns the current matrix
  69556. */
  69557. reset(): Matrix;
  69558. /**
  69559. * Adds the current matrix with a second one
  69560. * @param other defines the matrix to add
  69561. * @returns a new matrix as the addition of the current matrix and the given one
  69562. */
  69563. add(other: DeepImmutable<Matrix>): Matrix;
  69564. /**
  69565. * Sets the given matrix "result" to the addition of the current matrix and the given one
  69566. * @param other defines the matrix to add
  69567. * @param result defines the target matrix
  69568. * @returns the current matrix
  69569. */
  69570. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  69571. /**
  69572. * Adds in place the given matrix to the current matrix
  69573. * @param other defines the second operand
  69574. * @returns the current updated matrix
  69575. */
  69576. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  69577. /**
  69578. * Sets the given matrix to the current inverted Matrix
  69579. * @param other defines the target matrix
  69580. * @returns the unmodified current matrix
  69581. */
  69582. invertToRef(other: Matrix): Matrix;
  69583. /**
  69584. * add a value at the specified position in the current Matrix
  69585. * @param index the index of the value within the matrix. between 0 and 15.
  69586. * @param value the value to be added
  69587. * @returns the current updated matrix
  69588. */
  69589. addAtIndex(index: number, value: number): Matrix;
  69590. /**
  69591. * mutiply the specified position in the current Matrix by a value
  69592. * @param index the index of the value within the matrix. between 0 and 15.
  69593. * @param value the value to be added
  69594. * @returns the current updated matrix
  69595. */
  69596. multiplyAtIndex(index: number, value: number): Matrix;
  69597. /**
  69598. * Inserts the translation vector (using 3 floats) in the current matrix
  69599. * @param x defines the 1st component of the translation
  69600. * @param y defines the 2nd component of the translation
  69601. * @param z defines the 3rd component of the translation
  69602. * @returns the current updated matrix
  69603. */
  69604. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  69605. /**
  69606. * Adds the translation vector (using 3 floats) in the current matrix
  69607. * @param x defines the 1st component of the translation
  69608. * @param y defines the 2nd component of the translation
  69609. * @param z defines the 3rd component of the translation
  69610. * @returns the current updated matrix
  69611. */
  69612. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  69613. /**
  69614. * Inserts the translation vector in the current matrix
  69615. * @param vector3 defines the translation to insert
  69616. * @returns the current updated matrix
  69617. */
  69618. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  69619. /**
  69620. * Gets the translation value of the current matrix
  69621. * @returns a new Vector3 as the extracted translation from the matrix
  69622. */
  69623. getTranslation(): Vector3;
  69624. /**
  69625. * Fill a Vector3 with the extracted translation from the matrix
  69626. * @param result defines the Vector3 where to store the translation
  69627. * @returns the current matrix
  69628. */
  69629. getTranslationToRef(result: Vector3): Matrix;
  69630. /**
  69631. * Remove rotation and scaling part from the matrix
  69632. * @returns the updated matrix
  69633. */
  69634. removeRotationAndScaling(): Matrix;
  69635. /**
  69636. * Multiply two matrices
  69637. * @param other defines the second operand
  69638. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  69639. */
  69640. multiply(other: DeepImmutable<Matrix>): Matrix;
  69641. /**
  69642. * Copy the current matrix from the given one
  69643. * @param other defines the source matrix
  69644. * @returns the current updated matrix
  69645. */
  69646. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  69647. /**
  69648. * Populates the given array from the starting index with the current matrix values
  69649. * @param array defines the target array
  69650. * @param offset defines the offset in the target array where to start storing values
  69651. * @returns the current matrix
  69652. */
  69653. copyToArray(array: Float32Array, offset?: number): Matrix;
  69654. /**
  69655. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  69656. * @param other defines the second operand
  69657. * @param result defines the matrix where to store the multiplication
  69658. * @returns the current matrix
  69659. */
  69660. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  69661. /**
  69662. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  69663. * @param other defines the second operand
  69664. * @param result defines the array where to store the multiplication
  69665. * @param offset defines the offset in the target array where to start storing values
  69666. * @returns the current matrix
  69667. */
  69668. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  69669. /**
  69670. * Check equality between this matrix and a second one
  69671. * @param value defines the second matrix to compare
  69672. * @returns true is the current matrix and the given one values are strictly equal
  69673. */
  69674. equals(value: DeepImmutable<Matrix>): boolean;
  69675. /**
  69676. * Clone the current matrix
  69677. * @returns a new matrix from the current matrix
  69678. */
  69679. clone(): Matrix;
  69680. /**
  69681. * Returns the name of the current matrix class
  69682. * @returns the string "Matrix"
  69683. */
  69684. getClassName(): string;
  69685. /**
  69686. * Gets the hash code of the current matrix
  69687. * @returns the hash code
  69688. */
  69689. getHashCode(): number;
  69690. /**
  69691. * Decomposes the current Matrix into a translation, rotation and scaling components
  69692. * @param scale defines the scale vector3 given as a reference to update
  69693. * @param rotation defines the rotation quaternion given as a reference to update
  69694. * @param translation defines the translation vector3 given as a reference to update
  69695. * @returns true if operation was successful
  69696. */
  69697. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  69698. /**
  69699. * Gets specific row of the matrix
  69700. * @param index defines the number of the row to get
  69701. * @returns the index-th row of the current matrix as a new Vector4
  69702. */
  69703. getRow(index: number): Nullable<Vector4>;
  69704. /**
  69705. * Sets the index-th row of the current matrix to the vector4 values
  69706. * @param index defines the number of the row to set
  69707. * @param row defines the target vector4
  69708. * @returns the updated current matrix
  69709. */
  69710. setRow(index: number, row: Vector4): Matrix;
  69711. /**
  69712. * Compute the transpose of the matrix
  69713. * @returns the new transposed matrix
  69714. */
  69715. transpose(): Matrix;
  69716. /**
  69717. * Compute the transpose of the matrix and store it in a given matrix
  69718. * @param result defines the target matrix
  69719. * @returns the current matrix
  69720. */
  69721. transposeToRef(result: Matrix): Matrix;
  69722. /**
  69723. * Sets the index-th row of the current matrix with the given 4 x float values
  69724. * @param index defines the row index
  69725. * @param x defines the x component to set
  69726. * @param y defines the y component to set
  69727. * @param z defines the z component to set
  69728. * @param w defines the w component to set
  69729. * @returns the updated current matrix
  69730. */
  69731. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  69732. /**
  69733. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  69734. * @param scale defines the scale factor
  69735. * @returns a new matrix
  69736. */
  69737. scale(scale: number): Matrix;
  69738. /**
  69739. * Scale the current matrix values by a factor to a given result matrix
  69740. * @param scale defines the scale factor
  69741. * @param result defines the matrix to store the result
  69742. * @returns the current matrix
  69743. */
  69744. scaleToRef(scale: number, result: Matrix): Matrix;
  69745. /**
  69746. * Scale the current matrix values by a factor and add the result to a given matrix
  69747. * @param scale defines the scale factor
  69748. * @param result defines the Matrix to store the result
  69749. * @returns the current matrix
  69750. */
  69751. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  69752. /**
  69753. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  69754. * @param ref matrix to store the result
  69755. */
  69756. toNormalMatrix(ref: Matrix): void;
  69757. /**
  69758. * Gets only rotation part of the current matrix
  69759. * @returns a new matrix sets to the extracted rotation matrix from the current one
  69760. */
  69761. getRotationMatrix(): Matrix;
  69762. /**
  69763. * Extracts the rotation matrix from the current one and sets it as the given "result"
  69764. * @param result defines the target matrix to store data to
  69765. * @returns the current matrix
  69766. */
  69767. getRotationMatrixToRef(result: Matrix): Matrix;
  69768. /**
  69769. * Toggles model matrix from being right handed to left handed in place and vice versa
  69770. */
  69771. toggleModelMatrixHandInPlace(): void;
  69772. /**
  69773. * Toggles projection matrix from being right handed to left handed in place and vice versa
  69774. */
  69775. toggleProjectionMatrixHandInPlace(): void;
  69776. /**
  69777. * Creates a matrix from an array
  69778. * @param array defines the source array
  69779. * @param offset defines an offset in the source array
  69780. * @returns a new Matrix set from the starting index of the given array
  69781. */
  69782. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  69783. /**
  69784. * Copy the content of an array into a given matrix
  69785. * @param array defines the source array
  69786. * @param offset defines an offset in the source array
  69787. * @param result defines the target matrix
  69788. */
  69789. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  69790. /**
  69791. * Stores an array into a matrix after having multiplied each component by a given factor
  69792. * @param array defines the source array
  69793. * @param offset defines the offset in the source array
  69794. * @param scale defines the scaling factor
  69795. * @param result defines the target matrix
  69796. */
  69797. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  69798. /**
  69799. * Gets an identity matrix that must not be updated
  69800. */
  69801. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  69802. /**
  69803. * Stores a list of values (16) inside a given matrix
  69804. * @param initialM11 defines 1st value of 1st row
  69805. * @param initialM12 defines 2nd value of 1st row
  69806. * @param initialM13 defines 3rd value of 1st row
  69807. * @param initialM14 defines 4th value of 1st row
  69808. * @param initialM21 defines 1st value of 2nd row
  69809. * @param initialM22 defines 2nd value of 2nd row
  69810. * @param initialM23 defines 3rd value of 2nd row
  69811. * @param initialM24 defines 4th value of 2nd row
  69812. * @param initialM31 defines 1st value of 3rd row
  69813. * @param initialM32 defines 2nd value of 3rd row
  69814. * @param initialM33 defines 3rd value of 3rd row
  69815. * @param initialM34 defines 4th value of 3rd row
  69816. * @param initialM41 defines 1st value of 4th row
  69817. * @param initialM42 defines 2nd value of 4th row
  69818. * @param initialM43 defines 3rd value of 4th row
  69819. * @param initialM44 defines 4th value of 4th row
  69820. * @param result defines the target matrix
  69821. */
  69822. 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;
  69823. /**
  69824. * Creates new matrix from a list of values (16)
  69825. * @param initialM11 defines 1st value of 1st row
  69826. * @param initialM12 defines 2nd value of 1st row
  69827. * @param initialM13 defines 3rd value of 1st row
  69828. * @param initialM14 defines 4th value of 1st row
  69829. * @param initialM21 defines 1st value of 2nd row
  69830. * @param initialM22 defines 2nd value of 2nd row
  69831. * @param initialM23 defines 3rd value of 2nd row
  69832. * @param initialM24 defines 4th value of 2nd row
  69833. * @param initialM31 defines 1st value of 3rd row
  69834. * @param initialM32 defines 2nd value of 3rd row
  69835. * @param initialM33 defines 3rd value of 3rd row
  69836. * @param initialM34 defines 4th value of 3rd row
  69837. * @param initialM41 defines 1st value of 4th row
  69838. * @param initialM42 defines 2nd value of 4th row
  69839. * @param initialM43 defines 3rd value of 4th row
  69840. * @param initialM44 defines 4th value of 4th row
  69841. * @returns the new matrix
  69842. */
  69843. 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;
  69844. /**
  69845. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  69846. * @param scale defines the scale vector3
  69847. * @param rotation defines the rotation quaternion
  69848. * @param translation defines the translation vector3
  69849. * @returns a new matrix
  69850. */
  69851. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  69852. /**
  69853. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  69854. * @param scale defines the scale vector3
  69855. * @param rotation defines the rotation quaternion
  69856. * @param translation defines the translation vector3
  69857. * @param result defines the target matrix
  69858. */
  69859. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  69860. /**
  69861. * Creates a new identity matrix
  69862. * @returns a new identity matrix
  69863. */
  69864. static Identity(): Matrix;
  69865. /**
  69866. * Creates a new identity matrix and stores the result in a given matrix
  69867. * @param result defines the target matrix
  69868. */
  69869. static IdentityToRef(result: Matrix): void;
  69870. /**
  69871. * Creates a new zero matrix
  69872. * @returns a new zero matrix
  69873. */
  69874. static Zero(): Matrix;
  69875. /**
  69876. * Creates a new rotation matrix for "angle" radians around the X axis
  69877. * @param angle defines the angle (in radians) to use
  69878. * @return the new matrix
  69879. */
  69880. static RotationX(angle: number): Matrix;
  69881. /**
  69882. * Creates a new matrix as the invert of a given matrix
  69883. * @param source defines the source matrix
  69884. * @returns the new matrix
  69885. */
  69886. static Invert(source: DeepImmutable<Matrix>): Matrix;
  69887. /**
  69888. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  69889. * @param angle defines the angle (in radians) to use
  69890. * @param result defines the target matrix
  69891. */
  69892. static RotationXToRef(angle: number, result: Matrix): void;
  69893. /**
  69894. * Creates a new rotation matrix for "angle" radians around the Y axis
  69895. * @param angle defines the angle (in radians) to use
  69896. * @return the new matrix
  69897. */
  69898. static RotationY(angle: number): Matrix;
  69899. /**
  69900. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  69901. * @param angle defines the angle (in radians) to use
  69902. * @param result defines the target matrix
  69903. */
  69904. static RotationYToRef(angle: number, result: Matrix): void;
  69905. /**
  69906. * Creates a new rotation matrix for "angle" radians around the Z axis
  69907. * @param angle defines the angle (in radians) to use
  69908. * @return the new matrix
  69909. */
  69910. static RotationZ(angle: number): Matrix;
  69911. /**
  69912. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  69913. * @param angle defines the angle (in radians) to use
  69914. * @param result defines the target matrix
  69915. */
  69916. static RotationZToRef(angle: number, result: Matrix): void;
  69917. /**
  69918. * Creates a new rotation matrix for "angle" radians around the given axis
  69919. * @param axis defines the axis to use
  69920. * @param angle defines the angle (in radians) to use
  69921. * @return the new matrix
  69922. */
  69923. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  69924. /**
  69925. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  69926. * @param axis defines the axis to use
  69927. * @param angle defines the angle (in radians) to use
  69928. * @param result defines the target matrix
  69929. */
  69930. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  69931. /**
  69932. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  69933. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  69934. * @param from defines the vector to align
  69935. * @param to defines the vector to align to
  69936. * @param result defines the target matrix
  69937. */
  69938. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  69939. /**
  69940. * Creates a rotation matrix
  69941. * @param yaw defines the yaw angle in radians (Y axis)
  69942. * @param pitch defines the pitch angle in radians (X axis)
  69943. * @param roll defines the roll angle in radians (X axis)
  69944. * @returns the new rotation matrix
  69945. */
  69946. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  69947. /**
  69948. * Creates a rotation matrix and stores it in a given matrix
  69949. * @param yaw defines the yaw angle in radians (Y axis)
  69950. * @param pitch defines the pitch angle in radians (X axis)
  69951. * @param roll defines the roll angle in radians (X axis)
  69952. * @param result defines the target matrix
  69953. */
  69954. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  69955. /**
  69956. * Creates a scaling matrix
  69957. * @param x defines the scale factor on X axis
  69958. * @param y defines the scale factor on Y axis
  69959. * @param z defines the scale factor on Z axis
  69960. * @returns the new matrix
  69961. */
  69962. static Scaling(x: number, y: number, z: number): Matrix;
  69963. /**
  69964. * Creates a scaling matrix and stores it in a given matrix
  69965. * @param x defines the scale factor on X axis
  69966. * @param y defines the scale factor on Y axis
  69967. * @param z defines the scale factor on Z axis
  69968. * @param result defines the target matrix
  69969. */
  69970. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  69971. /**
  69972. * Creates a translation matrix
  69973. * @param x defines the translation on X axis
  69974. * @param y defines the translation on Y axis
  69975. * @param z defines the translationon Z axis
  69976. * @returns the new matrix
  69977. */
  69978. static Translation(x: number, y: number, z: number): Matrix;
  69979. /**
  69980. * Creates a translation matrix and stores it in a given matrix
  69981. * @param x defines the translation on X axis
  69982. * @param y defines the translation on Y axis
  69983. * @param z defines the translationon Z axis
  69984. * @param result defines the target matrix
  69985. */
  69986. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  69987. /**
  69988. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  69989. * @param startValue defines the start value
  69990. * @param endValue defines the end value
  69991. * @param gradient defines the gradient factor
  69992. * @returns the new matrix
  69993. */
  69994. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  69995. /**
  69996. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  69997. * @param startValue defines the start value
  69998. * @param endValue defines the end value
  69999. * @param gradient defines the gradient factor
  70000. * @param result defines the Matrix object where to store data
  70001. */
  70002. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  70003. /**
  70004. * Builds a new matrix whose values are computed by:
  70005. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  70006. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  70007. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  70008. * @param startValue defines the first matrix
  70009. * @param endValue defines the second matrix
  70010. * @param gradient defines the gradient between the two matrices
  70011. * @returns the new matrix
  70012. */
  70013. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  70014. /**
  70015. * Update a matrix to values which are computed by:
  70016. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  70017. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  70018. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  70019. * @param startValue defines the first matrix
  70020. * @param endValue defines the second matrix
  70021. * @param gradient defines the gradient between the two matrices
  70022. * @param result defines the target matrix
  70023. */
  70024. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  70025. /**
  70026. * 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"
  70027. * This function works in left handed mode
  70028. * @param eye defines the final position of the entity
  70029. * @param target defines where the entity should look at
  70030. * @param up defines the up vector for the entity
  70031. * @returns the new matrix
  70032. */
  70033. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  70034. /**
  70035. * 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".
  70036. * This function works in left handed mode
  70037. * @param eye defines the final position of the entity
  70038. * @param target defines where the entity should look at
  70039. * @param up defines the up vector for the entity
  70040. * @param result defines the target matrix
  70041. */
  70042. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  70043. /**
  70044. * 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"
  70045. * This function works in right handed mode
  70046. * @param eye defines the final position of the entity
  70047. * @param target defines where the entity should look at
  70048. * @param up defines the up vector for the entity
  70049. * @returns the new matrix
  70050. */
  70051. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  70052. /**
  70053. * 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".
  70054. * This function works in right handed mode
  70055. * @param eye defines the final position of the entity
  70056. * @param target defines where the entity should look at
  70057. * @param up defines the up vector for the entity
  70058. * @param result defines the target matrix
  70059. */
  70060. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  70061. /**
  70062. * Create a left-handed orthographic projection matrix
  70063. * @param width defines the viewport width
  70064. * @param height defines the viewport height
  70065. * @param znear defines the near clip plane
  70066. * @param zfar defines the far clip plane
  70067. * @returns a new matrix as a left-handed orthographic projection matrix
  70068. */
  70069. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  70070. /**
  70071. * Store a left-handed orthographic projection to a given matrix
  70072. * @param width defines the viewport width
  70073. * @param height defines the viewport height
  70074. * @param znear defines the near clip plane
  70075. * @param zfar defines the far clip plane
  70076. * @param result defines the target matrix
  70077. */
  70078. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  70079. /**
  70080. * Create a left-handed orthographic projection matrix
  70081. * @param left defines the viewport left coordinate
  70082. * @param right defines the viewport right coordinate
  70083. * @param bottom defines the viewport bottom coordinate
  70084. * @param top defines the viewport top coordinate
  70085. * @param znear defines the near clip plane
  70086. * @param zfar defines the far clip plane
  70087. * @returns a new matrix as a left-handed orthographic projection matrix
  70088. */
  70089. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  70090. /**
  70091. * Stores a left-handed orthographic projection into a given matrix
  70092. * @param left defines the viewport left coordinate
  70093. * @param right defines the viewport right coordinate
  70094. * @param bottom defines the viewport bottom coordinate
  70095. * @param top defines the viewport top coordinate
  70096. * @param znear defines the near clip plane
  70097. * @param zfar defines the far clip plane
  70098. * @param result defines the target matrix
  70099. */
  70100. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  70101. /**
  70102. * Creates a right-handed orthographic projection matrix
  70103. * @param left defines the viewport left coordinate
  70104. * @param right defines the viewport right coordinate
  70105. * @param bottom defines the viewport bottom coordinate
  70106. * @param top defines the viewport top coordinate
  70107. * @param znear defines the near clip plane
  70108. * @param zfar defines the far clip plane
  70109. * @returns a new matrix as a right-handed orthographic projection matrix
  70110. */
  70111. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  70112. /**
  70113. * Stores a right-handed orthographic projection into a given matrix
  70114. * @param left defines the viewport left coordinate
  70115. * @param right defines the viewport right coordinate
  70116. * @param bottom defines the viewport bottom coordinate
  70117. * @param top defines the viewport top coordinate
  70118. * @param znear defines the near clip plane
  70119. * @param zfar defines the far clip plane
  70120. * @param result defines the target matrix
  70121. */
  70122. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  70123. /**
  70124. * Creates a left-handed perspective projection matrix
  70125. * @param width defines the viewport width
  70126. * @param height defines the viewport height
  70127. * @param znear defines the near clip plane
  70128. * @param zfar defines the far clip plane
  70129. * @returns a new matrix as a left-handed perspective projection matrix
  70130. */
  70131. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  70132. /**
  70133. * Creates a left-handed perspective projection matrix
  70134. * @param fov defines the horizontal field of view
  70135. * @param aspect defines the aspect ratio
  70136. * @param znear defines the near clip plane
  70137. * @param zfar defines the far clip plane
  70138. * @returns a new matrix as a left-handed perspective projection matrix
  70139. */
  70140. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  70141. /**
  70142. * Stores a left-handed perspective projection into a given matrix
  70143. * @param fov defines the horizontal field of view
  70144. * @param aspect defines the aspect ratio
  70145. * @param znear defines the near clip plane
  70146. * @param zfar defines the far clip plane
  70147. * @param result defines the target matrix
  70148. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  70149. */
  70150. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  70151. /**
  70152. * Creates a right-handed perspective projection matrix
  70153. * @param fov defines the horizontal field of view
  70154. * @param aspect defines the aspect ratio
  70155. * @param znear defines the near clip plane
  70156. * @param zfar defines the far clip plane
  70157. * @returns a new matrix as a right-handed perspective projection matrix
  70158. */
  70159. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  70160. /**
  70161. * Stores a right-handed perspective projection into a given matrix
  70162. * @param fov defines the horizontal field of view
  70163. * @param aspect defines the aspect ratio
  70164. * @param znear defines the near clip plane
  70165. * @param zfar defines the far clip plane
  70166. * @param result defines the target matrix
  70167. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  70168. */
  70169. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  70170. /**
  70171. * Stores a perspective projection for WebVR info a given matrix
  70172. * @param fov defines the field of view
  70173. * @param znear defines the near clip plane
  70174. * @param zfar defines the far clip plane
  70175. * @param result defines the target matrix
  70176. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  70177. */
  70178. static PerspectiveFovWebVRToRef(fov: {
  70179. upDegrees: number;
  70180. downDegrees: number;
  70181. leftDegrees: number;
  70182. rightDegrees: number;
  70183. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  70184. /**
  70185. * Computes a complete transformation matrix
  70186. * @param viewport defines the viewport to use
  70187. * @param world defines the world matrix
  70188. * @param view defines the view matrix
  70189. * @param projection defines the projection matrix
  70190. * @param zmin defines the near clip plane
  70191. * @param zmax defines the far clip plane
  70192. * @returns the transformation matrix
  70193. */
  70194. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  70195. /**
  70196. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  70197. * @param matrix defines the matrix to use
  70198. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  70199. */
  70200. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  70201. /**
  70202. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  70203. * @param matrix defines the matrix to use
  70204. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  70205. */
  70206. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  70207. /**
  70208. * Compute the transpose of a given matrix
  70209. * @param matrix defines the matrix to transpose
  70210. * @returns the new matrix
  70211. */
  70212. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  70213. /**
  70214. * Compute the transpose of a matrix and store it in a target matrix
  70215. * @param matrix defines the matrix to transpose
  70216. * @param result defines the target matrix
  70217. */
  70218. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  70219. /**
  70220. * Computes a reflection matrix from a plane
  70221. * @param plane defines the reflection plane
  70222. * @returns a new matrix
  70223. */
  70224. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  70225. /**
  70226. * Computes a reflection matrix from a plane
  70227. * @param plane defines the reflection plane
  70228. * @param result defines the target matrix
  70229. */
  70230. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  70231. /**
  70232. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  70233. * @param xaxis defines the value of the 1st axis
  70234. * @param yaxis defines the value of the 2nd axis
  70235. * @param zaxis defines the value of the 3rd axis
  70236. * @param result defines the target matrix
  70237. */
  70238. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  70239. /**
  70240. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  70241. * @param quat defines the quaternion to use
  70242. * @param result defines the target matrix
  70243. */
  70244. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  70245. }
  70246. /**
  70247. * @hidden
  70248. */
  70249. export class TmpVectors {
  70250. static Vector2: Vector2[];
  70251. static Vector3: Vector3[];
  70252. static Vector4: Vector4[];
  70253. static Quaternion: Quaternion[];
  70254. static Matrix: Matrix[];
  70255. }
  70256. }
  70257. declare module BABYLON {
  70258. /**
  70259. * Class used to hold a RBG color
  70260. */
  70261. export class Color3 {
  70262. /**
  70263. * Defines the red component (between 0 and 1, default is 0)
  70264. */
  70265. r: number;
  70266. /**
  70267. * Defines the green component (between 0 and 1, default is 0)
  70268. */
  70269. g: number;
  70270. /**
  70271. * Defines the blue component (between 0 and 1, default is 0)
  70272. */
  70273. b: number;
  70274. /**
  70275. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  70276. * @param r defines the red component (between 0 and 1, default is 0)
  70277. * @param g defines the green component (between 0 and 1, default is 0)
  70278. * @param b defines the blue component (between 0 and 1, default is 0)
  70279. */
  70280. constructor(
  70281. /**
  70282. * Defines the red component (between 0 and 1, default is 0)
  70283. */
  70284. r?: number,
  70285. /**
  70286. * Defines the green component (between 0 and 1, default is 0)
  70287. */
  70288. g?: number,
  70289. /**
  70290. * Defines the blue component (between 0 and 1, default is 0)
  70291. */
  70292. b?: number);
  70293. /**
  70294. * Creates a string with the Color3 current values
  70295. * @returns the string representation of the Color3 object
  70296. */
  70297. toString(): string;
  70298. /**
  70299. * Returns the string "Color3"
  70300. * @returns "Color3"
  70301. */
  70302. getClassName(): string;
  70303. /**
  70304. * Compute the Color3 hash code
  70305. * @returns an unique number that can be used to hash Color3 objects
  70306. */
  70307. getHashCode(): number;
  70308. /**
  70309. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  70310. * @param array defines the array where to store the r,g,b components
  70311. * @param index defines an optional index in the target array to define where to start storing values
  70312. * @returns the current Color3 object
  70313. */
  70314. toArray(array: FloatArray, index?: number): Color3;
  70315. /**
  70316. * Returns a new Color4 object from the current Color3 and the given alpha
  70317. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  70318. * @returns a new Color4 object
  70319. */
  70320. toColor4(alpha?: number): Color4;
  70321. /**
  70322. * Returns a new array populated with 3 numeric elements : red, green and blue values
  70323. * @returns the new array
  70324. */
  70325. asArray(): number[];
  70326. /**
  70327. * Returns the luminance value
  70328. * @returns a float value
  70329. */
  70330. toLuminance(): number;
  70331. /**
  70332. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  70333. * @param otherColor defines the second operand
  70334. * @returns the new Color3 object
  70335. */
  70336. multiply(otherColor: DeepImmutable<Color3>): Color3;
  70337. /**
  70338. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  70339. * @param otherColor defines the second operand
  70340. * @param result defines the Color3 object where to store the result
  70341. * @returns the current Color3
  70342. */
  70343. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  70344. /**
  70345. * Determines equality between Color3 objects
  70346. * @param otherColor defines the second operand
  70347. * @returns true if the rgb values are equal to the given ones
  70348. */
  70349. equals(otherColor: DeepImmutable<Color3>): boolean;
  70350. /**
  70351. * Determines equality between the current Color3 object and a set of r,b,g values
  70352. * @param r defines the red component to check
  70353. * @param g defines the green component to check
  70354. * @param b defines the blue component to check
  70355. * @returns true if the rgb values are equal to the given ones
  70356. */
  70357. equalsFloats(r: number, g: number, b: number): boolean;
  70358. /**
  70359. * Multiplies in place each rgb value by scale
  70360. * @param scale defines the scaling factor
  70361. * @returns the updated Color3
  70362. */
  70363. scale(scale: number): Color3;
  70364. /**
  70365. * Multiplies the rgb values by scale and stores the result into "result"
  70366. * @param scale defines the scaling factor
  70367. * @param result defines the Color3 object where to store the result
  70368. * @returns the unmodified current Color3
  70369. */
  70370. scaleToRef(scale: number, result: Color3): Color3;
  70371. /**
  70372. * Scale the current Color3 values by a factor and add the result to a given Color3
  70373. * @param scale defines the scale factor
  70374. * @param result defines color to store the result into
  70375. * @returns the unmodified current Color3
  70376. */
  70377. scaleAndAddToRef(scale: number, result: Color3): Color3;
  70378. /**
  70379. * Clamps the rgb values by the min and max values and stores the result into "result"
  70380. * @param min defines minimum clamping value (default is 0)
  70381. * @param max defines maximum clamping value (default is 1)
  70382. * @param result defines color to store the result into
  70383. * @returns the original Color3
  70384. */
  70385. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  70386. /**
  70387. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  70388. * @param otherColor defines the second operand
  70389. * @returns the new Color3
  70390. */
  70391. add(otherColor: DeepImmutable<Color3>): Color3;
  70392. /**
  70393. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  70394. * @param otherColor defines the second operand
  70395. * @param result defines Color3 object to store the result into
  70396. * @returns the unmodified current Color3
  70397. */
  70398. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  70399. /**
  70400. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  70401. * @param otherColor defines the second operand
  70402. * @returns the new Color3
  70403. */
  70404. subtract(otherColor: DeepImmutable<Color3>): Color3;
  70405. /**
  70406. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  70407. * @param otherColor defines the second operand
  70408. * @param result defines Color3 object to store the result into
  70409. * @returns the unmodified current Color3
  70410. */
  70411. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  70412. /**
  70413. * Copy the current object
  70414. * @returns a new Color3 copied the current one
  70415. */
  70416. clone(): Color3;
  70417. /**
  70418. * Copies the rgb values from the source in the current Color3
  70419. * @param source defines the source Color3 object
  70420. * @returns the updated Color3 object
  70421. */
  70422. copyFrom(source: DeepImmutable<Color3>): Color3;
  70423. /**
  70424. * Updates the Color3 rgb values from the given floats
  70425. * @param r defines the red component to read from
  70426. * @param g defines the green component to read from
  70427. * @param b defines the blue component to read from
  70428. * @returns the current Color3 object
  70429. */
  70430. copyFromFloats(r: number, g: number, b: number): Color3;
  70431. /**
  70432. * Updates the Color3 rgb values from the given floats
  70433. * @param r defines the red component to read from
  70434. * @param g defines the green component to read from
  70435. * @param b defines the blue component to read from
  70436. * @returns the current Color3 object
  70437. */
  70438. set(r: number, g: number, b: number): Color3;
  70439. /**
  70440. * Compute the Color3 hexadecimal code as a string
  70441. * @returns a string containing the hexadecimal representation of the Color3 object
  70442. */
  70443. toHexString(): string;
  70444. /**
  70445. * Computes a new Color3 converted from the current one to linear space
  70446. * @returns a new Color3 object
  70447. */
  70448. toLinearSpace(): Color3;
  70449. /**
  70450. * Converts current color in rgb space to HSV values
  70451. * @returns a new color3 representing the HSV values
  70452. */
  70453. toHSV(): Color3;
  70454. /**
  70455. * Converts current color in rgb space to HSV values
  70456. * @param result defines the Color3 where to store the HSV values
  70457. */
  70458. toHSVToRef(result: Color3): void;
  70459. /**
  70460. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  70461. * @param convertedColor defines the Color3 object where to store the linear space version
  70462. * @returns the unmodified Color3
  70463. */
  70464. toLinearSpaceToRef(convertedColor: Color3): Color3;
  70465. /**
  70466. * Computes a new Color3 converted from the current one to gamma space
  70467. * @returns a new Color3 object
  70468. */
  70469. toGammaSpace(): Color3;
  70470. /**
  70471. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  70472. * @param convertedColor defines the Color3 object where to store the gamma space version
  70473. * @returns the unmodified Color3
  70474. */
  70475. toGammaSpaceToRef(convertedColor: Color3): Color3;
  70476. private static _BlackReadOnly;
  70477. /**
  70478. * Convert Hue, saturation and value to a Color3 (RGB)
  70479. * @param hue defines the hue
  70480. * @param saturation defines the saturation
  70481. * @param value defines the value
  70482. * @param result defines the Color3 where to store the RGB values
  70483. */
  70484. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  70485. /**
  70486. * Creates a new Color3 from the string containing valid hexadecimal values
  70487. * @param hex defines a string containing valid hexadecimal values
  70488. * @returns a new Color3 object
  70489. */
  70490. static FromHexString(hex: string): Color3;
  70491. /**
  70492. * Creates a new Color3 from the starting index of the given array
  70493. * @param array defines the source array
  70494. * @param offset defines an offset in the source array
  70495. * @returns a new Color3 object
  70496. */
  70497. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  70498. /**
  70499. * Creates a new Color3 from integer values (< 256)
  70500. * @param r defines the red component to read from (value between 0 and 255)
  70501. * @param g defines the green component to read from (value between 0 and 255)
  70502. * @param b defines the blue component to read from (value between 0 and 255)
  70503. * @returns a new Color3 object
  70504. */
  70505. static FromInts(r: number, g: number, b: number): Color3;
  70506. /**
  70507. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  70508. * @param start defines the start Color3 value
  70509. * @param end defines the end Color3 value
  70510. * @param amount defines the gradient value between start and end
  70511. * @returns a new Color3 object
  70512. */
  70513. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  70514. /**
  70515. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  70516. * @param left defines the start value
  70517. * @param right defines the end value
  70518. * @param amount defines the gradient factor
  70519. * @param result defines the Color3 object where to store the result
  70520. */
  70521. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  70522. /**
  70523. * Returns a Color3 value containing a red color
  70524. * @returns a new Color3 object
  70525. */
  70526. static Red(): Color3;
  70527. /**
  70528. * Returns a Color3 value containing a green color
  70529. * @returns a new Color3 object
  70530. */
  70531. static Green(): Color3;
  70532. /**
  70533. * Returns a Color3 value containing a blue color
  70534. * @returns a new Color3 object
  70535. */
  70536. static Blue(): Color3;
  70537. /**
  70538. * Returns a Color3 value containing a black color
  70539. * @returns a new Color3 object
  70540. */
  70541. static Black(): Color3;
  70542. /**
  70543. * Gets a Color3 value containing a black color that must not be updated
  70544. */
  70545. static readonly BlackReadOnly: DeepImmutable<Color3>;
  70546. /**
  70547. * Returns a Color3 value containing a white color
  70548. * @returns a new Color3 object
  70549. */
  70550. static White(): Color3;
  70551. /**
  70552. * Returns a Color3 value containing a purple color
  70553. * @returns a new Color3 object
  70554. */
  70555. static Purple(): Color3;
  70556. /**
  70557. * Returns a Color3 value containing a magenta color
  70558. * @returns a new Color3 object
  70559. */
  70560. static Magenta(): Color3;
  70561. /**
  70562. * Returns a Color3 value containing a yellow color
  70563. * @returns a new Color3 object
  70564. */
  70565. static Yellow(): Color3;
  70566. /**
  70567. * Returns a Color3 value containing a gray color
  70568. * @returns a new Color3 object
  70569. */
  70570. static Gray(): Color3;
  70571. /**
  70572. * Returns a Color3 value containing a teal color
  70573. * @returns a new Color3 object
  70574. */
  70575. static Teal(): Color3;
  70576. /**
  70577. * Returns a Color3 value containing a random color
  70578. * @returns a new Color3 object
  70579. */
  70580. static Random(): Color3;
  70581. }
  70582. /**
  70583. * Class used to hold a RBGA color
  70584. */
  70585. export class Color4 {
  70586. /**
  70587. * Defines the red component (between 0 and 1, default is 0)
  70588. */
  70589. r: number;
  70590. /**
  70591. * Defines the green component (between 0 and 1, default is 0)
  70592. */
  70593. g: number;
  70594. /**
  70595. * Defines the blue component (between 0 and 1, default is 0)
  70596. */
  70597. b: number;
  70598. /**
  70599. * Defines the alpha component (between 0 and 1, default is 1)
  70600. */
  70601. a: number;
  70602. /**
  70603. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  70604. * @param r defines the red component (between 0 and 1, default is 0)
  70605. * @param g defines the green component (between 0 and 1, default is 0)
  70606. * @param b defines the blue component (between 0 and 1, default is 0)
  70607. * @param a defines the alpha component (between 0 and 1, default is 1)
  70608. */
  70609. constructor(
  70610. /**
  70611. * Defines the red component (between 0 and 1, default is 0)
  70612. */
  70613. r?: number,
  70614. /**
  70615. * Defines the green component (between 0 and 1, default is 0)
  70616. */
  70617. g?: number,
  70618. /**
  70619. * Defines the blue component (between 0 and 1, default is 0)
  70620. */
  70621. b?: number,
  70622. /**
  70623. * Defines the alpha component (between 0 and 1, default is 1)
  70624. */
  70625. a?: number);
  70626. /**
  70627. * Adds in place the given Color4 values to the current Color4 object
  70628. * @param right defines the second operand
  70629. * @returns the current updated Color4 object
  70630. */
  70631. addInPlace(right: DeepImmutable<Color4>): Color4;
  70632. /**
  70633. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  70634. * @returns the new array
  70635. */
  70636. asArray(): number[];
  70637. /**
  70638. * Stores from the starting index in the given array the Color4 successive values
  70639. * @param array defines the array where to store the r,g,b components
  70640. * @param index defines an optional index in the target array to define where to start storing values
  70641. * @returns the current Color4 object
  70642. */
  70643. toArray(array: number[], index?: number): Color4;
  70644. /**
  70645. * Determines equality between Color4 objects
  70646. * @param otherColor defines the second operand
  70647. * @returns true if the rgba values are equal to the given ones
  70648. */
  70649. equals(otherColor: DeepImmutable<Color4>): boolean;
  70650. /**
  70651. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  70652. * @param right defines the second operand
  70653. * @returns a new Color4 object
  70654. */
  70655. add(right: DeepImmutable<Color4>): Color4;
  70656. /**
  70657. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  70658. * @param right defines the second operand
  70659. * @returns a new Color4 object
  70660. */
  70661. subtract(right: DeepImmutable<Color4>): Color4;
  70662. /**
  70663. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  70664. * @param right defines the second operand
  70665. * @param result defines the Color4 object where to store the result
  70666. * @returns the current Color4 object
  70667. */
  70668. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  70669. /**
  70670. * Creates a new Color4 with the current Color4 values multiplied by scale
  70671. * @param scale defines the scaling factor to apply
  70672. * @returns a new Color4 object
  70673. */
  70674. scale(scale: number): Color4;
  70675. /**
  70676. * Multiplies the current Color4 values by scale and stores the result in "result"
  70677. * @param scale defines the scaling factor to apply
  70678. * @param result defines the Color4 object where to store the result
  70679. * @returns the current unmodified Color4
  70680. */
  70681. scaleToRef(scale: number, result: Color4): Color4;
  70682. /**
  70683. * Scale the current Color4 values by a factor and add the result to a given Color4
  70684. * @param scale defines the scale factor
  70685. * @param result defines the Color4 object where to store the result
  70686. * @returns the unmodified current Color4
  70687. */
  70688. scaleAndAddToRef(scale: number, result: Color4): Color4;
  70689. /**
  70690. * Clamps the rgb values by the min and max values and stores the result into "result"
  70691. * @param min defines minimum clamping value (default is 0)
  70692. * @param max defines maximum clamping value (default is 1)
  70693. * @param result defines color to store the result into.
  70694. * @returns the cuurent Color4
  70695. */
  70696. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  70697. /**
  70698. * Multipy an Color4 value by another and return a new Color4 object
  70699. * @param color defines the Color4 value to multiply by
  70700. * @returns a new Color4 object
  70701. */
  70702. multiply(color: Color4): Color4;
  70703. /**
  70704. * Multipy a Color4 value by another and push the result in a reference value
  70705. * @param color defines the Color4 value to multiply by
  70706. * @param result defines the Color4 to fill the result in
  70707. * @returns the result Color4
  70708. */
  70709. multiplyToRef(color: Color4, result: Color4): Color4;
  70710. /**
  70711. * Creates a string with the Color4 current values
  70712. * @returns the string representation of the Color4 object
  70713. */
  70714. toString(): string;
  70715. /**
  70716. * Returns the string "Color4"
  70717. * @returns "Color4"
  70718. */
  70719. getClassName(): string;
  70720. /**
  70721. * Compute the Color4 hash code
  70722. * @returns an unique number that can be used to hash Color4 objects
  70723. */
  70724. getHashCode(): number;
  70725. /**
  70726. * Creates a new Color4 copied from the current one
  70727. * @returns a new Color4 object
  70728. */
  70729. clone(): Color4;
  70730. /**
  70731. * Copies the given Color4 values into the current one
  70732. * @param source defines the source Color4 object
  70733. * @returns the current updated Color4 object
  70734. */
  70735. copyFrom(source: Color4): Color4;
  70736. /**
  70737. * Copies the given float values into the current one
  70738. * @param r defines the red component to read from
  70739. * @param g defines the green component to read from
  70740. * @param b defines the blue component to read from
  70741. * @param a defines the alpha component to read from
  70742. * @returns the current updated Color4 object
  70743. */
  70744. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  70745. /**
  70746. * Copies the given float values into the current one
  70747. * @param r defines the red component to read from
  70748. * @param g defines the green component to read from
  70749. * @param b defines the blue component to read from
  70750. * @param a defines the alpha component to read from
  70751. * @returns the current updated Color4 object
  70752. */
  70753. set(r: number, g: number, b: number, a: number): Color4;
  70754. /**
  70755. * Compute the Color4 hexadecimal code as a string
  70756. * @returns a string containing the hexadecimal representation of the Color4 object
  70757. */
  70758. toHexString(): string;
  70759. /**
  70760. * Computes a new Color4 converted from the current one to linear space
  70761. * @returns a new Color4 object
  70762. */
  70763. toLinearSpace(): Color4;
  70764. /**
  70765. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  70766. * @param convertedColor defines the Color4 object where to store the linear space version
  70767. * @returns the unmodified Color4
  70768. */
  70769. toLinearSpaceToRef(convertedColor: Color4): Color4;
  70770. /**
  70771. * Computes a new Color4 converted from the current one to gamma space
  70772. * @returns a new Color4 object
  70773. */
  70774. toGammaSpace(): Color4;
  70775. /**
  70776. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  70777. * @param convertedColor defines the Color4 object where to store the gamma space version
  70778. * @returns the unmodified Color4
  70779. */
  70780. toGammaSpaceToRef(convertedColor: Color4): Color4;
  70781. /**
  70782. * Creates a new Color4 from the string containing valid hexadecimal values
  70783. * @param hex defines a string containing valid hexadecimal values
  70784. * @returns a new Color4 object
  70785. */
  70786. static FromHexString(hex: string): Color4;
  70787. /**
  70788. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  70789. * @param left defines the start value
  70790. * @param right defines the end value
  70791. * @param amount defines the gradient factor
  70792. * @returns a new Color4 object
  70793. */
  70794. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  70795. /**
  70796. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  70797. * @param left defines the start value
  70798. * @param right defines the end value
  70799. * @param amount defines the gradient factor
  70800. * @param result defines the Color4 object where to store data
  70801. */
  70802. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  70803. /**
  70804. * Creates a new Color4 from a Color3 and an alpha value
  70805. * @param color3 defines the source Color3 to read from
  70806. * @param alpha defines the alpha component (1.0 by default)
  70807. * @returns a new Color4 object
  70808. */
  70809. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  70810. /**
  70811. * Creates a new Color4 from the starting index element of the given array
  70812. * @param array defines the source array to read from
  70813. * @param offset defines the offset in the source array
  70814. * @returns a new Color4 object
  70815. */
  70816. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  70817. /**
  70818. * Creates a new Color3 from integer values (< 256)
  70819. * @param r defines the red component to read from (value between 0 and 255)
  70820. * @param g defines the green component to read from (value between 0 and 255)
  70821. * @param b defines the blue component to read from (value between 0 and 255)
  70822. * @param a defines the alpha component to read from (value between 0 and 255)
  70823. * @returns a new Color3 object
  70824. */
  70825. static FromInts(r: number, g: number, b: number, a: number): Color4;
  70826. /**
  70827. * Check the content of a given array and convert it to an array containing RGBA data
  70828. * If the original array was already containing count * 4 values then it is returned directly
  70829. * @param colors defines the array to check
  70830. * @param count defines the number of RGBA data to expect
  70831. * @returns an array containing count * 4 values (RGBA)
  70832. */
  70833. static CheckColors4(colors: number[], count: number): number[];
  70834. }
  70835. /**
  70836. * @hidden
  70837. */
  70838. export class TmpColors {
  70839. static Color3: Color3[];
  70840. static Color4: Color4[];
  70841. }
  70842. }
  70843. declare module BABYLON {
  70844. /**
  70845. * Class representing spherical harmonics coefficients to the 3rd degree
  70846. */
  70847. export class SphericalHarmonics {
  70848. /**
  70849. * Defines whether or not the harmonics have been prescaled for rendering.
  70850. */
  70851. preScaled: boolean;
  70852. /**
  70853. * The l0,0 coefficients of the spherical harmonics
  70854. */
  70855. l00: Vector3;
  70856. /**
  70857. * The l1,-1 coefficients of the spherical harmonics
  70858. */
  70859. l1_1: Vector3;
  70860. /**
  70861. * The l1,0 coefficients of the spherical harmonics
  70862. */
  70863. l10: Vector3;
  70864. /**
  70865. * The l1,1 coefficients of the spherical harmonics
  70866. */
  70867. l11: Vector3;
  70868. /**
  70869. * The l2,-2 coefficients of the spherical harmonics
  70870. */
  70871. l2_2: Vector3;
  70872. /**
  70873. * The l2,-1 coefficients of the spherical harmonics
  70874. */
  70875. l2_1: Vector3;
  70876. /**
  70877. * The l2,0 coefficients of the spherical harmonics
  70878. */
  70879. l20: Vector3;
  70880. /**
  70881. * The l2,1 coefficients of the spherical harmonics
  70882. */
  70883. l21: Vector3;
  70884. /**
  70885. * The l2,2 coefficients of the spherical harmonics
  70886. */
  70887. l22: Vector3;
  70888. /**
  70889. * Adds a light to the spherical harmonics
  70890. * @param direction the direction of the light
  70891. * @param color the color of the light
  70892. * @param deltaSolidAngle the delta solid angle of the light
  70893. */
  70894. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  70895. /**
  70896. * Scales the spherical harmonics by the given amount
  70897. * @param scale the amount to scale
  70898. */
  70899. scaleInPlace(scale: number): void;
  70900. /**
  70901. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  70902. *
  70903. * ```
  70904. * E_lm = A_l * L_lm
  70905. * ```
  70906. *
  70907. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  70908. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  70909. * the scaling factors are given in equation 9.
  70910. */
  70911. convertIncidentRadianceToIrradiance(): void;
  70912. /**
  70913. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  70914. *
  70915. * ```
  70916. * L = (1/pi) * E * rho
  70917. * ```
  70918. *
  70919. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  70920. */
  70921. convertIrradianceToLambertianRadiance(): void;
  70922. /**
  70923. * Integrates the reconstruction coefficients directly in to the SH preventing further
  70924. * required operations at run time.
  70925. *
  70926. * This is simply done by scaling back the SH with Ylm constants parameter.
  70927. * The trigonometric part being applied by the shader at run time.
  70928. */
  70929. preScaleForRendering(): void;
  70930. /**
  70931. * Constructs a spherical harmonics from an array.
  70932. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  70933. * @returns the spherical harmonics
  70934. */
  70935. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  70936. /**
  70937. * Gets the spherical harmonics from polynomial
  70938. * @param polynomial the spherical polynomial
  70939. * @returns the spherical harmonics
  70940. */
  70941. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  70942. }
  70943. /**
  70944. * Class representing spherical polynomial coefficients to the 3rd degree
  70945. */
  70946. export class SphericalPolynomial {
  70947. private _harmonics;
  70948. /**
  70949. * The spherical harmonics used to create the polynomials.
  70950. */
  70951. readonly preScaledHarmonics: SphericalHarmonics;
  70952. /**
  70953. * The x coefficients of the spherical polynomial
  70954. */
  70955. x: Vector3;
  70956. /**
  70957. * The y coefficients of the spherical polynomial
  70958. */
  70959. y: Vector3;
  70960. /**
  70961. * The z coefficients of the spherical polynomial
  70962. */
  70963. z: Vector3;
  70964. /**
  70965. * The xx coefficients of the spherical polynomial
  70966. */
  70967. xx: Vector3;
  70968. /**
  70969. * The yy coefficients of the spherical polynomial
  70970. */
  70971. yy: Vector3;
  70972. /**
  70973. * The zz coefficients of the spherical polynomial
  70974. */
  70975. zz: Vector3;
  70976. /**
  70977. * The xy coefficients of the spherical polynomial
  70978. */
  70979. xy: Vector3;
  70980. /**
  70981. * The yz coefficients of the spherical polynomial
  70982. */
  70983. yz: Vector3;
  70984. /**
  70985. * The zx coefficients of the spherical polynomial
  70986. */
  70987. zx: Vector3;
  70988. /**
  70989. * Adds an ambient color to the spherical polynomial
  70990. * @param color the color to add
  70991. */
  70992. addAmbient(color: Color3): void;
  70993. /**
  70994. * Scales the spherical polynomial by the given amount
  70995. * @param scale the amount to scale
  70996. */
  70997. scaleInPlace(scale: number): void;
  70998. /**
  70999. * Gets the spherical polynomial from harmonics
  71000. * @param harmonics the spherical harmonics
  71001. * @returns the spherical polynomial
  71002. */
  71003. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  71004. /**
  71005. * Constructs a spherical polynomial from an array.
  71006. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  71007. * @returns the spherical polynomial
  71008. */
  71009. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  71010. }
  71011. }
  71012. declare module BABYLON {
  71013. /**
  71014. * Define options used to create a render target texture
  71015. */
  71016. export class RenderTargetCreationOptions {
  71017. /**
  71018. * Specifies is mipmaps must be generated
  71019. */
  71020. generateMipMaps?: boolean;
  71021. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  71022. generateDepthBuffer?: boolean;
  71023. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  71024. generateStencilBuffer?: boolean;
  71025. /** Defines texture type (int by default) */
  71026. type?: number;
  71027. /** Defines sampling mode (trilinear by default) */
  71028. samplingMode?: number;
  71029. /** Defines format (RGBA by default) */
  71030. format?: number;
  71031. }
  71032. }
  71033. declare module BABYLON {
  71034. /**
  71035. * @hidden
  71036. **/
  71037. export class _TimeToken {
  71038. _startTimeQuery: Nullable<WebGLQuery>;
  71039. _endTimeQuery: Nullable<WebGLQuery>;
  71040. _timeElapsedQuery: Nullable<WebGLQuery>;
  71041. _timeElapsedQueryEnded: boolean;
  71042. }
  71043. }
  71044. declare module BABYLON {
  71045. /** Defines the cross module used constants to avoid circular dependncies */
  71046. export class Constants {
  71047. /** Defines that alpha blending is disabled */
  71048. static readonly ALPHA_DISABLE: number;
  71049. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  71050. static readonly ALPHA_ADD: number;
  71051. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  71052. static readonly ALPHA_COMBINE: number;
  71053. /** Defines that alpha blending to DEST - SRC * DEST */
  71054. static readonly ALPHA_SUBTRACT: number;
  71055. /** Defines that alpha blending to SRC * DEST */
  71056. static readonly ALPHA_MULTIPLY: number;
  71057. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  71058. static readonly ALPHA_MAXIMIZED: number;
  71059. /** Defines that alpha blending to SRC + DEST */
  71060. static readonly ALPHA_ONEONE: number;
  71061. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  71062. static readonly ALPHA_PREMULTIPLIED: number;
  71063. /**
  71064. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  71065. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  71066. */
  71067. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  71068. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  71069. static readonly ALPHA_INTERPOLATE: number;
  71070. /**
  71071. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  71072. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  71073. */
  71074. static readonly ALPHA_SCREENMODE: number;
  71075. /**
  71076. * Defines that alpha blending to SRC + DST
  71077. * Alpha will be set to SRC ALPHA + DST ALPHA
  71078. */
  71079. static readonly ALPHA_ONEONE_ONEONE: number;
  71080. /**
  71081. * Defines that alpha blending to SRC * DST ALPHA + DST
  71082. * Alpha will be set to 0
  71083. */
  71084. static readonly ALPHA_ALPHATOCOLOR: number;
  71085. /**
  71086. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  71087. */
  71088. static readonly ALPHA_REVERSEONEMINUS: number;
  71089. /**
  71090. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  71091. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  71092. */
  71093. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  71094. /**
  71095. * Defines that alpha blending to SRC + DST
  71096. * Alpha will be set to SRC ALPHA
  71097. */
  71098. static readonly ALPHA_ONEONE_ONEZERO: number;
  71099. /** Defines that alpha blending equation a SUM */
  71100. static readonly ALPHA_EQUATION_ADD: number;
  71101. /** Defines that alpha blending equation a SUBSTRACTION */
  71102. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  71103. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  71104. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  71105. /** Defines that alpha blending equation a MAX operation */
  71106. static readonly ALPHA_EQUATION_MAX: number;
  71107. /** Defines that alpha blending equation a MIN operation */
  71108. static readonly ALPHA_EQUATION_MIN: number;
  71109. /**
  71110. * Defines that alpha blending equation a DARKEN operation:
  71111. * It takes the min of the src and sums the alpha channels.
  71112. */
  71113. static readonly ALPHA_EQUATION_DARKEN: number;
  71114. /** Defines that the ressource is not delayed*/
  71115. static readonly DELAYLOADSTATE_NONE: number;
  71116. /** Defines that the ressource was successfully delay loaded */
  71117. static readonly DELAYLOADSTATE_LOADED: number;
  71118. /** Defines that the ressource is currently delay loading */
  71119. static readonly DELAYLOADSTATE_LOADING: number;
  71120. /** Defines that the ressource is delayed and has not started loading */
  71121. static readonly DELAYLOADSTATE_NOTLOADED: number;
  71122. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  71123. static readonly NEVER: number;
  71124. /** 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 */
  71125. static readonly ALWAYS: number;
  71126. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  71127. static readonly LESS: number;
  71128. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  71129. static readonly EQUAL: number;
  71130. /** 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 */
  71131. static readonly LEQUAL: number;
  71132. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  71133. static readonly GREATER: number;
  71134. /** 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 */
  71135. static readonly GEQUAL: number;
  71136. /** 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 */
  71137. static readonly NOTEQUAL: number;
  71138. /** Passed to stencilOperation to specify that stencil value must be kept */
  71139. static readonly KEEP: number;
  71140. /** Passed to stencilOperation to specify that stencil value must be replaced */
  71141. static readonly REPLACE: number;
  71142. /** Passed to stencilOperation to specify that stencil value must be incremented */
  71143. static readonly INCR: number;
  71144. /** Passed to stencilOperation to specify that stencil value must be decremented */
  71145. static readonly DECR: number;
  71146. /** Passed to stencilOperation to specify that stencil value must be inverted */
  71147. static readonly INVERT: number;
  71148. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  71149. static readonly INCR_WRAP: number;
  71150. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  71151. static readonly DECR_WRAP: number;
  71152. /** Texture is not repeating outside of 0..1 UVs */
  71153. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  71154. /** Texture is repeating outside of 0..1 UVs */
  71155. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  71156. /** Texture is repeating and mirrored */
  71157. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  71158. /** ALPHA */
  71159. static readonly TEXTUREFORMAT_ALPHA: number;
  71160. /** LUMINANCE */
  71161. static readonly TEXTUREFORMAT_LUMINANCE: number;
  71162. /** LUMINANCE_ALPHA */
  71163. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  71164. /** RGB */
  71165. static readonly TEXTUREFORMAT_RGB: number;
  71166. /** RGBA */
  71167. static readonly TEXTUREFORMAT_RGBA: number;
  71168. /** RED */
  71169. static readonly TEXTUREFORMAT_RED: number;
  71170. /** RED (2nd reference) */
  71171. static readonly TEXTUREFORMAT_R: number;
  71172. /** RG */
  71173. static readonly TEXTUREFORMAT_RG: number;
  71174. /** RED_INTEGER */
  71175. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  71176. /** RED_INTEGER (2nd reference) */
  71177. static readonly TEXTUREFORMAT_R_INTEGER: number;
  71178. /** RG_INTEGER */
  71179. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  71180. /** RGB_INTEGER */
  71181. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  71182. /** RGBA_INTEGER */
  71183. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  71184. /** UNSIGNED_BYTE */
  71185. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  71186. /** UNSIGNED_BYTE (2nd reference) */
  71187. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  71188. /** FLOAT */
  71189. static readonly TEXTURETYPE_FLOAT: number;
  71190. /** HALF_FLOAT */
  71191. static readonly TEXTURETYPE_HALF_FLOAT: number;
  71192. /** BYTE */
  71193. static readonly TEXTURETYPE_BYTE: number;
  71194. /** SHORT */
  71195. static readonly TEXTURETYPE_SHORT: number;
  71196. /** UNSIGNED_SHORT */
  71197. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  71198. /** INT */
  71199. static readonly TEXTURETYPE_INT: number;
  71200. /** UNSIGNED_INT */
  71201. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  71202. /** UNSIGNED_SHORT_4_4_4_4 */
  71203. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  71204. /** UNSIGNED_SHORT_5_5_5_1 */
  71205. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  71206. /** UNSIGNED_SHORT_5_6_5 */
  71207. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  71208. /** UNSIGNED_INT_2_10_10_10_REV */
  71209. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  71210. /** UNSIGNED_INT_24_8 */
  71211. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  71212. /** UNSIGNED_INT_10F_11F_11F_REV */
  71213. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  71214. /** UNSIGNED_INT_5_9_9_9_REV */
  71215. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  71216. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  71217. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  71218. /** nearest is mag = nearest and min = nearest and mip = linear */
  71219. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  71220. /** Bilinear is mag = linear and min = linear and mip = nearest */
  71221. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  71222. /** Trilinear is mag = linear and min = linear and mip = linear */
  71223. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  71224. /** nearest is mag = nearest and min = nearest and mip = linear */
  71225. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  71226. /** Bilinear is mag = linear and min = linear and mip = nearest */
  71227. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  71228. /** Trilinear is mag = linear and min = linear and mip = linear */
  71229. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  71230. /** mag = nearest and min = nearest and mip = nearest */
  71231. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  71232. /** mag = nearest and min = linear and mip = nearest */
  71233. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  71234. /** mag = nearest and min = linear and mip = linear */
  71235. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  71236. /** mag = nearest and min = linear and mip = none */
  71237. static readonly TEXTURE_NEAREST_LINEAR: number;
  71238. /** mag = nearest and min = nearest and mip = none */
  71239. static readonly TEXTURE_NEAREST_NEAREST: number;
  71240. /** mag = linear and min = nearest and mip = nearest */
  71241. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  71242. /** mag = linear and min = nearest and mip = linear */
  71243. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  71244. /** mag = linear and min = linear and mip = none */
  71245. static readonly TEXTURE_LINEAR_LINEAR: number;
  71246. /** mag = linear and min = nearest and mip = none */
  71247. static readonly TEXTURE_LINEAR_NEAREST: number;
  71248. /** Explicit coordinates mode */
  71249. static readonly TEXTURE_EXPLICIT_MODE: number;
  71250. /** Spherical coordinates mode */
  71251. static readonly TEXTURE_SPHERICAL_MODE: number;
  71252. /** Planar coordinates mode */
  71253. static readonly TEXTURE_PLANAR_MODE: number;
  71254. /** Cubic coordinates mode */
  71255. static readonly TEXTURE_CUBIC_MODE: number;
  71256. /** Projection coordinates mode */
  71257. static readonly TEXTURE_PROJECTION_MODE: number;
  71258. /** Skybox coordinates mode */
  71259. static readonly TEXTURE_SKYBOX_MODE: number;
  71260. /** Inverse Cubic coordinates mode */
  71261. static readonly TEXTURE_INVCUBIC_MODE: number;
  71262. /** Equirectangular coordinates mode */
  71263. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  71264. /** Equirectangular Fixed coordinates mode */
  71265. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  71266. /** Equirectangular Fixed Mirrored coordinates mode */
  71267. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  71268. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  71269. static readonly SCALEMODE_FLOOR: number;
  71270. /** Defines that texture rescaling will look for the nearest power of 2 size */
  71271. static readonly SCALEMODE_NEAREST: number;
  71272. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  71273. static readonly SCALEMODE_CEILING: number;
  71274. /**
  71275. * The dirty texture flag value
  71276. */
  71277. static readonly MATERIAL_TextureDirtyFlag: number;
  71278. /**
  71279. * The dirty light flag value
  71280. */
  71281. static readonly MATERIAL_LightDirtyFlag: number;
  71282. /**
  71283. * The dirty fresnel flag value
  71284. */
  71285. static readonly MATERIAL_FresnelDirtyFlag: number;
  71286. /**
  71287. * The dirty attribute flag value
  71288. */
  71289. static readonly MATERIAL_AttributesDirtyFlag: number;
  71290. /**
  71291. * The dirty misc flag value
  71292. */
  71293. static readonly MATERIAL_MiscDirtyFlag: number;
  71294. /**
  71295. * The all dirty flag value
  71296. */
  71297. static readonly MATERIAL_AllDirtyFlag: number;
  71298. /**
  71299. * Returns the triangle fill mode
  71300. */
  71301. static readonly MATERIAL_TriangleFillMode: number;
  71302. /**
  71303. * Returns the wireframe mode
  71304. */
  71305. static readonly MATERIAL_WireFrameFillMode: number;
  71306. /**
  71307. * Returns the point fill mode
  71308. */
  71309. static readonly MATERIAL_PointFillMode: number;
  71310. /**
  71311. * Returns the point list draw mode
  71312. */
  71313. static readonly MATERIAL_PointListDrawMode: number;
  71314. /**
  71315. * Returns the line list draw mode
  71316. */
  71317. static readonly MATERIAL_LineListDrawMode: number;
  71318. /**
  71319. * Returns the line loop draw mode
  71320. */
  71321. static readonly MATERIAL_LineLoopDrawMode: number;
  71322. /**
  71323. * Returns the line strip draw mode
  71324. */
  71325. static readonly MATERIAL_LineStripDrawMode: number;
  71326. /**
  71327. * Returns the triangle strip draw mode
  71328. */
  71329. static readonly MATERIAL_TriangleStripDrawMode: number;
  71330. /**
  71331. * Returns the triangle fan draw mode
  71332. */
  71333. static readonly MATERIAL_TriangleFanDrawMode: number;
  71334. /**
  71335. * Stores the clock-wise side orientation
  71336. */
  71337. static readonly MATERIAL_ClockWiseSideOrientation: number;
  71338. /**
  71339. * Stores the counter clock-wise side orientation
  71340. */
  71341. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  71342. /**
  71343. * Nothing
  71344. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71345. */
  71346. static readonly ACTION_NothingTrigger: number;
  71347. /**
  71348. * On pick
  71349. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71350. */
  71351. static readonly ACTION_OnPickTrigger: number;
  71352. /**
  71353. * On left pick
  71354. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71355. */
  71356. static readonly ACTION_OnLeftPickTrigger: number;
  71357. /**
  71358. * On right pick
  71359. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71360. */
  71361. static readonly ACTION_OnRightPickTrigger: number;
  71362. /**
  71363. * On center pick
  71364. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71365. */
  71366. static readonly ACTION_OnCenterPickTrigger: number;
  71367. /**
  71368. * On pick down
  71369. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71370. */
  71371. static readonly ACTION_OnPickDownTrigger: number;
  71372. /**
  71373. * On double pick
  71374. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71375. */
  71376. static readonly ACTION_OnDoublePickTrigger: number;
  71377. /**
  71378. * On pick up
  71379. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71380. */
  71381. static readonly ACTION_OnPickUpTrigger: number;
  71382. /**
  71383. * On pick out.
  71384. * This trigger will only be raised if you also declared a OnPickDown
  71385. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71386. */
  71387. static readonly ACTION_OnPickOutTrigger: number;
  71388. /**
  71389. * On long press
  71390. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71391. */
  71392. static readonly ACTION_OnLongPressTrigger: number;
  71393. /**
  71394. * On pointer over
  71395. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71396. */
  71397. static readonly ACTION_OnPointerOverTrigger: number;
  71398. /**
  71399. * On pointer out
  71400. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71401. */
  71402. static readonly ACTION_OnPointerOutTrigger: number;
  71403. /**
  71404. * On every frame
  71405. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71406. */
  71407. static readonly ACTION_OnEveryFrameTrigger: number;
  71408. /**
  71409. * On intersection enter
  71410. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71411. */
  71412. static readonly ACTION_OnIntersectionEnterTrigger: number;
  71413. /**
  71414. * On intersection exit
  71415. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71416. */
  71417. static readonly ACTION_OnIntersectionExitTrigger: number;
  71418. /**
  71419. * On key down
  71420. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71421. */
  71422. static readonly ACTION_OnKeyDownTrigger: number;
  71423. /**
  71424. * On key up
  71425. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71426. */
  71427. static readonly ACTION_OnKeyUpTrigger: number;
  71428. /**
  71429. * Billboard mode will only apply to Y axis
  71430. */
  71431. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  71432. /**
  71433. * Billboard mode will apply to all axes
  71434. */
  71435. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  71436. /**
  71437. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  71438. */
  71439. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  71440. /**
  71441. * Gets or sets base Assets URL
  71442. */
  71443. static PARTICLES_BaseAssetsUrl: string;
  71444. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  71445. * Test order :
  71446. * Is the bounding sphere outside the frustum ?
  71447. * If not, are the bounding box vertices outside the frustum ?
  71448. * It not, then the cullable object is in the frustum.
  71449. */
  71450. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  71451. /** Culling strategy : Bounding Sphere Only.
  71452. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  71453. * It's also less accurate than the standard because some not visible objects can still be selected.
  71454. * Test : is the bounding sphere outside the frustum ?
  71455. * If not, then the cullable object is in the frustum.
  71456. */
  71457. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  71458. /** Culling strategy : Optimistic Inclusion.
  71459. * This in an inclusion test first, then the standard exclusion test.
  71460. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  71461. * 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.
  71462. * Anyway, it's as accurate as the standard strategy.
  71463. * Test :
  71464. * Is the cullable object bounding sphere center in the frustum ?
  71465. * If not, apply the default culling strategy.
  71466. */
  71467. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  71468. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  71469. * This in an inclusion test first, then the bounding sphere only exclusion test.
  71470. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  71471. * 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.
  71472. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  71473. * Test :
  71474. * Is the cullable object bounding sphere center in the frustum ?
  71475. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  71476. */
  71477. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  71478. /**
  71479. * No logging while loading
  71480. */
  71481. static readonly SCENELOADER_NO_LOGGING: number;
  71482. /**
  71483. * Minimal logging while loading
  71484. */
  71485. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  71486. /**
  71487. * Summary logging while loading
  71488. */
  71489. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  71490. /**
  71491. * Detailled logging while loading
  71492. */
  71493. static readonly SCENELOADER_DETAILED_LOGGING: number;
  71494. }
  71495. }
  71496. declare module BABYLON {
  71497. /**
  71498. * This represents the required contract to create a new type of texture loader.
  71499. */
  71500. export interface IInternalTextureLoader {
  71501. /**
  71502. * Defines wether the loader supports cascade loading the different faces.
  71503. */
  71504. supportCascades: boolean;
  71505. /**
  71506. * This returns if the loader support the current file information.
  71507. * @param extension defines the file extension of the file being loaded
  71508. * @param textureFormatInUse defines the current compressed format in use iun the engine
  71509. * @param fallback defines the fallback internal texture if any
  71510. * @param isBase64 defines whether the texture is encoded as a base64
  71511. * @param isBuffer defines whether the texture data are stored as a buffer
  71512. * @returns true if the loader can load the specified file
  71513. */
  71514. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  71515. /**
  71516. * Transform the url before loading if required.
  71517. * @param rootUrl the url of the texture
  71518. * @param textureFormatInUse defines the current compressed format in use iun the engine
  71519. * @returns the transformed texture
  71520. */
  71521. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  71522. /**
  71523. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  71524. * @param rootUrl the url of the texture
  71525. * @param textureFormatInUse defines the current compressed format in use iun the engine
  71526. * @returns the fallback texture
  71527. */
  71528. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  71529. /**
  71530. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  71531. * @param data contains the texture data
  71532. * @param texture defines the BabylonJS internal texture
  71533. * @param createPolynomials will be true if polynomials have been requested
  71534. * @param onLoad defines the callback to trigger once the texture is ready
  71535. * @param onError defines the callback to trigger in case of error
  71536. */
  71537. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  71538. /**
  71539. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  71540. * @param data contains the texture data
  71541. * @param texture defines the BabylonJS internal texture
  71542. * @param callback defines the method to call once ready to upload
  71543. */
  71544. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  71545. }
  71546. }
  71547. declare module BABYLON {
  71548. /**
  71549. * Class used to store and describe the pipeline context associated with an effect
  71550. */
  71551. export interface IPipelineContext {
  71552. /**
  71553. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  71554. */
  71555. isAsync: boolean;
  71556. /**
  71557. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  71558. */
  71559. isReady: boolean;
  71560. /** @hidden */
  71561. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  71562. }
  71563. }
  71564. declare module BABYLON {
  71565. /**
  71566. * Class used to store gfx data (like WebGLBuffer)
  71567. */
  71568. export class DataBuffer {
  71569. /**
  71570. * Gets or sets the number of objects referencing this buffer
  71571. */
  71572. references: number;
  71573. /** Gets or sets the size of the underlying buffer */
  71574. capacity: number;
  71575. /**
  71576. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  71577. */
  71578. is32Bits: boolean;
  71579. /**
  71580. * Gets the underlying buffer
  71581. */
  71582. readonly underlyingResource: any;
  71583. }
  71584. }
  71585. declare module BABYLON {
  71586. /** @hidden */
  71587. export interface IShaderProcessor {
  71588. attributeProcessor?: (attribute: string) => string;
  71589. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  71590. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  71591. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  71592. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  71593. lineProcessor?: (line: string, isFragment: boolean) => string;
  71594. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  71595. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  71596. }
  71597. }
  71598. declare module BABYLON {
  71599. /** @hidden */
  71600. export interface ProcessingOptions {
  71601. defines: string[];
  71602. indexParameters: any;
  71603. isFragment: boolean;
  71604. shouldUseHighPrecisionShader: boolean;
  71605. supportsUniformBuffers: boolean;
  71606. shadersRepository: string;
  71607. includesShadersStore: {
  71608. [key: string]: string;
  71609. };
  71610. processor?: IShaderProcessor;
  71611. version: string;
  71612. platformName: string;
  71613. lookForClosingBracketForUniformBuffer?: boolean;
  71614. }
  71615. }
  71616. declare module BABYLON {
  71617. /**
  71618. * Helper to manipulate strings
  71619. */
  71620. export class StringTools {
  71621. /**
  71622. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  71623. * @param str Source string
  71624. * @param suffix Suffix to search for in the source string
  71625. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  71626. */
  71627. static EndsWith(str: string, suffix: string): boolean;
  71628. /**
  71629. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  71630. * @param str Source string
  71631. * @param suffix Suffix to search for in the source string
  71632. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  71633. */
  71634. static StartsWith(str: string, suffix: string): boolean;
  71635. }
  71636. }
  71637. declare module BABYLON {
  71638. /** @hidden */
  71639. export class ShaderCodeNode {
  71640. line: string;
  71641. children: ShaderCodeNode[];
  71642. additionalDefineKey?: string;
  71643. additionalDefineValue?: string;
  71644. isValid(preprocessors: {
  71645. [key: string]: string;
  71646. }): boolean;
  71647. process(preprocessors: {
  71648. [key: string]: string;
  71649. }, options: ProcessingOptions): string;
  71650. }
  71651. }
  71652. declare module BABYLON {
  71653. /** @hidden */
  71654. export class ShaderCodeCursor {
  71655. private _lines;
  71656. lineIndex: number;
  71657. readonly currentLine: string;
  71658. readonly canRead: boolean;
  71659. lines: string[];
  71660. }
  71661. }
  71662. declare module BABYLON {
  71663. /** @hidden */
  71664. export class ShaderCodeConditionNode extends ShaderCodeNode {
  71665. process(preprocessors: {
  71666. [key: string]: string;
  71667. }, options: ProcessingOptions): string;
  71668. }
  71669. }
  71670. declare module BABYLON {
  71671. /** @hidden */
  71672. export class ShaderDefineExpression {
  71673. isTrue(preprocessors: {
  71674. [key: string]: string;
  71675. }): boolean;
  71676. }
  71677. }
  71678. declare module BABYLON {
  71679. /** @hidden */
  71680. export class ShaderCodeTestNode extends ShaderCodeNode {
  71681. testExpression: ShaderDefineExpression;
  71682. isValid(preprocessors: {
  71683. [key: string]: string;
  71684. }): boolean;
  71685. }
  71686. }
  71687. declare module BABYLON {
  71688. /** @hidden */
  71689. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  71690. define: string;
  71691. not: boolean;
  71692. constructor(define: string, not?: boolean);
  71693. isTrue(preprocessors: {
  71694. [key: string]: string;
  71695. }): boolean;
  71696. }
  71697. }
  71698. declare module BABYLON {
  71699. /** @hidden */
  71700. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  71701. leftOperand: ShaderDefineExpression;
  71702. rightOperand: ShaderDefineExpression;
  71703. isTrue(preprocessors: {
  71704. [key: string]: string;
  71705. }): boolean;
  71706. }
  71707. }
  71708. declare module BABYLON {
  71709. /** @hidden */
  71710. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  71711. leftOperand: ShaderDefineExpression;
  71712. rightOperand: ShaderDefineExpression;
  71713. isTrue(preprocessors: {
  71714. [key: string]: string;
  71715. }): boolean;
  71716. }
  71717. }
  71718. declare module BABYLON {
  71719. /** @hidden */
  71720. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  71721. define: string;
  71722. operand: string;
  71723. testValue: string;
  71724. constructor(define: string, operand: string, testValue: string);
  71725. isTrue(preprocessors: {
  71726. [key: string]: string;
  71727. }): boolean;
  71728. }
  71729. }
  71730. declare module BABYLON {
  71731. /**
  71732. * @ignore
  71733. * Application error to support additional information when loading a file
  71734. */
  71735. export class LoadFileError extends Error {
  71736. /** defines the optional web request */
  71737. request?: WebRequest | undefined;
  71738. private static _setPrototypeOf;
  71739. /**
  71740. * Creates a new LoadFileError
  71741. * @param message defines the message of the error
  71742. * @param request defines the optional web request
  71743. */
  71744. constructor(message: string,
  71745. /** defines the optional web request */
  71746. request?: WebRequest | undefined);
  71747. }
  71748. }
  71749. declare module BABYLON {
  71750. /**
  71751. * Class used to enable access to offline support
  71752. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  71753. */
  71754. export interface IOfflineProvider {
  71755. /**
  71756. * Gets a boolean indicating if scene must be saved in the database
  71757. */
  71758. enableSceneOffline: boolean;
  71759. /**
  71760. * Gets a boolean indicating if textures must be saved in the database
  71761. */
  71762. enableTexturesOffline: boolean;
  71763. /**
  71764. * Open the offline support and make it available
  71765. * @param successCallback defines the callback to call on success
  71766. * @param errorCallback defines the callback to call on error
  71767. */
  71768. open(successCallback: () => void, errorCallback: () => void): void;
  71769. /**
  71770. * Loads an image from the offline support
  71771. * @param url defines the url to load from
  71772. * @param image defines the target DOM image
  71773. */
  71774. loadImage(url: string, image: HTMLImageElement): void;
  71775. /**
  71776. * Loads a file from offline support
  71777. * @param url defines the URL to load from
  71778. * @param sceneLoaded defines a callback to call on success
  71779. * @param progressCallBack defines a callback to call when progress changed
  71780. * @param errorCallback defines a callback to call on error
  71781. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  71782. */
  71783. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  71784. }
  71785. }
  71786. declare module BABYLON {
  71787. /**
  71788. * Class used to help managing file picking and drag'n'drop
  71789. * File Storage
  71790. */
  71791. export class FilesInputStore {
  71792. /**
  71793. * List of files ready to be loaded
  71794. */
  71795. static FilesToLoad: {
  71796. [key: string]: File;
  71797. };
  71798. }
  71799. }
  71800. declare module BABYLON {
  71801. /**
  71802. * Class used to define a retry strategy when error happens while loading assets
  71803. */
  71804. export class RetryStrategy {
  71805. /**
  71806. * Function used to defines an exponential back off strategy
  71807. * @param maxRetries defines the maximum number of retries (3 by default)
  71808. * @param baseInterval defines the interval between retries
  71809. * @returns the strategy function to use
  71810. */
  71811. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  71812. }
  71813. }
  71814. declare module BABYLON {
  71815. /**
  71816. * @hidden
  71817. */
  71818. export class FileTools {
  71819. /**
  71820. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  71821. */
  71822. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  71823. /**
  71824. * Gets or sets the base URL to use to load assets
  71825. */
  71826. static BaseUrl: string;
  71827. /**
  71828. * Default behaviour for cors in the application.
  71829. * It can be a string if the expected behavior is identical in the entire app.
  71830. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  71831. */
  71832. static CorsBehavior: string | ((url: string | string[]) => string);
  71833. /**
  71834. * Gets or sets a function used to pre-process url before using them to load assets
  71835. */
  71836. static PreprocessUrl: (url: string) => string;
  71837. /**
  71838. * Removes unwanted characters from an url
  71839. * @param url defines the url to clean
  71840. * @returns the cleaned url
  71841. */
  71842. private static _CleanUrl;
  71843. /**
  71844. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  71845. * @param url define the url we are trying
  71846. * @param element define the dom element where to configure the cors policy
  71847. */
  71848. static SetCorsBehavior(url: string | string[], element: {
  71849. crossOrigin: string | null;
  71850. }): void;
  71851. /**
  71852. * Loads an image as an HTMLImageElement.
  71853. * @param input url string, ArrayBuffer, or Blob to load
  71854. * @param onLoad callback called when the image successfully loads
  71855. * @param onError callback called when the image fails to load
  71856. * @param offlineProvider offline provider for caching
  71857. * @returns the HTMLImageElement of the loaded image
  71858. */
  71859. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  71860. /**
  71861. * Loads a file
  71862. * @param fileToLoad defines the file to load
  71863. * @param callback defines the callback to call when data is loaded
  71864. * @param progressCallBack defines the callback to call during loading process
  71865. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  71866. * @returns a file request object
  71867. */
  71868. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  71869. /**
  71870. * Loads a file
  71871. * @param url url string, ArrayBuffer, or Blob to load
  71872. * @param onSuccess callback called when the file successfully loads
  71873. * @param onProgress callback called while file is loading (if the server supports this mode)
  71874. * @param offlineProvider defines the offline provider for caching
  71875. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  71876. * @param onError callback called when the file fails to load
  71877. * @returns a file request object
  71878. */
  71879. 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;
  71880. /**
  71881. * Checks if the loaded document was accessed via `file:`-Protocol.
  71882. * @returns boolean
  71883. */
  71884. static IsFileURL(): boolean;
  71885. }
  71886. }
  71887. declare module BABYLON {
  71888. /** @hidden */
  71889. export class ShaderProcessor {
  71890. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  71891. private static _ProcessPrecision;
  71892. private static _ExtractOperation;
  71893. private static _BuildSubExpression;
  71894. private static _BuildExpression;
  71895. private static _MoveCursorWithinIf;
  71896. private static _MoveCursor;
  71897. private static _EvaluatePreProcessors;
  71898. private static _PreparePreProcessors;
  71899. private static _ProcessShaderConversion;
  71900. private static _ProcessIncludes;
  71901. }
  71902. }
  71903. declare module BABYLON {
  71904. /**
  71905. * Interface used to define common properties for effect fallbacks
  71906. */
  71907. export interface IEffectFallbacks {
  71908. /**
  71909. * Removes the defines that should be removed when falling back.
  71910. * @param currentDefines defines the current define statements for the shader.
  71911. * @param effect defines the current effect we try to compile
  71912. * @returns The resulting defines with defines of the current rank removed.
  71913. */
  71914. reduce(currentDefines: string, effect: Effect): string;
  71915. /**
  71916. * Removes the fallback from the bound mesh.
  71917. */
  71918. unBindMesh(): void;
  71919. /**
  71920. * Checks to see if more fallbacks are still availible.
  71921. */
  71922. hasMoreFallbacks: boolean;
  71923. }
  71924. }
  71925. declare module BABYLON {
  71926. /**
  71927. * Class used to evalaute queries containing `and` and `or` operators
  71928. */
  71929. export class AndOrNotEvaluator {
  71930. /**
  71931. * Evaluate a query
  71932. * @param query defines the query to evaluate
  71933. * @param evaluateCallback defines the callback used to filter result
  71934. * @returns true if the query matches
  71935. */
  71936. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  71937. private static _HandleParenthesisContent;
  71938. private static _SimplifyNegation;
  71939. }
  71940. }
  71941. declare module BABYLON {
  71942. /**
  71943. * Class used to store custom tags
  71944. */
  71945. export class Tags {
  71946. /**
  71947. * Adds support for tags on the given object
  71948. * @param obj defines the object to use
  71949. */
  71950. static EnableFor(obj: any): void;
  71951. /**
  71952. * Removes tags support
  71953. * @param obj defines the object to use
  71954. */
  71955. static DisableFor(obj: any): void;
  71956. /**
  71957. * Gets a boolean indicating if the given object has tags
  71958. * @param obj defines the object to use
  71959. * @returns a boolean
  71960. */
  71961. static HasTags(obj: any): boolean;
  71962. /**
  71963. * Gets the tags available on a given object
  71964. * @param obj defines the object to use
  71965. * @param asString defines if the tags must be returned as a string instead of an array of strings
  71966. * @returns the tags
  71967. */
  71968. static GetTags(obj: any, asString?: boolean): any;
  71969. /**
  71970. * Adds tags to an object
  71971. * @param obj defines the object to use
  71972. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  71973. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  71974. */
  71975. static AddTagsTo(obj: any, tagsString: string): void;
  71976. /**
  71977. * @hidden
  71978. */
  71979. static _AddTagTo(obj: any, tag: string): void;
  71980. /**
  71981. * Removes specific tags from a specific object
  71982. * @param obj defines the object to use
  71983. * @param tagsString defines the tags to remove
  71984. */
  71985. static RemoveTagsFrom(obj: any, tagsString: string): void;
  71986. /**
  71987. * @hidden
  71988. */
  71989. static _RemoveTagFrom(obj: any, tag: string): void;
  71990. /**
  71991. * Defines if tags hosted on an object match a given query
  71992. * @param obj defines the object to use
  71993. * @param tagsQuery defines the tag query
  71994. * @returns a boolean
  71995. */
  71996. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  71997. }
  71998. }
  71999. declare module BABYLON {
  72000. /**
  72001. * Defines potential orientation for back face culling
  72002. */
  72003. export enum Orientation {
  72004. /**
  72005. * Clockwise
  72006. */
  72007. CW = 0,
  72008. /** Counter clockwise */
  72009. CCW = 1
  72010. }
  72011. /** Class used to represent a Bezier curve */
  72012. export class BezierCurve {
  72013. /**
  72014. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  72015. * @param t defines the time
  72016. * @param x1 defines the left coordinate on X axis
  72017. * @param y1 defines the left coordinate on Y axis
  72018. * @param x2 defines the right coordinate on X axis
  72019. * @param y2 defines the right coordinate on Y axis
  72020. * @returns the interpolated value
  72021. */
  72022. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  72023. }
  72024. /**
  72025. * Defines angle representation
  72026. */
  72027. export class Angle {
  72028. private _radians;
  72029. /**
  72030. * Creates an Angle object of "radians" radians (float).
  72031. * @param radians the angle in radians
  72032. */
  72033. constructor(radians: number);
  72034. /**
  72035. * Get value in degrees
  72036. * @returns the Angle value in degrees (float)
  72037. */
  72038. degrees(): number;
  72039. /**
  72040. * Get value in radians
  72041. * @returns the Angle value in radians (float)
  72042. */
  72043. radians(): number;
  72044. /**
  72045. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  72046. * @param a defines first vector
  72047. * @param b defines second vector
  72048. * @returns a new Angle
  72049. */
  72050. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  72051. /**
  72052. * Gets a new Angle object from the given float in radians
  72053. * @param radians defines the angle value in radians
  72054. * @returns a new Angle
  72055. */
  72056. static FromRadians(radians: number): Angle;
  72057. /**
  72058. * Gets a new Angle object from the given float in degrees
  72059. * @param degrees defines the angle value in degrees
  72060. * @returns a new Angle
  72061. */
  72062. static FromDegrees(degrees: number): Angle;
  72063. }
  72064. /**
  72065. * This represents an arc in a 2d space.
  72066. */
  72067. export class Arc2 {
  72068. /** Defines the start point of the arc */
  72069. startPoint: Vector2;
  72070. /** Defines the mid point of the arc */
  72071. midPoint: Vector2;
  72072. /** Defines the end point of the arc */
  72073. endPoint: Vector2;
  72074. /**
  72075. * Defines the center point of the arc.
  72076. */
  72077. centerPoint: Vector2;
  72078. /**
  72079. * Defines the radius of the arc.
  72080. */
  72081. radius: number;
  72082. /**
  72083. * Defines the angle of the arc (from mid point to end point).
  72084. */
  72085. angle: Angle;
  72086. /**
  72087. * Defines the start angle of the arc (from start point to middle point).
  72088. */
  72089. startAngle: Angle;
  72090. /**
  72091. * Defines the orientation of the arc (clock wise/counter clock wise).
  72092. */
  72093. orientation: Orientation;
  72094. /**
  72095. * Creates an Arc object from the three given points : start, middle and end.
  72096. * @param startPoint Defines the start point of the arc
  72097. * @param midPoint Defines the midlle point of the arc
  72098. * @param endPoint Defines the end point of the arc
  72099. */
  72100. constructor(
  72101. /** Defines the start point of the arc */
  72102. startPoint: Vector2,
  72103. /** Defines the mid point of the arc */
  72104. midPoint: Vector2,
  72105. /** Defines the end point of the arc */
  72106. endPoint: Vector2);
  72107. }
  72108. /**
  72109. * Represents a 2D path made up of multiple 2D points
  72110. */
  72111. export class Path2 {
  72112. private _points;
  72113. private _length;
  72114. /**
  72115. * If the path start and end point are the same
  72116. */
  72117. closed: boolean;
  72118. /**
  72119. * Creates a Path2 object from the starting 2D coordinates x and y.
  72120. * @param x the starting points x value
  72121. * @param y the starting points y value
  72122. */
  72123. constructor(x: number, y: number);
  72124. /**
  72125. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  72126. * @param x the added points x value
  72127. * @param y the added points y value
  72128. * @returns the updated Path2.
  72129. */
  72130. addLineTo(x: number, y: number): Path2;
  72131. /**
  72132. * 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.
  72133. * @param midX middle point x value
  72134. * @param midY middle point y value
  72135. * @param endX end point x value
  72136. * @param endY end point y value
  72137. * @param numberOfSegments (default: 36)
  72138. * @returns the updated Path2.
  72139. */
  72140. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  72141. /**
  72142. * Closes the Path2.
  72143. * @returns the Path2.
  72144. */
  72145. close(): Path2;
  72146. /**
  72147. * Gets the sum of the distance between each sequential point in the path
  72148. * @returns the Path2 total length (float).
  72149. */
  72150. length(): number;
  72151. /**
  72152. * Gets the points which construct the path
  72153. * @returns the Path2 internal array of points.
  72154. */
  72155. getPoints(): Vector2[];
  72156. /**
  72157. * Retreives the point at the distance aways from the starting point
  72158. * @param normalizedLengthPosition the length along the path to retreive the point from
  72159. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  72160. */
  72161. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  72162. /**
  72163. * Creates a new path starting from an x and y position
  72164. * @param x starting x value
  72165. * @param y starting y value
  72166. * @returns a new Path2 starting at the coordinates (x, y).
  72167. */
  72168. static StartingAt(x: number, y: number): Path2;
  72169. }
  72170. /**
  72171. * Represents a 3D path made up of multiple 3D points
  72172. */
  72173. export class Path3D {
  72174. /**
  72175. * an array of Vector3, the curve axis of the Path3D
  72176. */
  72177. path: Vector3[];
  72178. private _curve;
  72179. private _distances;
  72180. private _tangents;
  72181. private _normals;
  72182. private _binormals;
  72183. private _raw;
  72184. /**
  72185. * new Path3D(path, normal, raw)
  72186. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  72187. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  72188. * @param path an array of Vector3, the curve axis of the Path3D
  72189. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  72190. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  72191. */
  72192. constructor(
  72193. /**
  72194. * an array of Vector3, the curve axis of the Path3D
  72195. */
  72196. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  72197. /**
  72198. * Returns the Path3D array of successive Vector3 designing its curve.
  72199. * @returns the Path3D array of successive Vector3 designing its curve.
  72200. */
  72201. getCurve(): Vector3[];
  72202. /**
  72203. * Returns an array populated with tangent vectors on each Path3D curve point.
  72204. * @returns an array populated with tangent vectors on each Path3D curve point.
  72205. */
  72206. getTangents(): Vector3[];
  72207. /**
  72208. * Returns an array populated with normal vectors on each Path3D curve point.
  72209. * @returns an array populated with normal vectors on each Path3D curve point.
  72210. */
  72211. getNormals(): Vector3[];
  72212. /**
  72213. * Returns an array populated with binormal vectors on each Path3D curve point.
  72214. * @returns an array populated with binormal vectors on each Path3D curve point.
  72215. */
  72216. getBinormals(): Vector3[];
  72217. /**
  72218. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  72219. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  72220. */
  72221. getDistances(): number[];
  72222. /**
  72223. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  72224. * @param path path which all values are copied into the curves points
  72225. * @param firstNormal which should be projected onto the curve
  72226. * @returns the same object updated.
  72227. */
  72228. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  72229. private _compute;
  72230. private _getFirstNonNullVector;
  72231. private _getLastNonNullVector;
  72232. private _normalVector;
  72233. }
  72234. /**
  72235. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  72236. * A Curve3 is designed from a series of successive Vector3.
  72237. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  72238. */
  72239. export class Curve3 {
  72240. private _points;
  72241. private _length;
  72242. /**
  72243. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  72244. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  72245. * @param v1 (Vector3) the control point
  72246. * @param v2 (Vector3) the end point of the Quadratic Bezier
  72247. * @param nbPoints (integer) the wanted number of points in the curve
  72248. * @returns the created Curve3
  72249. */
  72250. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  72251. /**
  72252. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  72253. * @param v0 (Vector3) the origin point of the Cubic Bezier
  72254. * @param v1 (Vector3) the first control point
  72255. * @param v2 (Vector3) the second control point
  72256. * @param v3 (Vector3) the end point of the Cubic Bezier
  72257. * @param nbPoints (integer) the wanted number of points in the curve
  72258. * @returns the created Curve3
  72259. */
  72260. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  72261. /**
  72262. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  72263. * @param p1 (Vector3) the origin point of the Hermite Spline
  72264. * @param t1 (Vector3) the tangent vector at the origin point
  72265. * @param p2 (Vector3) the end point of the Hermite Spline
  72266. * @param t2 (Vector3) the tangent vector at the end point
  72267. * @param nbPoints (integer) the wanted number of points in the curve
  72268. * @returns the created Curve3
  72269. */
  72270. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  72271. /**
  72272. * Returns a Curve3 object along a CatmullRom Spline curve :
  72273. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  72274. * @param nbPoints (integer) the wanted number of points between each curve control points
  72275. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  72276. * @returns the created Curve3
  72277. */
  72278. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  72279. /**
  72280. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  72281. * A Curve3 is designed from a series of successive Vector3.
  72282. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  72283. * @param points points which make up the curve
  72284. */
  72285. constructor(points: Vector3[]);
  72286. /**
  72287. * @returns the Curve3 stored array of successive Vector3
  72288. */
  72289. getPoints(): Vector3[];
  72290. /**
  72291. * @returns the computed length (float) of the curve.
  72292. */
  72293. length(): number;
  72294. /**
  72295. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  72296. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  72297. * curveA and curveB keep unchanged.
  72298. * @param curve the curve to continue from this curve
  72299. * @returns the newly constructed curve
  72300. */
  72301. continue(curve: DeepImmutable<Curve3>): Curve3;
  72302. private _computeLength;
  72303. }
  72304. }
  72305. declare module BABYLON {
  72306. /**
  72307. * This represents the main contract an easing function should follow.
  72308. * Easing functions are used throughout the animation system.
  72309. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72310. */
  72311. export interface IEasingFunction {
  72312. /**
  72313. * Given an input gradient between 0 and 1, this returns the corrseponding value
  72314. * of the easing function.
  72315. * The link below provides some of the most common examples of easing functions.
  72316. * @see https://easings.net/
  72317. * @param gradient Defines the value between 0 and 1 we want the easing value for
  72318. * @returns the corresponding value on the curve defined by the easing function
  72319. */
  72320. ease(gradient: number): number;
  72321. }
  72322. /**
  72323. * Base class used for every default easing function.
  72324. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72325. */
  72326. export class EasingFunction implements IEasingFunction {
  72327. /**
  72328. * Interpolation follows the mathematical formula associated with the easing function.
  72329. */
  72330. static readonly EASINGMODE_EASEIN: number;
  72331. /**
  72332. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  72333. */
  72334. static readonly EASINGMODE_EASEOUT: number;
  72335. /**
  72336. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  72337. */
  72338. static readonly EASINGMODE_EASEINOUT: number;
  72339. private _easingMode;
  72340. /**
  72341. * Sets the easing mode of the current function.
  72342. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  72343. */
  72344. setEasingMode(easingMode: number): void;
  72345. /**
  72346. * Gets the current easing mode.
  72347. * @returns the easing mode
  72348. */
  72349. getEasingMode(): number;
  72350. /**
  72351. * @hidden
  72352. */
  72353. easeInCore(gradient: number): number;
  72354. /**
  72355. * Given an input gradient between 0 and 1, this returns the corresponding value
  72356. * of the easing function.
  72357. * @param gradient Defines the value between 0 and 1 we want the easing value for
  72358. * @returns the corresponding value on the curve defined by the easing function
  72359. */
  72360. ease(gradient: number): number;
  72361. }
  72362. /**
  72363. * Easing function with a circle shape (see link below).
  72364. * @see https://easings.net/#easeInCirc
  72365. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72366. */
  72367. export class CircleEase extends EasingFunction implements IEasingFunction {
  72368. /** @hidden */
  72369. easeInCore(gradient: number): number;
  72370. }
  72371. /**
  72372. * Easing function with a ease back shape (see link below).
  72373. * @see https://easings.net/#easeInBack
  72374. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72375. */
  72376. export class BackEase extends EasingFunction implements IEasingFunction {
  72377. /** Defines the amplitude of the function */
  72378. amplitude: number;
  72379. /**
  72380. * Instantiates a back ease easing
  72381. * @see https://easings.net/#easeInBack
  72382. * @param amplitude Defines the amplitude of the function
  72383. */
  72384. constructor(
  72385. /** Defines the amplitude of the function */
  72386. amplitude?: number);
  72387. /** @hidden */
  72388. easeInCore(gradient: number): number;
  72389. }
  72390. /**
  72391. * Easing function with a bouncing shape (see link below).
  72392. * @see https://easings.net/#easeInBounce
  72393. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72394. */
  72395. export class BounceEase extends EasingFunction implements IEasingFunction {
  72396. /** Defines the number of bounces */
  72397. bounces: number;
  72398. /** Defines the amplitude of the bounce */
  72399. bounciness: number;
  72400. /**
  72401. * Instantiates a bounce easing
  72402. * @see https://easings.net/#easeInBounce
  72403. * @param bounces Defines the number of bounces
  72404. * @param bounciness Defines the amplitude of the bounce
  72405. */
  72406. constructor(
  72407. /** Defines the number of bounces */
  72408. bounces?: number,
  72409. /** Defines the amplitude of the bounce */
  72410. bounciness?: number);
  72411. /** @hidden */
  72412. easeInCore(gradient: number): number;
  72413. }
  72414. /**
  72415. * Easing function with a power of 3 shape (see link below).
  72416. * @see https://easings.net/#easeInCubic
  72417. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72418. */
  72419. export class CubicEase extends EasingFunction implements IEasingFunction {
  72420. /** @hidden */
  72421. easeInCore(gradient: number): number;
  72422. }
  72423. /**
  72424. * Easing function with an elastic shape (see link below).
  72425. * @see https://easings.net/#easeInElastic
  72426. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72427. */
  72428. export class ElasticEase extends EasingFunction implements IEasingFunction {
  72429. /** Defines the number of oscillations*/
  72430. oscillations: number;
  72431. /** Defines the amplitude of the oscillations*/
  72432. springiness: number;
  72433. /**
  72434. * Instantiates an elastic easing function
  72435. * @see https://easings.net/#easeInElastic
  72436. * @param oscillations Defines the number of oscillations
  72437. * @param springiness Defines the amplitude of the oscillations
  72438. */
  72439. constructor(
  72440. /** Defines the number of oscillations*/
  72441. oscillations?: number,
  72442. /** Defines the amplitude of the oscillations*/
  72443. springiness?: number);
  72444. /** @hidden */
  72445. easeInCore(gradient: number): number;
  72446. }
  72447. /**
  72448. * Easing function with an exponential shape (see link below).
  72449. * @see https://easings.net/#easeInExpo
  72450. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72451. */
  72452. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  72453. /** Defines the exponent of the function */
  72454. exponent: number;
  72455. /**
  72456. * Instantiates an exponential easing function
  72457. * @see https://easings.net/#easeInExpo
  72458. * @param exponent Defines the exponent of the function
  72459. */
  72460. constructor(
  72461. /** Defines the exponent of the function */
  72462. exponent?: number);
  72463. /** @hidden */
  72464. easeInCore(gradient: number): number;
  72465. }
  72466. /**
  72467. * Easing function with a power shape (see link below).
  72468. * @see https://easings.net/#easeInQuad
  72469. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72470. */
  72471. export class PowerEase extends EasingFunction implements IEasingFunction {
  72472. /** Defines the power of the function */
  72473. power: number;
  72474. /**
  72475. * Instantiates an power base easing function
  72476. * @see https://easings.net/#easeInQuad
  72477. * @param power Defines the power of the function
  72478. */
  72479. constructor(
  72480. /** Defines the power of the function */
  72481. power?: number);
  72482. /** @hidden */
  72483. easeInCore(gradient: number): number;
  72484. }
  72485. /**
  72486. * Easing function with a power of 2 shape (see link below).
  72487. * @see https://easings.net/#easeInQuad
  72488. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72489. */
  72490. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  72491. /** @hidden */
  72492. easeInCore(gradient: number): number;
  72493. }
  72494. /**
  72495. * Easing function with a power of 4 shape (see link below).
  72496. * @see https://easings.net/#easeInQuart
  72497. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72498. */
  72499. export class QuarticEase extends EasingFunction implements IEasingFunction {
  72500. /** @hidden */
  72501. easeInCore(gradient: number): number;
  72502. }
  72503. /**
  72504. * Easing function with a power of 5 shape (see link below).
  72505. * @see https://easings.net/#easeInQuint
  72506. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72507. */
  72508. export class QuinticEase extends EasingFunction implements IEasingFunction {
  72509. /** @hidden */
  72510. easeInCore(gradient: number): number;
  72511. }
  72512. /**
  72513. * Easing function with a sin shape (see link below).
  72514. * @see https://easings.net/#easeInSine
  72515. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72516. */
  72517. export class SineEase extends EasingFunction implements IEasingFunction {
  72518. /** @hidden */
  72519. easeInCore(gradient: number): number;
  72520. }
  72521. /**
  72522. * Easing function with a bezier shape (see link below).
  72523. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  72524. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72525. */
  72526. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  72527. /** Defines the x component of the start tangent in the bezier curve */
  72528. x1: number;
  72529. /** Defines the y component of the start tangent in the bezier curve */
  72530. y1: number;
  72531. /** Defines the x component of the end tangent in the bezier curve */
  72532. x2: number;
  72533. /** Defines the y component of the end tangent in the bezier curve */
  72534. y2: number;
  72535. /**
  72536. * Instantiates a bezier function
  72537. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  72538. * @param x1 Defines the x component of the start tangent in the bezier curve
  72539. * @param y1 Defines the y component of the start tangent in the bezier curve
  72540. * @param x2 Defines the x component of the end tangent in the bezier curve
  72541. * @param y2 Defines the y component of the end tangent in the bezier curve
  72542. */
  72543. constructor(
  72544. /** Defines the x component of the start tangent in the bezier curve */
  72545. x1?: number,
  72546. /** Defines the y component of the start tangent in the bezier curve */
  72547. y1?: number,
  72548. /** Defines the x component of the end tangent in the bezier curve */
  72549. x2?: number,
  72550. /** Defines the y component of the end tangent in the bezier curve */
  72551. y2?: number);
  72552. /** @hidden */
  72553. easeInCore(gradient: number): number;
  72554. }
  72555. }
  72556. declare module BABYLON {
  72557. /**
  72558. * Defines an interface which represents an animation key frame
  72559. */
  72560. export interface IAnimationKey {
  72561. /**
  72562. * Frame of the key frame
  72563. */
  72564. frame: number;
  72565. /**
  72566. * Value at the specifies key frame
  72567. */
  72568. value: any;
  72569. /**
  72570. * The input tangent for the cubic hermite spline
  72571. */
  72572. inTangent?: any;
  72573. /**
  72574. * The output tangent for the cubic hermite spline
  72575. */
  72576. outTangent?: any;
  72577. /**
  72578. * The animation interpolation type
  72579. */
  72580. interpolation?: AnimationKeyInterpolation;
  72581. }
  72582. /**
  72583. * Enum for the animation key frame interpolation type
  72584. */
  72585. export enum AnimationKeyInterpolation {
  72586. /**
  72587. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  72588. */
  72589. STEP = 1
  72590. }
  72591. }
  72592. declare module BABYLON {
  72593. /**
  72594. * Represents the range of an animation
  72595. */
  72596. export class AnimationRange {
  72597. /**The name of the animation range**/
  72598. name: string;
  72599. /**The starting frame of the animation */
  72600. from: number;
  72601. /**The ending frame of the animation*/
  72602. to: number;
  72603. /**
  72604. * Initializes the range of an animation
  72605. * @param name The name of the animation range
  72606. * @param from The starting frame of the animation
  72607. * @param to The ending frame of the animation
  72608. */
  72609. constructor(
  72610. /**The name of the animation range**/
  72611. name: string,
  72612. /**The starting frame of the animation */
  72613. from: number,
  72614. /**The ending frame of the animation*/
  72615. to: number);
  72616. /**
  72617. * Makes a copy of the animation range
  72618. * @returns A copy of the animation range
  72619. */
  72620. clone(): AnimationRange;
  72621. }
  72622. }
  72623. declare module BABYLON {
  72624. /**
  72625. * Composed of a frame, and an action function
  72626. */
  72627. export class AnimationEvent {
  72628. /** The frame for which the event is triggered **/
  72629. frame: number;
  72630. /** The event to perform when triggered **/
  72631. action: (currentFrame: number) => void;
  72632. /** Specifies if the event should be triggered only once**/
  72633. onlyOnce?: boolean | undefined;
  72634. /**
  72635. * Specifies if the animation event is done
  72636. */
  72637. isDone: boolean;
  72638. /**
  72639. * Initializes the animation event
  72640. * @param frame The frame for which the event is triggered
  72641. * @param action The event to perform when triggered
  72642. * @param onlyOnce Specifies if the event should be triggered only once
  72643. */
  72644. constructor(
  72645. /** The frame for which the event is triggered **/
  72646. frame: number,
  72647. /** The event to perform when triggered **/
  72648. action: (currentFrame: number) => void,
  72649. /** Specifies if the event should be triggered only once**/
  72650. onlyOnce?: boolean | undefined);
  72651. /** @hidden */
  72652. _clone(): AnimationEvent;
  72653. }
  72654. }
  72655. declare module BABYLON {
  72656. /**
  72657. * Interface used to define a behavior
  72658. */
  72659. export interface Behavior<T> {
  72660. /** gets or sets behavior's name */
  72661. name: string;
  72662. /**
  72663. * Function called when the behavior needs to be initialized (after attaching it to a target)
  72664. */
  72665. init(): void;
  72666. /**
  72667. * Called when the behavior is attached to a target
  72668. * @param target defines the target where the behavior is attached to
  72669. */
  72670. attach(target: T): void;
  72671. /**
  72672. * Called when the behavior is detached from its target
  72673. */
  72674. detach(): void;
  72675. }
  72676. /**
  72677. * Interface implemented by classes supporting behaviors
  72678. */
  72679. export interface IBehaviorAware<T> {
  72680. /**
  72681. * Attach a behavior
  72682. * @param behavior defines the behavior to attach
  72683. * @returns the current host
  72684. */
  72685. addBehavior(behavior: Behavior<T>): T;
  72686. /**
  72687. * Remove a behavior from the current object
  72688. * @param behavior defines the behavior to detach
  72689. * @returns the current host
  72690. */
  72691. removeBehavior(behavior: Behavior<T>): T;
  72692. /**
  72693. * Gets a behavior using its name to search
  72694. * @param name defines the name to search
  72695. * @returns the behavior or null if not found
  72696. */
  72697. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  72698. }
  72699. }
  72700. declare module BABYLON {
  72701. /**
  72702. * Defines an array and its length.
  72703. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  72704. */
  72705. export interface ISmartArrayLike<T> {
  72706. /**
  72707. * The data of the array.
  72708. */
  72709. data: Array<T>;
  72710. /**
  72711. * The active length of the array.
  72712. */
  72713. length: number;
  72714. }
  72715. /**
  72716. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  72717. */
  72718. export class SmartArray<T> implements ISmartArrayLike<T> {
  72719. /**
  72720. * The full set of data from the array.
  72721. */
  72722. data: Array<T>;
  72723. /**
  72724. * The active length of the array.
  72725. */
  72726. length: number;
  72727. protected _id: number;
  72728. /**
  72729. * Instantiates a Smart Array.
  72730. * @param capacity defines the default capacity of the array.
  72731. */
  72732. constructor(capacity: number);
  72733. /**
  72734. * Pushes a value at the end of the active data.
  72735. * @param value defines the object to push in the array.
  72736. */
  72737. push(value: T): void;
  72738. /**
  72739. * Iterates over the active data and apply the lambda to them.
  72740. * @param func defines the action to apply on each value.
  72741. */
  72742. forEach(func: (content: T) => void): void;
  72743. /**
  72744. * Sorts the full sets of data.
  72745. * @param compareFn defines the comparison function to apply.
  72746. */
  72747. sort(compareFn: (a: T, b: T) => number): void;
  72748. /**
  72749. * Resets the active data to an empty array.
  72750. */
  72751. reset(): void;
  72752. /**
  72753. * Releases all the data from the array as well as the array.
  72754. */
  72755. dispose(): void;
  72756. /**
  72757. * Concats the active data with a given array.
  72758. * @param array defines the data to concatenate with.
  72759. */
  72760. concat(array: any): void;
  72761. /**
  72762. * Returns the position of a value in the active data.
  72763. * @param value defines the value to find the index for
  72764. * @returns the index if found in the active data otherwise -1
  72765. */
  72766. indexOf(value: T): number;
  72767. /**
  72768. * Returns whether an element is part of the active data.
  72769. * @param value defines the value to look for
  72770. * @returns true if found in the active data otherwise false
  72771. */
  72772. contains(value: T): boolean;
  72773. private static _GlobalId;
  72774. }
  72775. /**
  72776. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  72777. * The data in this array can only be present once
  72778. */
  72779. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  72780. private _duplicateId;
  72781. /**
  72782. * Pushes a value at the end of the active data.
  72783. * THIS DOES NOT PREVENT DUPPLICATE DATA
  72784. * @param value defines the object to push in the array.
  72785. */
  72786. push(value: T): void;
  72787. /**
  72788. * Pushes a value at the end of the active data.
  72789. * If the data is already present, it won t be added again
  72790. * @param value defines the object to push in the array.
  72791. * @returns true if added false if it was already present
  72792. */
  72793. pushNoDuplicate(value: T): boolean;
  72794. /**
  72795. * Resets the active data to an empty array.
  72796. */
  72797. reset(): void;
  72798. /**
  72799. * Concats the active data with a given array.
  72800. * This ensures no dupplicate will be present in the result.
  72801. * @param array defines the data to concatenate with.
  72802. */
  72803. concatWithNoDuplicate(array: any): void;
  72804. }
  72805. }
  72806. declare module BABYLON {
  72807. /**
  72808. * @ignore
  72809. * This is a list of all the different input types that are available in the application.
  72810. * Fo instance: ArcRotateCameraGamepadInput...
  72811. */
  72812. export var CameraInputTypes: {};
  72813. /**
  72814. * This is the contract to implement in order to create a new input class.
  72815. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  72816. */
  72817. export interface ICameraInput<TCamera extends Camera> {
  72818. /**
  72819. * Defines the camera the input is attached to.
  72820. */
  72821. camera: Nullable<TCamera>;
  72822. /**
  72823. * Gets the class name of the current intput.
  72824. * @returns the class name
  72825. */
  72826. getClassName(): string;
  72827. /**
  72828. * Get the friendly name associated with the input class.
  72829. * @returns the input friendly name
  72830. */
  72831. getSimpleName(): string;
  72832. /**
  72833. * Attach the input controls to a specific dom element to get the input from.
  72834. * @param element Defines the element the controls should be listened from
  72835. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72836. */
  72837. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72838. /**
  72839. * Detach the current controls from the specified dom element.
  72840. * @param element Defines the element to stop listening the inputs from
  72841. */
  72842. detachControl(element: Nullable<HTMLElement>): void;
  72843. /**
  72844. * Update the current camera state depending on the inputs that have been used this frame.
  72845. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  72846. */
  72847. checkInputs?: () => void;
  72848. }
  72849. /**
  72850. * Represents a map of input types to input instance or input index to input instance.
  72851. */
  72852. export interface CameraInputsMap<TCamera extends Camera> {
  72853. /**
  72854. * Accessor to the input by input type.
  72855. */
  72856. [name: string]: ICameraInput<TCamera>;
  72857. /**
  72858. * Accessor to the input by input index.
  72859. */
  72860. [idx: number]: ICameraInput<TCamera>;
  72861. }
  72862. /**
  72863. * This represents the input manager used within a camera.
  72864. * It helps dealing with all the different kind of input attached to a camera.
  72865. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72866. */
  72867. export class CameraInputsManager<TCamera extends Camera> {
  72868. /**
  72869. * Defines the list of inputs attahed to the camera.
  72870. */
  72871. attached: CameraInputsMap<TCamera>;
  72872. /**
  72873. * Defines the dom element the camera is collecting inputs from.
  72874. * This is null if the controls have not been attached.
  72875. */
  72876. attachedElement: Nullable<HTMLElement>;
  72877. /**
  72878. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72879. */
  72880. noPreventDefault: boolean;
  72881. /**
  72882. * Defined the camera the input manager belongs to.
  72883. */
  72884. camera: TCamera;
  72885. /**
  72886. * Update the current camera state depending on the inputs that have been used this frame.
  72887. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  72888. */
  72889. checkInputs: () => void;
  72890. /**
  72891. * Instantiate a new Camera Input Manager.
  72892. * @param camera Defines the camera the input manager blongs to
  72893. */
  72894. constructor(camera: TCamera);
  72895. /**
  72896. * Add an input method to a camera
  72897. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72898. * @param input camera input method
  72899. */
  72900. add(input: ICameraInput<TCamera>): void;
  72901. /**
  72902. * Remove a specific input method from a camera
  72903. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  72904. * @param inputToRemove camera input method
  72905. */
  72906. remove(inputToRemove: ICameraInput<TCamera>): void;
  72907. /**
  72908. * Remove a specific input type from a camera
  72909. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  72910. * @param inputType the type of the input to remove
  72911. */
  72912. removeByType(inputType: string): void;
  72913. private _addCheckInputs;
  72914. /**
  72915. * Attach the input controls to the currently attached dom element to listen the events from.
  72916. * @param input Defines the input to attach
  72917. */
  72918. attachInput(input: ICameraInput<TCamera>): void;
  72919. /**
  72920. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  72921. * @param element Defines the dom element to collect the events from
  72922. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72923. */
  72924. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  72925. /**
  72926. * Detach the current manager inputs controls from a specific dom element.
  72927. * @param element Defines the dom element to collect the events from
  72928. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  72929. */
  72930. detachElement(element: HTMLElement, disconnect?: boolean): void;
  72931. /**
  72932. * Rebuild the dynamic inputCheck function from the current list of
  72933. * defined inputs in the manager.
  72934. */
  72935. rebuildInputCheck(): void;
  72936. /**
  72937. * Remove all attached input methods from a camera
  72938. */
  72939. clear(): void;
  72940. /**
  72941. * Serialize the current input manager attached to a camera.
  72942. * This ensures than once parsed,
  72943. * the input associated to the camera will be identical to the current ones
  72944. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  72945. */
  72946. serialize(serializedCamera: any): void;
  72947. /**
  72948. * Parses an input manager serialized JSON to restore the previous list of inputs
  72949. * and states associated to a camera.
  72950. * @param parsedCamera Defines the JSON to parse
  72951. */
  72952. parse(parsedCamera: any): void;
  72953. }
  72954. }
  72955. declare module BABYLON {
  72956. /**
  72957. * Class used to store data that will be store in GPU memory
  72958. */
  72959. export class Buffer {
  72960. private _engine;
  72961. private _buffer;
  72962. /** @hidden */
  72963. _data: Nullable<DataArray>;
  72964. private _updatable;
  72965. private _instanced;
  72966. /**
  72967. * Gets the byte stride.
  72968. */
  72969. readonly byteStride: number;
  72970. /**
  72971. * Constructor
  72972. * @param engine the engine
  72973. * @param data the data to use for this buffer
  72974. * @param updatable whether the data is updatable
  72975. * @param stride the stride (optional)
  72976. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  72977. * @param instanced whether the buffer is instanced (optional)
  72978. * @param useBytes set to true if the stride in in bytes (optional)
  72979. */
  72980. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  72981. /**
  72982. * Create a new VertexBuffer based on the current buffer
  72983. * @param kind defines the vertex buffer kind (position, normal, etc.)
  72984. * @param offset defines offset in the buffer (0 by default)
  72985. * @param size defines the size in floats of attributes (position is 3 for instance)
  72986. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  72987. * @param instanced defines if the vertex buffer contains indexed data
  72988. * @param useBytes defines if the offset and stride are in bytes
  72989. * @returns the new vertex buffer
  72990. */
  72991. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  72992. /**
  72993. * Gets a boolean indicating if the Buffer is updatable?
  72994. * @returns true if the buffer is updatable
  72995. */
  72996. isUpdatable(): boolean;
  72997. /**
  72998. * Gets current buffer's data
  72999. * @returns a DataArray or null
  73000. */
  73001. getData(): Nullable<DataArray>;
  73002. /**
  73003. * Gets underlying native buffer
  73004. * @returns underlying native buffer
  73005. */
  73006. getBuffer(): Nullable<DataBuffer>;
  73007. /**
  73008. * Gets the stride in float32 units (i.e. byte stride / 4).
  73009. * May not be an integer if the byte stride is not divisible by 4.
  73010. * DEPRECATED. Use byteStride instead.
  73011. * @returns the stride in float32 units
  73012. */
  73013. getStrideSize(): number;
  73014. /**
  73015. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  73016. * @param data defines the data to store
  73017. */
  73018. create(data?: Nullable<DataArray>): void;
  73019. /** @hidden */
  73020. _rebuild(): void;
  73021. /**
  73022. * Update current buffer data
  73023. * @param data defines the data to store
  73024. */
  73025. update(data: DataArray): void;
  73026. /**
  73027. * Updates the data directly.
  73028. * @param data the new data
  73029. * @param offset the new offset
  73030. * @param vertexCount the vertex count (optional)
  73031. * @param useBytes set to true if the offset is in bytes
  73032. */
  73033. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  73034. /**
  73035. * Release all resources
  73036. */
  73037. dispose(): void;
  73038. }
  73039. /**
  73040. * Specialized buffer used to store vertex data
  73041. */
  73042. export class VertexBuffer {
  73043. /** @hidden */
  73044. _buffer: Buffer;
  73045. private _kind;
  73046. private _size;
  73047. private _ownsBuffer;
  73048. private _instanced;
  73049. private _instanceDivisor;
  73050. /**
  73051. * The byte type.
  73052. */
  73053. static readonly BYTE: number;
  73054. /**
  73055. * The unsigned byte type.
  73056. */
  73057. static readonly UNSIGNED_BYTE: number;
  73058. /**
  73059. * The short type.
  73060. */
  73061. static readonly SHORT: number;
  73062. /**
  73063. * The unsigned short type.
  73064. */
  73065. static readonly UNSIGNED_SHORT: number;
  73066. /**
  73067. * The integer type.
  73068. */
  73069. static readonly INT: number;
  73070. /**
  73071. * The unsigned integer type.
  73072. */
  73073. static readonly UNSIGNED_INT: number;
  73074. /**
  73075. * The float type.
  73076. */
  73077. static readonly FLOAT: number;
  73078. /**
  73079. * Gets or sets the instance divisor when in instanced mode
  73080. */
  73081. instanceDivisor: number;
  73082. /**
  73083. * Gets the byte stride.
  73084. */
  73085. readonly byteStride: number;
  73086. /**
  73087. * Gets the byte offset.
  73088. */
  73089. readonly byteOffset: number;
  73090. /**
  73091. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  73092. */
  73093. readonly normalized: boolean;
  73094. /**
  73095. * Gets the data type of each component in the array.
  73096. */
  73097. readonly type: number;
  73098. /**
  73099. * Constructor
  73100. * @param engine the engine
  73101. * @param data the data to use for this vertex buffer
  73102. * @param kind the vertex buffer kind
  73103. * @param updatable whether the data is updatable
  73104. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  73105. * @param stride the stride (optional)
  73106. * @param instanced whether the buffer is instanced (optional)
  73107. * @param offset the offset of the data (optional)
  73108. * @param size the number of components (optional)
  73109. * @param type the type of the component (optional)
  73110. * @param normalized whether the data contains normalized data (optional)
  73111. * @param useBytes set to true if stride and offset are in bytes (optional)
  73112. */
  73113. 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);
  73114. /** @hidden */
  73115. _rebuild(): void;
  73116. /**
  73117. * Returns the kind of the VertexBuffer (string)
  73118. * @returns a string
  73119. */
  73120. getKind(): string;
  73121. /**
  73122. * Gets a boolean indicating if the VertexBuffer is updatable?
  73123. * @returns true if the buffer is updatable
  73124. */
  73125. isUpdatable(): boolean;
  73126. /**
  73127. * Gets current buffer's data
  73128. * @returns a DataArray or null
  73129. */
  73130. getData(): Nullable<DataArray>;
  73131. /**
  73132. * Gets underlying native buffer
  73133. * @returns underlying native buffer
  73134. */
  73135. getBuffer(): Nullable<DataBuffer>;
  73136. /**
  73137. * Gets the stride in float32 units (i.e. byte stride / 4).
  73138. * May not be an integer if the byte stride is not divisible by 4.
  73139. * DEPRECATED. Use byteStride instead.
  73140. * @returns the stride in float32 units
  73141. */
  73142. getStrideSize(): number;
  73143. /**
  73144. * Returns the offset as a multiple of the type byte length.
  73145. * DEPRECATED. Use byteOffset instead.
  73146. * @returns the offset in bytes
  73147. */
  73148. getOffset(): number;
  73149. /**
  73150. * Returns the number of components per vertex attribute (integer)
  73151. * @returns the size in float
  73152. */
  73153. getSize(): number;
  73154. /**
  73155. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  73156. * @returns true if this buffer is instanced
  73157. */
  73158. getIsInstanced(): boolean;
  73159. /**
  73160. * Returns the instancing divisor, zero for non-instanced (integer).
  73161. * @returns a number
  73162. */
  73163. getInstanceDivisor(): number;
  73164. /**
  73165. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  73166. * @param data defines the data to store
  73167. */
  73168. create(data?: DataArray): void;
  73169. /**
  73170. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  73171. * This function will create a new buffer if the current one is not updatable
  73172. * @param data defines the data to store
  73173. */
  73174. update(data: DataArray): void;
  73175. /**
  73176. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  73177. * Returns the directly updated WebGLBuffer.
  73178. * @param data the new data
  73179. * @param offset the new offset
  73180. * @param useBytes set to true if the offset is in bytes
  73181. */
  73182. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  73183. /**
  73184. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  73185. */
  73186. dispose(): void;
  73187. /**
  73188. * Enumerates each value of this vertex buffer as numbers.
  73189. * @param count the number of values to enumerate
  73190. * @param callback the callback function called for each value
  73191. */
  73192. forEach(count: number, callback: (value: number, index: number) => void): void;
  73193. /**
  73194. * Positions
  73195. */
  73196. static readonly PositionKind: string;
  73197. /**
  73198. * Normals
  73199. */
  73200. static readonly NormalKind: string;
  73201. /**
  73202. * Tangents
  73203. */
  73204. static readonly TangentKind: string;
  73205. /**
  73206. * Texture coordinates
  73207. */
  73208. static readonly UVKind: string;
  73209. /**
  73210. * Texture coordinates 2
  73211. */
  73212. static readonly UV2Kind: string;
  73213. /**
  73214. * Texture coordinates 3
  73215. */
  73216. static readonly UV3Kind: string;
  73217. /**
  73218. * Texture coordinates 4
  73219. */
  73220. static readonly UV4Kind: string;
  73221. /**
  73222. * Texture coordinates 5
  73223. */
  73224. static readonly UV5Kind: string;
  73225. /**
  73226. * Texture coordinates 6
  73227. */
  73228. static readonly UV6Kind: string;
  73229. /**
  73230. * Colors
  73231. */
  73232. static readonly ColorKind: string;
  73233. /**
  73234. * Matrix indices (for bones)
  73235. */
  73236. static readonly MatricesIndicesKind: string;
  73237. /**
  73238. * Matrix weights (for bones)
  73239. */
  73240. static readonly MatricesWeightsKind: string;
  73241. /**
  73242. * Additional matrix indices (for bones)
  73243. */
  73244. static readonly MatricesIndicesExtraKind: string;
  73245. /**
  73246. * Additional matrix weights (for bones)
  73247. */
  73248. static readonly MatricesWeightsExtraKind: string;
  73249. /**
  73250. * Deduces the stride given a kind.
  73251. * @param kind The kind string to deduce
  73252. * @returns The deduced stride
  73253. */
  73254. static DeduceStride(kind: string): number;
  73255. /**
  73256. * Gets the byte length of the given type.
  73257. * @param type the type
  73258. * @returns the number of bytes
  73259. */
  73260. static GetTypeByteLength(type: number): number;
  73261. /**
  73262. * Enumerates each value of the given parameters as numbers.
  73263. * @param data the data to enumerate
  73264. * @param byteOffset the byte offset of the data
  73265. * @param byteStride the byte stride of the data
  73266. * @param componentCount the number of components per element
  73267. * @param componentType the type of the component
  73268. * @param count the number of values to enumerate
  73269. * @param normalized whether the data is normalized
  73270. * @param callback the callback function called for each value
  73271. */
  73272. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  73273. private static _GetFloatValue;
  73274. }
  73275. }
  73276. declare module BABYLON {
  73277. /**
  73278. * @hidden
  73279. */
  73280. export class IntersectionInfo {
  73281. bu: Nullable<number>;
  73282. bv: Nullable<number>;
  73283. distance: number;
  73284. faceId: number;
  73285. subMeshId: number;
  73286. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  73287. }
  73288. }
  73289. declare module BABYLON {
  73290. /**
  73291. * Represens a plane by the equation ax + by + cz + d = 0
  73292. */
  73293. export class Plane {
  73294. private static _TmpMatrix;
  73295. /**
  73296. * Normal of the plane (a,b,c)
  73297. */
  73298. normal: Vector3;
  73299. /**
  73300. * d component of the plane
  73301. */
  73302. d: number;
  73303. /**
  73304. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  73305. * @param a a component of the plane
  73306. * @param b b component of the plane
  73307. * @param c c component of the plane
  73308. * @param d d component of the plane
  73309. */
  73310. constructor(a: number, b: number, c: number, d: number);
  73311. /**
  73312. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  73313. */
  73314. asArray(): number[];
  73315. /**
  73316. * @returns a new plane copied from the current Plane.
  73317. */
  73318. clone(): Plane;
  73319. /**
  73320. * @returns the string "Plane".
  73321. */
  73322. getClassName(): string;
  73323. /**
  73324. * @returns the Plane hash code.
  73325. */
  73326. getHashCode(): number;
  73327. /**
  73328. * Normalize the current Plane in place.
  73329. * @returns the updated Plane.
  73330. */
  73331. normalize(): Plane;
  73332. /**
  73333. * Applies a transformation the plane and returns the result
  73334. * @param transformation the transformation matrix to be applied to the plane
  73335. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  73336. */
  73337. transform(transformation: DeepImmutable<Matrix>): Plane;
  73338. /**
  73339. * Calcualtte the dot product between the point and the plane normal
  73340. * @param point point to calculate the dot product with
  73341. * @returns the dot product (float) of the point coordinates and the plane normal.
  73342. */
  73343. dotCoordinate(point: DeepImmutable<Vector3>): number;
  73344. /**
  73345. * Updates the current Plane from the plane defined by the three given points.
  73346. * @param point1 one of the points used to contruct the plane
  73347. * @param point2 one of the points used to contruct the plane
  73348. * @param point3 one of the points used to contruct the plane
  73349. * @returns the updated Plane.
  73350. */
  73351. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  73352. /**
  73353. * Checks if the plane is facing a given direction
  73354. * @param direction the direction to check if the plane is facing
  73355. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  73356. * @returns True is the vector "direction" is the same side than the plane normal.
  73357. */
  73358. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  73359. /**
  73360. * Calculates the distance to a point
  73361. * @param point point to calculate distance to
  73362. * @returns the signed distance (float) from the given point to the Plane.
  73363. */
  73364. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  73365. /**
  73366. * Creates a plane from an array
  73367. * @param array the array to create a plane from
  73368. * @returns a new Plane from the given array.
  73369. */
  73370. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  73371. /**
  73372. * Creates a plane from three points
  73373. * @param point1 point used to create the plane
  73374. * @param point2 point used to create the plane
  73375. * @param point3 point used to create the plane
  73376. * @returns a new Plane defined by the three given points.
  73377. */
  73378. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  73379. /**
  73380. * Creates a plane from an origin point and a normal
  73381. * @param origin origin of the plane to be constructed
  73382. * @param normal normal of the plane to be constructed
  73383. * @returns a new Plane the normal vector to this plane at the given origin point.
  73384. * Note : the vector "normal" is updated because normalized.
  73385. */
  73386. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  73387. /**
  73388. * Calculates the distance from a plane and a point
  73389. * @param origin origin of the plane to be constructed
  73390. * @param normal normal of the plane to be constructed
  73391. * @param point point to calculate distance to
  73392. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  73393. */
  73394. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  73395. }
  73396. }
  73397. declare module BABYLON {
  73398. /**
  73399. * Class used to store bounding sphere information
  73400. */
  73401. export class BoundingSphere {
  73402. /**
  73403. * Gets the center of the bounding sphere in local space
  73404. */
  73405. readonly center: Vector3;
  73406. /**
  73407. * Radius of the bounding sphere in local space
  73408. */
  73409. radius: number;
  73410. /**
  73411. * Gets the center of the bounding sphere in world space
  73412. */
  73413. readonly centerWorld: Vector3;
  73414. /**
  73415. * Radius of the bounding sphere in world space
  73416. */
  73417. radiusWorld: number;
  73418. /**
  73419. * Gets the minimum vector in local space
  73420. */
  73421. readonly minimum: Vector3;
  73422. /**
  73423. * Gets the maximum vector in local space
  73424. */
  73425. readonly maximum: Vector3;
  73426. private _worldMatrix;
  73427. private static readonly TmpVector3;
  73428. /**
  73429. * Creates a new bounding sphere
  73430. * @param min defines the minimum vector (in local space)
  73431. * @param max defines the maximum vector (in local space)
  73432. * @param worldMatrix defines the new world matrix
  73433. */
  73434. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  73435. /**
  73436. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  73437. * @param min defines the new minimum vector (in local space)
  73438. * @param max defines the new maximum vector (in local space)
  73439. * @param worldMatrix defines the new world matrix
  73440. */
  73441. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  73442. /**
  73443. * Scale the current bounding sphere by applying a scale factor
  73444. * @param factor defines the scale factor to apply
  73445. * @returns the current bounding box
  73446. */
  73447. scale(factor: number): BoundingSphere;
  73448. /**
  73449. * Gets the world matrix of the bounding box
  73450. * @returns a matrix
  73451. */
  73452. getWorldMatrix(): DeepImmutable<Matrix>;
  73453. /** @hidden */
  73454. _update(worldMatrix: DeepImmutable<Matrix>): void;
  73455. /**
  73456. * Tests if the bounding sphere is intersecting the frustum planes
  73457. * @param frustumPlanes defines the frustum planes to test
  73458. * @returns true if there is an intersection
  73459. */
  73460. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73461. /**
  73462. * Tests if the bounding sphere center is in between the frustum planes.
  73463. * Used for optimistic fast inclusion.
  73464. * @param frustumPlanes defines the frustum planes to test
  73465. * @returns true if the sphere center is in between the frustum planes
  73466. */
  73467. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73468. /**
  73469. * Tests if a point is inside the bounding sphere
  73470. * @param point defines the point to test
  73471. * @returns true if the point is inside the bounding sphere
  73472. */
  73473. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  73474. /**
  73475. * Checks if two sphere intersct
  73476. * @param sphere0 sphere 0
  73477. * @param sphere1 sphere 1
  73478. * @returns true if the speres intersect
  73479. */
  73480. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  73481. }
  73482. }
  73483. declare module BABYLON {
  73484. /**
  73485. * Class used to store bounding box information
  73486. */
  73487. export class BoundingBox implements ICullable {
  73488. /**
  73489. * Gets the 8 vectors representing the bounding box in local space
  73490. */
  73491. readonly vectors: Vector3[];
  73492. /**
  73493. * Gets the center of the bounding box in local space
  73494. */
  73495. readonly center: Vector3;
  73496. /**
  73497. * Gets the center of the bounding box in world space
  73498. */
  73499. readonly centerWorld: Vector3;
  73500. /**
  73501. * Gets the extend size in local space
  73502. */
  73503. readonly extendSize: Vector3;
  73504. /**
  73505. * Gets the extend size in world space
  73506. */
  73507. readonly extendSizeWorld: Vector3;
  73508. /**
  73509. * Gets the OBB (object bounding box) directions
  73510. */
  73511. readonly directions: Vector3[];
  73512. /**
  73513. * Gets the 8 vectors representing the bounding box in world space
  73514. */
  73515. readonly vectorsWorld: Vector3[];
  73516. /**
  73517. * Gets the minimum vector in world space
  73518. */
  73519. readonly minimumWorld: Vector3;
  73520. /**
  73521. * Gets the maximum vector in world space
  73522. */
  73523. readonly maximumWorld: Vector3;
  73524. /**
  73525. * Gets the minimum vector in local space
  73526. */
  73527. readonly minimum: Vector3;
  73528. /**
  73529. * Gets the maximum vector in local space
  73530. */
  73531. readonly maximum: Vector3;
  73532. private _worldMatrix;
  73533. private static readonly TmpVector3;
  73534. /**
  73535. * @hidden
  73536. */
  73537. _tag: number;
  73538. /**
  73539. * Creates a new bounding box
  73540. * @param min defines the minimum vector (in local space)
  73541. * @param max defines the maximum vector (in local space)
  73542. * @param worldMatrix defines the new world matrix
  73543. */
  73544. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  73545. /**
  73546. * Recreates the entire bounding box from scratch as if we call the constructor in place
  73547. * @param min defines the new minimum vector (in local space)
  73548. * @param max defines the new maximum vector (in local space)
  73549. * @param worldMatrix defines the new world matrix
  73550. */
  73551. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  73552. /**
  73553. * Scale the current bounding box by applying a scale factor
  73554. * @param factor defines the scale factor to apply
  73555. * @returns the current bounding box
  73556. */
  73557. scale(factor: number): BoundingBox;
  73558. /**
  73559. * Gets the world matrix of the bounding box
  73560. * @returns a matrix
  73561. */
  73562. getWorldMatrix(): DeepImmutable<Matrix>;
  73563. /** @hidden */
  73564. _update(world: DeepImmutable<Matrix>): void;
  73565. /**
  73566. * Tests if the bounding box is intersecting the frustum planes
  73567. * @param frustumPlanes defines the frustum planes to test
  73568. * @returns true if there is an intersection
  73569. */
  73570. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73571. /**
  73572. * Tests if the bounding box is entirely inside the frustum planes
  73573. * @param frustumPlanes defines the frustum planes to test
  73574. * @returns true if there is an inclusion
  73575. */
  73576. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73577. /**
  73578. * Tests if a point is inside the bounding box
  73579. * @param point defines the point to test
  73580. * @returns true if the point is inside the bounding box
  73581. */
  73582. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  73583. /**
  73584. * Tests if the bounding box intersects with a bounding sphere
  73585. * @param sphere defines the sphere to test
  73586. * @returns true if there is an intersection
  73587. */
  73588. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  73589. /**
  73590. * Tests if the bounding box intersects with a box defined by a min and max vectors
  73591. * @param min defines the min vector to use
  73592. * @param max defines the max vector to use
  73593. * @returns true if there is an intersection
  73594. */
  73595. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  73596. /**
  73597. * Tests if two bounding boxes are intersections
  73598. * @param box0 defines the first box to test
  73599. * @param box1 defines the second box to test
  73600. * @returns true if there is an intersection
  73601. */
  73602. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  73603. /**
  73604. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  73605. * @param minPoint defines the minimum vector of the bounding box
  73606. * @param maxPoint defines the maximum vector of the bounding box
  73607. * @param sphereCenter defines the sphere center
  73608. * @param sphereRadius defines the sphere radius
  73609. * @returns true if there is an intersection
  73610. */
  73611. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  73612. /**
  73613. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  73614. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  73615. * @param frustumPlanes defines the frustum planes to test
  73616. * @return true if there is an inclusion
  73617. */
  73618. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73619. /**
  73620. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  73621. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  73622. * @param frustumPlanes defines the frustum planes to test
  73623. * @return true if there is an intersection
  73624. */
  73625. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73626. }
  73627. }
  73628. declare module BABYLON {
  73629. /** @hidden */
  73630. export class Collider {
  73631. /** Define if a collision was found */
  73632. collisionFound: boolean;
  73633. /**
  73634. * Define last intersection point in local space
  73635. */
  73636. intersectionPoint: Vector3;
  73637. /**
  73638. * Define last collided mesh
  73639. */
  73640. collidedMesh: Nullable<AbstractMesh>;
  73641. private _collisionPoint;
  73642. private _planeIntersectionPoint;
  73643. private _tempVector;
  73644. private _tempVector2;
  73645. private _tempVector3;
  73646. private _tempVector4;
  73647. private _edge;
  73648. private _baseToVertex;
  73649. private _destinationPoint;
  73650. private _slidePlaneNormal;
  73651. private _displacementVector;
  73652. /** @hidden */
  73653. _radius: Vector3;
  73654. /** @hidden */
  73655. _retry: number;
  73656. private _velocity;
  73657. private _basePoint;
  73658. private _epsilon;
  73659. /** @hidden */
  73660. _velocityWorldLength: number;
  73661. /** @hidden */
  73662. _basePointWorld: Vector3;
  73663. private _velocityWorld;
  73664. private _normalizedVelocity;
  73665. /** @hidden */
  73666. _initialVelocity: Vector3;
  73667. /** @hidden */
  73668. _initialPosition: Vector3;
  73669. private _nearestDistance;
  73670. private _collisionMask;
  73671. collisionMask: number;
  73672. /**
  73673. * Gets the plane normal used to compute the sliding response (in local space)
  73674. */
  73675. readonly slidePlaneNormal: Vector3;
  73676. /** @hidden */
  73677. _initialize(source: Vector3, dir: Vector3, e: number): void;
  73678. /** @hidden */
  73679. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  73680. /** @hidden */
  73681. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  73682. /** @hidden */
  73683. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  73684. /** @hidden */
  73685. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  73686. /** @hidden */
  73687. _getResponse(pos: Vector3, vel: Vector3): void;
  73688. }
  73689. }
  73690. declare module BABYLON {
  73691. /**
  73692. * Interface for cullable objects
  73693. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  73694. */
  73695. export interface ICullable {
  73696. /**
  73697. * Checks if the object or part of the object is in the frustum
  73698. * @param frustumPlanes Camera near/planes
  73699. * @returns true if the object is in frustum otherwise false
  73700. */
  73701. isInFrustum(frustumPlanes: Plane[]): boolean;
  73702. /**
  73703. * Checks if a cullable object (mesh...) is in the camera frustum
  73704. * Unlike isInFrustum this cheks the full bounding box
  73705. * @param frustumPlanes Camera near/planes
  73706. * @returns true if the object is in frustum otherwise false
  73707. */
  73708. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  73709. }
  73710. /**
  73711. * Info for a bounding data of a mesh
  73712. */
  73713. export class BoundingInfo implements ICullable {
  73714. /**
  73715. * Bounding box for the mesh
  73716. */
  73717. readonly boundingBox: BoundingBox;
  73718. /**
  73719. * Bounding sphere for the mesh
  73720. */
  73721. readonly boundingSphere: BoundingSphere;
  73722. private _isLocked;
  73723. private static readonly TmpVector3;
  73724. /**
  73725. * Constructs bounding info
  73726. * @param minimum min vector of the bounding box/sphere
  73727. * @param maximum max vector of the bounding box/sphere
  73728. * @param worldMatrix defines the new world matrix
  73729. */
  73730. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  73731. /**
  73732. * Recreates the entire bounding info from scratch as if we call the constructor in place
  73733. * @param min defines the new minimum vector (in local space)
  73734. * @param max defines the new maximum vector (in local space)
  73735. * @param worldMatrix defines the new world matrix
  73736. */
  73737. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  73738. /**
  73739. * min vector of the bounding box/sphere
  73740. */
  73741. readonly minimum: Vector3;
  73742. /**
  73743. * max vector of the bounding box/sphere
  73744. */
  73745. readonly maximum: Vector3;
  73746. /**
  73747. * If the info is locked and won't be updated to avoid perf overhead
  73748. */
  73749. isLocked: boolean;
  73750. /**
  73751. * Updates the bounding sphere and box
  73752. * @param world world matrix to be used to update
  73753. */
  73754. update(world: DeepImmutable<Matrix>): void;
  73755. /**
  73756. * Recreate the bounding info to be centered around a specific point given a specific extend.
  73757. * @param center New center of the bounding info
  73758. * @param extend New extend of the bounding info
  73759. * @returns the current bounding info
  73760. */
  73761. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  73762. /**
  73763. * Scale the current bounding info by applying a scale factor
  73764. * @param factor defines the scale factor to apply
  73765. * @returns the current bounding info
  73766. */
  73767. scale(factor: number): BoundingInfo;
  73768. /**
  73769. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  73770. * @param frustumPlanes defines the frustum to test
  73771. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  73772. * @returns true if the bounding info is in the frustum planes
  73773. */
  73774. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  73775. /**
  73776. * Gets the world distance between the min and max points of the bounding box
  73777. */
  73778. readonly diagonalLength: number;
  73779. /**
  73780. * Checks if a cullable object (mesh...) is in the camera frustum
  73781. * Unlike isInFrustum this cheks the full bounding box
  73782. * @param frustumPlanes Camera near/planes
  73783. * @returns true if the object is in frustum otherwise false
  73784. */
  73785. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73786. /** @hidden */
  73787. _checkCollision(collider: Collider): boolean;
  73788. /**
  73789. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  73790. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  73791. * @param point the point to check intersection with
  73792. * @returns if the point intersects
  73793. */
  73794. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  73795. /**
  73796. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  73797. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  73798. * @param boundingInfo the bounding info to check intersection with
  73799. * @param precise if the intersection should be done using OBB
  73800. * @returns if the bounding info intersects
  73801. */
  73802. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  73803. }
  73804. }
  73805. declare module BABYLON {
  73806. /**
  73807. * Extracts minimum and maximum values from a list of indexed positions
  73808. * @param positions defines the positions to use
  73809. * @param indices defines the indices to the positions
  73810. * @param indexStart defines the start index
  73811. * @param indexCount defines the end index
  73812. * @param bias defines bias value to add to the result
  73813. * @return minimum and maximum values
  73814. */
  73815. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  73816. minimum: Vector3;
  73817. maximum: Vector3;
  73818. };
  73819. /**
  73820. * Extracts minimum and maximum values from a list of positions
  73821. * @param positions defines the positions to use
  73822. * @param start defines the start index in the positions array
  73823. * @param count defines the number of positions to handle
  73824. * @param bias defines bias value to add to the result
  73825. * @param stride defines the stride size to use (distance between two positions in the positions array)
  73826. * @return minimum and maximum values
  73827. */
  73828. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  73829. minimum: Vector3;
  73830. maximum: Vector3;
  73831. };
  73832. }
  73833. declare module BABYLON {
  73834. /** @hidden */
  73835. export class WebGLDataBuffer extends DataBuffer {
  73836. private _buffer;
  73837. constructor(resource: WebGLBuffer);
  73838. readonly underlyingResource: any;
  73839. }
  73840. }
  73841. declare module BABYLON {
  73842. /** @hidden */
  73843. export class WebGLPipelineContext implements IPipelineContext {
  73844. engine: ThinEngine;
  73845. program: Nullable<WebGLProgram>;
  73846. context?: WebGLRenderingContext;
  73847. vertexShader?: WebGLShader;
  73848. fragmentShader?: WebGLShader;
  73849. isParallelCompiled: boolean;
  73850. onCompiled?: () => void;
  73851. transformFeedback?: WebGLTransformFeedback | null;
  73852. readonly isAsync: boolean;
  73853. readonly isReady: boolean;
  73854. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  73855. }
  73856. }
  73857. declare module BABYLON {
  73858. interface ThinEngine {
  73859. /**
  73860. * Create an uniform buffer
  73861. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  73862. * @param elements defines the content of the uniform buffer
  73863. * @returns the webGL uniform buffer
  73864. */
  73865. createUniformBuffer(elements: FloatArray): DataBuffer;
  73866. /**
  73867. * Create a dynamic uniform buffer
  73868. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  73869. * @param elements defines the content of the uniform buffer
  73870. * @returns the webGL uniform buffer
  73871. */
  73872. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  73873. /**
  73874. * Update an existing uniform buffer
  73875. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  73876. * @param uniformBuffer defines the target uniform buffer
  73877. * @param elements defines the content to update
  73878. * @param offset defines the offset in the uniform buffer where update should start
  73879. * @param count defines the size of the data to update
  73880. */
  73881. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  73882. /**
  73883. * Bind an uniform buffer to the current webGL context
  73884. * @param buffer defines the buffer to bind
  73885. */
  73886. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  73887. /**
  73888. * Bind a buffer to the current webGL context at a given location
  73889. * @param buffer defines the buffer to bind
  73890. * @param location defines the index where to bind the buffer
  73891. */
  73892. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  73893. /**
  73894. * Bind a specific block at a given index in a specific shader program
  73895. * @param pipelineContext defines the pipeline context to use
  73896. * @param blockName defines the block name
  73897. * @param index defines the index where to bind the block
  73898. */
  73899. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  73900. }
  73901. }
  73902. declare module BABYLON {
  73903. /**
  73904. * Uniform buffer objects.
  73905. *
  73906. * Handles blocks of uniform on the GPU.
  73907. *
  73908. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  73909. *
  73910. * For more information, please refer to :
  73911. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  73912. */
  73913. export class UniformBuffer {
  73914. private _engine;
  73915. private _buffer;
  73916. private _data;
  73917. private _bufferData;
  73918. private _dynamic?;
  73919. private _uniformLocations;
  73920. private _uniformSizes;
  73921. private _uniformLocationPointer;
  73922. private _needSync;
  73923. private _noUBO;
  73924. private _currentEffect;
  73925. private static _MAX_UNIFORM_SIZE;
  73926. private static _tempBuffer;
  73927. /**
  73928. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  73929. * This is dynamic to allow compat with webgl 1 and 2.
  73930. * You will need to pass the name of the uniform as well as the value.
  73931. */
  73932. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  73933. /**
  73934. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  73935. * This is dynamic to allow compat with webgl 1 and 2.
  73936. * You will need to pass the name of the uniform as well as the value.
  73937. */
  73938. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  73939. /**
  73940. * Lambda to Update a single float in a uniform buffer.
  73941. * This is dynamic to allow compat with webgl 1 and 2.
  73942. * You will need to pass the name of the uniform as well as the value.
  73943. */
  73944. updateFloat: (name: string, x: number) => void;
  73945. /**
  73946. * Lambda to Update a vec2 of float in a uniform buffer.
  73947. * This is dynamic to allow compat with webgl 1 and 2.
  73948. * You will need to pass the name of the uniform as well as the value.
  73949. */
  73950. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  73951. /**
  73952. * Lambda to Update a vec3 of float in a uniform buffer.
  73953. * This is dynamic to allow compat with webgl 1 and 2.
  73954. * You will need to pass the name of the uniform as well as the value.
  73955. */
  73956. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  73957. /**
  73958. * Lambda to Update a vec4 of float in a uniform buffer.
  73959. * This is dynamic to allow compat with webgl 1 and 2.
  73960. * You will need to pass the name of the uniform as well as the value.
  73961. */
  73962. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  73963. /**
  73964. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  73965. * This is dynamic to allow compat with webgl 1 and 2.
  73966. * You will need to pass the name of the uniform as well as the value.
  73967. */
  73968. updateMatrix: (name: string, mat: Matrix) => void;
  73969. /**
  73970. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  73971. * This is dynamic to allow compat with webgl 1 and 2.
  73972. * You will need to pass the name of the uniform as well as the value.
  73973. */
  73974. updateVector3: (name: string, vector: Vector3) => void;
  73975. /**
  73976. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  73977. * This is dynamic to allow compat with webgl 1 and 2.
  73978. * You will need to pass the name of the uniform as well as the value.
  73979. */
  73980. updateVector4: (name: string, vector: Vector4) => void;
  73981. /**
  73982. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  73983. * This is dynamic to allow compat with webgl 1 and 2.
  73984. * You will need to pass the name of the uniform as well as the value.
  73985. */
  73986. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  73987. /**
  73988. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  73989. * This is dynamic to allow compat with webgl 1 and 2.
  73990. * You will need to pass the name of the uniform as well as the value.
  73991. */
  73992. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  73993. /**
  73994. * Instantiates a new Uniform buffer objects.
  73995. *
  73996. * Handles blocks of uniform on the GPU.
  73997. *
  73998. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  73999. *
  74000. * For more information, please refer to :
  74001. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  74002. * @param engine Define the engine the buffer is associated with
  74003. * @param data Define the data contained in the buffer
  74004. * @param dynamic Define if the buffer is updatable
  74005. */
  74006. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  74007. /**
  74008. * Indicates if the buffer is using the WebGL2 UBO implementation,
  74009. * or just falling back on setUniformXXX calls.
  74010. */
  74011. readonly useUbo: boolean;
  74012. /**
  74013. * Indicates if the WebGL underlying uniform buffer is in sync
  74014. * with the javascript cache data.
  74015. */
  74016. readonly isSync: boolean;
  74017. /**
  74018. * Indicates if the WebGL underlying uniform buffer is dynamic.
  74019. * Also, a dynamic UniformBuffer will disable cache verification and always
  74020. * update the underlying WebGL uniform buffer to the GPU.
  74021. * @returns if Dynamic, otherwise false
  74022. */
  74023. isDynamic(): boolean;
  74024. /**
  74025. * The data cache on JS side.
  74026. * @returns the underlying data as a float array
  74027. */
  74028. getData(): Float32Array;
  74029. /**
  74030. * The underlying WebGL Uniform buffer.
  74031. * @returns the webgl buffer
  74032. */
  74033. getBuffer(): Nullable<DataBuffer>;
  74034. /**
  74035. * std140 layout specifies how to align data within an UBO structure.
  74036. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  74037. * for specs.
  74038. */
  74039. private _fillAlignment;
  74040. /**
  74041. * Adds an uniform in the buffer.
  74042. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  74043. * for the layout to be correct !
  74044. * @param name Name of the uniform, as used in the uniform block in the shader.
  74045. * @param size Data size, or data directly.
  74046. */
  74047. addUniform(name: string, size: number | number[]): void;
  74048. /**
  74049. * Adds a Matrix 4x4 to the uniform buffer.
  74050. * @param name Name of the uniform, as used in the uniform block in the shader.
  74051. * @param mat A 4x4 matrix.
  74052. */
  74053. addMatrix(name: string, mat: Matrix): void;
  74054. /**
  74055. * Adds a vec2 to the uniform buffer.
  74056. * @param name Name of the uniform, as used in the uniform block in the shader.
  74057. * @param x Define the x component value of the vec2
  74058. * @param y Define the y component value of the vec2
  74059. */
  74060. addFloat2(name: string, x: number, y: number): void;
  74061. /**
  74062. * Adds a vec3 to the uniform buffer.
  74063. * @param name Name of the uniform, as used in the uniform block in the shader.
  74064. * @param x Define the x component value of the vec3
  74065. * @param y Define the y component value of the vec3
  74066. * @param z Define the z component value of the vec3
  74067. */
  74068. addFloat3(name: string, x: number, y: number, z: number): void;
  74069. /**
  74070. * Adds a vec3 to the uniform buffer.
  74071. * @param name Name of the uniform, as used in the uniform block in the shader.
  74072. * @param color Define the vec3 from a Color
  74073. */
  74074. addColor3(name: string, color: Color3): void;
  74075. /**
  74076. * Adds a vec4 to the uniform buffer.
  74077. * @param name Name of the uniform, as used in the uniform block in the shader.
  74078. * @param color Define the rgb components from a Color
  74079. * @param alpha Define the a component of the vec4
  74080. */
  74081. addColor4(name: string, color: Color3, alpha: number): void;
  74082. /**
  74083. * Adds a vec3 to the uniform buffer.
  74084. * @param name Name of the uniform, as used in the uniform block in the shader.
  74085. * @param vector Define the vec3 components from a Vector
  74086. */
  74087. addVector3(name: string, vector: Vector3): void;
  74088. /**
  74089. * Adds a Matrix 3x3 to the uniform buffer.
  74090. * @param name Name of the uniform, as used in the uniform block in the shader.
  74091. */
  74092. addMatrix3x3(name: string): void;
  74093. /**
  74094. * Adds a Matrix 2x2 to the uniform buffer.
  74095. * @param name Name of the uniform, as used in the uniform block in the shader.
  74096. */
  74097. addMatrix2x2(name: string): void;
  74098. /**
  74099. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  74100. */
  74101. create(): void;
  74102. /** @hidden */
  74103. _rebuild(): void;
  74104. /**
  74105. * Updates the WebGL Uniform Buffer on the GPU.
  74106. * If the `dynamic` flag is set to true, no cache comparison is done.
  74107. * Otherwise, the buffer will be updated only if the cache differs.
  74108. */
  74109. update(): void;
  74110. /**
  74111. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  74112. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  74113. * @param data Define the flattened data
  74114. * @param size Define the size of the data.
  74115. */
  74116. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  74117. private _valueCache;
  74118. private _cacheMatrix;
  74119. private _updateMatrix3x3ForUniform;
  74120. private _updateMatrix3x3ForEffect;
  74121. private _updateMatrix2x2ForEffect;
  74122. private _updateMatrix2x2ForUniform;
  74123. private _updateFloatForEffect;
  74124. private _updateFloatForUniform;
  74125. private _updateFloat2ForEffect;
  74126. private _updateFloat2ForUniform;
  74127. private _updateFloat3ForEffect;
  74128. private _updateFloat3ForUniform;
  74129. private _updateFloat4ForEffect;
  74130. private _updateFloat4ForUniform;
  74131. private _updateMatrixForEffect;
  74132. private _updateMatrixForUniform;
  74133. private _updateVector3ForEffect;
  74134. private _updateVector3ForUniform;
  74135. private _updateVector4ForEffect;
  74136. private _updateVector4ForUniform;
  74137. private _updateColor3ForEffect;
  74138. private _updateColor3ForUniform;
  74139. private _updateColor4ForEffect;
  74140. private _updateColor4ForUniform;
  74141. /**
  74142. * Sets a sampler uniform on the effect.
  74143. * @param name Define the name of the sampler.
  74144. * @param texture Define the texture to set in the sampler
  74145. */
  74146. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  74147. /**
  74148. * Directly updates the value of the uniform in the cache AND on the GPU.
  74149. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  74150. * @param data Define the flattened data
  74151. */
  74152. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  74153. /**
  74154. * Binds this uniform buffer to an effect.
  74155. * @param effect Define the effect to bind the buffer to
  74156. * @param name Name of the uniform block in the shader.
  74157. */
  74158. bindToEffect(effect: Effect, name: string): void;
  74159. /**
  74160. * Disposes the uniform buffer.
  74161. */
  74162. dispose(): void;
  74163. }
  74164. }
  74165. declare module BABYLON {
  74166. /**
  74167. * Enum that determines the text-wrapping mode to use.
  74168. */
  74169. export enum InspectableType {
  74170. /**
  74171. * Checkbox for booleans
  74172. */
  74173. Checkbox = 0,
  74174. /**
  74175. * Sliders for numbers
  74176. */
  74177. Slider = 1,
  74178. /**
  74179. * Vector3
  74180. */
  74181. Vector3 = 2,
  74182. /**
  74183. * Quaternions
  74184. */
  74185. Quaternion = 3,
  74186. /**
  74187. * Color3
  74188. */
  74189. Color3 = 4,
  74190. /**
  74191. * String
  74192. */
  74193. String = 5
  74194. }
  74195. /**
  74196. * Interface used to define custom inspectable properties.
  74197. * This interface is used by the inspector to display custom property grids
  74198. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  74199. */
  74200. export interface IInspectable {
  74201. /**
  74202. * Gets the label to display
  74203. */
  74204. label: string;
  74205. /**
  74206. * Gets the name of the property to edit
  74207. */
  74208. propertyName: string;
  74209. /**
  74210. * Gets the type of the editor to use
  74211. */
  74212. type: InspectableType;
  74213. /**
  74214. * Gets the minimum value of the property when using in "slider" mode
  74215. */
  74216. min?: number;
  74217. /**
  74218. * Gets the maximum value of the property when using in "slider" mode
  74219. */
  74220. max?: number;
  74221. /**
  74222. * Gets the setp to use when using in "slider" mode
  74223. */
  74224. step?: number;
  74225. }
  74226. }
  74227. declare module BABYLON {
  74228. /**
  74229. * Class used to provide helper for timing
  74230. */
  74231. export class TimingTools {
  74232. /**
  74233. * Polyfill for setImmediate
  74234. * @param action defines the action to execute after the current execution block
  74235. */
  74236. static SetImmediate(action: () => void): void;
  74237. }
  74238. }
  74239. declare module BABYLON {
  74240. /**
  74241. * Class used to enable instatition of objects by class name
  74242. */
  74243. export class InstantiationTools {
  74244. /**
  74245. * Use this object to register external classes like custom textures or material
  74246. * to allow the laoders to instantiate them
  74247. */
  74248. static RegisteredExternalClasses: {
  74249. [key: string]: Object;
  74250. };
  74251. /**
  74252. * Tries to instantiate a new object from a given class name
  74253. * @param className defines the class name to instantiate
  74254. * @returns the new object or null if the system was not able to do the instantiation
  74255. */
  74256. static Instantiate(className: string): any;
  74257. }
  74258. }
  74259. declare module BABYLON {
  74260. /**
  74261. * Define options used to create a depth texture
  74262. */
  74263. export class DepthTextureCreationOptions {
  74264. /** Specifies whether or not a stencil should be allocated in the texture */
  74265. generateStencil?: boolean;
  74266. /** Specifies whether or not bilinear filtering is enable on the texture */
  74267. bilinearFiltering?: boolean;
  74268. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  74269. comparisonFunction?: number;
  74270. /** Specifies if the created texture is a cube texture */
  74271. isCube?: boolean;
  74272. }
  74273. }
  74274. declare module BABYLON {
  74275. interface ThinEngine {
  74276. /**
  74277. * Creates a depth stencil cube texture.
  74278. * This is only available in WebGL 2.
  74279. * @param size The size of face edge in the cube texture.
  74280. * @param options The options defining the cube texture.
  74281. * @returns The cube texture
  74282. */
  74283. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  74284. /**
  74285. * Creates a cube texture
  74286. * @param rootUrl defines the url where the files to load is located
  74287. * @param scene defines the current scene
  74288. * @param files defines the list of files to load (1 per face)
  74289. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  74290. * @param onLoad defines an optional callback raised when the texture is loaded
  74291. * @param onError defines an optional callback raised if there is an issue to load the texture
  74292. * @param format defines the format of the data
  74293. * @param forcedExtension defines the extension to use to pick the right loader
  74294. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  74295. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  74296. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  74297. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  74298. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  74299. * @returns the cube texture as an InternalTexture
  74300. */
  74301. 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;
  74302. /**
  74303. * Creates a cube texture
  74304. * @param rootUrl defines the url where the files to load is located
  74305. * @param scene defines the current scene
  74306. * @param files defines the list of files to load (1 per face)
  74307. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  74308. * @param onLoad defines an optional callback raised when the texture is loaded
  74309. * @param onError defines an optional callback raised if there is an issue to load the texture
  74310. * @param format defines the format of the data
  74311. * @param forcedExtension defines the extension to use to pick the right loader
  74312. * @returns the cube texture as an InternalTexture
  74313. */
  74314. 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;
  74315. /**
  74316. * Creates a cube texture
  74317. * @param rootUrl defines the url where the files to load is located
  74318. * @param scene defines the current scene
  74319. * @param files defines the list of files to load (1 per face)
  74320. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  74321. * @param onLoad defines an optional callback raised when the texture is loaded
  74322. * @param onError defines an optional callback raised if there is an issue to load the texture
  74323. * @param format defines the format of the data
  74324. * @param forcedExtension defines the extension to use to pick the right loader
  74325. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  74326. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  74327. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  74328. * @returns the cube texture as an InternalTexture
  74329. */
  74330. 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;
  74331. /** @hidden */
  74332. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  74333. /** @hidden */
  74334. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  74335. /** @hidden */
  74336. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  74337. /** @hidden */
  74338. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  74339. }
  74340. }
  74341. declare module BABYLON {
  74342. /**
  74343. * Class for creating a cube texture
  74344. */
  74345. export class CubeTexture extends BaseTexture {
  74346. private _delayedOnLoad;
  74347. /**
  74348. * The url of the texture
  74349. */
  74350. url: string;
  74351. /**
  74352. * Gets or sets the center of the bounding box associated with the cube texture.
  74353. * It must define where the camera used to render the texture was set
  74354. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  74355. */
  74356. boundingBoxPosition: Vector3;
  74357. private _boundingBoxSize;
  74358. /**
  74359. * Gets or sets the size of the bounding box associated with the cube texture
  74360. * When defined, the cubemap will switch to local mode
  74361. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  74362. * @example https://www.babylonjs-playground.com/#RNASML
  74363. */
  74364. /**
  74365. * Returns the bounding box size
  74366. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  74367. */
  74368. boundingBoxSize: Vector3;
  74369. protected _rotationY: number;
  74370. /**
  74371. * Sets texture matrix rotation angle around Y axis in radians.
  74372. */
  74373. /**
  74374. * Gets texture matrix rotation angle around Y axis radians.
  74375. */
  74376. rotationY: number;
  74377. /**
  74378. * Are mip maps generated for this texture or not.
  74379. */
  74380. readonly noMipmap: boolean;
  74381. private _noMipmap;
  74382. private _files;
  74383. protected _forcedExtension: Nullable<string>;
  74384. private _extensions;
  74385. private _textureMatrix;
  74386. private _format;
  74387. private _createPolynomials;
  74388. /** @hidden */
  74389. _prefiltered: boolean;
  74390. /**
  74391. * Creates a cube texture from an array of image urls
  74392. * @param files defines an array of image urls
  74393. * @param scene defines the hosting scene
  74394. * @param noMipmap specifies if mip maps are not used
  74395. * @returns a cube texture
  74396. */
  74397. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  74398. /**
  74399. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  74400. * @param url defines the url of the prefiltered texture
  74401. * @param scene defines the scene the texture is attached to
  74402. * @param forcedExtension defines the extension of the file if different from the url
  74403. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  74404. * @return the prefiltered texture
  74405. */
  74406. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  74407. /**
  74408. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  74409. * as prefiltered data.
  74410. * @param rootUrl defines the url of the texture or the root name of the six images
  74411. * @param scene defines the scene the texture is attached to
  74412. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  74413. * @param noMipmap defines if mipmaps should be created or not
  74414. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  74415. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  74416. * @param onError defines a callback triggered in case of error during load
  74417. * @param format defines the internal format to use for the texture once loaded
  74418. * @param prefiltered defines whether or not the texture is created from prefiltered data
  74419. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  74420. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  74421. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  74422. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  74423. * @return the cube texture
  74424. */
  74425. 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);
  74426. /**
  74427. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  74428. */
  74429. readonly isPrefiltered: boolean;
  74430. /**
  74431. * Get the current class name of the texture useful for serialization or dynamic coding.
  74432. * @returns "CubeTexture"
  74433. */
  74434. getClassName(): string;
  74435. /**
  74436. * Update the url (and optional buffer) of this texture if url was null during construction.
  74437. * @param url the url of the texture
  74438. * @param forcedExtension defines the extension to use
  74439. * @param onLoad callback called when the texture is loaded (defaults to null)
  74440. */
  74441. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  74442. /**
  74443. * Delays loading of the cube texture
  74444. * @param forcedExtension defines the extension to use
  74445. */
  74446. delayLoad(forcedExtension?: string): void;
  74447. /**
  74448. * Returns the reflection texture matrix
  74449. * @returns the reflection texture matrix
  74450. */
  74451. getReflectionTextureMatrix(): Matrix;
  74452. /**
  74453. * Sets the reflection texture matrix
  74454. * @param value Reflection texture matrix
  74455. */
  74456. setReflectionTextureMatrix(value: Matrix): void;
  74457. /**
  74458. * Parses text to create a cube texture
  74459. * @param parsedTexture define the serialized text to read from
  74460. * @param scene defines the hosting scene
  74461. * @param rootUrl defines the root url of the cube texture
  74462. * @returns a cube texture
  74463. */
  74464. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  74465. /**
  74466. * Makes a clone, or deep copy, of the cube texture
  74467. * @returns a new cube texture
  74468. */
  74469. clone(): CubeTexture;
  74470. }
  74471. }
  74472. declare module BABYLON {
  74473. /**
  74474. * Manages the defines for the Material
  74475. */
  74476. export class MaterialDefines {
  74477. /** @hidden */
  74478. protected _keys: string[];
  74479. private _isDirty;
  74480. /** @hidden */
  74481. _renderId: number;
  74482. /** @hidden */
  74483. _areLightsDirty: boolean;
  74484. /** @hidden */
  74485. _areLightsDisposed: boolean;
  74486. /** @hidden */
  74487. _areAttributesDirty: boolean;
  74488. /** @hidden */
  74489. _areTexturesDirty: boolean;
  74490. /** @hidden */
  74491. _areFresnelDirty: boolean;
  74492. /** @hidden */
  74493. _areMiscDirty: boolean;
  74494. /** @hidden */
  74495. _areImageProcessingDirty: boolean;
  74496. /** @hidden */
  74497. _normals: boolean;
  74498. /** @hidden */
  74499. _uvs: boolean;
  74500. /** @hidden */
  74501. _needNormals: boolean;
  74502. /** @hidden */
  74503. _needUVs: boolean;
  74504. [id: string]: any;
  74505. /**
  74506. * Specifies if the material needs to be re-calculated
  74507. */
  74508. readonly isDirty: boolean;
  74509. /**
  74510. * Marks the material to indicate that it has been re-calculated
  74511. */
  74512. markAsProcessed(): void;
  74513. /**
  74514. * Marks the material to indicate that it needs to be re-calculated
  74515. */
  74516. markAsUnprocessed(): void;
  74517. /**
  74518. * Marks the material to indicate all of its defines need to be re-calculated
  74519. */
  74520. markAllAsDirty(): void;
  74521. /**
  74522. * Marks the material to indicate that image processing needs to be re-calculated
  74523. */
  74524. markAsImageProcessingDirty(): void;
  74525. /**
  74526. * Marks the material to indicate the lights need to be re-calculated
  74527. * @param disposed Defines whether the light is dirty due to dispose or not
  74528. */
  74529. markAsLightDirty(disposed?: boolean): void;
  74530. /**
  74531. * Marks the attribute state as changed
  74532. */
  74533. markAsAttributesDirty(): void;
  74534. /**
  74535. * Marks the texture state as changed
  74536. */
  74537. markAsTexturesDirty(): void;
  74538. /**
  74539. * Marks the fresnel state as changed
  74540. */
  74541. markAsFresnelDirty(): void;
  74542. /**
  74543. * Marks the misc state as changed
  74544. */
  74545. markAsMiscDirty(): void;
  74546. /**
  74547. * Rebuilds the material defines
  74548. */
  74549. rebuild(): void;
  74550. /**
  74551. * Specifies if two material defines are equal
  74552. * @param other - A material define instance to compare to
  74553. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  74554. */
  74555. isEqual(other: MaterialDefines): boolean;
  74556. /**
  74557. * Clones this instance's defines to another instance
  74558. * @param other - material defines to clone values to
  74559. */
  74560. cloneTo(other: MaterialDefines): void;
  74561. /**
  74562. * Resets the material define values
  74563. */
  74564. reset(): void;
  74565. /**
  74566. * Converts the material define values to a string
  74567. * @returns - String of material define information
  74568. */
  74569. toString(): string;
  74570. }
  74571. }
  74572. declare module BABYLON {
  74573. /**
  74574. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  74575. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  74576. * 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;
  74577. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  74578. */
  74579. export class ColorCurves {
  74580. private _dirty;
  74581. private _tempColor;
  74582. private _globalCurve;
  74583. private _highlightsCurve;
  74584. private _midtonesCurve;
  74585. private _shadowsCurve;
  74586. private _positiveCurve;
  74587. private _negativeCurve;
  74588. private _globalHue;
  74589. private _globalDensity;
  74590. private _globalSaturation;
  74591. private _globalExposure;
  74592. /**
  74593. * Gets the global Hue value.
  74594. * 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).
  74595. */
  74596. /**
  74597. * Sets the global Hue value.
  74598. * 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).
  74599. */
  74600. globalHue: number;
  74601. /**
  74602. * Gets the global Density value.
  74603. * 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.
  74604. * Values less than zero provide a filter of opposite hue.
  74605. */
  74606. /**
  74607. * Sets the global Density value.
  74608. * 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.
  74609. * Values less than zero provide a filter of opposite hue.
  74610. */
  74611. globalDensity: number;
  74612. /**
  74613. * Gets the global Saturation value.
  74614. * 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.
  74615. */
  74616. /**
  74617. * Sets the global Saturation value.
  74618. * 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.
  74619. */
  74620. globalSaturation: number;
  74621. /**
  74622. * Gets the global Exposure value.
  74623. * 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.
  74624. */
  74625. /**
  74626. * Sets the global Exposure value.
  74627. * 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.
  74628. */
  74629. globalExposure: number;
  74630. private _highlightsHue;
  74631. private _highlightsDensity;
  74632. private _highlightsSaturation;
  74633. private _highlightsExposure;
  74634. /**
  74635. * Gets the highlights Hue value.
  74636. * 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).
  74637. */
  74638. /**
  74639. * Sets the highlights Hue value.
  74640. * 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).
  74641. */
  74642. highlightsHue: number;
  74643. /**
  74644. * Gets the highlights Density value.
  74645. * 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.
  74646. * Values less than zero provide a filter of opposite hue.
  74647. */
  74648. /**
  74649. * Sets the highlights Density value.
  74650. * 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.
  74651. * Values less than zero provide a filter of opposite hue.
  74652. */
  74653. highlightsDensity: number;
  74654. /**
  74655. * Gets the highlights Saturation value.
  74656. * 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.
  74657. */
  74658. /**
  74659. * Sets the highlights Saturation value.
  74660. * 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.
  74661. */
  74662. highlightsSaturation: number;
  74663. /**
  74664. * Gets the highlights Exposure value.
  74665. * 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.
  74666. */
  74667. /**
  74668. * Sets the highlights Exposure value.
  74669. * 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.
  74670. */
  74671. highlightsExposure: number;
  74672. private _midtonesHue;
  74673. private _midtonesDensity;
  74674. private _midtonesSaturation;
  74675. private _midtonesExposure;
  74676. /**
  74677. * Gets the midtones Hue value.
  74678. * 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).
  74679. */
  74680. /**
  74681. * Sets the midtones Hue value.
  74682. * 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).
  74683. */
  74684. midtonesHue: number;
  74685. /**
  74686. * Gets the midtones Density value.
  74687. * 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.
  74688. * Values less than zero provide a filter of opposite hue.
  74689. */
  74690. /**
  74691. * Sets the midtones Density value.
  74692. * 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.
  74693. * Values less than zero provide a filter of opposite hue.
  74694. */
  74695. midtonesDensity: number;
  74696. /**
  74697. * Gets the midtones Saturation value.
  74698. * 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.
  74699. */
  74700. /**
  74701. * Sets the midtones Saturation value.
  74702. * 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.
  74703. */
  74704. midtonesSaturation: number;
  74705. /**
  74706. * Gets the midtones Exposure value.
  74707. * 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.
  74708. */
  74709. /**
  74710. * Sets the midtones Exposure value.
  74711. * 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.
  74712. */
  74713. midtonesExposure: number;
  74714. private _shadowsHue;
  74715. private _shadowsDensity;
  74716. private _shadowsSaturation;
  74717. private _shadowsExposure;
  74718. /**
  74719. * Gets the shadows Hue value.
  74720. * 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).
  74721. */
  74722. /**
  74723. * Sets the shadows Hue value.
  74724. * 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).
  74725. */
  74726. shadowsHue: number;
  74727. /**
  74728. * Gets the shadows Density value.
  74729. * 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.
  74730. * Values less than zero provide a filter of opposite hue.
  74731. */
  74732. /**
  74733. * Sets the shadows Density value.
  74734. * 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.
  74735. * Values less than zero provide a filter of opposite hue.
  74736. */
  74737. shadowsDensity: number;
  74738. /**
  74739. * Gets the shadows Saturation value.
  74740. * 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.
  74741. */
  74742. /**
  74743. * Sets the shadows Saturation value.
  74744. * 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.
  74745. */
  74746. shadowsSaturation: number;
  74747. /**
  74748. * Gets the shadows Exposure value.
  74749. * 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.
  74750. */
  74751. /**
  74752. * Sets the shadows Exposure value.
  74753. * 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.
  74754. */
  74755. shadowsExposure: number;
  74756. /**
  74757. * Returns the class name
  74758. * @returns The class name
  74759. */
  74760. getClassName(): string;
  74761. /**
  74762. * Binds the color curves to the shader.
  74763. * @param colorCurves The color curve to bind
  74764. * @param effect The effect to bind to
  74765. * @param positiveUniform The positive uniform shader parameter
  74766. * @param neutralUniform The neutral uniform shader parameter
  74767. * @param negativeUniform The negative uniform shader parameter
  74768. */
  74769. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  74770. /**
  74771. * Prepare the list of uniforms associated with the ColorCurves effects.
  74772. * @param uniformsList The list of uniforms used in the effect
  74773. */
  74774. static PrepareUniforms(uniformsList: string[]): void;
  74775. /**
  74776. * Returns color grading data based on a hue, density, saturation and exposure value.
  74777. * @param filterHue The hue of the color filter.
  74778. * @param filterDensity The density of the color filter.
  74779. * @param saturation The saturation.
  74780. * @param exposure The exposure.
  74781. * @param result The result data container.
  74782. */
  74783. private getColorGradingDataToRef;
  74784. /**
  74785. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  74786. * @param value The input slider value in range [-100,100].
  74787. * @returns Adjusted value.
  74788. */
  74789. private static applyColorGradingSliderNonlinear;
  74790. /**
  74791. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  74792. * @param hue The hue (H) input.
  74793. * @param saturation The saturation (S) input.
  74794. * @param brightness The brightness (B) input.
  74795. * @result An RGBA color represented as Vector4.
  74796. */
  74797. private static fromHSBToRef;
  74798. /**
  74799. * Returns a value clamped between min and max
  74800. * @param value The value to clamp
  74801. * @param min The minimum of value
  74802. * @param max The maximum of value
  74803. * @returns The clamped value.
  74804. */
  74805. private static clamp;
  74806. /**
  74807. * Clones the current color curve instance.
  74808. * @return The cloned curves
  74809. */
  74810. clone(): ColorCurves;
  74811. /**
  74812. * Serializes the current color curve instance to a json representation.
  74813. * @return a JSON representation
  74814. */
  74815. serialize(): any;
  74816. /**
  74817. * Parses the color curve from a json representation.
  74818. * @param source the JSON source to parse
  74819. * @return The parsed curves
  74820. */
  74821. static Parse(source: any): ColorCurves;
  74822. }
  74823. }
  74824. declare module BABYLON {
  74825. /**
  74826. * Interface to follow in your material defines to integrate easily the
  74827. * Image proccessing functions.
  74828. * @hidden
  74829. */
  74830. export interface IImageProcessingConfigurationDefines {
  74831. IMAGEPROCESSING: boolean;
  74832. VIGNETTE: boolean;
  74833. VIGNETTEBLENDMODEMULTIPLY: boolean;
  74834. VIGNETTEBLENDMODEOPAQUE: boolean;
  74835. TONEMAPPING: boolean;
  74836. TONEMAPPING_ACES: boolean;
  74837. CONTRAST: boolean;
  74838. EXPOSURE: boolean;
  74839. COLORCURVES: boolean;
  74840. COLORGRADING: boolean;
  74841. COLORGRADING3D: boolean;
  74842. SAMPLER3DGREENDEPTH: boolean;
  74843. SAMPLER3DBGRMAP: boolean;
  74844. IMAGEPROCESSINGPOSTPROCESS: boolean;
  74845. }
  74846. /**
  74847. * @hidden
  74848. */
  74849. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  74850. IMAGEPROCESSING: boolean;
  74851. VIGNETTE: boolean;
  74852. VIGNETTEBLENDMODEMULTIPLY: boolean;
  74853. VIGNETTEBLENDMODEOPAQUE: boolean;
  74854. TONEMAPPING: boolean;
  74855. TONEMAPPING_ACES: boolean;
  74856. CONTRAST: boolean;
  74857. COLORCURVES: boolean;
  74858. COLORGRADING: boolean;
  74859. COLORGRADING3D: boolean;
  74860. SAMPLER3DGREENDEPTH: boolean;
  74861. SAMPLER3DBGRMAP: boolean;
  74862. IMAGEPROCESSINGPOSTPROCESS: boolean;
  74863. EXPOSURE: boolean;
  74864. constructor();
  74865. }
  74866. /**
  74867. * This groups together the common properties used for image processing either in direct forward pass
  74868. * or through post processing effect depending on the use of the image processing pipeline in your scene
  74869. * or not.
  74870. */
  74871. export class ImageProcessingConfiguration {
  74872. /**
  74873. * Default tone mapping applied in BabylonJS.
  74874. */
  74875. static readonly TONEMAPPING_STANDARD: number;
  74876. /**
  74877. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  74878. * to other engines rendering to increase portability.
  74879. */
  74880. static readonly TONEMAPPING_ACES: number;
  74881. /**
  74882. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  74883. */
  74884. colorCurves: Nullable<ColorCurves>;
  74885. private _colorCurvesEnabled;
  74886. /**
  74887. * Gets wether the color curves effect is enabled.
  74888. */
  74889. /**
  74890. * Sets wether the color curves effect is enabled.
  74891. */
  74892. colorCurvesEnabled: boolean;
  74893. private _colorGradingTexture;
  74894. /**
  74895. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  74896. */
  74897. /**
  74898. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  74899. */
  74900. colorGradingTexture: Nullable<BaseTexture>;
  74901. private _colorGradingEnabled;
  74902. /**
  74903. * Gets wether the color grading effect is enabled.
  74904. */
  74905. /**
  74906. * Sets wether the color grading effect is enabled.
  74907. */
  74908. colorGradingEnabled: boolean;
  74909. private _colorGradingWithGreenDepth;
  74910. /**
  74911. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  74912. */
  74913. /**
  74914. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  74915. */
  74916. colorGradingWithGreenDepth: boolean;
  74917. private _colorGradingBGR;
  74918. /**
  74919. * Gets wether the color grading texture contains BGR values.
  74920. */
  74921. /**
  74922. * Sets wether the color grading texture contains BGR values.
  74923. */
  74924. colorGradingBGR: boolean;
  74925. /** @hidden */
  74926. _exposure: number;
  74927. /**
  74928. * Gets the Exposure used in the effect.
  74929. */
  74930. /**
  74931. * Sets the Exposure used in the effect.
  74932. */
  74933. exposure: number;
  74934. private _toneMappingEnabled;
  74935. /**
  74936. * Gets wether the tone mapping effect is enabled.
  74937. */
  74938. /**
  74939. * Sets wether the tone mapping effect is enabled.
  74940. */
  74941. toneMappingEnabled: boolean;
  74942. private _toneMappingType;
  74943. /**
  74944. * Gets the type of tone mapping effect.
  74945. */
  74946. /**
  74947. * Sets the type of tone mapping effect used in BabylonJS.
  74948. */
  74949. toneMappingType: number;
  74950. protected _contrast: number;
  74951. /**
  74952. * Gets the contrast used in the effect.
  74953. */
  74954. /**
  74955. * Sets the contrast used in the effect.
  74956. */
  74957. contrast: number;
  74958. /**
  74959. * Vignette stretch size.
  74960. */
  74961. vignetteStretch: number;
  74962. /**
  74963. * Vignette centre X Offset.
  74964. */
  74965. vignetteCentreX: number;
  74966. /**
  74967. * Vignette centre Y Offset.
  74968. */
  74969. vignetteCentreY: number;
  74970. /**
  74971. * Vignette weight or intensity of the vignette effect.
  74972. */
  74973. vignetteWeight: number;
  74974. /**
  74975. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  74976. * if vignetteEnabled is set to true.
  74977. */
  74978. vignetteColor: Color4;
  74979. /**
  74980. * Camera field of view used by the Vignette effect.
  74981. */
  74982. vignetteCameraFov: number;
  74983. private _vignetteBlendMode;
  74984. /**
  74985. * Gets the vignette blend mode allowing different kind of effect.
  74986. */
  74987. /**
  74988. * Sets the vignette blend mode allowing different kind of effect.
  74989. */
  74990. vignetteBlendMode: number;
  74991. private _vignetteEnabled;
  74992. /**
  74993. * Gets wether the vignette effect is enabled.
  74994. */
  74995. /**
  74996. * Sets wether the vignette effect is enabled.
  74997. */
  74998. vignetteEnabled: boolean;
  74999. private _applyByPostProcess;
  75000. /**
  75001. * Gets wether the image processing is applied through a post process or not.
  75002. */
  75003. /**
  75004. * Sets wether the image processing is applied through a post process or not.
  75005. */
  75006. applyByPostProcess: boolean;
  75007. private _isEnabled;
  75008. /**
  75009. * Gets wether the image processing is enabled or not.
  75010. */
  75011. /**
  75012. * Sets wether the image processing is enabled or not.
  75013. */
  75014. isEnabled: boolean;
  75015. /**
  75016. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  75017. */
  75018. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  75019. /**
  75020. * Method called each time the image processing information changes requires to recompile the effect.
  75021. */
  75022. protected _updateParameters(): void;
  75023. /**
  75024. * Gets the current class name.
  75025. * @return "ImageProcessingConfiguration"
  75026. */
  75027. getClassName(): string;
  75028. /**
  75029. * Prepare the list of uniforms associated with the Image Processing effects.
  75030. * @param uniforms The list of uniforms used in the effect
  75031. * @param defines the list of defines currently in use
  75032. */
  75033. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  75034. /**
  75035. * Prepare the list of samplers associated with the Image Processing effects.
  75036. * @param samplersList The list of uniforms used in the effect
  75037. * @param defines the list of defines currently in use
  75038. */
  75039. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  75040. /**
  75041. * Prepare the list of defines associated to the shader.
  75042. * @param defines the list of defines to complete
  75043. * @param forPostProcess Define if we are currently in post process mode or not
  75044. */
  75045. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  75046. /**
  75047. * Returns true if all the image processing information are ready.
  75048. * @returns True if ready, otherwise, false
  75049. */
  75050. isReady(): boolean;
  75051. /**
  75052. * Binds the image processing to the shader.
  75053. * @param effect The effect to bind to
  75054. * @param aspectRatio Define the current aspect ratio of the effect
  75055. */
  75056. bind(effect: Effect, aspectRatio?: number): void;
  75057. /**
  75058. * Clones the current image processing instance.
  75059. * @return The cloned image processing
  75060. */
  75061. clone(): ImageProcessingConfiguration;
  75062. /**
  75063. * Serializes the current image processing instance to a json representation.
  75064. * @return a JSON representation
  75065. */
  75066. serialize(): any;
  75067. /**
  75068. * Parses the image processing from a json representation.
  75069. * @param source the JSON source to parse
  75070. * @return The parsed image processing
  75071. */
  75072. static Parse(source: any): ImageProcessingConfiguration;
  75073. private static _VIGNETTEMODE_MULTIPLY;
  75074. private static _VIGNETTEMODE_OPAQUE;
  75075. /**
  75076. * Used to apply the vignette as a mix with the pixel color.
  75077. */
  75078. static readonly VIGNETTEMODE_MULTIPLY: number;
  75079. /**
  75080. * Used to apply the vignette as a replacement of the pixel color.
  75081. */
  75082. static readonly VIGNETTEMODE_OPAQUE: number;
  75083. }
  75084. }
  75085. declare module BABYLON {
  75086. /** @hidden */
  75087. export var postprocessVertexShader: {
  75088. name: string;
  75089. shader: string;
  75090. };
  75091. }
  75092. declare module BABYLON {
  75093. /** Defines supported spaces */
  75094. export enum Space {
  75095. /** Local (object) space */
  75096. LOCAL = 0,
  75097. /** World space */
  75098. WORLD = 1,
  75099. /** Bone space */
  75100. BONE = 2
  75101. }
  75102. /** Defines the 3 main axes */
  75103. export class Axis {
  75104. /** X axis */
  75105. static X: Vector3;
  75106. /** Y axis */
  75107. static Y: Vector3;
  75108. /** Z axis */
  75109. static Z: Vector3;
  75110. }
  75111. }
  75112. declare module BABYLON {
  75113. /**
  75114. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  75115. * This is the base of the follow, arc rotate cameras and Free camera
  75116. * @see http://doc.babylonjs.com/features/cameras
  75117. */
  75118. export class TargetCamera extends Camera {
  75119. private static _RigCamTransformMatrix;
  75120. private static _TargetTransformMatrix;
  75121. private static _TargetFocalPoint;
  75122. /**
  75123. * Define the current direction the camera is moving to
  75124. */
  75125. cameraDirection: Vector3;
  75126. /**
  75127. * Define the current rotation the camera is rotating to
  75128. */
  75129. cameraRotation: Vector2;
  75130. /**
  75131. * When set, the up vector of the camera will be updated by the rotation of the camera
  75132. */
  75133. updateUpVectorFromRotation: boolean;
  75134. private _tmpQuaternion;
  75135. /**
  75136. * Define the current rotation of the camera
  75137. */
  75138. rotation: Vector3;
  75139. /**
  75140. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  75141. */
  75142. rotationQuaternion: Quaternion;
  75143. /**
  75144. * Define the current speed of the camera
  75145. */
  75146. speed: number;
  75147. /**
  75148. * Add cconstraint to the camera to prevent it to move freely in all directions and
  75149. * around all axis.
  75150. */
  75151. noRotationConstraint: boolean;
  75152. /**
  75153. * Define the current target of the camera as an object or a position.
  75154. */
  75155. lockedTarget: any;
  75156. /** @hidden */
  75157. _currentTarget: Vector3;
  75158. /** @hidden */
  75159. _initialFocalDistance: number;
  75160. /** @hidden */
  75161. _viewMatrix: Matrix;
  75162. /** @hidden */
  75163. _camMatrix: Matrix;
  75164. /** @hidden */
  75165. _cameraTransformMatrix: Matrix;
  75166. /** @hidden */
  75167. _cameraRotationMatrix: Matrix;
  75168. /** @hidden */
  75169. _referencePoint: Vector3;
  75170. /** @hidden */
  75171. _transformedReferencePoint: Vector3;
  75172. protected _globalCurrentTarget: Vector3;
  75173. protected _globalCurrentUpVector: Vector3;
  75174. /** @hidden */
  75175. _reset: () => void;
  75176. private _defaultUp;
  75177. /**
  75178. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  75179. * This is the base of the follow, arc rotate cameras and Free camera
  75180. * @see http://doc.babylonjs.com/features/cameras
  75181. * @param name Defines the name of the camera in the scene
  75182. * @param position Defines the start position of the camera in the scene
  75183. * @param scene Defines the scene the camera belongs to
  75184. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  75185. */
  75186. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  75187. /**
  75188. * Gets the position in front of the camera at a given distance.
  75189. * @param distance The distance from the camera we want the position to be
  75190. * @returns the position
  75191. */
  75192. getFrontPosition(distance: number): Vector3;
  75193. /** @hidden */
  75194. _getLockedTargetPosition(): Nullable<Vector3>;
  75195. private _storedPosition;
  75196. private _storedRotation;
  75197. private _storedRotationQuaternion;
  75198. /**
  75199. * Store current camera state of the camera (fov, position, rotation, etc..)
  75200. * @returns the camera
  75201. */
  75202. storeState(): Camera;
  75203. /**
  75204. * Restored camera state. You must call storeState() first
  75205. * @returns whether it was successful or not
  75206. * @hidden
  75207. */
  75208. _restoreStateValues(): boolean;
  75209. /** @hidden */
  75210. _initCache(): void;
  75211. /** @hidden */
  75212. _updateCache(ignoreParentClass?: boolean): void;
  75213. /** @hidden */
  75214. _isSynchronizedViewMatrix(): boolean;
  75215. /** @hidden */
  75216. _computeLocalCameraSpeed(): number;
  75217. /**
  75218. * Defines the target the camera should look at.
  75219. * @param target Defines the new target as a Vector or a mesh
  75220. */
  75221. setTarget(target: Vector3): void;
  75222. /**
  75223. * Return the current target position of the camera. This value is expressed in local space.
  75224. * @returns the target position
  75225. */
  75226. getTarget(): Vector3;
  75227. /** @hidden */
  75228. _decideIfNeedsToMove(): boolean;
  75229. /** @hidden */
  75230. _updatePosition(): void;
  75231. /** @hidden */
  75232. _checkInputs(): void;
  75233. protected _updateCameraRotationMatrix(): void;
  75234. /**
  75235. * 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)
  75236. * @returns the current camera
  75237. */
  75238. private _rotateUpVectorWithCameraRotationMatrix;
  75239. private _cachedRotationZ;
  75240. private _cachedQuaternionRotationZ;
  75241. /** @hidden */
  75242. _getViewMatrix(): Matrix;
  75243. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  75244. /**
  75245. * @hidden
  75246. */
  75247. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  75248. /**
  75249. * @hidden
  75250. */
  75251. _updateRigCameras(): void;
  75252. private _getRigCamPositionAndTarget;
  75253. /**
  75254. * Gets the current object class name.
  75255. * @return the class name
  75256. */
  75257. getClassName(): string;
  75258. }
  75259. }
  75260. declare module BABYLON {
  75261. /**
  75262. * Gather the list of keyboard event types as constants.
  75263. */
  75264. export class KeyboardEventTypes {
  75265. /**
  75266. * The keydown event is fired when a key becomes active (pressed).
  75267. */
  75268. static readonly KEYDOWN: number;
  75269. /**
  75270. * The keyup event is fired when a key has been released.
  75271. */
  75272. static readonly KEYUP: number;
  75273. }
  75274. /**
  75275. * This class is used to store keyboard related info for the onKeyboardObservable event.
  75276. */
  75277. export class KeyboardInfo {
  75278. /**
  75279. * Defines the type of event (KeyboardEventTypes)
  75280. */
  75281. type: number;
  75282. /**
  75283. * Defines the related dom event
  75284. */
  75285. event: KeyboardEvent;
  75286. /**
  75287. * Instantiates a new keyboard info.
  75288. * This class is used to store keyboard related info for the onKeyboardObservable event.
  75289. * @param type Defines the type of event (KeyboardEventTypes)
  75290. * @param event Defines the related dom event
  75291. */
  75292. constructor(
  75293. /**
  75294. * Defines the type of event (KeyboardEventTypes)
  75295. */
  75296. type: number,
  75297. /**
  75298. * Defines the related dom event
  75299. */
  75300. event: KeyboardEvent);
  75301. }
  75302. /**
  75303. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  75304. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  75305. */
  75306. export class KeyboardInfoPre extends KeyboardInfo {
  75307. /**
  75308. * Defines the type of event (KeyboardEventTypes)
  75309. */
  75310. type: number;
  75311. /**
  75312. * Defines the related dom event
  75313. */
  75314. event: KeyboardEvent;
  75315. /**
  75316. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  75317. */
  75318. skipOnPointerObservable: boolean;
  75319. /**
  75320. * Instantiates a new keyboard pre info.
  75321. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  75322. * @param type Defines the type of event (KeyboardEventTypes)
  75323. * @param event Defines the related dom event
  75324. */
  75325. constructor(
  75326. /**
  75327. * Defines the type of event (KeyboardEventTypes)
  75328. */
  75329. type: number,
  75330. /**
  75331. * Defines the related dom event
  75332. */
  75333. event: KeyboardEvent);
  75334. }
  75335. }
  75336. declare module BABYLON {
  75337. /**
  75338. * Manage the keyboard inputs to control the movement of a free camera.
  75339. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  75340. */
  75341. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  75342. /**
  75343. * Defines the camera the input is attached to.
  75344. */
  75345. camera: FreeCamera;
  75346. /**
  75347. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  75348. */
  75349. keysUp: number[];
  75350. /**
  75351. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  75352. */
  75353. keysDown: number[];
  75354. /**
  75355. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  75356. */
  75357. keysLeft: number[];
  75358. /**
  75359. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  75360. */
  75361. keysRight: number[];
  75362. private _keys;
  75363. private _onCanvasBlurObserver;
  75364. private _onKeyboardObserver;
  75365. private _engine;
  75366. private _scene;
  75367. /**
  75368. * Attach the input controls to a specific dom element to get the input from.
  75369. * @param element Defines the element the controls should be listened from
  75370. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  75371. */
  75372. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  75373. /**
  75374. * Detach the current controls from the specified dom element.
  75375. * @param element Defines the element to stop listening the inputs from
  75376. */
  75377. detachControl(element: Nullable<HTMLElement>): void;
  75378. /**
  75379. * Update the current camera state depending on the inputs that have been used this frame.
  75380. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  75381. */
  75382. checkInputs(): void;
  75383. /**
  75384. * Gets the class name of the current intput.
  75385. * @returns the class name
  75386. */
  75387. getClassName(): string;
  75388. /** @hidden */
  75389. _onLostFocus(): void;
  75390. /**
  75391. * Get the friendly name associated with the input class.
  75392. * @returns the input friendly name
  75393. */
  75394. getSimpleName(): string;
  75395. }
  75396. }
  75397. declare module BABYLON {
  75398. /**
  75399. * Interface describing all the common properties and methods a shadow light needs to implement.
  75400. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  75401. * as well as binding the different shadow properties to the effects.
  75402. */
  75403. export interface IShadowLight extends Light {
  75404. /**
  75405. * The light id in the scene (used in scene.findLighById for instance)
  75406. */
  75407. id: string;
  75408. /**
  75409. * The position the shdow will be casted from.
  75410. */
  75411. position: Vector3;
  75412. /**
  75413. * In 2d mode (needCube being false), the direction used to cast the shadow.
  75414. */
  75415. direction: Vector3;
  75416. /**
  75417. * The transformed position. Position of the light in world space taking parenting in account.
  75418. */
  75419. transformedPosition: Vector3;
  75420. /**
  75421. * The transformed direction. Direction of the light in world space taking parenting in account.
  75422. */
  75423. transformedDirection: Vector3;
  75424. /**
  75425. * The friendly name of the light in the scene.
  75426. */
  75427. name: string;
  75428. /**
  75429. * Defines the shadow projection clipping minimum z value.
  75430. */
  75431. shadowMinZ: number;
  75432. /**
  75433. * Defines the shadow projection clipping maximum z value.
  75434. */
  75435. shadowMaxZ: number;
  75436. /**
  75437. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  75438. * @returns true if the information has been computed, false if it does not need to (no parenting)
  75439. */
  75440. computeTransformedInformation(): boolean;
  75441. /**
  75442. * Gets the scene the light belongs to.
  75443. * @returns The scene
  75444. */
  75445. getScene(): Scene;
  75446. /**
  75447. * Callback defining a custom Projection Matrix Builder.
  75448. * This can be used to override the default projection matrix computation.
  75449. */
  75450. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  75451. /**
  75452. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  75453. * @param matrix The materix to updated with the projection information
  75454. * @param viewMatrix The transform matrix of the light
  75455. * @param renderList The list of mesh to render in the map
  75456. * @returns The current light
  75457. */
  75458. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  75459. /**
  75460. * Gets the current depth scale used in ESM.
  75461. * @returns The scale
  75462. */
  75463. getDepthScale(): number;
  75464. /**
  75465. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  75466. * @returns true if a cube texture needs to be use
  75467. */
  75468. needCube(): boolean;
  75469. /**
  75470. * Detects if the projection matrix requires to be recomputed this frame.
  75471. * @returns true if it requires to be recomputed otherwise, false.
  75472. */
  75473. needProjectionMatrixCompute(): boolean;
  75474. /**
  75475. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  75476. */
  75477. forceProjectionMatrixCompute(): void;
  75478. /**
  75479. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  75480. * @param faceIndex The index of the face we are computed the direction to generate shadow
  75481. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  75482. */
  75483. getShadowDirection(faceIndex?: number): Vector3;
  75484. /**
  75485. * Gets the minZ used for shadow according to both the scene and the light.
  75486. * @param activeCamera The camera we are returning the min for
  75487. * @returns the depth min z
  75488. */
  75489. getDepthMinZ(activeCamera: Camera): number;
  75490. /**
  75491. * Gets the maxZ used for shadow according to both the scene and the light.
  75492. * @param activeCamera The camera we are returning the max for
  75493. * @returns the depth max z
  75494. */
  75495. getDepthMaxZ(activeCamera: Camera): number;
  75496. }
  75497. /**
  75498. * Base implementation IShadowLight
  75499. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  75500. */
  75501. export abstract class ShadowLight extends Light implements IShadowLight {
  75502. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  75503. protected _position: Vector3;
  75504. protected _setPosition(value: Vector3): void;
  75505. /**
  75506. * Sets the position the shadow will be casted from. Also use as the light position for both
  75507. * point and spot lights.
  75508. */
  75509. /**
  75510. * Sets the position the shadow will be casted from. Also use as the light position for both
  75511. * point and spot lights.
  75512. */
  75513. position: Vector3;
  75514. protected _direction: Vector3;
  75515. protected _setDirection(value: Vector3): void;
  75516. /**
  75517. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  75518. * Also use as the light direction on spot and directional lights.
  75519. */
  75520. /**
  75521. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  75522. * Also use as the light direction on spot and directional lights.
  75523. */
  75524. direction: Vector3;
  75525. private _shadowMinZ;
  75526. /**
  75527. * Gets the shadow projection clipping minimum z value.
  75528. */
  75529. /**
  75530. * Sets the shadow projection clipping minimum z value.
  75531. */
  75532. shadowMinZ: number;
  75533. private _shadowMaxZ;
  75534. /**
  75535. * Sets the shadow projection clipping maximum z value.
  75536. */
  75537. /**
  75538. * Gets the shadow projection clipping maximum z value.
  75539. */
  75540. shadowMaxZ: number;
  75541. /**
  75542. * Callback defining a custom Projection Matrix Builder.
  75543. * This can be used to override the default projection matrix computation.
  75544. */
  75545. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  75546. /**
  75547. * The transformed position. Position of the light in world space taking parenting in account.
  75548. */
  75549. transformedPosition: Vector3;
  75550. /**
  75551. * The transformed direction. Direction of the light in world space taking parenting in account.
  75552. */
  75553. transformedDirection: Vector3;
  75554. private _needProjectionMatrixCompute;
  75555. /**
  75556. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  75557. * @returns true if the information has been computed, false if it does not need to (no parenting)
  75558. */
  75559. computeTransformedInformation(): boolean;
  75560. /**
  75561. * Return the depth scale used for the shadow map.
  75562. * @returns the depth scale.
  75563. */
  75564. getDepthScale(): number;
  75565. /**
  75566. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  75567. * @param faceIndex The index of the face we are computed the direction to generate shadow
  75568. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  75569. */
  75570. getShadowDirection(faceIndex?: number): Vector3;
  75571. /**
  75572. * Returns the ShadowLight absolute position in the World.
  75573. * @returns the position vector in world space
  75574. */
  75575. getAbsolutePosition(): Vector3;
  75576. /**
  75577. * Sets the ShadowLight direction toward the passed target.
  75578. * @param target The point to target in local space
  75579. * @returns the updated ShadowLight direction
  75580. */
  75581. setDirectionToTarget(target: Vector3): Vector3;
  75582. /**
  75583. * Returns the light rotation in euler definition.
  75584. * @returns the x y z rotation in local space.
  75585. */
  75586. getRotation(): Vector3;
  75587. /**
  75588. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  75589. * @returns true if a cube texture needs to be use
  75590. */
  75591. needCube(): boolean;
  75592. /**
  75593. * Detects if the projection matrix requires to be recomputed this frame.
  75594. * @returns true if it requires to be recomputed otherwise, false.
  75595. */
  75596. needProjectionMatrixCompute(): boolean;
  75597. /**
  75598. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  75599. */
  75600. forceProjectionMatrixCompute(): void;
  75601. /** @hidden */
  75602. _initCache(): void;
  75603. /** @hidden */
  75604. _isSynchronized(): boolean;
  75605. /**
  75606. * Computes the world matrix of the node
  75607. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  75608. * @returns the world matrix
  75609. */
  75610. computeWorldMatrix(force?: boolean): Matrix;
  75611. /**
  75612. * Gets the minZ used for shadow according to both the scene and the light.
  75613. * @param activeCamera The camera we are returning the min for
  75614. * @returns the depth min z
  75615. */
  75616. getDepthMinZ(activeCamera: Camera): number;
  75617. /**
  75618. * Gets the maxZ used for shadow according to both the scene and the light.
  75619. * @param activeCamera The camera we are returning the max for
  75620. * @returns the depth max z
  75621. */
  75622. getDepthMaxZ(activeCamera: Camera): number;
  75623. /**
  75624. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  75625. * @param matrix The materix to updated with the projection information
  75626. * @param viewMatrix The transform matrix of the light
  75627. * @param renderList The list of mesh to render in the map
  75628. * @returns The current light
  75629. */
  75630. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  75631. }
  75632. }
  75633. declare module BABYLON {
  75634. /**
  75635. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  75636. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  75637. */
  75638. export class EffectFallbacks implements IEffectFallbacks {
  75639. private _defines;
  75640. private _currentRank;
  75641. private _maxRank;
  75642. private _mesh;
  75643. /**
  75644. * Removes the fallback from the bound mesh.
  75645. */
  75646. unBindMesh(): void;
  75647. /**
  75648. * Adds a fallback on the specified property.
  75649. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  75650. * @param define The name of the define in the shader
  75651. */
  75652. addFallback(rank: number, define: string): void;
  75653. /**
  75654. * Sets the mesh to use CPU skinning when needing to fallback.
  75655. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  75656. * @param mesh The mesh to use the fallbacks.
  75657. */
  75658. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  75659. /**
  75660. * Checks to see if more fallbacks are still availible.
  75661. */
  75662. readonly hasMoreFallbacks: boolean;
  75663. /**
  75664. * Removes the defines that should be removed when falling back.
  75665. * @param currentDefines defines the current define statements for the shader.
  75666. * @param effect defines the current effect we try to compile
  75667. * @returns The resulting defines with defines of the current rank removed.
  75668. */
  75669. reduce(currentDefines: string, effect: Effect): string;
  75670. }
  75671. }
  75672. declare module BABYLON {
  75673. /**
  75674. * "Static Class" containing the most commonly used helper while dealing with material for
  75675. * rendering purpose.
  75676. *
  75677. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  75678. *
  75679. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  75680. */
  75681. export class MaterialHelper {
  75682. /**
  75683. * Bind the current view position to an effect.
  75684. * @param effect The effect to be bound
  75685. * @param scene The scene the eyes position is used from
  75686. */
  75687. static BindEyePosition(effect: Effect, scene: Scene): void;
  75688. /**
  75689. * Helps preparing the defines values about the UVs in used in the effect.
  75690. * UVs are shared as much as we can accross channels in the shaders.
  75691. * @param texture The texture we are preparing the UVs for
  75692. * @param defines The defines to update
  75693. * @param key The channel key "diffuse", "specular"... used in the shader
  75694. */
  75695. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  75696. /**
  75697. * Binds a texture matrix value to its corrsponding uniform
  75698. * @param texture The texture to bind the matrix for
  75699. * @param uniformBuffer The uniform buffer receivin the data
  75700. * @param key The channel key "diffuse", "specular"... used in the shader
  75701. */
  75702. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  75703. /**
  75704. * Gets the current status of the fog (should it be enabled?)
  75705. * @param mesh defines the mesh to evaluate for fog support
  75706. * @param scene defines the hosting scene
  75707. * @returns true if fog must be enabled
  75708. */
  75709. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  75710. /**
  75711. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  75712. * @param mesh defines the current mesh
  75713. * @param scene defines the current scene
  75714. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  75715. * @param pointsCloud defines if point cloud rendering has to be turned on
  75716. * @param fogEnabled defines if fog has to be turned on
  75717. * @param alphaTest defines if alpha testing has to be turned on
  75718. * @param defines defines the current list of defines
  75719. */
  75720. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  75721. /**
  75722. * Helper used to prepare the list of defines associated with frame values for shader compilation
  75723. * @param scene defines the current scene
  75724. * @param engine defines the current engine
  75725. * @param defines specifies the list of active defines
  75726. * @param useInstances defines if instances have to be turned on
  75727. * @param useClipPlane defines if clip plane have to be turned on
  75728. */
  75729. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  75730. /**
  75731. * Prepares the defines for bones
  75732. * @param mesh The mesh containing the geometry data we will draw
  75733. * @param defines The defines to update
  75734. */
  75735. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  75736. /**
  75737. * Prepares the defines for morph targets
  75738. * @param mesh The mesh containing the geometry data we will draw
  75739. * @param defines The defines to update
  75740. */
  75741. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  75742. /**
  75743. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  75744. * @param mesh The mesh containing the geometry data we will draw
  75745. * @param defines The defines to update
  75746. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  75747. * @param useBones Precise whether bones should be used or not (override mesh info)
  75748. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  75749. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  75750. * @returns false if defines are considered not dirty and have not been checked
  75751. */
  75752. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  75753. /**
  75754. * Prepares the defines related to multiview
  75755. * @param scene The scene we are intending to draw
  75756. * @param defines The defines to update
  75757. */
  75758. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  75759. /**
  75760. * Prepares the defines related to the light information passed in parameter
  75761. * @param scene The scene we are intending to draw
  75762. * @param mesh The mesh the effect is compiling for
  75763. * @param light The light the effect is compiling for
  75764. * @param lightIndex The index of the light
  75765. * @param defines The defines to update
  75766. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  75767. * @param state Defines the current state regarding what is needed (normals, etc...)
  75768. */
  75769. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  75770. needNormals: boolean;
  75771. needRebuild: boolean;
  75772. shadowEnabled: boolean;
  75773. specularEnabled: boolean;
  75774. lightmapMode: boolean;
  75775. }): void;
  75776. /**
  75777. * Prepares the defines related to the light information passed in parameter
  75778. * @param scene The scene we are intending to draw
  75779. * @param mesh The mesh the effect is compiling for
  75780. * @param defines The defines to update
  75781. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  75782. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  75783. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  75784. * @returns true if normals will be required for the rest of the effect
  75785. */
  75786. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  75787. /**
  75788. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  75789. * @param lightIndex defines the light index
  75790. * @param uniformsList The uniform list
  75791. * @param samplersList The sampler list
  75792. * @param projectedLightTexture defines if projected texture must be used
  75793. * @param uniformBuffersList defines an optional list of uniform buffers
  75794. */
  75795. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  75796. /**
  75797. * Prepares the uniforms and samplers list to be used in the effect
  75798. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  75799. * @param samplersList The sampler list
  75800. * @param defines The defines helping in the list generation
  75801. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  75802. */
  75803. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  75804. /**
  75805. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  75806. * @param defines The defines to update while falling back
  75807. * @param fallbacks The authorized effect fallbacks
  75808. * @param maxSimultaneousLights The maximum number of lights allowed
  75809. * @param rank the current rank of the Effect
  75810. * @returns The newly affected rank
  75811. */
  75812. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  75813. private static _TmpMorphInfluencers;
  75814. /**
  75815. * Prepares the list of attributes required for morph targets according to the effect defines.
  75816. * @param attribs The current list of supported attribs
  75817. * @param mesh The mesh to prepare the morph targets attributes for
  75818. * @param influencers The number of influencers
  75819. */
  75820. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  75821. /**
  75822. * Prepares the list of attributes required for morph targets according to the effect defines.
  75823. * @param attribs The current list of supported attribs
  75824. * @param mesh The mesh to prepare the morph targets attributes for
  75825. * @param defines The current Defines of the effect
  75826. */
  75827. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  75828. /**
  75829. * Prepares the list of attributes required for bones according to the effect defines.
  75830. * @param attribs The current list of supported attribs
  75831. * @param mesh The mesh to prepare the bones attributes for
  75832. * @param defines The current Defines of the effect
  75833. * @param fallbacks The current efffect fallback strategy
  75834. */
  75835. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  75836. /**
  75837. * Check and prepare the list of attributes required for instances according to the effect defines.
  75838. * @param attribs The current list of supported attribs
  75839. * @param defines The current MaterialDefines of the effect
  75840. */
  75841. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  75842. /**
  75843. * Add the list of attributes required for instances to the attribs array.
  75844. * @param attribs The current list of supported attribs
  75845. */
  75846. static PushAttributesForInstances(attribs: string[]): void;
  75847. /**
  75848. * Binds the light shadow information to the effect for the given mesh.
  75849. * @param light The light containing the generator
  75850. * @param scene The scene the lights belongs to
  75851. * @param mesh The mesh we are binding the information to render
  75852. * @param lightIndex The light index in the effect used to render the mesh
  75853. * @param effect The effect we are binding the data to
  75854. */
  75855. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  75856. /**
  75857. * Binds the light information to the effect.
  75858. * @param light The light containing the generator
  75859. * @param effect The effect we are binding the data to
  75860. * @param lightIndex The light index in the effect used to render
  75861. */
  75862. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  75863. /**
  75864. * Binds the lights information from the scene to the effect for the given mesh.
  75865. * @param light Light to bind
  75866. * @param lightIndex Light index
  75867. * @param scene The scene where the light belongs to
  75868. * @param mesh The mesh we are binding the information to render
  75869. * @param effect The effect we are binding the data to
  75870. * @param useSpecular Defines if specular is supported
  75871. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  75872. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  75873. */
  75874. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  75875. /**
  75876. * Binds the lights information from the scene to the effect for the given mesh.
  75877. * @param scene The scene the lights belongs to
  75878. * @param mesh The mesh we are binding the information to render
  75879. * @param effect The effect we are binding the data to
  75880. * @param defines The generated defines for the effect
  75881. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  75882. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  75883. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  75884. */
  75885. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  75886. private static _tempFogColor;
  75887. /**
  75888. * Binds the fog information from the scene to the effect for the given mesh.
  75889. * @param scene The scene the lights belongs to
  75890. * @param mesh The mesh we are binding the information to render
  75891. * @param effect The effect we are binding the data to
  75892. * @param linearSpace Defines if the fog effect is applied in linear space
  75893. */
  75894. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  75895. /**
  75896. * Binds the bones information from the mesh to the effect.
  75897. * @param mesh The mesh we are binding the information to render
  75898. * @param effect The effect we are binding the data to
  75899. */
  75900. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  75901. /**
  75902. * Binds the morph targets information from the mesh to the effect.
  75903. * @param abstractMesh The mesh we are binding the information to render
  75904. * @param effect The effect we are binding the data to
  75905. */
  75906. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  75907. /**
  75908. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  75909. * @param defines The generated defines used in the effect
  75910. * @param effect The effect we are binding the data to
  75911. * @param scene The scene we are willing to render with logarithmic scale for
  75912. */
  75913. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  75914. /**
  75915. * Binds the clip plane information from the scene to the effect.
  75916. * @param scene The scene the clip plane information are extracted from
  75917. * @param effect The effect we are binding the data to
  75918. */
  75919. static BindClipPlane(effect: Effect, scene: Scene): void;
  75920. }
  75921. }
  75922. declare module BABYLON {
  75923. /** @hidden */
  75924. export var packingFunctions: {
  75925. name: string;
  75926. shader: string;
  75927. };
  75928. }
  75929. declare module BABYLON {
  75930. /** @hidden */
  75931. export var shadowMapPixelShader: {
  75932. name: string;
  75933. shader: string;
  75934. };
  75935. }
  75936. declare module BABYLON {
  75937. /** @hidden */
  75938. export var bonesDeclaration: {
  75939. name: string;
  75940. shader: string;
  75941. };
  75942. }
  75943. declare module BABYLON {
  75944. /** @hidden */
  75945. export var morphTargetsVertexGlobalDeclaration: {
  75946. name: string;
  75947. shader: string;
  75948. };
  75949. }
  75950. declare module BABYLON {
  75951. /** @hidden */
  75952. export var morphTargetsVertexDeclaration: {
  75953. name: string;
  75954. shader: string;
  75955. };
  75956. }
  75957. declare module BABYLON {
  75958. /** @hidden */
  75959. export var instancesDeclaration: {
  75960. name: string;
  75961. shader: string;
  75962. };
  75963. }
  75964. declare module BABYLON {
  75965. /** @hidden */
  75966. export var helperFunctions: {
  75967. name: string;
  75968. shader: string;
  75969. };
  75970. }
  75971. declare module BABYLON {
  75972. /** @hidden */
  75973. export var morphTargetsVertex: {
  75974. name: string;
  75975. shader: string;
  75976. };
  75977. }
  75978. declare module BABYLON {
  75979. /** @hidden */
  75980. export var instancesVertex: {
  75981. name: string;
  75982. shader: string;
  75983. };
  75984. }
  75985. declare module BABYLON {
  75986. /** @hidden */
  75987. export var bonesVertex: {
  75988. name: string;
  75989. shader: string;
  75990. };
  75991. }
  75992. declare module BABYLON {
  75993. /** @hidden */
  75994. export var shadowMapVertexShader: {
  75995. name: string;
  75996. shader: string;
  75997. };
  75998. }
  75999. declare module BABYLON {
  76000. /** @hidden */
  76001. export var depthBoxBlurPixelShader: {
  76002. name: string;
  76003. shader: string;
  76004. };
  76005. }
  76006. declare module BABYLON {
  76007. /**
  76008. * Defines the options associated with the creation of a custom shader for a shadow generator.
  76009. */
  76010. export interface ICustomShaderOptions {
  76011. /**
  76012. * Gets or sets the custom shader name to use
  76013. */
  76014. shaderName: string;
  76015. /**
  76016. * The list of attribute names used in the shader
  76017. */
  76018. attributes?: string[];
  76019. /**
  76020. * The list of unifrom names used in the shader
  76021. */
  76022. uniforms?: string[];
  76023. /**
  76024. * The list of sampler names used in the shader
  76025. */
  76026. samplers?: string[];
  76027. /**
  76028. * The list of defines used in the shader
  76029. */
  76030. defines?: string[];
  76031. }
  76032. /**
  76033. * Interface to implement to create a shadow generator compatible with BJS.
  76034. */
  76035. export interface IShadowGenerator {
  76036. /**
  76037. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  76038. * @returns The render target texture if present otherwise, null
  76039. */
  76040. getShadowMap(): Nullable<RenderTargetTexture>;
  76041. /**
  76042. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  76043. * @returns The render target texture if the shadow map is present otherwise, null
  76044. */
  76045. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  76046. /**
  76047. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  76048. * @param subMesh The submesh we want to render in the shadow map
  76049. * @param useInstances Defines wether will draw in the map using instances
  76050. * @returns true if ready otherwise, false
  76051. */
  76052. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  76053. /**
  76054. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  76055. * @param defines Defines of the material we want to update
  76056. * @param lightIndex Index of the light in the enabled light list of the material
  76057. */
  76058. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  76059. /**
  76060. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  76061. * defined in the generator but impacting the effect).
  76062. * It implies the unifroms available on the materials are the standard BJS ones.
  76063. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  76064. * @param effect The effect we are binfing the information for
  76065. */
  76066. bindShadowLight(lightIndex: string, effect: Effect): void;
  76067. /**
  76068. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  76069. * (eq to shadow prjection matrix * light transform matrix)
  76070. * @returns The transform matrix used to create the shadow map
  76071. */
  76072. getTransformMatrix(): Matrix;
  76073. /**
  76074. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  76075. * Cube and 2D textures for instance.
  76076. */
  76077. recreateShadowMap(): void;
  76078. /**
  76079. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  76080. * @param onCompiled Callback triggered at the and of the effects compilation
  76081. * @param options Sets of optional options forcing the compilation with different modes
  76082. */
  76083. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  76084. useInstances: boolean;
  76085. }>): void;
  76086. /**
  76087. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  76088. * @param options Sets of optional options forcing the compilation with different modes
  76089. * @returns A promise that resolves when the compilation completes
  76090. */
  76091. forceCompilationAsync(options?: Partial<{
  76092. useInstances: boolean;
  76093. }>): Promise<void>;
  76094. /**
  76095. * Serializes the shadow generator setup to a json object.
  76096. * @returns The serialized JSON object
  76097. */
  76098. serialize(): any;
  76099. /**
  76100. * Disposes the Shadow map and related Textures and effects.
  76101. */
  76102. dispose(): void;
  76103. }
  76104. /**
  76105. * Default implementation IShadowGenerator.
  76106. * This is the main object responsible of generating shadows in the framework.
  76107. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  76108. */
  76109. export class ShadowGenerator implements IShadowGenerator {
  76110. /**
  76111. * Shadow generator mode None: no filtering applied.
  76112. */
  76113. static readonly FILTER_NONE: number;
  76114. /**
  76115. * Shadow generator mode ESM: Exponential Shadow Mapping.
  76116. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  76117. */
  76118. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  76119. /**
  76120. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  76121. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  76122. */
  76123. static readonly FILTER_POISSONSAMPLING: number;
  76124. /**
  76125. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  76126. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  76127. */
  76128. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  76129. /**
  76130. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  76131. * edge artifacts on steep falloff.
  76132. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  76133. */
  76134. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  76135. /**
  76136. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  76137. * edge artifacts on steep falloff.
  76138. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  76139. */
  76140. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  76141. /**
  76142. * Shadow generator mode PCF: Percentage Closer Filtering
  76143. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  76144. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  76145. */
  76146. static readonly FILTER_PCF: number;
  76147. /**
  76148. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  76149. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  76150. * Contact Hardening
  76151. */
  76152. static readonly FILTER_PCSS: number;
  76153. /**
  76154. * Reserved for PCF and PCSS
  76155. * Highest Quality.
  76156. *
  76157. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  76158. *
  76159. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  76160. */
  76161. static readonly QUALITY_HIGH: number;
  76162. /**
  76163. * Reserved for PCF and PCSS
  76164. * Good tradeoff for quality/perf cross devices
  76165. *
  76166. * Execute PCF on a 3*3 kernel.
  76167. *
  76168. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  76169. */
  76170. static readonly QUALITY_MEDIUM: number;
  76171. /**
  76172. * Reserved for PCF and PCSS
  76173. * The lowest quality but the fastest.
  76174. *
  76175. * Execute PCF on a 1*1 kernel.
  76176. *
  76177. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  76178. */
  76179. static readonly QUALITY_LOW: number;
  76180. /** Gets or sets the custom shader name to use */
  76181. customShaderOptions: ICustomShaderOptions;
  76182. /**
  76183. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  76184. */
  76185. onBeforeShadowMapRenderObservable: Observable<Effect>;
  76186. /**
  76187. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  76188. */
  76189. onAfterShadowMapRenderObservable: Observable<Effect>;
  76190. /**
  76191. * Observable triggered before a mesh is rendered in the shadow map.
  76192. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  76193. */
  76194. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  76195. /**
  76196. * Observable triggered after a mesh is rendered in the shadow map.
  76197. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  76198. */
  76199. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  76200. private _bias;
  76201. /**
  76202. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  76203. */
  76204. /**
  76205. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  76206. */
  76207. bias: number;
  76208. private _normalBias;
  76209. /**
  76210. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  76211. */
  76212. /**
  76213. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  76214. */
  76215. normalBias: number;
  76216. private _blurBoxOffset;
  76217. /**
  76218. * Gets the blur box offset: offset applied during the blur pass.
  76219. * Only useful if useKernelBlur = false
  76220. */
  76221. /**
  76222. * Sets the blur box offset: offset applied during the blur pass.
  76223. * Only useful if useKernelBlur = false
  76224. */
  76225. blurBoxOffset: number;
  76226. private _blurScale;
  76227. /**
  76228. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  76229. * 2 means half of the size.
  76230. */
  76231. /**
  76232. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  76233. * 2 means half of the size.
  76234. */
  76235. blurScale: number;
  76236. private _blurKernel;
  76237. /**
  76238. * Gets the blur kernel: kernel size of the blur pass.
  76239. * Only useful if useKernelBlur = true
  76240. */
  76241. /**
  76242. * Sets the blur kernel: kernel size of the blur pass.
  76243. * Only useful if useKernelBlur = true
  76244. */
  76245. blurKernel: number;
  76246. private _useKernelBlur;
  76247. /**
  76248. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  76249. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  76250. */
  76251. /**
  76252. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  76253. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  76254. */
  76255. useKernelBlur: boolean;
  76256. private _depthScale;
  76257. /**
  76258. * Gets the depth scale used in ESM mode.
  76259. */
  76260. /**
  76261. * Sets the depth scale used in ESM mode.
  76262. * This can override the scale stored on the light.
  76263. */
  76264. depthScale: number;
  76265. private _filter;
  76266. /**
  76267. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  76268. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  76269. */
  76270. /**
  76271. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  76272. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  76273. */
  76274. filter: number;
  76275. /**
  76276. * Gets if the current filter is set to Poisson Sampling.
  76277. */
  76278. /**
  76279. * Sets the current filter to Poisson Sampling.
  76280. */
  76281. usePoissonSampling: boolean;
  76282. /**
  76283. * Gets if the current filter is set to ESM.
  76284. */
  76285. /**
  76286. * Sets the current filter is to ESM.
  76287. */
  76288. useExponentialShadowMap: boolean;
  76289. /**
  76290. * Gets if the current filter is set to filtered ESM.
  76291. */
  76292. /**
  76293. * Gets if the current filter is set to filtered ESM.
  76294. */
  76295. useBlurExponentialShadowMap: boolean;
  76296. /**
  76297. * Gets if the current filter is set to "close ESM" (using the inverse of the
  76298. * exponential to prevent steep falloff artifacts).
  76299. */
  76300. /**
  76301. * Sets the current filter to "close ESM" (using the inverse of the
  76302. * exponential to prevent steep falloff artifacts).
  76303. */
  76304. useCloseExponentialShadowMap: boolean;
  76305. /**
  76306. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  76307. * exponential to prevent steep falloff artifacts).
  76308. */
  76309. /**
  76310. * Sets the current filter to filtered "close ESM" (using the inverse of the
  76311. * exponential to prevent steep falloff artifacts).
  76312. */
  76313. useBlurCloseExponentialShadowMap: boolean;
  76314. /**
  76315. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  76316. */
  76317. /**
  76318. * Sets the current filter to "PCF" (percentage closer filtering).
  76319. */
  76320. usePercentageCloserFiltering: boolean;
  76321. private _filteringQuality;
  76322. /**
  76323. * Gets the PCF or PCSS Quality.
  76324. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  76325. */
  76326. /**
  76327. * Sets the PCF or PCSS Quality.
  76328. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  76329. */
  76330. filteringQuality: number;
  76331. /**
  76332. * Gets if the current filter is set to "PCSS" (contact hardening).
  76333. */
  76334. /**
  76335. * Sets the current filter to "PCSS" (contact hardening).
  76336. */
  76337. useContactHardeningShadow: boolean;
  76338. private _contactHardeningLightSizeUVRatio;
  76339. /**
  76340. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  76341. * Using a ratio helps keeping shape stability independently of the map size.
  76342. *
  76343. * It does not account for the light projection as it was having too much
  76344. * instability during the light setup or during light position changes.
  76345. *
  76346. * Only valid if useContactHardeningShadow is true.
  76347. */
  76348. /**
  76349. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  76350. * Using a ratio helps keeping shape stability independently of the map size.
  76351. *
  76352. * It does not account for the light projection as it was having too much
  76353. * instability during the light setup or during light position changes.
  76354. *
  76355. * Only valid if useContactHardeningShadow is true.
  76356. */
  76357. contactHardeningLightSizeUVRatio: number;
  76358. private _darkness;
  76359. /** Gets or sets the actual darkness of a shadow */
  76360. darkness: number;
  76361. /**
  76362. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  76363. * 0 means strongest and 1 would means no shadow.
  76364. * @returns the darkness.
  76365. */
  76366. getDarkness(): number;
  76367. /**
  76368. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  76369. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  76370. * @returns the shadow generator allowing fluent coding.
  76371. */
  76372. setDarkness(darkness: number): ShadowGenerator;
  76373. private _transparencyShadow;
  76374. /** Gets or sets the ability to have transparent shadow */
  76375. transparencyShadow: boolean;
  76376. /**
  76377. * Sets the ability to have transparent shadow (boolean).
  76378. * @param transparent True if transparent else False
  76379. * @returns the shadow generator allowing fluent coding
  76380. */
  76381. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  76382. private _shadowMap;
  76383. private _shadowMap2;
  76384. /**
  76385. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  76386. * @returns The render target texture if present otherwise, null
  76387. */
  76388. getShadowMap(): Nullable<RenderTargetTexture>;
  76389. /**
  76390. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  76391. * @returns The render target texture if the shadow map is present otherwise, null
  76392. */
  76393. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  76394. /**
  76395. * Gets the class name of that object
  76396. * @returns "ShadowGenerator"
  76397. */
  76398. getClassName(): string;
  76399. /**
  76400. * Helper function to add a mesh and its descendants to the list of shadow casters.
  76401. * @param mesh Mesh to add
  76402. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  76403. * @returns the Shadow Generator itself
  76404. */
  76405. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  76406. /**
  76407. * Helper function to remove a mesh and its descendants from the list of shadow casters
  76408. * @param mesh Mesh to remove
  76409. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  76410. * @returns the Shadow Generator itself
  76411. */
  76412. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  76413. /**
  76414. * Controls the extent to which the shadows fade out at the edge of the frustum
  76415. * Used only by directionals and spots
  76416. */
  76417. frustumEdgeFalloff: number;
  76418. private _light;
  76419. /**
  76420. * Returns the associated light object.
  76421. * @returns the light generating the shadow
  76422. */
  76423. getLight(): IShadowLight;
  76424. /**
  76425. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  76426. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  76427. * It might on the other hand introduce peter panning.
  76428. */
  76429. forceBackFacesOnly: boolean;
  76430. private _scene;
  76431. private _lightDirection;
  76432. private _effect;
  76433. private _viewMatrix;
  76434. private _projectionMatrix;
  76435. private _transformMatrix;
  76436. private _cachedPosition;
  76437. private _cachedDirection;
  76438. private _cachedDefines;
  76439. private _currentRenderID;
  76440. private _boxBlurPostprocess;
  76441. private _kernelBlurXPostprocess;
  76442. private _kernelBlurYPostprocess;
  76443. private _blurPostProcesses;
  76444. private _mapSize;
  76445. private _currentFaceIndex;
  76446. private _currentFaceIndexCache;
  76447. private _textureType;
  76448. private _defaultTextureMatrix;
  76449. private _storedUniqueId;
  76450. /** @hidden */
  76451. static _SceneComponentInitialization: (scene: Scene) => void;
  76452. /**
  76453. * Creates a ShadowGenerator object.
  76454. * A ShadowGenerator is the required tool to use the shadows.
  76455. * Each light casting shadows needs to use its own ShadowGenerator.
  76456. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  76457. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  76458. * @param light The light object generating the shadows.
  76459. * @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.
  76460. */
  76461. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  76462. private _initializeGenerator;
  76463. private _initializeShadowMap;
  76464. private _initializeBlurRTTAndPostProcesses;
  76465. private _renderForShadowMap;
  76466. private _renderSubMeshForShadowMap;
  76467. private _applyFilterValues;
  76468. /**
  76469. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  76470. * @param onCompiled Callback triggered at the and of the effects compilation
  76471. * @param options Sets of optional options forcing the compilation with different modes
  76472. */
  76473. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  76474. useInstances: boolean;
  76475. }>): void;
  76476. /**
  76477. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  76478. * @param options Sets of optional options forcing the compilation with different modes
  76479. * @returns A promise that resolves when the compilation completes
  76480. */
  76481. forceCompilationAsync(options?: Partial<{
  76482. useInstances: boolean;
  76483. }>): Promise<void>;
  76484. /**
  76485. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  76486. * @param subMesh The submesh we want to render in the shadow map
  76487. * @param useInstances Defines wether will draw in the map using instances
  76488. * @returns true if ready otherwise, false
  76489. */
  76490. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  76491. /**
  76492. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  76493. * @param defines Defines of the material we want to update
  76494. * @param lightIndex Index of the light in the enabled light list of the material
  76495. */
  76496. prepareDefines(defines: any, lightIndex: number): void;
  76497. /**
  76498. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  76499. * defined in the generator but impacting the effect).
  76500. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  76501. * @param effect The effect we are binfing the information for
  76502. */
  76503. bindShadowLight(lightIndex: string, effect: Effect): void;
  76504. /**
  76505. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  76506. * (eq to shadow prjection matrix * light transform matrix)
  76507. * @returns The transform matrix used to create the shadow map
  76508. */
  76509. getTransformMatrix(): Matrix;
  76510. /**
  76511. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  76512. * Cube and 2D textures for instance.
  76513. */
  76514. recreateShadowMap(): void;
  76515. private _disposeBlurPostProcesses;
  76516. private _disposeRTTandPostProcesses;
  76517. /**
  76518. * Disposes the ShadowGenerator.
  76519. * Returns nothing.
  76520. */
  76521. dispose(): void;
  76522. /**
  76523. * Serializes the shadow generator setup to a json object.
  76524. * @returns The serialized JSON object
  76525. */
  76526. serialize(): any;
  76527. /**
  76528. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  76529. * @param parsedShadowGenerator The JSON object to parse
  76530. * @param scene The scene to create the shadow map for
  76531. * @returns The parsed shadow generator
  76532. */
  76533. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  76534. }
  76535. }
  76536. declare module BABYLON {
  76537. /**
  76538. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  76539. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  76540. * 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.
  76541. */
  76542. export abstract class Light extends Node {
  76543. /**
  76544. * Falloff Default: light is falling off following the material specification:
  76545. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  76546. */
  76547. static readonly FALLOFF_DEFAULT: number;
  76548. /**
  76549. * Falloff Physical: light is falling off following the inverse squared distance law.
  76550. */
  76551. static readonly FALLOFF_PHYSICAL: number;
  76552. /**
  76553. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  76554. * to enhance interoperability with other engines.
  76555. */
  76556. static readonly FALLOFF_GLTF: number;
  76557. /**
  76558. * Falloff Standard: light is falling off like in the standard material
  76559. * to enhance interoperability with other materials.
  76560. */
  76561. static readonly FALLOFF_STANDARD: number;
  76562. /**
  76563. * If every light affecting the material is in this lightmapMode,
  76564. * material.lightmapTexture adds or multiplies
  76565. * (depends on material.useLightmapAsShadowmap)
  76566. * after every other light calculations.
  76567. */
  76568. static readonly LIGHTMAP_DEFAULT: number;
  76569. /**
  76570. * material.lightmapTexture as only diffuse lighting from this light
  76571. * adds only specular lighting from this light
  76572. * adds dynamic shadows
  76573. */
  76574. static readonly LIGHTMAP_SPECULAR: number;
  76575. /**
  76576. * material.lightmapTexture as only lighting
  76577. * no light calculation from this light
  76578. * only adds dynamic shadows from this light
  76579. */
  76580. static readonly LIGHTMAP_SHADOWSONLY: number;
  76581. /**
  76582. * Each light type uses the default quantity according to its type:
  76583. * point/spot lights use luminous intensity
  76584. * directional lights use illuminance
  76585. */
  76586. static readonly INTENSITYMODE_AUTOMATIC: number;
  76587. /**
  76588. * lumen (lm)
  76589. */
  76590. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  76591. /**
  76592. * candela (lm/sr)
  76593. */
  76594. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  76595. /**
  76596. * lux (lm/m^2)
  76597. */
  76598. static readonly INTENSITYMODE_ILLUMINANCE: number;
  76599. /**
  76600. * nit (cd/m^2)
  76601. */
  76602. static readonly INTENSITYMODE_LUMINANCE: number;
  76603. /**
  76604. * Light type const id of the point light.
  76605. */
  76606. static readonly LIGHTTYPEID_POINTLIGHT: number;
  76607. /**
  76608. * Light type const id of the directional light.
  76609. */
  76610. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  76611. /**
  76612. * Light type const id of the spot light.
  76613. */
  76614. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  76615. /**
  76616. * Light type const id of the hemispheric light.
  76617. */
  76618. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  76619. /**
  76620. * Diffuse gives the basic color to an object.
  76621. */
  76622. diffuse: Color3;
  76623. /**
  76624. * Specular produces a highlight color on an object.
  76625. * Note: This is note affecting PBR materials.
  76626. */
  76627. specular: Color3;
  76628. /**
  76629. * Defines the falloff type for this light. This lets overrriding how punctual light are
  76630. * falling off base on range or angle.
  76631. * This can be set to any values in Light.FALLOFF_x.
  76632. *
  76633. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  76634. * other types of materials.
  76635. */
  76636. falloffType: number;
  76637. /**
  76638. * Strength of the light.
  76639. * Note: By default it is define in the framework own unit.
  76640. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  76641. */
  76642. intensity: number;
  76643. private _range;
  76644. protected _inverseSquaredRange: number;
  76645. /**
  76646. * Defines how far from the source the light is impacting in scene units.
  76647. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  76648. */
  76649. /**
  76650. * Defines how far from the source the light is impacting in scene units.
  76651. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  76652. */
  76653. range: number;
  76654. /**
  76655. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  76656. * of light.
  76657. */
  76658. private _photometricScale;
  76659. private _intensityMode;
  76660. /**
  76661. * Gets the photometric scale used to interpret the intensity.
  76662. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  76663. */
  76664. /**
  76665. * Sets the photometric scale used to interpret the intensity.
  76666. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  76667. */
  76668. intensityMode: number;
  76669. private _radius;
  76670. /**
  76671. * Gets the light radius used by PBR Materials to simulate soft area lights.
  76672. */
  76673. /**
  76674. * sets the light radius used by PBR Materials to simulate soft area lights.
  76675. */
  76676. radius: number;
  76677. private _renderPriority;
  76678. /**
  76679. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  76680. * exceeding the number allowed of the materials.
  76681. */
  76682. renderPriority: number;
  76683. private _shadowEnabled;
  76684. /**
  76685. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  76686. * the current shadow generator.
  76687. */
  76688. /**
  76689. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  76690. * the current shadow generator.
  76691. */
  76692. shadowEnabled: boolean;
  76693. private _includedOnlyMeshes;
  76694. /**
  76695. * Gets the only meshes impacted by this light.
  76696. */
  76697. /**
  76698. * Sets the only meshes impacted by this light.
  76699. */
  76700. includedOnlyMeshes: AbstractMesh[];
  76701. private _excludedMeshes;
  76702. /**
  76703. * Gets the meshes not impacted by this light.
  76704. */
  76705. /**
  76706. * Sets the meshes not impacted by this light.
  76707. */
  76708. excludedMeshes: AbstractMesh[];
  76709. private _excludeWithLayerMask;
  76710. /**
  76711. * Gets the layer id use to find what meshes are not impacted by the light.
  76712. * Inactive if 0
  76713. */
  76714. /**
  76715. * Sets the layer id use to find what meshes are not impacted by the light.
  76716. * Inactive if 0
  76717. */
  76718. excludeWithLayerMask: number;
  76719. private _includeOnlyWithLayerMask;
  76720. /**
  76721. * Gets the layer id use to find what meshes are impacted by the light.
  76722. * Inactive if 0
  76723. */
  76724. /**
  76725. * Sets the layer id use to find what meshes are impacted by the light.
  76726. * Inactive if 0
  76727. */
  76728. includeOnlyWithLayerMask: number;
  76729. private _lightmapMode;
  76730. /**
  76731. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  76732. */
  76733. /**
  76734. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  76735. */
  76736. lightmapMode: number;
  76737. /**
  76738. * Shadow generator associted to the light.
  76739. * @hidden Internal use only.
  76740. */
  76741. _shadowGenerator: Nullable<IShadowGenerator>;
  76742. /**
  76743. * @hidden Internal use only.
  76744. */
  76745. _excludedMeshesIds: string[];
  76746. /**
  76747. * @hidden Internal use only.
  76748. */
  76749. _includedOnlyMeshesIds: string[];
  76750. /**
  76751. * The current light unifom buffer.
  76752. * @hidden Internal use only.
  76753. */
  76754. _uniformBuffer: UniformBuffer;
  76755. /**
  76756. * Creates a Light object in the scene.
  76757. * Documentation : https://doc.babylonjs.com/babylon101/lights
  76758. * @param name The firendly name of the light
  76759. * @param scene The scene the light belongs too
  76760. */
  76761. constructor(name: string, scene: Scene);
  76762. protected abstract _buildUniformLayout(): void;
  76763. /**
  76764. * Sets the passed Effect "effect" with the Light information.
  76765. * @param effect The effect to update
  76766. * @param lightIndex The index of the light in the effect to update
  76767. * @returns The light
  76768. */
  76769. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  76770. /**
  76771. * Sets the passed Effect "effect" with the Light information.
  76772. * @param effect The effect to update
  76773. * @param lightDataUniformName The uniform used to store light data (position or direction)
  76774. * @returns The light
  76775. */
  76776. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  76777. /**
  76778. * Returns the string "Light".
  76779. * @returns the class name
  76780. */
  76781. getClassName(): string;
  76782. /** @hidden */
  76783. readonly _isLight: boolean;
  76784. /**
  76785. * Converts the light information to a readable string for debug purpose.
  76786. * @param fullDetails Supports for multiple levels of logging within scene loading
  76787. * @returns the human readable light info
  76788. */
  76789. toString(fullDetails?: boolean): string;
  76790. /** @hidden */
  76791. protected _syncParentEnabledState(): void;
  76792. /**
  76793. * Set the enabled state of this node.
  76794. * @param value - the new enabled state
  76795. */
  76796. setEnabled(value: boolean): void;
  76797. /**
  76798. * Returns the Light associated shadow generator if any.
  76799. * @return the associated shadow generator.
  76800. */
  76801. getShadowGenerator(): Nullable<IShadowGenerator>;
  76802. /**
  76803. * Returns a Vector3, the absolute light position in the World.
  76804. * @returns the world space position of the light
  76805. */
  76806. getAbsolutePosition(): Vector3;
  76807. /**
  76808. * Specifies if the light will affect the passed mesh.
  76809. * @param mesh The mesh to test against the light
  76810. * @return true the mesh is affected otherwise, false.
  76811. */
  76812. canAffectMesh(mesh: AbstractMesh): boolean;
  76813. /**
  76814. * Sort function to order lights for rendering.
  76815. * @param a First Light object to compare to second.
  76816. * @param b Second Light object to compare first.
  76817. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  76818. */
  76819. static CompareLightsPriority(a: Light, b: Light): number;
  76820. /**
  76821. * Releases resources associated with this node.
  76822. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  76823. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  76824. */
  76825. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  76826. /**
  76827. * Returns the light type ID (integer).
  76828. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  76829. */
  76830. getTypeID(): number;
  76831. /**
  76832. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  76833. * @returns the scaled intensity in intensity mode unit
  76834. */
  76835. getScaledIntensity(): number;
  76836. /**
  76837. * Returns a new Light object, named "name", from the current one.
  76838. * @param name The name of the cloned light
  76839. * @returns the new created light
  76840. */
  76841. clone(name: string): Nullable<Light>;
  76842. /**
  76843. * Serializes the current light into a Serialization object.
  76844. * @returns the serialized object.
  76845. */
  76846. serialize(): any;
  76847. /**
  76848. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  76849. * This new light is named "name" and added to the passed scene.
  76850. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  76851. * @param name The friendly name of the light
  76852. * @param scene The scene the new light will belong to
  76853. * @returns the constructor function
  76854. */
  76855. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  76856. /**
  76857. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  76858. * @param parsedLight The JSON representation of the light
  76859. * @param scene The scene to create the parsed light in
  76860. * @returns the created light after parsing
  76861. */
  76862. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  76863. private _hookArrayForExcluded;
  76864. private _hookArrayForIncludedOnly;
  76865. private _resyncMeshes;
  76866. /**
  76867. * Forces the meshes to update their light related information in their rendering used effects
  76868. * @hidden Internal Use Only
  76869. */
  76870. _markMeshesAsLightDirty(): void;
  76871. /**
  76872. * Recomputes the cached photometric scale if needed.
  76873. */
  76874. private _computePhotometricScale;
  76875. /**
  76876. * Returns the Photometric Scale according to the light type and intensity mode.
  76877. */
  76878. private _getPhotometricScale;
  76879. /**
  76880. * Reorder the light in the scene according to their defined priority.
  76881. * @hidden Internal Use Only
  76882. */
  76883. _reorderLightsInScene(): void;
  76884. /**
  76885. * Prepares the list of defines specific to the light type.
  76886. * @param defines the list of defines
  76887. * @param lightIndex defines the index of the light for the effect
  76888. */
  76889. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  76890. }
  76891. }
  76892. declare module BABYLON {
  76893. /**
  76894. * Interface used to define Action
  76895. */
  76896. export interface IAction {
  76897. /**
  76898. * Trigger for the action
  76899. */
  76900. trigger: number;
  76901. /** Options of the trigger */
  76902. triggerOptions: any;
  76903. /**
  76904. * Gets the trigger parameters
  76905. * @returns the trigger parameters
  76906. */
  76907. getTriggerParameter(): any;
  76908. /**
  76909. * Internal only - executes current action event
  76910. * @hidden
  76911. */
  76912. _executeCurrent(evt?: ActionEvent): void;
  76913. /**
  76914. * Serialize placeholder for child classes
  76915. * @param parent of child
  76916. * @returns the serialized object
  76917. */
  76918. serialize(parent: any): any;
  76919. /**
  76920. * Internal only
  76921. * @hidden
  76922. */
  76923. _prepare(): void;
  76924. /**
  76925. * Internal only - manager for action
  76926. * @hidden
  76927. */
  76928. _actionManager: AbstractActionManager;
  76929. /**
  76930. * Adds action to chain of actions, may be a DoNothingAction
  76931. * @param action defines the next action to execute
  76932. * @returns The action passed in
  76933. * @see https://www.babylonjs-playground.com/#1T30HR#0
  76934. */
  76935. then(action: IAction): IAction;
  76936. }
  76937. /**
  76938. * The action to be carried out following a trigger
  76939. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  76940. */
  76941. export class Action implements IAction {
  76942. /** the trigger, with or without parameters, for the action */
  76943. triggerOptions: any;
  76944. /**
  76945. * Trigger for the action
  76946. */
  76947. trigger: number;
  76948. /**
  76949. * Internal only - manager for action
  76950. * @hidden
  76951. */
  76952. _actionManager: ActionManager;
  76953. private _nextActiveAction;
  76954. private _child;
  76955. private _condition?;
  76956. private _triggerParameter;
  76957. /**
  76958. * An event triggered prior to action being executed.
  76959. */
  76960. onBeforeExecuteObservable: Observable<Action>;
  76961. /**
  76962. * Creates a new Action
  76963. * @param triggerOptions the trigger, with or without parameters, for the action
  76964. * @param condition an optional determinant of action
  76965. */
  76966. constructor(
  76967. /** the trigger, with or without parameters, for the action */
  76968. triggerOptions: any, condition?: Condition);
  76969. /**
  76970. * Internal only
  76971. * @hidden
  76972. */
  76973. _prepare(): void;
  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. * Execute placeholder for child classes
  76986. * @param evt optional action event
  76987. */
  76988. execute(evt?: ActionEvent): void;
  76989. /**
  76990. * Skips to next active action
  76991. */
  76992. skipToNextActiveAction(): void;
  76993. /**
  76994. * Adds action to chain of actions, may be a DoNothingAction
  76995. * @param action defines the next action to execute
  76996. * @returns The action passed in
  76997. * @see https://www.babylonjs-playground.com/#1T30HR#0
  76998. */
  76999. then(action: Action): Action;
  77000. /**
  77001. * Internal only
  77002. * @hidden
  77003. */
  77004. _getProperty(propertyPath: string): string;
  77005. /**
  77006. * Internal only
  77007. * @hidden
  77008. */
  77009. _getEffectiveTarget(target: any, propertyPath: string): any;
  77010. /**
  77011. * Serialize placeholder for child classes
  77012. * @param parent of child
  77013. * @returns the serialized object
  77014. */
  77015. serialize(parent: any): any;
  77016. /**
  77017. * Internal only called by serialize
  77018. * @hidden
  77019. */
  77020. protected _serialize(serializedAction: any, parent?: any): any;
  77021. /**
  77022. * Internal only
  77023. * @hidden
  77024. */
  77025. static _SerializeValueAsString: (value: any) => string;
  77026. /**
  77027. * Internal only
  77028. * @hidden
  77029. */
  77030. static _GetTargetProperty: (target: Node | Scene) => {
  77031. name: string;
  77032. targetType: string;
  77033. value: string;
  77034. };
  77035. }
  77036. }
  77037. declare module BABYLON {
  77038. /**
  77039. * A Condition applied to an Action
  77040. */
  77041. export class Condition {
  77042. /**
  77043. * Internal only - manager for action
  77044. * @hidden
  77045. */
  77046. _actionManager: ActionManager;
  77047. /**
  77048. * Internal only
  77049. * @hidden
  77050. */
  77051. _evaluationId: number;
  77052. /**
  77053. * Internal only
  77054. * @hidden
  77055. */
  77056. _currentResult: boolean;
  77057. /**
  77058. * Creates a new Condition
  77059. * @param actionManager the manager of the action the condition is applied to
  77060. */
  77061. constructor(actionManager: ActionManager);
  77062. /**
  77063. * Check if the current condition is valid
  77064. * @returns a boolean
  77065. */
  77066. isValid(): boolean;
  77067. /**
  77068. * Internal only
  77069. * @hidden
  77070. */
  77071. _getProperty(propertyPath: string): string;
  77072. /**
  77073. * Internal only
  77074. * @hidden
  77075. */
  77076. _getEffectiveTarget(target: any, propertyPath: string): any;
  77077. /**
  77078. * Serialize placeholder for child classes
  77079. * @returns the serialized object
  77080. */
  77081. serialize(): any;
  77082. /**
  77083. * Internal only
  77084. * @hidden
  77085. */
  77086. protected _serialize(serializedCondition: any): any;
  77087. }
  77088. /**
  77089. * Defines specific conditional operators as extensions of Condition
  77090. */
  77091. export class ValueCondition extends Condition {
  77092. /** path to specify the property of the target the conditional operator uses */
  77093. propertyPath: string;
  77094. /** the value compared by the conditional operator against the current value of the property */
  77095. value: any;
  77096. /** the conditional operator, default ValueCondition.IsEqual */
  77097. operator: number;
  77098. /**
  77099. * Internal only
  77100. * @hidden
  77101. */
  77102. private static _IsEqual;
  77103. /**
  77104. * Internal only
  77105. * @hidden
  77106. */
  77107. private static _IsDifferent;
  77108. /**
  77109. * Internal only
  77110. * @hidden
  77111. */
  77112. private static _IsGreater;
  77113. /**
  77114. * Internal only
  77115. * @hidden
  77116. */
  77117. private static _IsLesser;
  77118. /**
  77119. * returns the number for IsEqual
  77120. */
  77121. static readonly IsEqual: number;
  77122. /**
  77123. * Returns the number for IsDifferent
  77124. */
  77125. static readonly IsDifferent: number;
  77126. /**
  77127. * Returns the number for IsGreater
  77128. */
  77129. static readonly IsGreater: number;
  77130. /**
  77131. * Returns the number for IsLesser
  77132. */
  77133. static readonly IsLesser: number;
  77134. /**
  77135. * Internal only The action manager for the condition
  77136. * @hidden
  77137. */
  77138. _actionManager: ActionManager;
  77139. /**
  77140. * Internal only
  77141. * @hidden
  77142. */
  77143. private _target;
  77144. /**
  77145. * Internal only
  77146. * @hidden
  77147. */
  77148. private _effectiveTarget;
  77149. /**
  77150. * Internal only
  77151. * @hidden
  77152. */
  77153. private _property;
  77154. /**
  77155. * Creates a new ValueCondition
  77156. * @param actionManager manager for the action the condition applies to
  77157. * @param target for the action
  77158. * @param propertyPath path to specify the property of the target the conditional operator uses
  77159. * @param value the value compared by the conditional operator against the current value of the property
  77160. * @param operator the conditional operator, default ValueCondition.IsEqual
  77161. */
  77162. constructor(actionManager: ActionManager, target: any,
  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. * Compares the given value with the property value for the specified conditional operator
  77171. * @returns the result of the comparison
  77172. */
  77173. isValid(): boolean;
  77174. /**
  77175. * Serialize the ValueCondition into a JSON compatible object
  77176. * @returns serialization object
  77177. */
  77178. serialize(): any;
  77179. /**
  77180. * Gets the name of the conditional operator for the ValueCondition
  77181. * @param operator the conditional operator
  77182. * @returns the name
  77183. */
  77184. static GetOperatorName(operator: number): string;
  77185. }
  77186. /**
  77187. * Defines a predicate condition as an extension of Condition
  77188. */
  77189. export class PredicateCondition extends Condition {
  77190. /** defines the predicate function used to validate the condition */
  77191. predicate: () => boolean;
  77192. /**
  77193. * Internal only - manager for action
  77194. * @hidden
  77195. */
  77196. _actionManager: ActionManager;
  77197. /**
  77198. * Creates a new PredicateCondition
  77199. * @param actionManager manager for the action the condition applies to
  77200. * @param predicate defines the predicate function used to validate the condition
  77201. */
  77202. constructor(actionManager: ActionManager,
  77203. /** defines the predicate function used to validate the condition */
  77204. predicate: () => boolean);
  77205. /**
  77206. * @returns the validity of the predicate condition
  77207. */
  77208. isValid(): boolean;
  77209. }
  77210. /**
  77211. * Defines a state condition as an extension of Condition
  77212. */
  77213. export class StateCondition extends Condition {
  77214. /** Value to compare with target state */
  77215. value: string;
  77216. /**
  77217. * Internal only - manager for action
  77218. * @hidden
  77219. */
  77220. _actionManager: ActionManager;
  77221. /**
  77222. * Internal only
  77223. * @hidden
  77224. */
  77225. private _target;
  77226. /**
  77227. * Creates a new StateCondition
  77228. * @param actionManager manager for the action the condition applies to
  77229. * @param target of the condition
  77230. * @param value to compare with target state
  77231. */
  77232. constructor(actionManager: ActionManager, target: any,
  77233. /** Value to compare with target state */
  77234. value: string);
  77235. /**
  77236. * Gets a boolean indicating if the current condition is met
  77237. * @returns the validity of the state
  77238. */
  77239. isValid(): boolean;
  77240. /**
  77241. * Serialize the StateCondition into a JSON compatible object
  77242. * @returns serialization object
  77243. */
  77244. serialize(): any;
  77245. }
  77246. }
  77247. declare module BABYLON {
  77248. /**
  77249. * This defines an action responsible to toggle a boolean once triggered.
  77250. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77251. */
  77252. export class SwitchBooleanAction extends Action {
  77253. /**
  77254. * The path to the boolean property in the target object
  77255. */
  77256. propertyPath: string;
  77257. private _target;
  77258. private _effectiveTarget;
  77259. private _property;
  77260. /**
  77261. * Instantiate the action
  77262. * @param triggerOptions defines the trigger options
  77263. * @param target defines the object containing the boolean
  77264. * @param propertyPath defines the path to the boolean property in the target object
  77265. * @param condition defines the trigger related conditions
  77266. */
  77267. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  77268. /** @hidden */
  77269. _prepare(): void;
  77270. /**
  77271. * Execute the action toggle the boolean value.
  77272. */
  77273. execute(): void;
  77274. /**
  77275. * Serializes the actions and its related information.
  77276. * @param parent defines the object to serialize in
  77277. * @returns the serialized object
  77278. */
  77279. serialize(parent: any): any;
  77280. }
  77281. /**
  77282. * This defines an action responsible to set a the state field of the target
  77283. * to a desired value once triggered.
  77284. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77285. */
  77286. export class SetStateAction extends Action {
  77287. /**
  77288. * The value to store in the state field.
  77289. */
  77290. value: string;
  77291. private _target;
  77292. /**
  77293. * Instantiate the action
  77294. * @param triggerOptions defines the trigger options
  77295. * @param target defines the object containing the state property
  77296. * @param value defines the value to store in the state field
  77297. * @param condition defines the trigger related conditions
  77298. */
  77299. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  77300. /**
  77301. * Execute the action and store the value on the target state property.
  77302. */
  77303. execute(): void;
  77304. /**
  77305. * Serializes the actions and its related information.
  77306. * @param parent defines the object to serialize in
  77307. * @returns the serialized object
  77308. */
  77309. serialize(parent: any): any;
  77310. }
  77311. /**
  77312. * This defines an action responsible to set a property of the target
  77313. * to a desired value once triggered.
  77314. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77315. */
  77316. export class SetValueAction extends Action {
  77317. /**
  77318. * The path of the property to set in the target.
  77319. */
  77320. propertyPath: string;
  77321. /**
  77322. * The value to set in the property
  77323. */
  77324. value: any;
  77325. private _target;
  77326. private _effectiveTarget;
  77327. private _property;
  77328. /**
  77329. * Instantiate the action
  77330. * @param triggerOptions defines the trigger options
  77331. * @param target defines the object containing the property
  77332. * @param propertyPath defines the path of the property to set in the target
  77333. * @param value defines the value to set in the property
  77334. * @param condition defines the trigger related conditions
  77335. */
  77336. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  77337. /** @hidden */
  77338. _prepare(): void;
  77339. /**
  77340. * Execute the action and set the targetted property to the desired value.
  77341. */
  77342. execute(): void;
  77343. /**
  77344. * Serializes the actions and its related information.
  77345. * @param parent defines the object to serialize in
  77346. * @returns the serialized object
  77347. */
  77348. serialize(parent: any): any;
  77349. }
  77350. /**
  77351. * This defines an action responsible to increment the target value
  77352. * to a desired value once triggered.
  77353. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77354. */
  77355. export class IncrementValueAction extends Action {
  77356. /**
  77357. * The path of the property to increment in the target.
  77358. */
  77359. propertyPath: string;
  77360. /**
  77361. * The value we should increment the property by.
  77362. */
  77363. value: any;
  77364. private _target;
  77365. private _effectiveTarget;
  77366. private _property;
  77367. /**
  77368. * Instantiate the action
  77369. * @param triggerOptions defines the trigger options
  77370. * @param target defines the object containing the property
  77371. * @param propertyPath defines the path of the property to increment in the target
  77372. * @param value defines the value value we should increment the property by
  77373. * @param condition defines the trigger related conditions
  77374. */
  77375. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  77376. /** @hidden */
  77377. _prepare(): void;
  77378. /**
  77379. * Execute the action and increment the target of the value amount.
  77380. */
  77381. execute(): void;
  77382. /**
  77383. * Serializes the actions and its related information.
  77384. * @param parent defines the object to serialize in
  77385. * @returns the serialized object
  77386. */
  77387. serialize(parent: any): any;
  77388. }
  77389. /**
  77390. * This defines an action responsible to start an animation once triggered.
  77391. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77392. */
  77393. export class PlayAnimationAction extends Action {
  77394. /**
  77395. * Where the animation should start (animation frame)
  77396. */
  77397. from: number;
  77398. /**
  77399. * Where the animation should stop (animation frame)
  77400. */
  77401. to: number;
  77402. /**
  77403. * Define if the animation should loop or stop after the first play.
  77404. */
  77405. loop?: boolean;
  77406. private _target;
  77407. /**
  77408. * Instantiate the action
  77409. * @param triggerOptions defines the trigger options
  77410. * @param target defines the target animation or animation name
  77411. * @param from defines from where the animation should start (animation frame)
  77412. * @param end defines where the animation should stop (animation frame)
  77413. * @param loop defines if the animation should loop or stop after the first play
  77414. * @param condition defines the trigger related conditions
  77415. */
  77416. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  77417. /** @hidden */
  77418. _prepare(): void;
  77419. /**
  77420. * Execute the action and play the animation.
  77421. */
  77422. execute(): void;
  77423. /**
  77424. * Serializes the actions and its related information.
  77425. * @param parent defines the object to serialize in
  77426. * @returns the serialized object
  77427. */
  77428. serialize(parent: any): any;
  77429. }
  77430. /**
  77431. * This defines an action responsible to stop an animation once triggered.
  77432. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77433. */
  77434. export class StopAnimationAction extends Action {
  77435. private _target;
  77436. /**
  77437. * Instantiate the action
  77438. * @param triggerOptions defines the trigger options
  77439. * @param target defines the target animation or animation name
  77440. * @param condition defines the trigger related conditions
  77441. */
  77442. constructor(triggerOptions: any, target: any, condition?: Condition);
  77443. /** @hidden */
  77444. _prepare(): void;
  77445. /**
  77446. * Execute the action and stop the animation.
  77447. */
  77448. execute(): void;
  77449. /**
  77450. * Serializes the actions and its related information.
  77451. * @param parent defines the object to serialize in
  77452. * @returns the serialized object
  77453. */
  77454. serialize(parent: any): any;
  77455. }
  77456. /**
  77457. * This defines an action responsible that does nothing once triggered.
  77458. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77459. */
  77460. export class DoNothingAction extends Action {
  77461. /**
  77462. * Instantiate the action
  77463. * @param triggerOptions defines the trigger options
  77464. * @param condition defines the trigger related conditions
  77465. */
  77466. constructor(triggerOptions?: any, condition?: Condition);
  77467. /**
  77468. * Execute the action and do nothing.
  77469. */
  77470. execute(): void;
  77471. /**
  77472. * Serializes the actions and its related information.
  77473. * @param parent defines the object to serialize in
  77474. * @returns the serialized object
  77475. */
  77476. serialize(parent: any): any;
  77477. }
  77478. /**
  77479. * This defines an action responsible to trigger several actions once triggered.
  77480. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77481. */
  77482. export class CombineAction extends Action {
  77483. /**
  77484. * The list of aggregated animations to run.
  77485. */
  77486. children: Action[];
  77487. /**
  77488. * Instantiate the action
  77489. * @param triggerOptions defines the trigger options
  77490. * @param children defines the list of aggregated animations to run
  77491. * @param condition defines the trigger related conditions
  77492. */
  77493. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  77494. /** @hidden */
  77495. _prepare(): void;
  77496. /**
  77497. * Execute the action and executes all the aggregated actions.
  77498. */
  77499. execute(evt: ActionEvent): void;
  77500. /**
  77501. * Serializes the actions and its related information.
  77502. * @param parent defines the object to serialize in
  77503. * @returns the serialized object
  77504. */
  77505. serialize(parent: any): any;
  77506. }
  77507. /**
  77508. * This defines an action responsible to run code (external event) once triggered.
  77509. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77510. */
  77511. export class ExecuteCodeAction extends Action {
  77512. /**
  77513. * The callback function to run.
  77514. */
  77515. func: (evt: ActionEvent) => void;
  77516. /**
  77517. * Instantiate the action
  77518. * @param triggerOptions defines the trigger options
  77519. * @param func defines the callback function to run
  77520. * @param condition defines the trigger related conditions
  77521. */
  77522. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  77523. /**
  77524. * Execute the action and run the attached code.
  77525. */
  77526. execute(evt: ActionEvent): void;
  77527. }
  77528. /**
  77529. * This defines an action responsible to set the parent property of the target once triggered.
  77530. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77531. */
  77532. export class SetParentAction extends Action {
  77533. private _parent;
  77534. private _target;
  77535. /**
  77536. * Instantiate the action
  77537. * @param triggerOptions defines the trigger options
  77538. * @param target defines the target containing the parent property
  77539. * @param parent defines from where the animation should start (animation frame)
  77540. * @param condition defines the trigger related conditions
  77541. */
  77542. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  77543. /** @hidden */
  77544. _prepare(): void;
  77545. /**
  77546. * Execute the action and set the parent property.
  77547. */
  77548. execute(): void;
  77549. /**
  77550. * Serializes the actions and its related information.
  77551. * @param parent defines the object to serialize in
  77552. * @returns the serialized object
  77553. */
  77554. serialize(parent: any): any;
  77555. }
  77556. }
  77557. declare module BABYLON {
  77558. /**
  77559. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  77560. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  77561. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77562. */
  77563. export class ActionManager extends AbstractActionManager {
  77564. /**
  77565. * Nothing
  77566. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77567. */
  77568. static readonly NothingTrigger: number;
  77569. /**
  77570. * On pick
  77571. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77572. */
  77573. static readonly OnPickTrigger: number;
  77574. /**
  77575. * On left pick
  77576. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77577. */
  77578. static readonly OnLeftPickTrigger: number;
  77579. /**
  77580. * On right pick
  77581. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77582. */
  77583. static readonly OnRightPickTrigger: number;
  77584. /**
  77585. * On center pick
  77586. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77587. */
  77588. static readonly OnCenterPickTrigger: number;
  77589. /**
  77590. * On pick down
  77591. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77592. */
  77593. static readonly OnPickDownTrigger: number;
  77594. /**
  77595. * On double pick
  77596. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77597. */
  77598. static readonly OnDoublePickTrigger: number;
  77599. /**
  77600. * On pick up
  77601. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77602. */
  77603. static readonly OnPickUpTrigger: number;
  77604. /**
  77605. * On pick out.
  77606. * This trigger will only be raised if you also declared a OnPickDown
  77607. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77608. */
  77609. static readonly OnPickOutTrigger: number;
  77610. /**
  77611. * On long press
  77612. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77613. */
  77614. static readonly OnLongPressTrigger: number;
  77615. /**
  77616. * On pointer over
  77617. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77618. */
  77619. static readonly OnPointerOverTrigger: number;
  77620. /**
  77621. * On pointer out
  77622. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77623. */
  77624. static readonly OnPointerOutTrigger: number;
  77625. /**
  77626. * On every frame
  77627. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77628. */
  77629. static readonly OnEveryFrameTrigger: number;
  77630. /**
  77631. * On intersection enter
  77632. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77633. */
  77634. static readonly OnIntersectionEnterTrigger: number;
  77635. /**
  77636. * On intersection exit
  77637. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77638. */
  77639. static readonly OnIntersectionExitTrigger: number;
  77640. /**
  77641. * On key down
  77642. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77643. */
  77644. static readonly OnKeyDownTrigger: number;
  77645. /**
  77646. * On key up
  77647. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77648. */
  77649. static readonly OnKeyUpTrigger: number;
  77650. private _scene;
  77651. /**
  77652. * Creates a new action manager
  77653. * @param scene defines the hosting scene
  77654. */
  77655. constructor(scene: Scene);
  77656. /**
  77657. * Releases all associated resources
  77658. */
  77659. dispose(): void;
  77660. /**
  77661. * Gets hosting scene
  77662. * @returns the hosting scene
  77663. */
  77664. getScene(): Scene;
  77665. /**
  77666. * Does this action manager handles actions of any of the given triggers
  77667. * @param triggers defines the triggers to be tested
  77668. * @return a boolean indicating whether one (or more) of the triggers is handled
  77669. */
  77670. hasSpecificTriggers(triggers: number[]): boolean;
  77671. /**
  77672. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  77673. * speed.
  77674. * @param triggerA defines the trigger to be tested
  77675. * @param triggerB defines the trigger to be tested
  77676. * @return a boolean indicating whether one (or more) of the triggers is handled
  77677. */
  77678. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  77679. /**
  77680. * Does this action manager handles actions of a given trigger
  77681. * @param trigger defines the trigger to be tested
  77682. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  77683. * @return whether the trigger is handled
  77684. */
  77685. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  77686. /**
  77687. * Does this action manager has pointer triggers
  77688. */
  77689. readonly hasPointerTriggers: boolean;
  77690. /**
  77691. * Does this action manager has pick triggers
  77692. */
  77693. readonly hasPickTriggers: boolean;
  77694. /**
  77695. * Registers an action to this action manager
  77696. * @param action defines the action to be registered
  77697. * @return the action amended (prepared) after registration
  77698. */
  77699. registerAction(action: IAction): Nullable<IAction>;
  77700. /**
  77701. * Unregisters an action to this action manager
  77702. * @param action defines the action to be unregistered
  77703. * @return a boolean indicating whether the action has been unregistered
  77704. */
  77705. unregisterAction(action: IAction): Boolean;
  77706. /**
  77707. * Process a specific trigger
  77708. * @param trigger defines the trigger to process
  77709. * @param evt defines the event details to be processed
  77710. */
  77711. processTrigger(trigger: number, evt?: IActionEvent): void;
  77712. /** @hidden */
  77713. _getEffectiveTarget(target: any, propertyPath: string): any;
  77714. /** @hidden */
  77715. _getProperty(propertyPath: string): string;
  77716. /**
  77717. * Serialize this manager to a JSON object
  77718. * @param name defines the property name to store this manager
  77719. * @returns a JSON representation of this manager
  77720. */
  77721. serialize(name: string): any;
  77722. /**
  77723. * Creates a new ActionManager from a JSON data
  77724. * @param parsedActions defines the JSON data to read from
  77725. * @param object defines the hosting mesh
  77726. * @param scene defines the hosting scene
  77727. */
  77728. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  77729. /**
  77730. * Get a trigger name by index
  77731. * @param trigger defines the trigger index
  77732. * @returns a trigger name
  77733. */
  77734. static GetTriggerName(trigger: number): string;
  77735. }
  77736. }
  77737. declare module BABYLON {
  77738. /**
  77739. * Class representing a ray with position and direction
  77740. */
  77741. export class Ray {
  77742. /** origin point */
  77743. origin: Vector3;
  77744. /** direction */
  77745. direction: Vector3;
  77746. /** length of the ray */
  77747. length: number;
  77748. private static readonly TmpVector3;
  77749. private _tmpRay;
  77750. /**
  77751. * Creates a new ray
  77752. * @param origin origin point
  77753. * @param direction direction
  77754. * @param length length of the ray
  77755. */
  77756. constructor(
  77757. /** origin point */
  77758. origin: Vector3,
  77759. /** direction */
  77760. direction: Vector3,
  77761. /** length of the ray */
  77762. length?: number);
  77763. /**
  77764. * Checks if the ray intersects a box
  77765. * @param minimum bound of the box
  77766. * @param maximum bound of the box
  77767. * @param intersectionTreshold extra extend to be added to the box in all direction
  77768. * @returns if the box was hit
  77769. */
  77770. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  77771. /**
  77772. * Checks if the ray intersects a box
  77773. * @param box the bounding box to check
  77774. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  77775. * @returns if the box was hit
  77776. */
  77777. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  77778. /**
  77779. * If the ray hits a sphere
  77780. * @param sphere the bounding sphere to check
  77781. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  77782. * @returns true if it hits the sphere
  77783. */
  77784. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  77785. /**
  77786. * If the ray hits a triange
  77787. * @param vertex0 triangle vertex
  77788. * @param vertex1 triangle vertex
  77789. * @param vertex2 triangle vertex
  77790. * @returns intersection information if hit
  77791. */
  77792. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  77793. /**
  77794. * Checks if ray intersects a plane
  77795. * @param plane the plane to check
  77796. * @returns the distance away it was hit
  77797. */
  77798. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  77799. /**
  77800. * Calculate the intercept of a ray on a given axis
  77801. * @param axis to check 'x' | 'y' | 'z'
  77802. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  77803. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  77804. */
  77805. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  77806. /**
  77807. * Checks if ray intersects a mesh
  77808. * @param mesh the mesh to check
  77809. * @param fastCheck if only the bounding box should checked
  77810. * @returns picking info of the intersecton
  77811. */
  77812. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  77813. /**
  77814. * Checks if ray intersects a mesh
  77815. * @param meshes the meshes to check
  77816. * @param fastCheck if only the bounding box should checked
  77817. * @param results array to store result in
  77818. * @returns Array of picking infos
  77819. */
  77820. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  77821. private _comparePickingInfo;
  77822. private static smallnum;
  77823. private static rayl;
  77824. /**
  77825. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  77826. * @param sega the first point of the segment to test the intersection against
  77827. * @param segb the second point of the segment to test the intersection against
  77828. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  77829. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  77830. */
  77831. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  77832. /**
  77833. * Update the ray from viewport position
  77834. * @param x position
  77835. * @param y y position
  77836. * @param viewportWidth viewport width
  77837. * @param viewportHeight viewport height
  77838. * @param world world matrix
  77839. * @param view view matrix
  77840. * @param projection projection matrix
  77841. * @returns this ray updated
  77842. */
  77843. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  77844. /**
  77845. * Creates a ray with origin and direction of 0,0,0
  77846. * @returns the new ray
  77847. */
  77848. static Zero(): Ray;
  77849. /**
  77850. * Creates a new ray from screen space and viewport
  77851. * @param x position
  77852. * @param y y position
  77853. * @param viewportWidth viewport width
  77854. * @param viewportHeight viewport height
  77855. * @param world world matrix
  77856. * @param view view matrix
  77857. * @param projection projection matrix
  77858. * @returns new ray
  77859. */
  77860. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  77861. /**
  77862. * 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
  77863. * transformed to the given world matrix.
  77864. * @param origin The origin point
  77865. * @param end The end point
  77866. * @param world a matrix to transform the ray to. Default is the identity matrix.
  77867. * @returns the new ray
  77868. */
  77869. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  77870. /**
  77871. * Transforms a ray by a matrix
  77872. * @param ray ray to transform
  77873. * @param matrix matrix to apply
  77874. * @returns the resulting new ray
  77875. */
  77876. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  77877. /**
  77878. * Transforms a ray by a matrix
  77879. * @param ray ray to transform
  77880. * @param matrix matrix to apply
  77881. * @param result ray to store result in
  77882. */
  77883. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  77884. /**
  77885. * Unproject a ray from screen space to object space
  77886. * @param sourceX defines the screen space x coordinate to use
  77887. * @param sourceY defines the screen space y coordinate to use
  77888. * @param viewportWidth defines the current width of the viewport
  77889. * @param viewportHeight defines the current height of the viewport
  77890. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  77891. * @param view defines the view matrix to use
  77892. * @param projection defines the projection matrix to use
  77893. */
  77894. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  77895. }
  77896. /**
  77897. * Type used to define predicate used to select faces when a mesh intersection is detected
  77898. */
  77899. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  77900. interface Scene {
  77901. /** @hidden */
  77902. _tempPickingRay: Nullable<Ray>;
  77903. /** @hidden */
  77904. _cachedRayForTransform: Ray;
  77905. /** @hidden */
  77906. _pickWithRayInverseMatrix: Matrix;
  77907. /** @hidden */
  77908. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  77909. /** @hidden */
  77910. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  77911. }
  77912. }
  77913. declare module BABYLON {
  77914. /**
  77915. * Groups all the scene component constants in one place to ease maintenance.
  77916. * @hidden
  77917. */
  77918. export class SceneComponentConstants {
  77919. static readonly NAME_EFFECTLAYER: string;
  77920. static readonly NAME_LAYER: string;
  77921. static readonly NAME_LENSFLARESYSTEM: string;
  77922. static readonly NAME_BOUNDINGBOXRENDERER: string;
  77923. static readonly NAME_PARTICLESYSTEM: string;
  77924. static readonly NAME_GAMEPAD: string;
  77925. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  77926. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  77927. static readonly NAME_DEPTHRENDERER: string;
  77928. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  77929. static readonly NAME_SPRITE: string;
  77930. static readonly NAME_OUTLINERENDERER: string;
  77931. static readonly NAME_PROCEDURALTEXTURE: string;
  77932. static readonly NAME_SHADOWGENERATOR: string;
  77933. static readonly NAME_OCTREE: string;
  77934. static readonly NAME_PHYSICSENGINE: string;
  77935. static readonly NAME_AUDIO: string;
  77936. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  77937. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  77938. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  77939. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  77940. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  77941. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  77942. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  77943. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  77944. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  77945. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  77946. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  77947. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  77948. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  77949. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  77950. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  77951. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  77952. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  77953. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  77954. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  77955. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  77956. static readonly STEP_AFTERRENDER_AUDIO: number;
  77957. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  77958. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  77959. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  77960. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  77961. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  77962. static readonly STEP_POINTERMOVE_SPRITE: number;
  77963. static readonly STEP_POINTERDOWN_SPRITE: number;
  77964. static readonly STEP_POINTERUP_SPRITE: number;
  77965. }
  77966. /**
  77967. * This represents a scene component.
  77968. *
  77969. * This is used to decouple the dependency the scene is having on the different workloads like
  77970. * layers, post processes...
  77971. */
  77972. export interface ISceneComponent {
  77973. /**
  77974. * The name of the component. Each component must have a unique name.
  77975. */
  77976. name: string;
  77977. /**
  77978. * The scene the component belongs to.
  77979. */
  77980. scene: Scene;
  77981. /**
  77982. * Register the component to one instance of a scene.
  77983. */
  77984. register(): void;
  77985. /**
  77986. * Rebuilds the elements related to this component in case of
  77987. * context lost for instance.
  77988. */
  77989. rebuild(): void;
  77990. /**
  77991. * Disposes the component and the associated ressources.
  77992. */
  77993. dispose(): void;
  77994. }
  77995. /**
  77996. * This represents a SERIALIZABLE scene component.
  77997. *
  77998. * This extends Scene Component to add Serialization methods on top.
  77999. */
  78000. export interface ISceneSerializableComponent extends ISceneComponent {
  78001. /**
  78002. * Adds all the elements from the container to the scene
  78003. * @param container the container holding the elements
  78004. */
  78005. addFromContainer(container: AbstractScene): void;
  78006. /**
  78007. * Removes all the elements in the container from the scene
  78008. * @param container contains the elements to remove
  78009. * @param dispose if the removed element should be disposed (default: false)
  78010. */
  78011. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  78012. /**
  78013. * Serializes the component data to the specified json object
  78014. * @param serializationObject The object to serialize to
  78015. */
  78016. serialize(serializationObject: any): void;
  78017. }
  78018. /**
  78019. * Strong typing of a Mesh related stage step action
  78020. */
  78021. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  78022. /**
  78023. * Strong typing of a Evaluate Sub Mesh related stage step action
  78024. */
  78025. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  78026. /**
  78027. * Strong typing of a Active Mesh related stage step action
  78028. */
  78029. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  78030. /**
  78031. * Strong typing of a Camera related stage step action
  78032. */
  78033. export type CameraStageAction = (camera: Camera) => void;
  78034. /**
  78035. * Strong typing of a Camera Frame buffer related stage step action
  78036. */
  78037. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  78038. /**
  78039. * Strong typing of a Render Target related stage step action
  78040. */
  78041. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  78042. /**
  78043. * Strong typing of a RenderingGroup related stage step action
  78044. */
  78045. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  78046. /**
  78047. * Strong typing of a Mesh Render related stage step action
  78048. */
  78049. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  78050. /**
  78051. * Strong typing of a simple stage step action
  78052. */
  78053. export type SimpleStageAction = () => void;
  78054. /**
  78055. * Strong typing of a render target action.
  78056. */
  78057. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  78058. /**
  78059. * Strong typing of a pointer move action.
  78060. */
  78061. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  78062. /**
  78063. * Strong typing of a pointer up/down action.
  78064. */
  78065. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  78066. /**
  78067. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  78068. * @hidden
  78069. */
  78070. export class Stage<T extends Function> extends Array<{
  78071. index: number;
  78072. component: ISceneComponent;
  78073. action: T;
  78074. }> {
  78075. /**
  78076. * Hide ctor from the rest of the world.
  78077. * @param items The items to add.
  78078. */
  78079. private constructor();
  78080. /**
  78081. * Creates a new Stage.
  78082. * @returns A new instance of a Stage
  78083. */
  78084. static Create<T extends Function>(): Stage<T>;
  78085. /**
  78086. * Registers a step in an ordered way in the targeted stage.
  78087. * @param index Defines the position to register the step in
  78088. * @param component Defines the component attached to the step
  78089. * @param action Defines the action to launch during the step
  78090. */
  78091. registerStep(index: number, component: ISceneComponent, action: T): void;
  78092. /**
  78093. * Clears all the steps from the stage.
  78094. */
  78095. clear(): void;
  78096. }
  78097. }
  78098. declare module BABYLON {
  78099. interface Scene {
  78100. /** @hidden */
  78101. _pointerOverSprite: Nullable<Sprite>;
  78102. /** @hidden */
  78103. _pickedDownSprite: Nullable<Sprite>;
  78104. /** @hidden */
  78105. _tempSpritePickingRay: Nullable<Ray>;
  78106. /**
  78107. * All of the sprite managers added to this scene
  78108. * @see http://doc.babylonjs.com/babylon101/sprites
  78109. */
  78110. spriteManagers: Array<ISpriteManager>;
  78111. /**
  78112. * An event triggered when sprites rendering is about to start
  78113. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  78114. */
  78115. onBeforeSpritesRenderingObservable: Observable<Scene>;
  78116. /**
  78117. * An event triggered when sprites rendering is done
  78118. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  78119. */
  78120. onAfterSpritesRenderingObservable: Observable<Scene>;
  78121. /** @hidden */
  78122. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  78123. /** Launch a ray to try to pick a sprite in the scene
  78124. * @param x position on screen
  78125. * @param y position on screen
  78126. * @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
  78127. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  78128. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  78129. * @returns a PickingInfo
  78130. */
  78131. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  78132. /** Use the given ray to pick a sprite in the scene
  78133. * @param ray The ray (in world space) to use to pick meshes
  78134. * @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
  78135. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  78136. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  78137. * @returns a PickingInfo
  78138. */
  78139. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  78140. /** @hidden */
  78141. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  78142. /** Launch a ray to try to pick sprites in the scene
  78143. * @param x position on screen
  78144. * @param y position on screen
  78145. * @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
  78146. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  78147. * @returns a PickingInfo array
  78148. */
  78149. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  78150. /** Use the given ray to pick sprites in the scene
  78151. * @param ray The ray (in world space) to use to pick meshes
  78152. * @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
  78153. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  78154. * @returns a PickingInfo array
  78155. */
  78156. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  78157. /**
  78158. * Force the sprite under the pointer
  78159. * @param sprite defines the sprite to use
  78160. */
  78161. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  78162. /**
  78163. * Gets the sprite under the pointer
  78164. * @returns a Sprite or null if no sprite is under the pointer
  78165. */
  78166. getPointerOverSprite(): Nullable<Sprite>;
  78167. }
  78168. /**
  78169. * Defines the sprite scene component responsible to manage sprites
  78170. * in a given scene.
  78171. */
  78172. export class SpriteSceneComponent implements ISceneComponent {
  78173. /**
  78174. * The component name helpfull to identify the component in the list of scene components.
  78175. */
  78176. readonly name: string;
  78177. /**
  78178. * The scene the component belongs to.
  78179. */
  78180. scene: Scene;
  78181. /** @hidden */
  78182. private _spritePredicate;
  78183. /**
  78184. * Creates a new instance of the component for the given scene
  78185. * @param scene Defines the scene to register the component in
  78186. */
  78187. constructor(scene: Scene);
  78188. /**
  78189. * Registers the component in a given scene
  78190. */
  78191. register(): void;
  78192. /**
  78193. * Rebuilds the elements related to this component in case of
  78194. * context lost for instance.
  78195. */
  78196. rebuild(): void;
  78197. /**
  78198. * Disposes the component and the associated ressources.
  78199. */
  78200. dispose(): void;
  78201. private _pickSpriteButKeepRay;
  78202. private _pointerMove;
  78203. private _pointerDown;
  78204. private _pointerUp;
  78205. }
  78206. }
  78207. declare module BABYLON {
  78208. /** @hidden */
  78209. export var fogFragmentDeclaration: {
  78210. name: string;
  78211. shader: string;
  78212. };
  78213. }
  78214. declare module BABYLON {
  78215. /** @hidden */
  78216. export var fogFragment: {
  78217. name: string;
  78218. shader: string;
  78219. };
  78220. }
  78221. declare module BABYLON {
  78222. /** @hidden */
  78223. export var spritesPixelShader: {
  78224. name: string;
  78225. shader: string;
  78226. };
  78227. }
  78228. declare module BABYLON {
  78229. /** @hidden */
  78230. export var fogVertexDeclaration: {
  78231. name: string;
  78232. shader: string;
  78233. };
  78234. }
  78235. declare module BABYLON {
  78236. /** @hidden */
  78237. export var spritesVertexShader: {
  78238. name: string;
  78239. shader: string;
  78240. };
  78241. }
  78242. declare module BABYLON {
  78243. /**
  78244. * Defines the minimum interface to fullfil in order to be a sprite manager.
  78245. */
  78246. export interface ISpriteManager extends IDisposable {
  78247. /**
  78248. * Restricts the camera to viewing objects with the same layerMask.
  78249. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  78250. */
  78251. layerMask: number;
  78252. /**
  78253. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  78254. */
  78255. isPickable: boolean;
  78256. /**
  78257. * Specifies the rendering group id for this mesh (0 by default)
  78258. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  78259. */
  78260. renderingGroupId: number;
  78261. /**
  78262. * Defines the list of sprites managed by the manager.
  78263. */
  78264. sprites: Array<Sprite>;
  78265. /**
  78266. * Tests the intersection of a sprite with a specific ray.
  78267. * @param ray The ray we are sending to test the collision
  78268. * @param camera The camera space we are sending rays in
  78269. * @param predicate A predicate allowing excluding sprites from the list of object to test
  78270. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  78271. * @returns picking info or null.
  78272. */
  78273. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  78274. /**
  78275. * Intersects the sprites with a ray
  78276. * @param ray defines the ray to intersect with
  78277. * @param camera defines the current active camera
  78278. * @param predicate defines a predicate used to select candidate sprites
  78279. * @returns null if no hit or a PickingInfo array
  78280. */
  78281. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  78282. /**
  78283. * Renders the list of sprites on screen.
  78284. */
  78285. render(): void;
  78286. }
  78287. /**
  78288. * Class used to manage multiple sprites on the same spritesheet
  78289. * @see http://doc.babylonjs.com/babylon101/sprites
  78290. */
  78291. export class SpriteManager implements ISpriteManager {
  78292. /** defines the manager's name */
  78293. name: string;
  78294. /** Gets the list of sprites */
  78295. sprites: Sprite[];
  78296. /** Gets or sets the rendering group id (0 by default) */
  78297. renderingGroupId: number;
  78298. /** Gets or sets camera layer mask */
  78299. layerMask: number;
  78300. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  78301. fogEnabled: boolean;
  78302. /** Gets or sets a boolean indicating if the sprites are pickable */
  78303. isPickable: boolean;
  78304. /** Defines the default width of a cell in the spritesheet */
  78305. cellWidth: number;
  78306. /** Defines the default height of a cell in the spritesheet */
  78307. cellHeight: number;
  78308. /** Associative array from JSON sprite data file */
  78309. private _cellData;
  78310. /** Array of sprite names from JSON sprite data file */
  78311. private _spriteMap;
  78312. /** True when packed cell data from JSON file is ready*/
  78313. private _packedAndReady;
  78314. /**
  78315. * An event triggered when the manager is disposed.
  78316. */
  78317. onDisposeObservable: Observable<SpriteManager>;
  78318. private _onDisposeObserver;
  78319. /**
  78320. * Callback called when the manager is disposed
  78321. */
  78322. onDispose: () => void;
  78323. private _capacity;
  78324. private _fromPacked;
  78325. private _spriteTexture;
  78326. private _epsilon;
  78327. private _scene;
  78328. private _vertexData;
  78329. private _buffer;
  78330. private _vertexBuffers;
  78331. private _indexBuffer;
  78332. private _effectBase;
  78333. private _effectFog;
  78334. /**
  78335. * Gets or sets the spritesheet texture
  78336. */
  78337. texture: Texture;
  78338. /**
  78339. * Creates a new sprite manager
  78340. * @param name defines the manager's name
  78341. * @param imgUrl defines the sprite sheet url
  78342. * @param capacity defines the maximum allowed number of sprites
  78343. * @param cellSize defines the size of a sprite cell
  78344. * @param scene defines the hosting scene
  78345. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  78346. * @param samplingMode defines the smapling mode to use with spritesheet
  78347. * @param fromPacked set to false; do not alter
  78348. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  78349. */
  78350. constructor(
  78351. /** defines the manager's name */
  78352. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  78353. private _makePacked;
  78354. private _appendSpriteVertex;
  78355. /**
  78356. * Intersects the sprites with a ray
  78357. * @param ray defines the ray to intersect with
  78358. * @param camera defines the current active camera
  78359. * @param predicate defines a predicate used to select candidate sprites
  78360. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  78361. * @returns null if no hit or a PickingInfo
  78362. */
  78363. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  78364. /**
  78365. * Intersects the sprites with a ray
  78366. * @param ray defines the ray to intersect with
  78367. * @param camera defines the current active camera
  78368. * @param predicate defines a predicate used to select candidate sprites
  78369. * @returns null if no hit or a PickingInfo array
  78370. */
  78371. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  78372. /**
  78373. * Render all child sprites
  78374. */
  78375. render(): void;
  78376. /**
  78377. * Release associated resources
  78378. */
  78379. dispose(): void;
  78380. }
  78381. }
  78382. declare module BABYLON {
  78383. /**
  78384. * Class used to represent a sprite
  78385. * @see http://doc.babylonjs.com/babylon101/sprites
  78386. */
  78387. export class Sprite {
  78388. /** defines the name */
  78389. name: string;
  78390. /** Gets or sets the current world position */
  78391. position: Vector3;
  78392. /** Gets or sets the main color */
  78393. color: Color4;
  78394. /** Gets or sets the width */
  78395. width: number;
  78396. /** Gets or sets the height */
  78397. height: number;
  78398. /** Gets or sets rotation angle */
  78399. angle: number;
  78400. /** Gets or sets the cell index in the sprite sheet */
  78401. cellIndex: number;
  78402. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  78403. cellRef: string;
  78404. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  78405. invertU: number;
  78406. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  78407. invertV: number;
  78408. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  78409. disposeWhenFinishedAnimating: boolean;
  78410. /** Gets the list of attached animations */
  78411. animations: Animation[];
  78412. /** Gets or sets a boolean indicating if the sprite can be picked */
  78413. isPickable: boolean;
  78414. /**
  78415. * Gets or sets the associated action manager
  78416. */
  78417. actionManager: Nullable<ActionManager>;
  78418. private _animationStarted;
  78419. private _loopAnimation;
  78420. private _fromIndex;
  78421. private _toIndex;
  78422. private _delay;
  78423. private _direction;
  78424. private _manager;
  78425. private _time;
  78426. private _onAnimationEnd;
  78427. /**
  78428. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  78429. */
  78430. isVisible: boolean;
  78431. /**
  78432. * Gets or sets the sprite size
  78433. */
  78434. size: number;
  78435. /**
  78436. * Creates a new Sprite
  78437. * @param name defines the name
  78438. * @param manager defines the manager
  78439. */
  78440. constructor(
  78441. /** defines the name */
  78442. name: string, manager: ISpriteManager);
  78443. /**
  78444. * Starts an animation
  78445. * @param from defines the initial key
  78446. * @param to defines the end key
  78447. * @param loop defines if the animation must loop
  78448. * @param delay defines the start delay (in ms)
  78449. * @param onAnimationEnd defines a callback to call when animation ends
  78450. */
  78451. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  78452. /** Stops current animation (if any) */
  78453. stopAnimation(): void;
  78454. /** @hidden */
  78455. _animate(deltaTime: number): void;
  78456. /** Release associated resources */
  78457. dispose(): void;
  78458. }
  78459. }
  78460. declare module BABYLON {
  78461. /**
  78462. * Information about the result of picking within a scene
  78463. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  78464. */
  78465. export class PickingInfo {
  78466. /** @hidden */
  78467. _pickingUnavailable: boolean;
  78468. /**
  78469. * If the pick collided with an object
  78470. */
  78471. hit: boolean;
  78472. /**
  78473. * Distance away where the pick collided
  78474. */
  78475. distance: number;
  78476. /**
  78477. * The location of pick collision
  78478. */
  78479. pickedPoint: Nullable<Vector3>;
  78480. /**
  78481. * The mesh corresponding the the pick collision
  78482. */
  78483. pickedMesh: Nullable<AbstractMesh>;
  78484. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  78485. bu: number;
  78486. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  78487. bv: number;
  78488. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  78489. faceId: number;
  78490. /** Id of the the submesh that was picked */
  78491. subMeshId: number;
  78492. /** If a sprite was picked, this will be the sprite the pick collided with */
  78493. pickedSprite: Nullable<Sprite>;
  78494. /**
  78495. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  78496. */
  78497. originMesh: Nullable<AbstractMesh>;
  78498. /**
  78499. * The ray that was used to perform the picking.
  78500. */
  78501. ray: Nullable<Ray>;
  78502. /**
  78503. * Gets the normal correspodning to the face the pick collided with
  78504. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  78505. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  78506. * @returns The normal correspodning to the face the pick collided with
  78507. */
  78508. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  78509. /**
  78510. * Gets the texture coordinates of where the pick occured
  78511. * @returns the vector containing the coordnates of the texture
  78512. */
  78513. getTextureCoordinates(): Nullable<Vector2>;
  78514. }
  78515. }
  78516. declare module BABYLON {
  78517. /**
  78518. * Gather the list of pointer event types as constants.
  78519. */
  78520. export class PointerEventTypes {
  78521. /**
  78522. * 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.
  78523. */
  78524. static readonly POINTERDOWN: number;
  78525. /**
  78526. * The pointerup event is fired when a pointer is no longer active.
  78527. */
  78528. static readonly POINTERUP: number;
  78529. /**
  78530. * The pointermove event is fired when a pointer changes coordinates.
  78531. */
  78532. static readonly POINTERMOVE: number;
  78533. /**
  78534. * The pointerwheel event is fired when a mouse wheel has been rotated.
  78535. */
  78536. static readonly POINTERWHEEL: number;
  78537. /**
  78538. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  78539. */
  78540. static readonly POINTERPICK: number;
  78541. /**
  78542. * The pointertap event is fired when a the object has been touched and released without drag.
  78543. */
  78544. static readonly POINTERTAP: number;
  78545. /**
  78546. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  78547. */
  78548. static readonly POINTERDOUBLETAP: number;
  78549. }
  78550. /**
  78551. * Base class of pointer info types.
  78552. */
  78553. export class PointerInfoBase {
  78554. /**
  78555. * Defines the type of event (PointerEventTypes)
  78556. */
  78557. type: number;
  78558. /**
  78559. * Defines the related dom event
  78560. */
  78561. event: PointerEvent | MouseWheelEvent;
  78562. /**
  78563. * Instantiates the base class of pointers info.
  78564. * @param type Defines the type of event (PointerEventTypes)
  78565. * @param event Defines the related dom event
  78566. */
  78567. constructor(
  78568. /**
  78569. * Defines the type of event (PointerEventTypes)
  78570. */
  78571. type: number,
  78572. /**
  78573. * Defines the related dom event
  78574. */
  78575. event: PointerEvent | MouseWheelEvent);
  78576. }
  78577. /**
  78578. * This class is used to store pointer related info for the onPrePointerObservable event.
  78579. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  78580. */
  78581. export class PointerInfoPre extends PointerInfoBase {
  78582. /**
  78583. * Ray from a pointer if availible (eg. 6dof controller)
  78584. */
  78585. ray: Nullable<Ray>;
  78586. /**
  78587. * Defines the local position of the pointer on the canvas.
  78588. */
  78589. localPosition: Vector2;
  78590. /**
  78591. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  78592. */
  78593. skipOnPointerObservable: boolean;
  78594. /**
  78595. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  78596. * @param type Defines the type of event (PointerEventTypes)
  78597. * @param event Defines the related dom event
  78598. * @param localX Defines the local x coordinates of the pointer when the event occured
  78599. * @param localY Defines the local y coordinates of the pointer when the event occured
  78600. */
  78601. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  78602. }
  78603. /**
  78604. * This type contains all the data related to a pointer event in Babylon.js.
  78605. * 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.
  78606. */
  78607. export class PointerInfo extends PointerInfoBase {
  78608. /**
  78609. * Defines the picking info associated to the info (if any)\
  78610. */
  78611. pickInfo: Nullable<PickingInfo>;
  78612. /**
  78613. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  78614. * @param type Defines the type of event (PointerEventTypes)
  78615. * @param event Defines the related dom event
  78616. * @param pickInfo Defines the picking info associated to the info (if any)\
  78617. */
  78618. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  78619. /**
  78620. * Defines the picking info associated to the info (if any)\
  78621. */
  78622. pickInfo: Nullable<PickingInfo>);
  78623. }
  78624. /**
  78625. * Data relating to a touch event on the screen.
  78626. */
  78627. export interface PointerTouch {
  78628. /**
  78629. * X coordinate of touch.
  78630. */
  78631. x: number;
  78632. /**
  78633. * Y coordinate of touch.
  78634. */
  78635. y: number;
  78636. /**
  78637. * Id of touch. Unique for each finger.
  78638. */
  78639. pointerId: number;
  78640. /**
  78641. * Event type passed from DOM.
  78642. */
  78643. type: any;
  78644. }
  78645. }
  78646. declare module BABYLON {
  78647. /**
  78648. * Manage the mouse inputs to control the movement of a free camera.
  78649. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  78650. */
  78651. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  78652. /**
  78653. * Define if touch is enabled in the mouse input
  78654. */
  78655. touchEnabled: boolean;
  78656. /**
  78657. * Defines the camera the input is attached to.
  78658. */
  78659. camera: FreeCamera;
  78660. /**
  78661. * Defines the buttons associated with the input to handle camera move.
  78662. */
  78663. buttons: number[];
  78664. /**
  78665. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  78666. */
  78667. angularSensibility: number;
  78668. private _pointerInput;
  78669. private _onMouseMove;
  78670. private _observer;
  78671. private previousPosition;
  78672. /**
  78673. * Observable for when a pointer move event occurs containing the move offset
  78674. */
  78675. onPointerMovedObservable: Observable<{
  78676. offsetX: number;
  78677. offsetY: number;
  78678. }>;
  78679. /**
  78680. * @hidden
  78681. * If the camera should be rotated automatically based on pointer movement
  78682. */
  78683. _allowCameraRotation: boolean;
  78684. /**
  78685. * Manage the mouse inputs to control the movement of a free camera.
  78686. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  78687. * @param touchEnabled Defines if touch is enabled or not
  78688. */
  78689. constructor(
  78690. /**
  78691. * Define if touch is enabled in the mouse input
  78692. */
  78693. touchEnabled?: boolean);
  78694. /**
  78695. * Attach the input controls to a specific dom element to get the input from.
  78696. * @param element Defines the element the controls should be listened from
  78697. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  78698. */
  78699. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  78700. /**
  78701. * Called on JS contextmenu event.
  78702. * Override this method to provide functionality.
  78703. */
  78704. protected onContextMenu(evt: PointerEvent): void;
  78705. /**
  78706. * Detach the current controls from the specified dom element.
  78707. * @param element Defines the element to stop listening the inputs from
  78708. */
  78709. detachControl(element: Nullable<HTMLElement>): void;
  78710. /**
  78711. * Gets the class name of the current intput.
  78712. * @returns the class name
  78713. */
  78714. getClassName(): string;
  78715. /**
  78716. * Get the friendly name associated with the input class.
  78717. * @returns the input friendly name
  78718. */
  78719. getSimpleName(): string;
  78720. }
  78721. }
  78722. declare module BABYLON {
  78723. /**
  78724. * Manage the touch inputs to control the movement of a free camera.
  78725. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  78726. */
  78727. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  78728. /**
  78729. * Defines the camera the input is attached to.
  78730. */
  78731. camera: FreeCamera;
  78732. /**
  78733. * Defines the touch sensibility for rotation.
  78734. * The higher the faster.
  78735. */
  78736. touchAngularSensibility: number;
  78737. /**
  78738. * Defines the touch sensibility for move.
  78739. * The higher the faster.
  78740. */
  78741. touchMoveSensibility: number;
  78742. private _offsetX;
  78743. private _offsetY;
  78744. private _pointerPressed;
  78745. private _pointerInput;
  78746. private _observer;
  78747. private _onLostFocus;
  78748. /**
  78749. * Attach the input controls to a specific dom element to get the input from.
  78750. * @param element Defines the element the controls should be listened from
  78751. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  78752. */
  78753. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  78754. /**
  78755. * Detach the current controls from the specified dom element.
  78756. * @param element Defines the element to stop listening the inputs from
  78757. */
  78758. detachControl(element: Nullable<HTMLElement>): void;
  78759. /**
  78760. * Update the current camera state depending on the inputs that have been used this frame.
  78761. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  78762. */
  78763. checkInputs(): void;
  78764. /**
  78765. * Gets the class name of the current intput.
  78766. * @returns the class name
  78767. */
  78768. getClassName(): string;
  78769. /**
  78770. * Get the friendly name associated with the input class.
  78771. * @returns the input friendly name
  78772. */
  78773. getSimpleName(): string;
  78774. }
  78775. }
  78776. declare module BABYLON {
  78777. /**
  78778. * Default Inputs manager for the FreeCamera.
  78779. * It groups all the default supported inputs for ease of use.
  78780. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  78781. */
  78782. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  78783. /**
  78784. * @hidden
  78785. */
  78786. _mouseInput: Nullable<FreeCameraMouseInput>;
  78787. /**
  78788. * Instantiates a new FreeCameraInputsManager.
  78789. * @param camera Defines the camera the inputs belong to
  78790. */
  78791. constructor(camera: FreeCamera);
  78792. /**
  78793. * Add keyboard input support to the input manager.
  78794. * @returns the current input manager
  78795. */
  78796. addKeyboard(): FreeCameraInputsManager;
  78797. /**
  78798. * Add mouse input support to the input manager.
  78799. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  78800. * @returns the current input manager
  78801. */
  78802. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  78803. /**
  78804. * Removes the mouse input support from the manager
  78805. * @returns the current input manager
  78806. */
  78807. removeMouse(): FreeCameraInputsManager;
  78808. /**
  78809. * Add touch input support to the input manager.
  78810. * @returns the current input manager
  78811. */
  78812. addTouch(): FreeCameraInputsManager;
  78813. /**
  78814. * Remove all attached input methods from a camera
  78815. */
  78816. clear(): void;
  78817. }
  78818. }
  78819. declare module BABYLON {
  78820. /**
  78821. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  78822. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  78823. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  78824. */
  78825. export class FreeCamera extends TargetCamera {
  78826. /**
  78827. * Define the collision ellipsoid of the camera.
  78828. * This is helpful to simulate a camera body like the player body around the camera
  78829. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  78830. */
  78831. ellipsoid: Vector3;
  78832. /**
  78833. * Define an offset for the position of the ellipsoid around the camera.
  78834. * This can be helpful to determine the center of the body near the gravity center of the body
  78835. * instead of its head.
  78836. */
  78837. ellipsoidOffset: Vector3;
  78838. /**
  78839. * Enable or disable collisions of the camera with the rest of the scene objects.
  78840. */
  78841. checkCollisions: boolean;
  78842. /**
  78843. * Enable or disable gravity on the camera.
  78844. */
  78845. applyGravity: boolean;
  78846. /**
  78847. * Define the input manager associated to the camera.
  78848. */
  78849. inputs: FreeCameraInputsManager;
  78850. /**
  78851. * Gets the input sensibility for a mouse input. (default is 2000.0)
  78852. * Higher values reduce sensitivity.
  78853. */
  78854. /**
  78855. * Sets the input sensibility for a mouse input. (default is 2000.0)
  78856. * Higher values reduce sensitivity.
  78857. */
  78858. angularSensibility: number;
  78859. /**
  78860. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  78861. */
  78862. keysUp: number[];
  78863. /**
  78864. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  78865. */
  78866. keysDown: number[];
  78867. /**
  78868. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  78869. */
  78870. keysLeft: number[];
  78871. /**
  78872. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  78873. */
  78874. keysRight: number[];
  78875. /**
  78876. * Event raised when the camera collide with a mesh in the scene.
  78877. */
  78878. onCollide: (collidedMesh: AbstractMesh) => void;
  78879. private _collider;
  78880. private _needMoveForGravity;
  78881. private _oldPosition;
  78882. private _diffPosition;
  78883. private _newPosition;
  78884. /** @hidden */
  78885. _localDirection: Vector3;
  78886. /** @hidden */
  78887. _transformedDirection: Vector3;
  78888. /**
  78889. * Instantiates a Free Camera.
  78890. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  78891. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  78892. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  78893. * @param name Define the name of the camera in the scene
  78894. * @param position Define the start position of the camera in the scene
  78895. * @param scene Define the scene the camera belongs to
  78896. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  78897. */
  78898. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  78899. /**
  78900. * Attached controls to the current camera.
  78901. * @param element Defines the element the controls should be listened from
  78902. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  78903. */
  78904. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  78905. /**
  78906. * Detach the current controls from the camera.
  78907. * The camera will stop reacting to inputs.
  78908. * @param element Defines the element to stop listening the inputs from
  78909. */
  78910. detachControl(element: HTMLElement): void;
  78911. private _collisionMask;
  78912. /**
  78913. * Define a collision mask to limit the list of object the camera can collide with
  78914. */
  78915. collisionMask: number;
  78916. /** @hidden */
  78917. _collideWithWorld(displacement: Vector3): void;
  78918. private _onCollisionPositionChange;
  78919. /** @hidden */
  78920. _checkInputs(): void;
  78921. /** @hidden */
  78922. _decideIfNeedsToMove(): boolean;
  78923. /** @hidden */
  78924. _updatePosition(): void;
  78925. /**
  78926. * Destroy the camera and release the current resources hold by it.
  78927. */
  78928. dispose(): void;
  78929. /**
  78930. * Gets the current object class name.
  78931. * @return the class name
  78932. */
  78933. getClassName(): string;
  78934. }
  78935. }
  78936. declare module BABYLON {
  78937. /**
  78938. * Represents a gamepad control stick position
  78939. */
  78940. export class StickValues {
  78941. /**
  78942. * The x component of the control stick
  78943. */
  78944. x: number;
  78945. /**
  78946. * The y component of the control stick
  78947. */
  78948. y: number;
  78949. /**
  78950. * Initializes the gamepad x and y control stick values
  78951. * @param x The x component of the gamepad control stick value
  78952. * @param y The y component of the gamepad control stick value
  78953. */
  78954. constructor(
  78955. /**
  78956. * The x component of the control stick
  78957. */
  78958. x: number,
  78959. /**
  78960. * The y component of the control stick
  78961. */
  78962. y: number);
  78963. }
  78964. /**
  78965. * An interface which manages callbacks for gamepad button changes
  78966. */
  78967. export interface GamepadButtonChanges {
  78968. /**
  78969. * Called when a gamepad has been changed
  78970. */
  78971. changed: boolean;
  78972. /**
  78973. * Called when a gamepad press event has been triggered
  78974. */
  78975. pressChanged: boolean;
  78976. /**
  78977. * Called when a touch event has been triggered
  78978. */
  78979. touchChanged: boolean;
  78980. /**
  78981. * Called when a value has changed
  78982. */
  78983. valueChanged: boolean;
  78984. }
  78985. /**
  78986. * Represents a gamepad
  78987. */
  78988. export class Gamepad {
  78989. /**
  78990. * The id of the gamepad
  78991. */
  78992. id: string;
  78993. /**
  78994. * The index of the gamepad
  78995. */
  78996. index: number;
  78997. /**
  78998. * The browser gamepad
  78999. */
  79000. browserGamepad: any;
  79001. /**
  79002. * Specifies what type of gamepad this represents
  79003. */
  79004. type: number;
  79005. private _leftStick;
  79006. private _rightStick;
  79007. /** @hidden */
  79008. _isConnected: boolean;
  79009. private _leftStickAxisX;
  79010. private _leftStickAxisY;
  79011. private _rightStickAxisX;
  79012. private _rightStickAxisY;
  79013. /**
  79014. * Triggered when the left control stick has been changed
  79015. */
  79016. private _onleftstickchanged;
  79017. /**
  79018. * Triggered when the right control stick has been changed
  79019. */
  79020. private _onrightstickchanged;
  79021. /**
  79022. * Represents a gamepad controller
  79023. */
  79024. static GAMEPAD: number;
  79025. /**
  79026. * Represents a generic controller
  79027. */
  79028. static GENERIC: number;
  79029. /**
  79030. * Represents an XBox controller
  79031. */
  79032. static XBOX: number;
  79033. /**
  79034. * Represents a pose-enabled controller
  79035. */
  79036. static POSE_ENABLED: number;
  79037. /**
  79038. * Represents an Dual Shock controller
  79039. */
  79040. static DUALSHOCK: number;
  79041. /**
  79042. * Specifies whether the left control stick should be Y-inverted
  79043. */
  79044. protected _invertLeftStickY: boolean;
  79045. /**
  79046. * Specifies if the gamepad has been connected
  79047. */
  79048. readonly isConnected: boolean;
  79049. /**
  79050. * Initializes the gamepad
  79051. * @param id The id of the gamepad
  79052. * @param index The index of the gamepad
  79053. * @param browserGamepad The browser gamepad
  79054. * @param leftStickX The x component of the left joystick
  79055. * @param leftStickY The y component of the left joystick
  79056. * @param rightStickX The x component of the right joystick
  79057. * @param rightStickY The y component of the right joystick
  79058. */
  79059. constructor(
  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, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  79072. /**
  79073. * Callback triggered when the left joystick has changed
  79074. * @param callback
  79075. */
  79076. onleftstickchanged(callback: (values: StickValues) => void): void;
  79077. /**
  79078. * Callback triggered when the right joystick has changed
  79079. * @param callback
  79080. */
  79081. onrightstickchanged(callback: (values: StickValues) => void): void;
  79082. /**
  79083. * Gets the left joystick
  79084. */
  79085. /**
  79086. * Sets the left joystick values
  79087. */
  79088. leftStick: StickValues;
  79089. /**
  79090. * Gets the right joystick
  79091. */
  79092. /**
  79093. * Sets the right joystick value
  79094. */
  79095. rightStick: StickValues;
  79096. /**
  79097. * Updates the gamepad joystick positions
  79098. */
  79099. update(): void;
  79100. /**
  79101. * Disposes the gamepad
  79102. */
  79103. dispose(): void;
  79104. }
  79105. /**
  79106. * Represents a generic gamepad
  79107. */
  79108. export class GenericPad extends Gamepad {
  79109. private _buttons;
  79110. private _onbuttondown;
  79111. private _onbuttonup;
  79112. /**
  79113. * Observable triggered when a button has been pressed
  79114. */
  79115. onButtonDownObservable: Observable<number>;
  79116. /**
  79117. * Observable triggered when a button has been released
  79118. */
  79119. onButtonUpObservable: Observable<number>;
  79120. /**
  79121. * Callback triggered when a button has been pressed
  79122. * @param callback Called when a button has been pressed
  79123. */
  79124. onbuttondown(callback: (buttonPressed: number) => void): void;
  79125. /**
  79126. * Callback triggered when a button has been released
  79127. * @param callback Called when a button has been released
  79128. */
  79129. onbuttonup(callback: (buttonReleased: number) => void): void;
  79130. /**
  79131. * Initializes the generic gamepad
  79132. * @param id The id of the generic gamepad
  79133. * @param index The index of the generic gamepad
  79134. * @param browserGamepad The browser gamepad
  79135. */
  79136. constructor(id: string, index: number, browserGamepad: any);
  79137. private _setButtonValue;
  79138. /**
  79139. * Updates the generic gamepad
  79140. */
  79141. update(): void;
  79142. /**
  79143. * Disposes the generic gamepad
  79144. */
  79145. dispose(): void;
  79146. }
  79147. }
  79148. declare module BABYLON {
  79149. interface Engine {
  79150. /**
  79151. * Creates a raw texture
  79152. * @param data defines the data to store in the texture
  79153. * @param width defines the width of the texture
  79154. * @param height defines the height of the texture
  79155. * @param format defines the format of the data
  79156. * @param generateMipMaps defines if the engine should generate the mip levels
  79157. * @param invertY defines if data must be stored with Y axis inverted
  79158. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  79159. * @param compression defines the compression used (null by default)
  79160. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79161. * @returns the raw texture inside an InternalTexture
  79162. */
  79163. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  79164. /**
  79165. * Update a raw texture
  79166. * @param texture defines the texture to update
  79167. * @param data defines the data to store in the texture
  79168. * @param format defines the format of the data
  79169. * @param invertY defines if data must be stored with Y axis inverted
  79170. */
  79171. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  79172. /**
  79173. * Update a raw texture
  79174. * @param texture defines the texture to update
  79175. * @param data defines the data to store in the texture
  79176. * @param format defines the format of the data
  79177. * @param invertY defines if data must be stored with Y axis inverted
  79178. * @param compression defines the compression used (null by default)
  79179. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79180. */
  79181. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  79182. /**
  79183. * Creates a new raw cube texture
  79184. * @param data defines the array of data to use to create each face
  79185. * @param size defines the size of the textures
  79186. * @param format defines the format of the data
  79187. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  79188. * @param generateMipMaps defines if the engine should generate the mip levels
  79189. * @param invertY defines if data must be stored with Y axis inverted
  79190. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  79191. * @param compression defines the compression used (null by default)
  79192. * @returns the cube texture as an InternalTexture
  79193. */
  79194. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  79195. /**
  79196. * Update a raw cube texture
  79197. * @param texture defines the texture to udpdate
  79198. * @param data defines the data to store
  79199. * @param format defines the data format
  79200. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79201. * @param invertY defines if data must be stored with Y axis inverted
  79202. */
  79203. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  79204. /**
  79205. * Update a raw cube texture
  79206. * @param texture defines the texture to udpdate
  79207. * @param data defines the data to store
  79208. * @param format defines the data format
  79209. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79210. * @param invertY defines if data must be stored with Y axis inverted
  79211. * @param compression defines the compression used (null by default)
  79212. */
  79213. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  79214. /**
  79215. * Update a raw cube texture
  79216. * @param texture defines the texture to udpdate
  79217. * @param data defines the data to store
  79218. * @param format defines the data format
  79219. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79220. * @param invertY defines if data must be stored with Y axis inverted
  79221. * @param compression defines the compression used (null by default)
  79222. * @param level defines which level of the texture to update
  79223. */
  79224. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  79225. /**
  79226. * Creates a new raw cube texture from a specified url
  79227. * @param url defines the url where the data is located
  79228. * @param scene defines the current scene
  79229. * @param size defines the size of the textures
  79230. * @param format defines the format of the data
  79231. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  79232. * @param noMipmap defines if the engine should avoid generating the mip levels
  79233. * @param callback defines a callback used to extract texture data from loaded data
  79234. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  79235. * @param onLoad defines a callback called when texture is loaded
  79236. * @param onError defines a callback called if there is an error
  79237. * @returns the cube texture as an InternalTexture
  79238. */
  79239. 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;
  79240. /**
  79241. * Creates a new raw cube texture from a specified url
  79242. * @param url defines the url where the data is located
  79243. * @param scene defines the current scene
  79244. * @param size defines the size of the textures
  79245. * @param format defines the format of the data
  79246. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  79247. * @param noMipmap defines if the engine should avoid generating the mip levels
  79248. * @param callback defines a callback used to extract texture data from loaded data
  79249. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  79250. * @param onLoad defines a callback called when texture is loaded
  79251. * @param onError defines a callback called if there is an error
  79252. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  79253. * @param invertY defines if data must be stored with Y axis inverted
  79254. * @returns the cube texture as an InternalTexture
  79255. */
  79256. 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;
  79257. /**
  79258. * Creates a new raw 3D texture
  79259. * @param data defines the data used to create the texture
  79260. * @param width defines the width of the texture
  79261. * @param height defines the height of the texture
  79262. * @param depth defines the depth of the texture
  79263. * @param format defines the format of the texture
  79264. * @param generateMipMaps defines if the engine must generate mip levels
  79265. * @param invertY defines if data must be stored with Y axis inverted
  79266. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  79267. * @param compression defines the compressed used (can be null)
  79268. * @param textureType defines the compressed used (can be null)
  79269. * @returns a new raw 3D texture (stored in an InternalTexture)
  79270. */
  79271. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  79272. /**
  79273. * Update a raw 3D texture
  79274. * @param texture defines the texture to update
  79275. * @param data defines the data to store
  79276. * @param format defines the data format
  79277. * @param invertY defines if data must be stored with Y axis inverted
  79278. */
  79279. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  79280. /**
  79281. * Update a raw 3D texture
  79282. * @param texture defines the texture to update
  79283. * @param data defines the data to store
  79284. * @param format defines the data format
  79285. * @param invertY defines if data must be stored with Y axis inverted
  79286. * @param compression defines the used compression (can be null)
  79287. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  79288. */
  79289. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  79290. }
  79291. }
  79292. declare module BABYLON {
  79293. /**
  79294. * Raw texture can help creating a texture directly from an array of data.
  79295. * This can be super useful if you either get the data from an uncompressed source or
  79296. * if you wish to create your texture pixel by pixel.
  79297. */
  79298. export class RawTexture extends Texture {
  79299. /**
  79300. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  79301. */
  79302. format: number;
  79303. private _engine;
  79304. /**
  79305. * Instantiates a new RawTexture.
  79306. * Raw texture can help creating a texture directly from an array of data.
  79307. * This can be super useful if you either get the data from an uncompressed source or
  79308. * if you wish to create your texture pixel by pixel.
  79309. * @param data define the array of data to use to create the texture
  79310. * @param width define the width of the texture
  79311. * @param height define the height of the texture
  79312. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  79313. * @param scene define the scene the texture belongs to
  79314. * @param generateMipMaps define whether mip maps should be generated or not
  79315. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79316. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79317. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  79318. */
  79319. constructor(data: ArrayBufferView, width: number, height: number,
  79320. /**
  79321. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  79322. */
  79323. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  79324. /**
  79325. * Updates the texture underlying data.
  79326. * @param data Define the new data of the texture
  79327. */
  79328. update(data: ArrayBufferView): void;
  79329. /**
  79330. * Creates a luminance texture from some data.
  79331. * @param data Define the texture data
  79332. * @param width Define the width of the texture
  79333. * @param height Define the height of the texture
  79334. * @param scene Define the scene the texture belongs to
  79335. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79336. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79337. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79338. * @returns the luminance texture
  79339. */
  79340. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  79341. /**
  79342. * Creates a luminance alpha texture from some data.
  79343. * @param data Define the texture data
  79344. * @param width Define the width of the texture
  79345. * @param height Define the height of the texture
  79346. * @param scene Define the scene the texture belongs to
  79347. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79348. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79349. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79350. * @returns the luminance alpha texture
  79351. */
  79352. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  79353. /**
  79354. * Creates an alpha texture from some data.
  79355. * @param data Define the texture data
  79356. * @param width Define the width of the texture
  79357. * @param height Define the height of the texture
  79358. * @param scene Define the scene the texture belongs to
  79359. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79360. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79361. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79362. * @returns the alpha texture
  79363. */
  79364. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  79365. /**
  79366. * Creates a RGB texture from some data.
  79367. * @param data Define the texture data
  79368. * @param width Define the width of the texture
  79369. * @param height Define the height of the texture
  79370. * @param scene Define the scene the texture belongs to
  79371. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79372. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79373. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79374. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  79375. * @returns the RGB alpha texture
  79376. */
  79377. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  79378. /**
  79379. * Creates a RGBA texture from some data.
  79380. * @param data Define the texture data
  79381. * @param width Define the width of the texture
  79382. * @param height Define the height of the texture
  79383. * @param scene Define the scene the texture belongs to
  79384. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79385. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79386. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79387. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  79388. * @returns the RGBA texture
  79389. */
  79390. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  79391. /**
  79392. * Creates a R texture from some data.
  79393. * @param data Define the texture data
  79394. * @param width Define the width of the texture
  79395. * @param height Define the height of the texture
  79396. * @param scene Define the scene the texture belongs to
  79397. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79398. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79399. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79400. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  79401. * @returns the R texture
  79402. */
  79403. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  79404. }
  79405. }
  79406. declare module BABYLON {
  79407. /**
  79408. * Interface for the size containing width and height
  79409. */
  79410. export interface ISize {
  79411. /**
  79412. * Width
  79413. */
  79414. width: number;
  79415. /**
  79416. * Heighht
  79417. */
  79418. height: number;
  79419. }
  79420. /**
  79421. * Size containing widht and height
  79422. */
  79423. export class Size implements ISize {
  79424. /**
  79425. * Width
  79426. */
  79427. width: number;
  79428. /**
  79429. * Height
  79430. */
  79431. height: number;
  79432. /**
  79433. * Creates a Size object from the given width and height (floats).
  79434. * @param width width of the new size
  79435. * @param height height of the new size
  79436. */
  79437. constructor(width: number, height: number);
  79438. /**
  79439. * Returns a string with the Size width and height
  79440. * @returns a string with the Size width and height
  79441. */
  79442. toString(): string;
  79443. /**
  79444. * "Size"
  79445. * @returns the string "Size"
  79446. */
  79447. getClassName(): string;
  79448. /**
  79449. * Returns the Size hash code.
  79450. * @returns a hash code for a unique width and height
  79451. */
  79452. getHashCode(): number;
  79453. /**
  79454. * Updates the current size from the given one.
  79455. * @param src the given size
  79456. */
  79457. copyFrom(src: Size): void;
  79458. /**
  79459. * Updates in place the current Size from the given floats.
  79460. * @param width width of the new size
  79461. * @param height height of the new size
  79462. * @returns the updated Size.
  79463. */
  79464. copyFromFloats(width: number, height: number): Size;
  79465. /**
  79466. * Updates in place the current Size from the given floats.
  79467. * @param width width to set
  79468. * @param height height to set
  79469. * @returns the updated Size.
  79470. */
  79471. set(width: number, height: number): Size;
  79472. /**
  79473. * Multiplies the width and height by numbers
  79474. * @param w factor to multiple the width by
  79475. * @param h factor to multiple the height by
  79476. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  79477. */
  79478. multiplyByFloats(w: number, h: number): Size;
  79479. /**
  79480. * Clones the size
  79481. * @returns a new Size copied from the given one.
  79482. */
  79483. clone(): Size;
  79484. /**
  79485. * True if the current Size and the given one width and height are strictly equal.
  79486. * @param other the other size to compare against
  79487. * @returns True if the current Size and the given one width and height are strictly equal.
  79488. */
  79489. equals(other: Size): boolean;
  79490. /**
  79491. * The surface of the Size : width * height (float).
  79492. */
  79493. readonly surface: number;
  79494. /**
  79495. * Create a new size of zero
  79496. * @returns a new Size set to (0.0, 0.0)
  79497. */
  79498. static Zero(): Size;
  79499. /**
  79500. * Sums the width and height of two sizes
  79501. * @param otherSize size to add to this size
  79502. * @returns a new Size set as the addition result of the current Size and the given one.
  79503. */
  79504. add(otherSize: Size): Size;
  79505. /**
  79506. * Subtracts the width and height of two
  79507. * @param otherSize size to subtract to this size
  79508. * @returns a new Size set as the subtraction result of the given one from the current Size.
  79509. */
  79510. subtract(otherSize: Size): Size;
  79511. /**
  79512. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  79513. * @param start starting size to lerp between
  79514. * @param end end size to lerp between
  79515. * @param amount amount to lerp between the start and end values
  79516. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  79517. */
  79518. static Lerp(start: Size, end: Size, amount: number): Size;
  79519. }
  79520. }
  79521. declare module BABYLON {
  79522. /**
  79523. * Defines a runtime animation
  79524. */
  79525. export class RuntimeAnimation {
  79526. private _events;
  79527. /**
  79528. * The current frame of the runtime animation
  79529. */
  79530. private _currentFrame;
  79531. /**
  79532. * The animation used by the runtime animation
  79533. */
  79534. private _animation;
  79535. /**
  79536. * The target of the runtime animation
  79537. */
  79538. private _target;
  79539. /**
  79540. * The initiating animatable
  79541. */
  79542. private _host;
  79543. /**
  79544. * The original value of the runtime animation
  79545. */
  79546. private _originalValue;
  79547. /**
  79548. * The original blend value of the runtime animation
  79549. */
  79550. private _originalBlendValue;
  79551. /**
  79552. * The offsets cache of the runtime animation
  79553. */
  79554. private _offsetsCache;
  79555. /**
  79556. * The high limits cache of the runtime animation
  79557. */
  79558. private _highLimitsCache;
  79559. /**
  79560. * Specifies if the runtime animation has been stopped
  79561. */
  79562. private _stopped;
  79563. /**
  79564. * The blending factor of the runtime animation
  79565. */
  79566. private _blendingFactor;
  79567. /**
  79568. * The BabylonJS scene
  79569. */
  79570. private _scene;
  79571. /**
  79572. * The current value of the runtime animation
  79573. */
  79574. private _currentValue;
  79575. /** @hidden */
  79576. _animationState: _IAnimationState;
  79577. /**
  79578. * The active target of the runtime animation
  79579. */
  79580. private _activeTargets;
  79581. private _currentActiveTarget;
  79582. private _directTarget;
  79583. /**
  79584. * The target path of the runtime animation
  79585. */
  79586. private _targetPath;
  79587. /**
  79588. * The weight of the runtime animation
  79589. */
  79590. private _weight;
  79591. /**
  79592. * The ratio offset of the runtime animation
  79593. */
  79594. private _ratioOffset;
  79595. /**
  79596. * The previous delay of the runtime animation
  79597. */
  79598. private _previousDelay;
  79599. /**
  79600. * The previous ratio of the runtime animation
  79601. */
  79602. private _previousRatio;
  79603. private _enableBlending;
  79604. private _keys;
  79605. private _minFrame;
  79606. private _maxFrame;
  79607. private _minValue;
  79608. private _maxValue;
  79609. private _targetIsArray;
  79610. /**
  79611. * Gets the current frame of the runtime animation
  79612. */
  79613. readonly currentFrame: number;
  79614. /**
  79615. * Gets the weight of the runtime animation
  79616. */
  79617. readonly weight: number;
  79618. /**
  79619. * Gets the current value of the runtime animation
  79620. */
  79621. readonly currentValue: any;
  79622. /**
  79623. * Gets the target path of the runtime animation
  79624. */
  79625. readonly targetPath: string;
  79626. /**
  79627. * Gets the actual target of the runtime animation
  79628. */
  79629. readonly target: any;
  79630. /** @hidden */
  79631. _onLoop: () => void;
  79632. /**
  79633. * Create a new RuntimeAnimation object
  79634. * @param target defines the target of the animation
  79635. * @param animation defines the source animation object
  79636. * @param scene defines the hosting scene
  79637. * @param host defines the initiating Animatable
  79638. */
  79639. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  79640. private _preparePath;
  79641. /**
  79642. * Gets the animation from the runtime animation
  79643. */
  79644. readonly animation: Animation;
  79645. /**
  79646. * Resets the runtime animation to the beginning
  79647. * @param restoreOriginal defines whether to restore the target property to the original value
  79648. */
  79649. reset(restoreOriginal?: boolean): void;
  79650. /**
  79651. * Specifies if the runtime animation is stopped
  79652. * @returns Boolean specifying if the runtime animation is stopped
  79653. */
  79654. isStopped(): boolean;
  79655. /**
  79656. * Disposes of the runtime animation
  79657. */
  79658. dispose(): void;
  79659. /**
  79660. * Apply the interpolated value to the target
  79661. * @param currentValue defines the value computed by the animation
  79662. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  79663. */
  79664. setValue(currentValue: any, weight: number): void;
  79665. private _getOriginalValues;
  79666. private _setValue;
  79667. /**
  79668. * Gets the loop pmode of the runtime animation
  79669. * @returns Loop Mode
  79670. */
  79671. private _getCorrectLoopMode;
  79672. /**
  79673. * Move the current animation to a given frame
  79674. * @param frame defines the frame to move to
  79675. */
  79676. goToFrame(frame: number): void;
  79677. /**
  79678. * @hidden Internal use only
  79679. */
  79680. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  79681. /**
  79682. * Execute the current animation
  79683. * @param delay defines the delay to add to the current frame
  79684. * @param from defines the lower bound of the animation range
  79685. * @param to defines the upper bound of the animation range
  79686. * @param loop defines if the current animation must loop
  79687. * @param speedRatio defines the current speed ratio
  79688. * @param weight defines the weight of the animation (default is -1 so no weight)
  79689. * @param onLoop optional callback called when animation loops
  79690. * @returns a boolean indicating if the animation is running
  79691. */
  79692. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  79693. }
  79694. }
  79695. declare module BABYLON {
  79696. /**
  79697. * Class used to store an actual running animation
  79698. */
  79699. export class Animatable {
  79700. /** defines the target object */
  79701. target: any;
  79702. /** defines the starting frame number (default is 0) */
  79703. fromFrame: number;
  79704. /** defines the ending frame number (default is 100) */
  79705. toFrame: number;
  79706. /** defines if the animation must loop (default is false) */
  79707. loopAnimation: boolean;
  79708. /** defines a callback to call when animation ends if it is not looping */
  79709. onAnimationEnd?: (() => void) | null | undefined;
  79710. /** defines a callback to call when animation loops */
  79711. onAnimationLoop?: (() => void) | null | undefined;
  79712. private _localDelayOffset;
  79713. private _pausedDelay;
  79714. private _runtimeAnimations;
  79715. private _paused;
  79716. private _scene;
  79717. private _speedRatio;
  79718. private _weight;
  79719. private _syncRoot;
  79720. /**
  79721. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  79722. * This will only apply for non looping animation (default is true)
  79723. */
  79724. disposeOnEnd: boolean;
  79725. /**
  79726. * Gets a boolean indicating if the animation has started
  79727. */
  79728. animationStarted: boolean;
  79729. /**
  79730. * Observer raised when the animation ends
  79731. */
  79732. onAnimationEndObservable: Observable<Animatable>;
  79733. /**
  79734. * Observer raised when the animation loops
  79735. */
  79736. onAnimationLoopObservable: Observable<Animatable>;
  79737. /**
  79738. * Gets the root Animatable used to synchronize and normalize animations
  79739. */
  79740. readonly syncRoot: Nullable<Animatable>;
  79741. /**
  79742. * Gets the current frame of the first RuntimeAnimation
  79743. * Used to synchronize Animatables
  79744. */
  79745. readonly masterFrame: number;
  79746. /**
  79747. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  79748. */
  79749. weight: number;
  79750. /**
  79751. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  79752. */
  79753. speedRatio: number;
  79754. /**
  79755. * Creates a new Animatable
  79756. * @param scene defines the hosting scene
  79757. * @param target defines the target object
  79758. * @param fromFrame defines the starting frame number (default is 0)
  79759. * @param toFrame defines the ending frame number (default is 100)
  79760. * @param loopAnimation defines if the animation must loop (default is false)
  79761. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  79762. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  79763. * @param animations defines a group of animation to add to the new Animatable
  79764. * @param onAnimationLoop defines a callback to call when animation loops
  79765. */
  79766. constructor(scene: Scene,
  79767. /** defines the target object */
  79768. target: any,
  79769. /** defines the starting frame number (default is 0) */
  79770. fromFrame?: number,
  79771. /** defines the ending frame number (default is 100) */
  79772. toFrame?: number,
  79773. /** defines if the animation must loop (default is false) */
  79774. loopAnimation?: boolean, speedRatio?: number,
  79775. /** defines a callback to call when animation ends if it is not looping */
  79776. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  79777. /** defines a callback to call when animation loops */
  79778. onAnimationLoop?: (() => void) | null | undefined);
  79779. /**
  79780. * Synchronize and normalize current Animatable with a source Animatable
  79781. * This is useful when using animation weights and when animations are not of the same length
  79782. * @param root defines the root Animatable to synchronize with
  79783. * @returns the current Animatable
  79784. */
  79785. syncWith(root: Animatable): Animatable;
  79786. /**
  79787. * Gets the list of runtime animations
  79788. * @returns an array of RuntimeAnimation
  79789. */
  79790. getAnimations(): RuntimeAnimation[];
  79791. /**
  79792. * Adds more animations to the current animatable
  79793. * @param target defines the target of the animations
  79794. * @param animations defines the new animations to add
  79795. */
  79796. appendAnimations(target: any, animations: Animation[]): void;
  79797. /**
  79798. * Gets the source animation for a specific property
  79799. * @param property defines the propertyu to look for
  79800. * @returns null or the source animation for the given property
  79801. */
  79802. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  79803. /**
  79804. * Gets the runtime animation for a specific property
  79805. * @param property defines the propertyu to look for
  79806. * @returns null or the runtime animation for the given property
  79807. */
  79808. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  79809. /**
  79810. * Resets the animatable to its original state
  79811. */
  79812. reset(): void;
  79813. /**
  79814. * Allows the animatable to blend with current running animations
  79815. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  79816. * @param blendingSpeed defines the blending speed to use
  79817. */
  79818. enableBlending(blendingSpeed: number): void;
  79819. /**
  79820. * Disable animation blending
  79821. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  79822. */
  79823. disableBlending(): void;
  79824. /**
  79825. * Jump directly to a given frame
  79826. * @param frame defines the frame to jump to
  79827. */
  79828. goToFrame(frame: number): void;
  79829. /**
  79830. * Pause the animation
  79831. */
  79832. pause(): void;
  79833. /**
  79834. * Restart the animation
  79835. */
  79836. restart(): void;
  79837. private _raiseOnAnimationEnd;
  79838. /**
  79839. * Stop and delete the current animation
  79840. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  79841. * @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)
  79842. */
  79843. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  79844. /**
  79845. * Wait asynchronously for the animation to end
  79846. * @returns a promise which will be fullfilled when the animation ends
  79847. */
  79848. waitAsync(): Promise<Animatable>;
  79849. /** @hidden */
  79850. _animate(delay: number): boolean;
  79851. }
  79852. interface Scene {
  79853. /** @hidden */
  79854. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  79855. /** @hidden */
  79856. _processLateAnimationBindingsForMatrices(holder: {
  79857. totalWeight: number;
  79858. animations: RuntimeAnimation[];
  79859. originalValue: Matrix;
  79860. }): any;
  79861. /** @hidden */
  79862. _processLateAnimationBindingsForQuaternions(holder: {
  79863. totalWeight: number;
  79864. animations: RuntimeAnimation[];
  79865. originalValue: Quaternion;
  79866. }, refQuaternion: Quaternion): Quaternion;
  79867. /** @hidden */
  79868. _processLateAnimationBindings(): void;
  79869. /**
  79870. * Will start the animation sequence of a given target
  79871. * @param target defines the target
  79872. * @param from defines from which frame should animation start
  79873. * @param to defines until which frame should animation run.
  79874. * @param weight defines the weight to apply to the animation (1.0 by default)
  79875. * @param loop defines if the animation loops
  79876. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  79877. * @param onAnimationEnd defines the function to be executed when the animation ends
  79878. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  79879. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  79880. * @param onAnimationLoop defines the callback to call when an animation loops
  79881. * @returns the animatable object created for this animation
  79882. */
  79883. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  79884. /**
  79885. * Will start the animation sequence of a given target
  79886. * @param target defines the target
  79887. * @param from defines from which frame should animation start
  79888. * @param to defines until which frame should animation run.
  79889. * @param loop defines if the animation loops
  79890. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  79891. * @param onAnimationEnd defines the function to be executed when the animation ends
  79892. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  79893. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  79894. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  79895. * @param onAnimationLoop defines the callback to call when an animation loops
  79896. * @returns the animatable object created for this animation
  79897. */
  79898. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  79899. /**
  79900. * Will start the animation sequence of a given target and its hierarchy
  79901. * @param target defines the target
  79902. * @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.
  79903. * @param from defines from which frame should animation start
  79904. * @param to defines until which frame should animation run.
  79905. * @param loop defines if the animation loops
  79906. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  79907. * @param onAnimationEnd defines the function to be executed when the animation ends
  79908. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  79909. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  79910. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  79911. * @param onAnimationLoop defines the callback to call when an animation loops
  79912. * @returns the list of created animatables
  79913. */
  79914. 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[];
  79915. /**
  79916. * Begin a new animation on a given node
  79917. * @param target defines the target where the animation will take place
  79918. * @param animations defines the list of animations to start
  79919. * @param from defines the initial value
  79920. * @param to defines the final value
  79921. * @param loop defines if you want animation to loop (off by default)
  79922. * @param speedRatio defines the speed ratio to apply to all animations
  79923. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  79924. * @param onAnimationLoop defines the callback to call when an animation loops
  79925. * @returns the list of created animatables
  79926. */
  79927. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  79928. /**
  79929. * Begin a new animation on a given node and its hierarchy
  79930. * @param target defines the root node where the animation will take place
  79931. * @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.
  79932. * @param animations defines the list of animations to start
  79933. * @param from defines the initial value
  79934. * @param to defines the final value
  79935. * @param loop defines if you want animation to loop (off by default)
  79936. * @param speedRatio defines the speed ratio to apply to all animations
  79937. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  79938. * @param onAnimationLoop defines the callback to call when an animation loops
  79939. * @returns the list of animatables created for all nodes
  79940. */
  79941. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  79942. /**
  79943. * Gets the animatable associated with a specific target
  79944. * @param target defines the target of the animatable
  79945. * @returns the required animatable if found
  79946. */
  79947. getAnimatableByTarget(target: any): Nullable<Animatable>;
  79948. /**
  79949. * Gets all animatables associated with a given target
  79950. * @param target defines the target to look animatables for
  79951. * @returns an array of Animatables
  79952. */
  79953. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  79954. /**
  79955. * Stops and removes all animations that have been applied to the scene
  79956. */
  79957. stopAllAnimations(): void;
  79958. /**
  79959. * Gets the current delta time used by animation engine
  79960. */
  79961. deltaTime: number;
  79962. }
  79963. interface Bone {
  79964. /**
  79965. * Copy an animation range from another bone
  79966. * @param source defines the source bone
  79967. * @param rangeName defines the range name to copy
  79968. * @param frameOffset defines the frame offset
  79969. * @param rescaleAsRequired defines if rescaling must be applied if required
  79970. * @param skelDimensionsRatio defines the scaling ratio
  79971. * @returns true if operation was successful
  79972. */
  79973. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  79974. }
  79975. }
  79976. declare module BABYLON {
  79977. /**
  79978. * Class used to override all child animations of a given target
  79979. */
  79980. export class AnimationPropertiesOverride {
  79981. /**
  79982. * Gets or sets a value indicating if animation blending must be used
  79983. */
  79984. enableBlending: boolean;
  79985. /**
  79986. * Gets or sets the blending speed to use when enableBlending is true
  79987. */
  79988. blendingSpeed: number;
  79989. /**
  79990. * Gets or sets the default loop mode to use
  79991. */
  79992. loopMode: number;
  79993. }
  79994. }
  79995. declare module BABYLON {
  79996. /**
  79997. * Class used to handle skinning animations
  79998. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  79999. */
  80000. export class Skeleton implements IAnimatable {
  80001. /** defines the skeleton name */
  80002. name: string;
  80003. /** defines the skeleton Id */
  80004. id: string;
  80005. /**
  80006. * Defines the list of child bones
  80007. */
  80008. bones: Bone[];
  80009. /**
  80010. * Defines an estimate of the dimension of the skeleton at rest
  80011. */
  80012. dimensionsAtRest: Vector3;
  80013. /**
  80014. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  80015. */
  80016. needInitialSkinMatrix: boolean;
  80017. /**
  80018. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  80019. */
  80020. overrideMesh: Nullable<AbstractMesh>;
  80021. /**
  80022. * Gets the list of animations attached to this skeleton
  80023. */
  80024. animations: Array<Animation>;
  80025. private _scene;
  80026. private _isDirty;
  80027. private _transformMatrices;
  80028. private _transformMatrixTexture;
  80029. private _meshesWithPoseMatrix;
  80030. private _animatables;
  80031. private _identity;
  80032. private _synchronizedWithMesh;
  80033. private _ranges;
  80034. private _lastAbsoluteTransformsUpdateId;
  80035. private _canUseTextureForBones;
  80036. private _uniqueId;
  80037. /** @hidden */
  80038. _numBonesWithLinkedTransformNode: number;
  80039. /** @hidden */
  80040. _hasWaitingData: Nullable<boolean>;
  80041. /**
  80042. * Specifies if the skeleton should be serialized
  80043. */
  80044. doNotSerialize: boolean;
  80045. private _useTextureToStoreBoneMatrices;
  80046. /**
  80047. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  80048. * Please note that this option is not available if the hardware does not support it
  80049. */
  80050. useTextureToStoreBoneMatrices: boolean;
  80051. private _animationPropertiesOverride;
  80052. /**
  80053. * Gets or sets the animation properties override
  80054. */
  80055. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  80056. /**
  80057. * List of inspectable custom properties (used by the Inspector)
  80058. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  80059. */
  80060. inspectableCustomProperties: IInspectable[];
  80061. /**
  80062. * An observable triggered before computing the skeleton's matrices
  80063. */
  80064. onBeforeComputeObservable: Observable<Skeleton>;
  80065. /**
  80066. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  80067. */
  80068. readonly isUsingTextureForMatrices: boolean;
  80069. /**
  80070. * Gets the unique ID of this skeleton
  80071. */
  80072. readonly uniqueId: number;
  80073. /**
  80074. * Creates a new skeleton
  80075. * @param name defines the skeleton name
  80076. * @param id defines the skeleton Id
  80077. * @param scene defines the hosting scene
  80078. */
  80079. constructor(
  80080. /** defines the skeleton name */
  80081. name: string,
  80082. /** defines the skeleton Id */
  80083. id: string, scene: Scene);
  80084. /**
  80085. * Gets the current object class name.
  80086. * @return the class name
  80087. */
  80088. getClassName(): string;
  80089. /**
  80090. * Returns an array containing the root bones
  80091. * @returns an array containing the root bones
  80092. */
  80093. getChildren(): Array<Bone>;
  80094. /**
  80095. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  80096. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  80097. * @returns a Float32Array containing matrices data
  80098. */
  80099. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  80100. /**
  80101. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  80102. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  80103. * @returns a raw texture containing the data
  80104. */
  80105. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  80106. /**
  80107. * Gets the current hosting scene
  80108. * @returns a scene object
  80109. */
  80110. getScene(): Scene;
  80111. /**
  80112. * Gets a string representing the current skeleton data
  80113. * @param fullDetails defines a boolean indicating if we want a verbose version
  80114. * @returns a string representing the current skeleton data
  80115. */
  80116. toString(fullDetails?: boolean): string;
  80117. /**
  80118. * Get bone's index searching by name
  80119. * @param name defines bone's name to search for
  80120. * @return the indice of the bone. Returns -1 if not found
  80121. */
  80122. getBoneIndexByName(name: string): number;
  80123. /**
  80124. * Creater a new animation range
  80125. * @param name defines the name of the range
  80126. * @param from defines the start key
  80127. * @param to defines the end key
  80128. */
  80129. createAnimationRange(name: string, from: number, to: number): void;
  80130. /**
  80131. * Delete a specific animation range
  80132. * @param name defines the name of the range
  80133. * @param deleteFrames defines if frames must be removed as well
  80134. */
  80135. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  80136. /**
  80137. * Gets a specific animation range
  80138. * @param name defines the name of the range to look for
  80139. * @returns the requested animation range or null if not found
  80140. */
  80141. getAnimationRange(name: string): Nullable<AnimationRange>;
  80142. /**
  80143. * Gets the list of all animation ranges defined on this skeleton
  80144. * @returns an array
  80145. */
  80146. getAnimationRanges(): Nullable<AnimationRange>[];
  80147. /**
  80148. * Copy animation range from a source skeleton.
  80149. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  80150. * @param source defines the source skeleton
  80151. * @param name defines the name of the range to copy
  80152. * @param rescaleAsRequired defines if rescaling must be applied if required
  80153. * @returns true if operation was successful
  80154. */
  80155. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  80156. /**
  80157. * Forces the skeleton to go to rest pose
  80158. */
  80159. returnToRest(): void;
  80160. private _getHighestAnimationFrame;
  80161. /**
  80162. * Begin a specific animation range
  80163. * @param name defines the name of the range to start
  80164. * @param loop defines if looping must be turned on (false by default)
  80165. * @param speedRatio defines the speed ratio to apply (1 by default)
  80166. * @param onAnimationEnd defines a callback which will be called when animation will end
  80167. * @returns a new animatable
  80168. */
  80169. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  80170. /** @hidden */
  80171. _markAsDirty(): void;
  80172. /** @hidden */
  80173. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  80174. /** @hidden */
  80175. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  80176. private _computeTransformMatrices;
  80177. /**
  80178. * Build all resources required to render a skeleton
  80179. */
  80180. prepare(): void;
  80181. /**
  80182. * Gets the list of animatables currently running for this skeleton
  80183. * @returns an array of animatables
  80184. */
  80185. getAnimatables(): IAnimatable[];
  80186. /**
  80187. * Clone the current skeleton
  80188. * @param name defines the name of the new skeleton
  80189. * @param id defines the id of the new skeleton
  80190. * @returns the new skeleton
  80191. */
  80192. clone(name: string, id: string): Skeleton;
  80193. /**
  80194. * Enable animation blending for this skeleton
  80195. * @param blendingSpeed defines the blending speed to apply
  80196. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  80197. */
  80198. enableBlending(blendingSpeed?: number): void;
  80199. /**
  80200. * Releases all resources associated with the current skeleton
  80201. */
  80202. dispose(): void;
  80203. /**
  80204. * Serialize the skeleton in a JSON object
  80205. * @returns a JSON object
  80206. */
  80207. serialize(): any;
  80208. /**
  80209. * Creates a new skeleton from serialized data
  80210. * @param parsedSkeleton defines the serialized data
  80211. * @param scene defines the hosting scene
  80212. * @returns a new skeleton
  80213. */
  80214. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  80215. /**
  80216. * Compute all node absolute transforms
  80217. * @param forceUpdate defines if computation must be done even if cache is up to date
  80218. */
  80219. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  80220. /**
  80221. * Gets the root pose matrix
  80222. * @returns a matrix
  80223. */
  80224. getPoseMatrix(): Nullable<Matrix>;
  80225. /**
  80226. * Sorts bones per internal index
  80227. */
  80228. sortBones(): void;
  80229. private _sortBones;
  80230. }
  80231. }
  80232. declare module BABYLON {
  80233. /**
  80234. * Class used to store bone information
  80235. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  80236. */
  80237. export class Bone extends Node {
  80238. /**
  80239. * defines the bone name
  80240. */
  80241. name: string;
  80242. private static _tmpVecs;
  80243. private static _tmpQuat;
  80244. private static _tmpMats;
  80245. /**
  80246. * Gets the list of child bones
  80247. */
  80248. children: Bone[];
  80249. /** Gets the animations associated with this bone */
  80250. animations: Animation[];
  80251. /**
  80252. * Gets or sets bone length
  80253. */
  80254. length: number;
  80255. /**
  80256. * @hidden Internal only
  80257. * Set this value to map this bone to a different index in the transform matrices
  80258. * Set this value to -1 to exclude the bone from the transform matrices
  80259. */
  80260. _index: Nullable<number>;
  80261. private _skeleton;
  80262. private _localMatrix;
  80263. private _restPose;
  80264. private _baseMatrix;
  80265. private _absoluteTransform;
  80266. private _invertedAbsoluteTransform;
  80267. private _parent;
  80268. private _scalingDeterminant;
  80269. private _worldTransform;
  80270. private _localScaling;
  80271. private _localRotation;
  80272. private _localPosition;
  80273. private _needToDecompose;
  80274. private _needToCompose;
  80275. /** @hidden */
  80276. _linkedTransformNode: Nullable<TransformNode>;
  80277. /** @hidden */
  80278. _waitingTransformNodeId: Nullable<string>;
  80279. /** @hidden */
  80280. /** @hidden */
  80281. _matrix: Matrix;
  80282. /**
  80283. * Create a new bone
  80284. * @param name defines the bone name
  80285. * @param skeleton defines the parent skeleton
  80286. * @param parentBone defines the parent (can be null if the bone is the root)
  80287. * @param localMatrix defines the local matrix
  80288. * @param restPose defines the rest pose matrix
  80289. * @param baseMatrix defines the base matrix
  80290. * @param index defines index of the bone in the hiearchy
  80291. */
  80292. constructor(
  80293. /**
  80294. * defines the bone name
  80295. */
  80296. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  80297. /**
  80298. * Gets the current object class name.
  80299. * @return the class name
  80300. */
  80301. getClassName(): string;
  80302. /**
  80303. * Gets the parent skeleton
  80304. * @returns a skeleton
  80305. */
  80306. getSkeleton(): Skeleton;
  80307. /**
  80308. * Gets parent bone
  80309. * @returns a bone or null if the bone is the root of the bone hierarchy
  80310. */
  80311. getParent(): Nullable<Bone>;
  80312. /**
  80313. * Returns an array containing the root bones
  80314. * @returns an array containing the root bones
  80315. */
  80316. getChildren(): Array<Bone>;
  80317. /**
  80318. * Sets the parent bone
  80319. * @param parent defines the parent (can be null if the bone is the root)
  80320. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  80321. */
  80322. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  80323. /**
  80324. * Gets the local matrix
  80325. * @returns a matrix
  80326. */
  80327. getLocalMatrix(): Matrix;
  80328. /**
  80329. * Gets the base matrix (initial matrix which remains unchanged)
  80330. * @returns a matrix
  80331. */
  80332. getBaseMatrix(): Matrix;
  80333. /**
  80334. * Gets the rest pose matrix
  80335. * @returns a matrix
  80336. */
  80337. getRestPose(): Matrix;
  80338. /**
  80339. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  80340. */
  80341. getWorldMatrix(): Matrix;
  80342. /**
  80343. * Sets the local matrix to rest pose matrix
  80344. */
  80345. returnToRest(): void;
  80346. /**
  80347. * Gets the inverse of the absolute transform matrix.
  80348. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  80349. * @returns a matrix
  80350. */
  80351. getInvertedAbsoluteTransform(): Matrix;
  80352. /**
  80353. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  80354. * @returns a matrix
  80355. */
  80356. getAbsoluteTransform(): Matrix;
  80357. /**
  80358. * Links with the given transform node.
  80359. * The local matrix of this bone is copied from the transform node every frame.
  80360. * @param transformNode defines the transform node to link to
  80361. */
  80362. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  80363. /**
  80364. * Gets the node used to drive the bone's transformation
  80365. * @returns a transform node or null
  80366. */
  80367. getTransformNode(): Nullable<TransformNode>;
  80368. /** Gets or sets current position (in local space) */
  80369. position: Vector3;
  80370. /** Gets or sets current rotation (in local space) */
  80371. rotation: Vector3;
  80372. /** Gets or sets current rotation quaternion (in local space) */
  80373. rotationQuaternion: Quaternion;
  80374. /** Gets or sets current scaling (in local space) */
  80375. scaling: Vector3;
  80376. /**
  80377. * Gets the animation properties override
  80378. */
  80379. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  80380. private _decompose;
  80381. private _compose;
  80382. /**
  80383. * Update the base and local matrices
  80384. * @param matrix defines the new base or local matrix
  80385. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  80386. * @param updateLocalMatrix defines if the local matrix should be updated
  80387. */
  80388. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  80389. /** @hidden */
  80390. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  80391. /**
  80392. * Flag the bone as dirty (Forcing it to update everything)
  80393. */
  80394. markAsDirty(): void;
  80395. /** @hidden */
  80396. _markAsDirtyAndCompose(): void;
  80397. private _markAsDirtyAndDecompose;
  80398. /**
  80399. * Translate the bone in local or world space
  80400. * @param vec The amount to translate the bone
  80401. * @param space The space that the translation is in
  80402. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80403. */
  80404. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  80405. /**
  80406. * Set the postion of the bone in local or world space
  80407. * @param position The position to set the bone
  80408. * @param space The space that the position is in
  80409. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80410. */
  80411. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  80412. /**
  80413. * Set the absolute position of the bone (world space)
  80414. * @param position The position to set the bone
  80415. * @param mesh The mesh that this bone is attached to
  80416. */
  80417. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  80418. /**
  80419. * Scale the bone on the x, y and z axes (in local space)
  80420. * @param x The amount to scale the bone on the x axis
  80421. * @param y The amount to scale the bone on the y axis
  80422. * @param z The amount to scale the bone on the z axis
  80423. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  80424. */
  80425. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  80426. /**
  80427. * Set the bone scaling in local space
  80428. * @param scale defines the scaling vector
  80429. */
  80430. setScale(scale: Vector3): void;
  80431. /**
  80432. * Gets the current scaling in local space
  80433. * @returns the current scaling vector
  80434. */
  80435. getScale(): Vector3;
  80436. /**
  80437. * Gets the current scaling in local space and stores it in a target vector
  80438. * @param result defines the target vector
  80439. */
  80440. getScaleToRef(result: Vector3): void;
  80441. /**
  80442. * Set the yaw, pitch, and roll of the bone in local or world space
  80443. * @param yaw The rotation of the bone on the y axis
  80444. * @param pitch The rotation of the bone on the x axis
  80445. * @param roll The rotation of the bone on the z axis
  80446. * @param space The space that the axes of rotation are in
  80447. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80448. */
  80449. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  80450. /**
  80451. * Add a rotation to the bone on an axis in local or world space
  80452. * @param axis The axis to rotate the bone on
  80453. * @param amount The amount to rotate the bone
  80454. * @param space The space that the axis is in
  80455. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80456. */
  80457. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  80458. /**
  80459. * Set the rotation of the bone to a particular axis angle in local or world space
  80460. * @param axis The axis to rotate the bone on
  80461. * @param angle The angle that the bone should be rotated to
  80462. * @param space The space that the axis is in
  80463. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80464. */
  80465. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  80466. /**
  80467. * Set the euler rotation of the bone in local of world space
  80468. * @param rotation The euler rotation that the bone should be set to
  80469. * @param space The space that the rotation is in
  80470. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80471. */
  80472. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  80473. /**
  80474. * Set the quaternion rotation of the bone in local of world space
  80475. * @param quat The quaternion rotation that the bone should be set to
  80476. * @param space The space that the rotation is in
  80477. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80478. */
  80479. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  80480. /**
  80481. * Set the rotation matrix of the bone in local of world space
  80482. * @param rotMat The rotation matrix that the bone should be set to
  80483. * @param space The space that the rotation is in
  80484. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80485. */
  80486. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  80487. private _rotateWithMatrix;
  80488. private _getNegativeRotationToRef;
  80489. /**
  80490. * Get the position of the bone in local or world space
  80491. * @param space The space that the returned position is in
  80492. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80493. * @returns The position of the bone
  80494. */
  80495. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  80496. /**
  80497. * Copy the position of the bone to a vector3 in local or world space
  80498. * @param space The space that the returned position is in
  80499. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80500. * @param result The vector3 to copy the position to
  80501. */
  80502. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  80503. /**
  80504. * Get the absolute position of the bone (world space)
  80505. * @param mesh The mesh that this bone is attached to
  80506. * @returns The absolute position of the bone
  80507. */
  80508. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  80509. /**
  80510. * Copy the absolute position of the bone (world space) to the result param
  80511. * @param mesh The mesh that this bone is attached to
  80512. * @param result The vector3 to copy the absolute position to
  80513. */
  80514. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  80515. /**
  80516. * Compute the absolute transforms of this bone and its children
  80517. */
  80518. computeAbsoluteTransforms(): void;
  80519. /**
  80520. * Get the world direction from an axis that is in the local space of the bone
  80521. * @param localAxis The local direction that is used to compute the world direction
  80522. * @param mesh The mesh that this bone is attached to
  80523. * @returns The world direction
  80524. */
  80525. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  80526. /**
  80527. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  80528. * @param localAxis The local direction that is used to compute the world direction
  80529. * @param mesh The mesh that this bone is attached to
  80530. * @param result The vector3 that the world direction will be copied to
  80531. */
  80532. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80533. /**
  80534. * Get the euler rotation of the bone in local or world space
  80535. * @param space The space that the rotation should be in
  80536. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80537. * @returns The euler rotation
  80538. */
  80539. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  80540. /**
  80541. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  80542. * @param space The space that the rotation should be in
  80543. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80544. * @param result The vector3 that the rotation should be copied to
  80545. */
  80546. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80547. /**
  80548. * Get the quaternion rotation of the bone in either local or world space
  80549. * @param space The space that the rotation should be in
  80550. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80551. * @returns The quaternion rotation
  80552. */
  80553. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  80554. /**
  80555. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  80556. * @param space The space that the rotation should be in
  80557. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80558. * @param result The quaternion that the rotation should be copied to
  80559. */
  80560. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  80561. /**
  80562. * Get the rotation matrix of the bone in local or world space
  80563. * @param space The space that the rotation should be in
  80564. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80565. * @returns The rotation matrix
  80566. */
  80567. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  80568. /**
  80569. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  80570. * @param space The space that the rotation should be in
  80571. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80572. * @param result The quaternion that the rotation should be copied to
  80573. */
  80574. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  80575. /**
  80576. * Get the world position of a point that is in the local space of the bone
  80577. * @param position The local position
  80578. * @param mesh The mesh that this bone is attached to
  80579. * @returns The world position
  80580. */
  80581. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  80582. /**
  80583. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  80584. * @param position The local position
  80585. * @param mesh The mesh that this bone is attached to
  80586. * @param result The vector3 that the world position should be copied to
  80587. */
  80588. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80589. /**
  80590. * Get the local position of a point that is in world space
  80591. * @param position The world position
  80592. * @param mesh The mesh that this bone is attached to
  80593. * @returns The local position
  80594. */
  80595. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  80596. /**
  80597. * Get the local position of a point that is in world space and copy it to the result param
  80598. * @param position The world position
  80599. * @param mesh The mesh that this bone is attached to
  80600. * @param result The vector3 that the local position should be copied to
  80601. */
  80602. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80603. }
  80604. }
  80605. declare module BABYLON {
  80606. /**
  80607. * 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.
  80608. * @see https://doc.babylonjs.com/how_to/transformnode
  80609. */
  80610. export class TransformNode extends Node {
  80611. /**
  80612. * Object will not rotate to face the camera
  80613. */
  80614. static BILLBOARDMODE_NONE: number;
  80615. /**
  80616. * Object will rotate to face the camera but only on the x axis
  80617. */
  80618. static BILLBOARDMODE_X: number;
  80619. /**
  80620. * Object will rotate to face the camera but only on the y axis
  80621. */
  80622. static BILLBOARDMODE_Y: number;
  80623. /**
  80624. * Object will rotate to face the camera but only on the z axis
  80625. */
  80626. static BILLBOARDMODE_Z: number;
  80627. /**
  80628. * Object will rotate to face the camera
  80629. */
  80630. static BILLBOARDMODE_ALL: number;
  80631. /**
  80632. * Object will rotate to face the camera's position instead of orientation
  80633. */
  80634. static BILLBOARDMODE_USE_POSITION: number;
  80635. private _forward;
  80636. private _forwardInverted;
  80637. private _up;
  80638. private _right;
  80639. private _rightInverted;
  80640. private _position;
  80641. private _rotation;
  80642. private _rotationQuaternion;
  80643. protected _scaling: Vector3;
  80644. protected _isDirty: boolean;
  80645. private _transformToBoneReferal;
  80646. private _isAbsoluteSynced;
  80647. private _billboardMode;
  80648. /**
  80649. * Gets or sets the billboard mode. Default is 0.
  80650. *
  80651. * | Value | Type | Description |
  80652. * | --- | --- | --- |
  80653. * | 0 | BILLBOARDMODE_NONE | |
  80654. * | 1 | BILLBOARDMODE_X | |
  80655. * | 2 | BILLBOARDMODE_Y | |
  80656. * | 4 | BILLBOARDMODE_Z | |
  80657. * | 7 | BILLBOARDMODE_ALL | |
  80658. *
  80659. */
  80660. billboardMode: number;
  80661. private _preserveParentRotationForBillboard;
  80662. /**
  80663. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  80664. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  80665. */
  80666. preserveParentRotationForBillboard: boolean;
  80667. /**
  80668. * 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
  80669. */
  80670. scalingDeterminant: number;
  80671. private _infiniteDistance;
  80672. /**
  80673. * Gets or sets the distance of the object to max, often used by skybox
  80674. */
  80675. infiniteDistance: boolean;
  80676. /**
  80677. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  80678. * By default the system will update normals to compensate
  80679. */
  80680. ignoreNonUniformScaling: boolean;
  80681. /**
  80682. * 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
  80683. */
  80684. reIntegrateRotationIntoRotationQuaternion: boolean;
  80685. /** @hidden */
  80686. _poseMatrix: Nullable<Matrix>;
  80687. /** @hidden */
  80688. _localMatrix: Matrix;
  80689. private _usePivotMatrix;
  80690. private _absolutePosition;
  80691. private _absoluteScaling;
  80692. private _absoluteRotationQuaternion;
  80693. private _pivotMatrix;
  80694. private _pivotMatrixInverse;
  80695. protected _postMultiplyPivotMatrix: boolean;
  80696. protected _isWorldMatrixFrozen: boolean;
  80697. /** @hidden */
  80698. _indexInSceneTransformNodesArray: number;
  80699. /**
  80700. * An event triggered after the world matrix is updated
  80701. */
  80702. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  80703. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  80704. /**
  80705. * Gets a string identifying the name of the class
  80706. * @returns "TransformNode" string
  80707. */
  80708. getClassName(): string;
  80709. /**
  80710. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  80711. */
  80712. position: Vector3;
  80713. /**
  80714. * 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)).
  80715. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  80716. */
  80717. rotation: Vector3;
  80718. /**
  80719. * 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)).
  80720. */
  80721. scaling: Vector3;
  80722. /**
  80723. * 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).
  80724. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  80725. */
  80726. rotationQuaternion: Nullable<Quaternion>;
  80727. /**
  80728. * The forward direction of that transform in world space.
  80729. */
  80730. readonly forward: Vector3;
  80731. /**
  80732. * The up direction of that transform in world space.
  80733. */
  80734. readonly up: Vector3;
  80735. /**
  80736. * The right direction of that transform in world space.
  80737. */
  80738. readonly right: Vector3;
  80739. /**
  80740. * Copies the parameter passed Matrix into the mesh Pose matrix.
  80741. * @param matrix the matrix to copy the pose from
  80742. * @returns this TransformNode.
  80743. */
  80744. updatePoseMatrix(matrix: Matrix): TransformNode;
  80745. /**
  80746. * Returns the mesh Pose matrix.
  80747. * @returns the pose matrix
  80748. */
  80749. getPoseMatrix(): Matrix;
  80750. /** @hidden */
  80751. _isSynchronized(): boolean;
  80752. /** @hidden */
  80753. _initCache(): void;
  80754. /**
  80755. * Flag the transform node as dirty (Forcing it to update everything)
  80756. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  80757. * @returns this transform node
  80758. */
  80759. markAsDirty(property: string): TransformNode;
  80760. /**
  80761. * Returns the current mesh absolute position.
  80762. * Returns a Vector3.
  80763. */
  80764. readonly absolutePosition: Vector3;
  80765. /**
  80766. * Returns the current mesh absolute scaling.
  80767. * Returns a Vector3.
  80768. */
  80769. readonly absoluteScaling: Vector3;
  80770. /**
  80771. * Returns the current mesh absolute rotation.
  80772. * Returns a Quaternion.
  80773. */
  80774. readonly absoluteRotationQuaternion: Quaternion;
  80775. /**
  80776. * Sets a new matrix to apply before all other transformation
  80777. * @param matrix defines the transform matrix
  80778. * @returns the current TransformNode
  80779. */
  80780. setPreTransformMatrix(matrix: Matrix): TransformNode;
  80781. /**
  80782. * Sets a new pivot matrix to the current node
  80783. * @param matrix defines the new pivot matrix to use
  80784. * @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
  80785. * @returns the current TransformNode
  80786. */
  80787. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  80788. /**
  80789. * Returns the mesh pivot matrix.
  80790. * Default : Identity.
  80791. * @returns the matrix
  80792. */
  80793. getPivotMatrix(): Matrix;
  80794. /**
  80795. * Instantiate (when possible) or clone that node with its hierarchy
  80796. * @param newParent defines the new parent to use for the instance (or clone)
  80797. * @returns an instance (or a clone) of the current node with its hiearchy
  80798. */
  80799. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  80800. /**
  80801. * Prevents the World matrix to be computed any longer
  80802. * @param newWorldMatrix defines an optional matrix to use as world matrix
  80803. * @returns the TransformNode.
  80804. */
  80805. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  80806. /**
  80807. * Allows back the World matrix computation.
  80808. * @returns the TransformNode.
  80809. */
  80810. unfreezeWorldMatrix(): this;
  80811. /**
  80812. * True if the World matrix has been frozen.
  80813. */
  80814. readonly isWorldMatrixFrozen: boolean;
  80815. /**
  80816. * Retuns the mesh absolute position in the World.
  80817. * @returns a Vector3.
  80818. */
  80819. getAbsolutePosition(): Vector3;
  80820. /**
  80821. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  80822. * @param absolutePosition the absolute position to set
  80823. * @returns the TransformNode.
  80824. */
  80825. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  80826. /**
  80827. * Sets the mesh position in its local space.
  80828. * @param vector3 the position to set in localspace
  80829. * @returns the TransformNode.
  80830. */
  80831. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  80832. /**
  80833. * Returns the mesh position in the local space from the current World matrix values.
  80834. * @returns a new Vector3.
  80835. */
  80836. getPositionExpressedInLocalSpace(): Vector3;
  80837. /**
  80838. * Translates the mesh along the passed Vector3 in its local space.
  80839. * @param vector3 the distance to translate in localspace
  80840. * @returns the TransformNode.
  80841. */
  80842. locallyTranslate(vector3: Vector3): TransformNode;
  80843. private static _lookAtVectorCache;
  80844. /**
  80845. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  80846. * @param targetPoint the position (must be in same space as current mesh) to look at
  80847. * @param yawCor optional yaw (y-axis) correction in radians
  80848. * @param pitchCor optional pitch (x-axis) correction in radians
  80849. * @param rollCor optional roll (z-axis) correction in radians
  80850. * @param space the choosen space of the target
  80851. * @returns the TransformNode.
  80852. */
  80853. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  80854. /**
  80855. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  80856. * This Vector3 is expressed in the World space.
  80857. * @param localAxis axis to rotate
  80858. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  80859. */
  80860. getDirection(localAxis: Vector3): Vector3;
  80861. /**
  80862. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  80863. * localAxis is expressed in the mesh local space.
  80864. * result is computed in the Wordl space from the mesh World matrix.
  80865. * @param localAxis axis to rotate
  80866. * @param result the resulting transformnode
  80867. * @returns this TransformNode.
  80868. */
  80869. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  80870. /**
  80871. * Sets this transform node rotation to the given local axis.
  80872. * @param localAxis the axis in local space
  80873. * @param yawCor optional yaw (y-axis) correction in radians
  80874. * @param pitchCor optional pitch (x-axis) correction in radians
  80875. * @param rollCor optional roll (z-axis) correction in radians
  80876. * @returns this TransformNode
  80877. */
  80878. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  80879. /**
  80880. * Sets a new pivot point to the current node
  80881. * @param point defines the new pivot point to use
  80882. * @param space defines if the point is in world or local space (local by default)
  80883. * @returns the current TransformNode
  80884. */
  80885. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  80886. /**
  80887. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  80888. * @returns the pivot point
  80889. */
  80890. getPivotPoint(): Vector3;
  80891. /**
  80892. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  80893. * @param result the vector3 to store the result
  80894. * @returns this TransformNode.
  80895. */
  80896. getPivotPointToRef(result: Vector3): TransformNode;
  80897. /**
  80898. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  80899. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  80900. */
  80901. getAbsolutePivotPoint(): Vector3;
  80902. /**
  80903. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  80904. * @param result vector3 to store the result
  80905. * @returns this TransformNode.
  80906. */
  80907. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  80908. /**
  80909. * Defines the passed node as the parent of the current node.
  80910. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  80911. * @see https://doc.babylonjs.com/how_to/parenting
  80912. * @param node the node ot set as the parent
  80913. * @returns this TransformNode.
  80914. */
  80915. setParent(node: Nullable<Node>): TransformNode;
  80916. private _nonUniformScaling;
  80917. /**
  80918. * True if the scaling property of this object is non uniform eg. (1,2,1)
  80919. */
  80920. readonly nonUniformScaling: boolean;
  80921. /** @hidden */
  80922. _updateNonUniformScalingState(value: boolean): boolean;
  80923. /**
  80924. * Attach the current TransformNode to another TransformNode associated with a bone
  80925. * @param bone Bone affecting the TransformNode
  80926. * @param affectedTransformNode TransformNode associated with the bone
  80927. * @returns this object
  80928. */
  80929. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  80930. /**
  80931. * Detach the transform node if its associated with a bone
  80932. * @returns this object
  80933. */
  80934. detachFromBone(): TransformNode;
  80935. private static _rotationAxisCache;
  80936. /**
  80937. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  80938. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  80939. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  80940. * The passed axis is also normalized.
  80941. * @param axis the axis to rotate around
  80942. * @param amount the amount to rotate in radians
  80943. * @param space Space to rotate in (Default: local)
  80944. * @returns the TransformNode.
  80945. */
  80946. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  80947. /**
  80948. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  80949. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  80950. * The passed axis is also normalized. .
  80951. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  80952. * @param point the point to rotate around
  80953. * @param axis the axis to rotate around
  80954. * @param amount the amount to rotate in radians
  80955. * @returns the TransformNode
  80956. */
  80957. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  80958. /**
  80959. * Translates the mesh along the axis vector for the passed distance in the given space.
  80960. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  80961. * @param axis the axis to translate in
  80962. * @param distance the distance to translate
  80963. * @param space Space to rotate in (Default: local)
  80964. * @returns the TransformNode.
  80965. */
  80966. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  80967. /**
  80968. * Adds a rotation step to the mesh current rotation.
  80969. * x, y, z are Euler angles expressed in radians.
  80970. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  80971. * This means this rotation is made in the mesh local space only.
  80972. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  80973. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  80974. * ```javascript
  80975. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  80976. * ```
  80977. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  80978. * 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.
  80979. * @param x Rotation to add
  80980. * @param y Rotation to add
  80981. * @param z Rotation to add
  80982. * @returns the TransformNode.
  80983. */
  80984. addRotation(x: number, y: number, z: number): TransformNode;
  80985. /**
  80986. * @hidden
  80987. */
  80988. protected _getEffectiveParent(): Nullable<Node>;
  80989. /**
  80990. * Computes the world matrix of the node
  80991. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  80992. * @returns the world matrix
  80993. */
  80994. computeWorldMatrix(force?: boolean): Matrix;
  80995. protected _afterComputeWorldMatrix(): void;
  80996. /**
  80997. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  80998. * @param func callback function to add
  80999. *
  81000. * @returns the TransformNode.
  81001. */
  81002. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  81003. /**
  81004. * Removes a registered callback function.
  81005. * @param func callback function to remove
  81006. * @returns the TransformNode.
  81007. */
  81008. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  81009. /**
  81010. * Gets the position of the current mesh in camera space
  81011. * @param camera defines the camera to use
  81012. * @returns a position
  81013. */
  81014. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  81015. /**
  81016. * Returns the distance from the mesh to the active camera
  81017. * @param camera defines the camera to use
  81018. * @returns the distance
  81019. */
  81020. getDistanceToCamera(camera?: Nullable<Camera>): number;
  81021. /**
  81022. * Clone the current transform node
  81023. * @param name Name of the new clone
  81024. * @param newParent New parent for the clone
  81025. * @param doNotCloneChildren Do not clone children hierarchy
  81026. * @returns the new transform node
  81027. */
  81028. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  81029. /**
  81030. * Serializes the objects information.
  81031. * @param currentSerializationObject defines the object to serialize in
  81032. * @returns the serialized object
  81033. */
  81034. serialize(currentSerializationObject?: any): any;
  81035. /**
  81036. * Returns a new TransformNode object parsed from the source provided.
  81037. * @param parsedTransformNode is the source.
  81038. * @param scene the scne the object belongs to
  81039. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  81040. * @returns a new TransformNode object parsed from the source provided.
  81041. */
  81042. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  81043. /**
  81044. * Get all child-transformNodes of this node
  81045. * @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
  81046. * @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
  81047. * @returns an array of TransformNode
  81048. */
  81049. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  81050. /**
  81051. * Releases resources associated with this transform node.
  81052. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  81053. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  81054. */
  81055. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  81056. /**
  81057. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  81058. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  81059. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  81060. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  81061. * @returns the current mesh
  81062. */
  81063. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  81064. private _syncAbsoluteScalingAndRotation;
  81065. }
  81066. }
  81067. declare module BABYLON {
  81068. /**
  81069. * Defines the types of pose enabled controllers that are supported
  81070. */
  81071. export enum PoseEnabledControllerType {
  81072. /**
  81073. * HTC Vive
  81074. */
  81075. VIVE = 0,
  81076. /**
  81077. * Oculus Rift
  81078. */
  81079. OCULUS = 1,
  81080. /**
  81081. * Windows mixed reality
  81082. */
  81083. WINDOWS = 2,
  81084. /**
  81085. * Samsung gear VR
  81086. */
  81087. GEAR_VR = 3,
  81088. /**
  81089. * Google Daydream
  81090. */
  81091. DAYDREAM = 4,
  81092. /**
  81093. * Generic
  81094. */
  81095. GENERIC = 5
  81096. }
  81097. /**
  81098. * Defines the MutableGamepadButton interface for the state of a gamepad button
  81099. */
  81100. export interface MutableGamepadButton {
  81101. /**
  81102. * Value of the button/trigger
  81103. */
  81104. value: number;
  81105. /**
  81106. * If the button/trigger is currently touched
  81107. */
  81108. touched: boolean;
  81109. /**
  81110. * If the button/trigger is currently pressed
  81111. */
  81112. pressed: boolean;
  81113. }
  81114. /**
  81115. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  81116. * @hidden
  81117. */
  81118. export interface ExtendedGamepadButton extends GamepadButton {
  81119. /**
  81120. * If the button/trigger is currently pressed
  81121. */
  81122. readonly pressed: boolean;
  81123. /**
  81124. * If the button/trigger is currently touched
  81125. */
  81126. readonly touched: boolean;
  81127. /**
  81128. * Value of the button/trigger
  81129. */
  81130. readonly value: number;
  81131. }
  81132. /** @hidden */
  81133. export interface _GamePadFactory {
  81134. /**
  81135. * Returns wether or not the current gamepad can be created for this type of controller.
  81136. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  81137. * @returns true if it can be created, otherwise false
  81138. */
  81139. canCreate(gamepadInfo: any): boolean;
  81140. /**
  81141. * Creates a new instance of the Gamepad.
  81142. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  81143. * @returns the new gamepad instance
  81144. */
  81145. create(gamepadInfo: any): Gamepad;
  81146. }
  81147. /**
  81148. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  81149. */
  81150. export class PoseEnabledControllerHelper {
  81151. /** @hidden */
  81152. static _ControllerFactories: _GamePadFactory[];
  81153. /** @hidden */
  81154. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  81155. /**
  81156. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  81157. * @param vrGamepad the gamepad to initialized
  81158. * @returns a vr controller of the type the gamepad identified as
  81159. */
  81160. static InitiateController(vrGamepad: any): Gamepad;
  81161. }
  81162. /**
  81163. * Defines the PoseEnabledController object that contains state of a vr capable controller
  81164. */
  81165. export class PoseEnabledController extends Gamepad implements PoseControlled {
  81166. /**
  81167. * If the controller is used in a webXR session
  81168. */
  81169. isXR: boolean;
  81170. private _deviceRoomPosition;
  81171. private _deviceRoomRotationQuaternion;
  81172. /**
  81173. * The device position in babylon space
  81174. */
  81175. devicePosition: Vector3;
  81176. /**
  81177. * The device rotation in babylon space
  81178. */
  81179. deviceRotationQuaternion: Quaternion;
  81180. /**
  81181. * The scale factor of the device in babylon space
  81182. */
  81183. deviceScaleFactor: number;
  81184. /**
  81185. * (Likely devicePosition should be used instead) The device position in its room space
  81186. */
  81187. position: Vector3;
  81188. /**
  81189. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  81190. */
  81191. rotationQuaternion: Quaternion;
  81192. /**
  81193. * The type of controller (Eg. Windows mixed reality)
  81194. */
  81195. controllerType: PoseEnabledControllerType;
  81196. protected _calculatedPosition: Vector3;
  81197. private _calculatedRotation;
  81198. /**
  81199. * The raw pose from the device
  81200. */
  81201. rawPose: DevicePose;
  81202. private _trackPosition;
  81203. private _maxRotationDistFromHeadset;
  81204. private _draggedRoomRotation;
  81205. /**
  81206. * @hidden
  81207. */
  81208. _disableTrackPosition(fixedPosition: Vector3): void;
  81209. /**
  81210. * Internal, the mesh attached to the controller
  81211. * @hidden
  81212. */
  81213. _mesh: Nullable<AbstractMesh>;
  81214. private _poseControlledCamera;
  81215. private _leftHandSystemQuaternion;
  81216. /**
  81217. * Internal, matrix used to convert room space to babylon space
  81218. * @hidden
  81219. */
  81220. _deviceToWorld: Matrix;
  81221. /**
  81222. * Node to be used when casting a ray from the controller
  81223. * @hidden
  81224. */
  81225. _pointingPoseNode: Nullable<TransformNode>;
  81226. /**
  81227. * Name of the child mesh that can be used to cast a ray from the controller
  81228. */
  81229. static readonly POINTING_POSE: string;
  81230. /**
  81231. * Creates a new PoseEnabledController from a gamepad
  81232. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  81233. */
  81234. constructor(browserGamepad: any);
  81235. private _workingMatrix;
  81236. /**
  81237. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  81238. */
  81239. update(): void;
  81240. /**
  81241. * Updates only the pose device and mesh without doing any button event checking
  81242. */
  81243. protected _updatePoseAndMesh(): void;
  81244. /**
  81245. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  81246. * @param poseData raw pose fromthe device
  81247. */
  81248. updateFromDevice(poseData: DevicePose): void;
  81249. /**
  81250. * @hidden
  81251. */
  81252. _meshAttachedObservable: Observable<AbstractMesh>;
  81253. /**
  81254. * Attaches a mesh to the controller
  81255. * @param mesh the mesh to be attached
  81256. */
  81257. attachToMesh(mesh: AbstractMesh): void;
  81258. /**
  81259. * Attaches the controllers mesh to a camera
  81260. * @param camera the camera the mesh should be attached to
  81261. */
  81262. attachToPoseControlledCamera(camera: TargetCamera): void;
  81263. /**
  81264. * Disposes of the controller
  81265. */
  81266. dispose(): void;
  81267. /**
  81268. * The mesh that is attached to the controller
  81269. */
  81270. readonly mesh: Nullable<AbstractMesh>;
  81271. /**
  81272. * Gets the ray of the controller in the direction the controller is pointing
  81273. * @param length the length the resulting ray should be
  81274. * @returns a ray in the direction the controller is pointing
  81275. */
  81276. getForwardRay(length?: number): Ray;
  81277. }
  81278. }
  81279. declare module BABYLON {
  81280. /**
  81281. * Defines the WebVRController object that represents controllers tracked in 3D space
  81282. */
  81283. export abstract class WebVRController extends PoseEnabledController {
  81284. /**
  81285. * Internal, the default controller model for the controller
  81286. */
  81287. protected _defaultModel: Nullable<AbstractMesh>;
  81288. /**
  81289. * Fired when the trigger state has changed
  81290. */
  81291. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  81292. /**
  81293. * Fired when the main button state has changed
  81294. */
  81295. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  81296. /**
  81297. * Fired when the secondary button state has changed
  81298. */
  81299. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  81300. /**
  81301. * Fired when the pad state has changed
  81302. */
  81303. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  81304. /**
  81305. * Fired when controllers stick values have changed
  81306. */
  81307. onPadValuesChangedObservable: Observable<StickValues>;
  81308. /**
  81309. * Array of button availible on the controller
  81310. */
  81311. protected _buttons: Array<MutableGamepadButton>;
  81312. private _onButtonStateChange;
  81313. /**
  81314. * Fired when a controller button's state has changed
  81315. * @param callback the callback containing the button that was modified
  81316. */
  81317. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  81318. /**
  81319. * X and Y axis corresponding to the controllers joystick
  81320. */
  81321. pad: StickValues;
  81322. /**
  81323. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  81324. */
  81325. hand: string;
  81326. /**
  81327. * The default controller model for the controller
  81328. */
  81329. readonly defaultModel: Nullable<AbstractMesh>;
  81330. /**
  81331. * Creates a new WebVRController from a gamepad
  81332. * @param vrGamepad the gamepad that the WebVRController should be created from
  81333. */
  81334. constructor(vrGamepad: any);
  81335. /**
  81336. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  81337. */
  81338. update(): void;
  81339. /**
  81340. * Function to be called when a button is modified
  81341. */
  81342. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  81343. /**
  81344. * Loads a mesh and attaches it to the controller
  81345. * @param scene the scene the mesh should be added to
  81346. * @param meshLoaded callback for when the mesh has been loaded
  81347. */
  81348. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  81349. private _setButtonValue;
  81350. private _changes;
  81351. private _checkChanges;
  81352. /**
  81353. * Disposes of th webVRCOntroller
  81354. */
  81355. dispose(): void;
  81356. }
  81357. }
  81358. declare module BABYLON {
  81359. /**
  81360. * The HemisphericLight simulates the ambient environment light,
  81361. * so the passed direction is the light reflection direction, not the incoming direction.
  81362. */
  81363. export class HemisphericLight extends Light {
  81364. /**
  81365. * The groundColor is the light in the opposite direction to the one specified during creation.
  81366. * 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.
  81367. */
  81368. groundColor: Color3;
  81369. /**
  81370. * The light reflection direction, not the incoming direction.
  81371. */
  81372. direction: Vector3;
  81373. /**
  81374. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  81375. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  81376. * The HemisphericLight can't cast shadows.
  81377. * Documentation : https://doc.babylonjs.com/babylon101/lights
  81378. * @param name The friendly name of the light
  81379. * @param direction The direction of the light reflection
  81380. * @param scene The scene the light belongs to
  81381. */
  81382. constructor(name: string, direction: Vector3, scene: Scene);
  81383. protected _buildUniformLayout(): void;
  81384. /**
  81385. * Returns the string "HemisphericLight".
  81386. * @return The class name
  81387. */
  81388. getClassName(): string;
  81389. /**
  81390. * Sets the HemisphericLight direction towards the passed target (Vector3).
  81391. * Returns the updated direction.
  81392. * @param target The target the direction should point to
  81393. * @return The computed direction
  81394. */
  81395. setDirectionToTarget(target: Vector3): Vector3;
  81396. /**
  81397. * Returns the shadow generator associated to the light.
  81398. * @returns Always null for hemispheric lights because it does not support shadows.
  81399. */
  81400. getShadowGenerator(): Nullable<IShadowGenerator>;
  81401. /**
  81402. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  81403. * @param effect The effect to update
  81404. * @param lightIndex The index of the light in the effect to update
  81405. * @returns The hemispheric light
  81406. */
  81407. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  81408. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  81409. /**
  81410. * Computes the world matrix of the node
  81411. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  81412. * @param useWasUpdatedFlag defines a reserved property
  81413. * @returns the world matrix
  81414. */
  81415. computeWorldMatrix(): Matrix;
  81416. /**
  81417. * Returns the integer 3.
  81418. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  81419. */
  81420. getTypeID(): number;
  81421. /**
  81422. * Prepares the list of defines specific to the light type.
  81423. * @param defines the list of defines
  81424. * @param lightIndex defines the index of the light for the effect
  81425. */
  81426. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  81427. }
  81428. }
  81429. declare module BABYLON {
  81430. /** @hidden */
  81431. export var vrMultiviewToSingleviewPixelShader: {
  81432. name: string;
  81433. shader: string;
  81434. };
  81435. }
  81436. declare module BABYLON {
  81437. /**
  81438. * Renders to multiple views with a single draw call
  81439. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  81440. */
  81441. export class MultiviewRenderTarget extends RenderTargetTexture {
  81442. /**
  81443. * Creates a multiview render target
  81444. * @param scene scene used with the render target
  81445. * @param size the size of the render target (used for each view)
  81446. */
  81447. constructor(scene: Scene, size?: number | {
  81448. width: number;
  81449. height: number;
  81450. } | {
  81451. ratio: number;
  81452. });
  81453. /**
  81454. * @hidden
  81455. * @param faceIndex the face index, if its a cube texture
  81456. */
  81457. _bindFrameBuffer(faceIndex?: number): void;
  81458. /**
  81459. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  81460. * @returns the view count
  81461. */
  81462. getViewCount(): number;
  81463. }
  81464. }
  81465. declare module BABYLON {
  81466. /**
  81467. * Represents a camera frustum
  81468. */
  81469. export class Frustum {
  81470. /**
  81471. * Gets the planes representing the frustum
  81472. * @param transform matrix to be applied to the returned planes
  81473. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  81474. */
  81475. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  81476. /**
  81477. * Gets the near frustum plane transformed by the transform matrix
  81478. * @param transform transformation matrix to be applied to the resulting frustum plane
  81479. * @param frustumPlane the resuling frustum plane
  81480. */
  81481. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81482. /**
  81483. * Gets the far frustum plane transformed by the transform matrix
  81484. * @param transform transformation matrix to be applied to the resulting frustum plane
  81485. * @param frustumPlane the resuling frustum plane
  81486. */
  81487. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81488. /**
  81489. * Gets the left frustum plane transformed by the transform matrix
  81490. * @param transform transformation matrix to be applied to the resulting frustum plane
  81491. * @param frustumPlane the resuling frustum plane
  81492. */
  81493. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81494. /**
  81495. * Gets the right frustum plane transformed by the transform matrix
  81496. * @param transform transformation matrix to be applied to the resulting frustum plane
  81497. * @param frustumPlane the resuling frustum plane
  81498. */
  81499. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81500. /**
  81501. * Gets the top frustum plane transformed by the transform matrix
  81502. * @param transform transformation matrix to be applied to the resulting frustum plane
  81503. * @param frustumPlane the resuling frustum plane
  81504. */
  81505. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81506. /**
  81507. * Gets the bottom frustum plane transformed by the transform matrix
  81508. * @param transform transformation matrix to be applied to the resulting frustum plane
  81509. * @param frustumPlane the resuling frustum plane
  81510. */
  81511. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81512. /**
  81513. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  81514. * @param transform transformation matrix to be applied to the resulting frustum planes
  81515. * @param frustumPlanes the resuling frustum planes
  81516. */
  81517. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  81518. }
  81519. }
  81520. declare module BABYLON {
  81521. interface Engine {
  81522. /**
  81523. * Creates a new multiview render target
  81524. * @param width defines the width of the texture
  81525. * @param height defines the height of the texture
  81526. * @returns the created multiview texture
  81527. */
  81528. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  81529. /**
  81530. * Binds a multiview framebuffer to be drawn to
  81531. * @param multiviewTexture texture to bind
  81532. */
  81533. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  81534. }
  81535. interface Camera {
  81536. /**
  81537. * @hidden
  81538. * 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)
  81539. */
  81540. _useMultiviewToSingleView: boolean;
  81541. /**
  81542. * @hidden
  81543. * 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)
  81544. */
  81545. _multiviewTexture: Nullable<RenderTargetTexture>;
  81546. /**
  81547. * @hidden
  81548. * ensures the multiview texture of the camera exists and has the specified width/height
  81549. * @param width height to set on the multiview texture
  81550. * @param height width to set on the multiview texture
  81551. */
  81552. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  81553. }
  81554. interface Scene {
  81555. /** @hidden */
  81556. _transformMatrixR: Matrix;
  81557. /** @hidden */
  81558. _multiviewSceneUbo: Nullable<UniformBuffer>;
  81559. /** @hidden */
  81560. _createMultiviewUbo(): void;
  81561. /** @hidden */
  81562. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  81563. /** @hidden */
  81564. _renderMultiviewToSingleView(camera: Camera): void;
  81565. }
  81566. }
  81567. declare module BABYLON {
  81568. /**
  81569. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  81570. * This will not be used for webXR as it supports displaying texture arrays directly
  81571. */
  81572. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  81573. /**
  81574. * Initializes a VRMultiviewToSingleview
  81575. * @param name name of the post process
  81576. * @param camera camera to be applied to
  81577. * @param scaleFactor scaling factor to the size of the output texture
  81578. */
  81579. constructor(name: string, camera: Camera, scaleFactor: number);
  81580. }
  81581. }
  81582. declare module BABYLON {
  81583. interface Engine {
  81584. /** @hidden */
  81585. _vrDisplay: any;
  81586. /** @hidden */
  81587. _vrSupported: boolean;
  81588. /** @hidden */
  81589. _oldSize: Size;
  81590. /** @hidden */
  81591. _oldHardwareScaleFactor: number;
  81592. /** @hidden */
  81593. _vrExclusivePointerMode: boolean;
  81594. /** @hidden */
  81595. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  81596. /** @hidden */
  81597. _onVRDisplayPointerRestricted: () => void;
  81598. /** @hidden */
  81599. _onVRDisplayPointerUnrestricted: () => void;
  81600. /** @hidden */
  81601. _onVrDisplayConnect: Nullable<(display: any) => void>;
  81602. /** @hidden */
  81603. _onVrDisplayDisconnect: Nullable<() => void>;
  81604. /** @hidden */
  81605. _onVrDisplayPresentChange: Nullable<() => void>;
  81606. /**
  81607. * Observable signaled when VR display mode changes
  81608. */
  81609. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  81610. /**
  81611. * Observable signaled when VR request present is complete
  81612. */
  81613. onVRRequestPresentComplete: Observable<boolean>;
  81614. /**
  81615. * Observable signaled when VR request present starts
  81616. */
  81617. onVRRequestPresentStart: Observable<Engine>;
  81618. /**
  81619. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  81620. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  81621. */
  81622. isInVRExclusivePointerMode: boolean;
  81623. /**
  81624. * Gets a boolean indicating if a webVR device was detected
  81625. * @returns true if a webVR device was detected
  81626. */
  81627. isVRDevicePresent(): boolean;
  81628. /**
  81629. * Gets the current webVR device
  81630. * @returns the current webVR device (or null)
  81631. */
  81632. getVRDevice(): any;
  81633. /**
  81634. * Initializes a webVR display and starts listening to display change events
  81635. * The onVRDisplayChangedObservable will be notified upon these changes
  81636. * @returns A promise containing a VRDisplay and if vr is supported
  81637. */
  81638. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  81639. /** @hidden */
  81640. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  81641. /**
  81642. * Call this function to switch to webVR mode
  81643. * Will do nothing if webVR is not supported or if there is no webVR device
  81644. * @see http://doc.babylonjs.com/how_to/webvr_camera
  81645. */
  81646. enableVR(): void;
  81647. /** @hidden */
  81648. _onVRFullScreenTriggered(): void;
  81649. }
  81650. }
  81651. declare module BABYLON {
  81652. /**
  81653. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  81654. * IMPORTANT!! The data is right-hand data.
  81655. * @export
  81656. * @interface DevicePose
  81657. */
  81658. export interface DevicePose {
  81659. /**
  81660. * The position of the device, values in array are [x,y,z].
  81661. */
  81662. readonly position: Nullable<Float32Array>;
  81663. /**
  81664. * The linearVelocity of the device, values in array are [x,y,z].
  81665. */
  81666. readonly linearVelocity: Nullable<Float32Array>;
  81667. /**
  81668. * The linearAcceleration of the device, values in array are [x,y,z].
  81669. */
  81670. readonly linearAcceleration: Nullable<Float32Array>;
  81671. /**
  81672. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  81673. */
  81674. readonly orientation: Nullable<Float32Array>;
  81675. /**
  81676. * The angularVelocity of the device, values in array are [x,y,z].
  81677. */
  81678. readonly angularVelocity: Nullable<Float32Array>;
  81679. /**
  81680. * The angularAcceleration of the device, values in array are [x,y,z].
  81681. */
  81682. readonly angularAcceleration: Nullable<Float32Array>;
  81683. }
  81684. /**
  81685. * Interface representing a pose controlled object in Babylon.
  81686. * A pose controlled object has both regular pose values as well as pose values
  81687. * from an external device such as a VR head mounted display
  81688. */
  81689. export interface PoseControlled {
  81690. /**
  81691. * The position of the object in babylon space.
  81692. */
  81693. position: Vector3;
  81694. /**
  81695. * The rotation quaternion of the object in babylon space.
  81696. */
  81697. rotationQuaternion: Quaternion;
  81698. /**
  81699. * The position of the device in babylon space.
  81700. */
  81701. devicePosition?: Vector3;
  81702. /**
  81703. * The rotation quaternion of the device in babylon space.
  81704. */
  81705. deviceRotationQuaternion: Quaternion;
  81706. /**
  81707. * The raw pose coming from the device.
  81708. */
  81709. rawPose: Nullable<DevicePose>;
  81710. /**
  81711. * The scale of the device to be used when translating from device space to babylon space.
  81712. */
  81713. deviceScaleFactor: number;
  81714. /**
  81715. * Updates the poseControlled values based on the input device pose.
  81716. * @param poseData the pose data to update the object with
  81717. */
  81718. updateFromDevice(poseData: DevicePose): void;
  81719. }
  81720. /**
  81721. * Set of options to customize the webVRCamera
  81722. */
  81723. export interface WebVROptions {
  81724. /**
  81725. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  81726. */
  81727. trackPosition?: boolean;
  81728. /**
  81729. * Sets the scale of the vrDevice in babylon space. (default: 1)
  81730. */
  81731. positionScale?: number;
  81732. /**
  81733. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  81734. */
  81735. displayName?: string;
  81736. /**
  81737. * Should the native controller meshes be initialized. (default: true)
  81738. */
  81739. controllerMeshes?: boolean;
  81740. /**
  81741. * Creating a default HemiLight only on controllers. (default: true)
  81742. */
  81743. defaultLightingOnControllers?: boolean;
  81744. /**
  81745. * If you don't want to use the default VR button of the helper. (default: false)
  81746. */
  81747. useCustomVRButton?: boolean;
  81748. /**
  81749. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  81750. */
  81751. customVRButton?: HTMLButtonElement;
  81752. /**
  81753. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  81754. */
  81755. rayLength?: number;
  81756. /**
  81757. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  81758. */
  81759. defaultHeight?: number;
  81760. /**
  81761. * If multiview should be used if availible (default: false)
  81762. */
  81763. useMultiview?: boolean;
  81764. }
  81765. /**
  81766. * This represents a WebVR camera.
  81767. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  81768. * @example http://doc.babylonjs.com/how_to/webvr_camera
  81769. */
  81770. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  81771. private webVROptions;
  81772. /**
  81773. * @hidden
  81774. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  81775. */
  81776. _vrDevice: any;
  81777. /**
  81778. * The rawPose of the vrDevice.
  81779. */
  81780. rawPose: Nullable<DevicePose>;
  81781. private _onVREnabled;
  81782. private _specsVersion;
  81783. private _attached;
  81784. private _frameData;
  81785. protected _descendants: Array<Node>;
  81786. private _deviceRoomPosition;
  81787. /** @hidden */
  81788. _deviceRoomRotationQuaternion: Quaternion;
  81789. private _standingMatrix;
  81790. /**
  81791. * Represents device position in babylon space.
  81792. */
  81793. devicePosition: Vector3;
  81794. /**
  81795. * Represents device rotation in babylon space.
  81796. */
  81797. deviceRotationQuaternion: Quaternion;
  81798. /**
  81799. * The scale of the device to be used when translating from device space to babylon space.
  81800. */
  81801. deviceScaleFactor: number;
  81802. private _deviceToWorld;
  81803. private _worldToDevice;
  81804. /**
  81805. * References to the webVR controllers for the vrDevice.
  81806. */
  81807. controllers: Array<WebVRController>;
  81808. /**
  81809. * Emits an event when a controller is attached.
  81810. */
  81811. onControllersAttachedObservable: Observable<WebVRController[]>;
  81812. /**
  81813. * Emits an event when a controller's mesh has been loaded;
  81814. */
  81815. onControllerMeshLoadedObservable: Observable<WebVRController>;
  81816. /**
  81817. * Emits an event when the HMD's pose has been updated.
  81818. */
  81819. onPoseUpdatedFromDeviceObservable: Observable<any>;
  81820. private _poseSet;
  81821. /**
  81822. * If the rig cameras be used as parent instead of this camera.
  81823. */
  81824. rigParenting: boolean;
  81825. private _lightOnControllers;
  81826. private _defaultHeight?;
  81827. /**
  81828. * Instantiates a WebVRFreeCamera.
  81829. * @param name The name of the WebVRFreeCamera
  81830. * @param position The starting anchor position for the camera
  81831. * @param scene The scene the camera belongs to
  81832. * @param webVROptions a set of customizable options for the webVRCamera
  81833. */
  81834. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  81835. /**
  81836. * Gets the device distance from the ground in meters.
  81837. * @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.
  81838. */
  81839. deviceDistanceToRoomGround(): number;
  81840. /**
  81841. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  81842. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  81843. */
  81844. useStandingMatrix(callback?: (bool: boolean) => void): void;
  81845. /**
  81846. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  81847. * @returns A promise with a boolean set to if the standing matrix is supported.
  81848. */
  81849. useStandingMatrixAsync(): Promise<boolean>;
  81850. /**
  81851. * Disposes the camera
  81852. */
  81853. dispose(): void;
  81854. /**
  81855. * Gets a vrController by name.
  81856. * @param name The name of the controller to retreive
  81857. * @returns the controller matching the name specified or null if not found
  81858. */
  81859. getControllerByName(name: string): Nullable<WebVRController>;
  81860. private _leftController;
  81861. /**
  81862. * The controller corresponding to the users left hand.
  81863. */
  81864. readonly leftController: Nullable<WebVRController>;
  81865. private _rightController;
  81866. /**
  81867. * The controller corresponding to the users right hand.
  81868. */
  81869. readonly rightController: Nullable<WebVRController>;
  81870. /**
  81871. * Casts a ray forward from the vrCamera's gaze.
  81872. * @param length Length of the ray (default: 100)
  81873. * @returns the ray corresponding to the gaze
  81874. */
  81875. getForwardRay(length?: number): Ray;
  81876. /**
  81877. * @hidden
  81878. * Updates the camera based on device's frame data
  81879. */
  81880. _checkInputs(): void;
  81881. /**
  81882. * Updates the poseControlled values based on the input device pose.
  81883. * @param poseData Pose coming from the device
  81884. */
  81885. updateFromDevice(poseData: DevicePose): void;
  81886. private _htmlElementAttached;
  81887. private _detachIfAttached;
  81888. /**
  81889. * WebVR's attach control will start broadcasting frames to the device.
  81890. * Note that in certain browsers (chrome for example) this function must be called
  81891. * within a user-interaction callback. Example:
  81892. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  81893. *
  81894. * @param element html element to attach the vrDevice to
  81895. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  81896. */
  81897. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  81898. /**
  81899. * Detaches the camera from the html element and disables VR
  81900. *
  81901. * @param element html element to detach from
  81902. */
  81903. detachControl(element: HTMLElement): void;
  81904. /**
  81905. * @returns the name of this class
  81906. */
  81907. getClassName(): string;
  81908. /**
  81909. * Calls resetPose on the vrDisplay
  81910. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  81911. */
  81912. resetToCurrentRotation(): void;
  81913. /**
  81914. * @hidden
  81915. * Updates the rig cameras (left and right eye)
  81916. */
  81917. _updateRigCameras(): void;
  81918. private _workingVector;
  81919. private _oneVector;
  81920. private _workingMatrix;
  81921. private updateCacheCalled;
  81922. private _correctPositionIfNotTrackPosition;
  81923. /**
  81924. * @hidden
  81925. * Updates the cached values of the camera
  81926. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  81927. */
  81928. _updateCache(ignoreParentClass?: boolean): void;
  81929. /**
  81930. * @hidden
  81931. * Get current device position in babylon world
  81932. */
  81933. _computeDevicePosition(): void;
  81934. /**
  81935. * Updates the current device position and rotation in the babylon world
  81936. */
  81937. update(): void;
  81938. /**
  81939. * @hidden
  81940. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  81941. * @returns an identity matrix
  81942. */
  81943. _getViewMatrix(): Matrix;
  81944. private _tmpMatrix;
  81945. /**
  81946. * This function is called by the two RIG cameras.
  81947. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  81948. * @hidden
  81949. */
  81950. _getWebVRViewMatrix(): Matrix;
  81951. /** @hidden */
  81952. _getWebVRProjectionMatrix(): Matrix;
  81953. private _onGamepadConnectedObserver;
  81954. private _onGamepadDisconnectedObserver;
  81955. private _updateCacheWhenTrackingDisabledObserver;
  81956. /**
  81957. * Initializes the controllers and their meshes
  81958. */
  81959. initControllers(): void;
  81960. }
  81961. }
  81962. declare module BABYLON {
  81963. /**
  81964. * Size options for a post process
  81965. */
  81966. export type PostProcessOptions = {
  81967. width: number;
  81968. height: number;
  81969. };
  81970. /**
  81971. * PostProcess can be used to apply a shader to a texture after it has been rendered
  81972. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  81973. */
  81974. export class PostProcess {
  81975. /** Name of the PostProcess. */
  81976. name: string;
  81977. /**
  81978. * Gets or sets the unique id of the post process
  81979. */
  81980. uniqueId: number;
  81981. /**
  81982. * Width of the texture to apply the post process on
  81983. */
  81984. width: number;
  81985. /**
  81986. * Height of the texture to apply the post process on
  81987. */
  81988. height: number;
  81989. /**
  81990. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  81991. * @hidden
  81992. */
  81993. _outputTexture: Nullable<InternalTexture>;
  81994. /**
  81995. * Sampling mode used by the shader
  81996. * See https://doc.babylonjs.com/classes/3.1/texture
  81997. */
  81998. renderTargetSamplingMode: number;
  81999. /**
  82000. * Clear color to use when screen clearing
  82001. */
  82002. clearColor: Color4;
  82003. /**
  82004. * If the buffer needs to be cleared before applying the post process. (default: true)
  82005. * Should be set to false if shader will overwrite all previous pixels.
  82006. */
  82007. autoClear: boolean;
  82008. /**
  82009. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  82010. */
  82011. alphaMode: number;
  82012. /**
  82013. * Sets the setAlphaBlendConstants of the babylon engine
  82014. */
  82015. alphaConstants: Color4;
  82016. /**
  82017. * Animations to be used for the post processing
  82018. */
  82019. animations: Animation[];
  82020. /**
  82021. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  82022. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  82023. */
  82024. enablePixelPerfectMode: boolean;
  82025. /**
  82026. * Force the postprocess to be applied without taking in account viewport
  82027. */
  82028. forceFullscreenViewport: boolean;
  82029. /**
  82030. * List of inspectable custom properties (used by the Inspector)
  82031. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  82032. */
  82033. inspectableCustomProperties: IInspectable[];
  82034. /**
  82035. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  82036. *
  82037. * | Value | Type | Description |
  82038. * | ----- | ----------------------------------- | ----------- |
  82039. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  82040. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  82041. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  82042. *
  82043. */
  82044. scaleMode: number;
  82045. /**
  82046. * Force textures to be a power of two (default: false)
  82047. */
  82048. alwaysForcePOT: boolean;
  82049. private _samples;
  82050. /**
  82051. * Number of sample textures (default: 1)
  82052. */
  82053. samples: number;
  82054. /**
  82055. * Modify the scale of the post process to be the same as the viewport (default: false)
  82056. */
  82057. adaptScaleToCurrentViewport: boolean;
  82058. private _camera;
  82059. private _scene;
  82060. private _engine;
  82061. private _options;
  82062. private _reusable;
  82063. private _textureType;
  82064. /**
  82065. * Smart array of input and output textures for the post process.
  82066. * @hidden
  82067. */
  82068. _textures: SmartArray<InternalTexture>;
  82069. /**
  82070. * The index in _textures that corresponds to the output texture.
  82071. * @hidden
  82072. */
  82073. _currentRenderTextureInd: number;
  82074. private _effect;
  82075. private _samplers;
  82076. private _fragmentUrl;
  82077. private _vertexUrl;
  82078. private _parameters;
  82079. private _scaleRatio;
  82080. protected _indexParameters: any;
  82081. private _shareOutputWithPostProcess;
  82082. private _texelSize;
  82083. private _forcedOutputTexture;
  82084. /**
  82085. * Returns the fragment url or shader name used in the post process.
  82086. * @returns the fragment url or name in the shader store.
  82087. */
  82088. getEffectName(): string;
  82089. /**
  82090. * An event triggered when the postprocess is activated.
  82091. */
  82092. onActivateObservable: Observable<Camera>;
  82093. private _onActivateObserver;
  82094. /**
  82095. * A function that is added to the onActivateObservable
  82096. */
  82097. onActivate: Nullable<(camera: Camera) => void>;
  82098. /**
  82099. * An event triggered when the postprocess changes its size.
  82100. */
  82101. onSizeChangedObservable: Observable<PostProcess>;
  82102. private _onSizeChangedObserver;
  82103. /**
  82104. * A function that is added to the onSizeChangedObservable
  82105. */
  82106. onSizeChanged: (postProcess: PostProcess) => void;
  82107. /**
  82108. * An event triggered when the postprocess applies its effect.
  82109. */
  82110. onApplyObservable: Observable<Effect>;
  82111. private _onApplyObserver;
  82112. /**
  82113. * A function that is added to the onApplyObservable
  82114. */
  82115. onApply: (effect: Effect) => void;
  82116. /**
  82117. * An event triggered before rendering the postprocess
  82118. */
  82119. onBeforeRenderObservable: Observable<Effect>;
  82120. private _onBeforeRenderObserver;
  82121. /**
  82122. * A function that is added to the onBeforeRenderObservable
  82123. */
  82124. onBeforeRender: (effect: Effect) => void;
  82125. /**
  82126. * An event triggered after rendering the postprocess
  82127. */
  82128. onAfterRenderObservable: Observable<Effect>;
  82129. private _onAfterRenderObserver;
  82130. /**
  82131. * A function that is added to the onAfterRenderObservable
  82132. */
  82133. onAfterRender: (efect: Effect) => void;
  82134. /**
  82135. * 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
  82136. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  82137. */
  82138. inputTexture: InternalTexture;
  82139. /**
  82140. * Gets the camera which post process is applied to.
  82141. * @returns The camera the post process is applied to.
  82142. */
  82143. getCamera(): Camera;
  82144. /**
  82145. * Gets the texel size of the postprocess.
  82146. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  82147. */
  82148. readonly texelSize: Vector2;
  82149. /**
  82150. * Creates a new instance PostProcess
  82151. * @param name The name of the PostProcess.
  82152. * @param fragmentUrl The url of the fragment shader to be used.
  82153. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  82154. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  82155. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  82156. * @param camera The camera to apply the render pass to.
  82157. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  82158. * @param engine The engine which the post process will be applied. (default: current engine)
  82159. * @param reusable If the post process can be reused on the same frame. (default: false)
  82160. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  82161. * @param textureType Type of textures used when performing the post process. (default: 0)
  82162. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  82163. * @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
  82164. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  82165. */
  82166. constructor(
  82167. /** Name of the PostProcess. */
  82168. 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);
  82169. /**
  82170. * Gets a string idenfifying the name of the class
  82171. * @returns "PostProcess" string
  82172. */
  82173. getClassName(): string;
  82174. /**
  82175. * Gets the engine which this post process belongs to.
  82176. * @returns The engine the post process was enabled with.
  82177. */
  82178. getEngine(): Engine;
  82179. /**
  82180. * The effect that is created when initializing the post process.
  82181. * @returns The created effect corresponding the the postprocess.
  82182. */
  82183. getEffect(): Effect;
  82184. /**
  82185. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  82186. * @param postProcess The post process to share the output with.
  82187. * @returns This post process.
  82188. */
  82189. shareOutputWith(postProcess: PostProcess): PostProcess;
  82190. /**
  82191. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  82192. * This should be called if the post process that shares output with this post process is disabled/disposed.
  82193. */
  82194. useOwnOutput(): void;
  82195. /**
  82196. * Updates the effect with the current post process compile time values and recompiles the shader.
  82197. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  82198. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  82199. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  82200. * @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
  82201. * @param onCompiled Called when the shader has been compiled.
  82202. * @param onError Called if there is an error when compiling a shader.
  82203. */
  82204. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  82205. /**
  82206. * The post process is reusable if it can be used multiple times within one frame.
  82207. * @returns If the post process is reusable
  82208. */
  82209. isReusable(): boolean;
  82210. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  82211. markTextureDirty(): void;
  82212. /**
  82213. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  82214. * 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.
  82215. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  82216. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  82217. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  82218. * @returns The target texture that was bound to be written to.
  82219. */
  82220. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  82221. /**
  82222. * If the post process is supported.
  82223. */
  82224. readonly isSupported: boolean;
  82225. /**
  82226. * The aspect ratio of the output texture.
  82227. */
  82228. readonly aspectRatio: number;
  82229. /**
  82230. * Get a value indicating if the post-process is ready to be used
  82231. * @returns true if the post-process is ready (shader is compiled)
  82232. */
  82233. isReady(): boolean;
  82234. /**
  82235. * Binds all textures and uniforms to the shader, this will be run on every pass.
  82236. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  82237. */
  82238. apply(): Nullable<Effect>;
  82239. private _disposeTextures;
  82240. /**
  82241. * Disposes the post process.
  82242. * @param camera The camera to dispose the post process on.
  82243. */
  82244. dispose(camera?: Camera): void;
  82245. }
  82246. }
  82247. declare module BABYLON {
  82248. /** @hidden */
  82249. export var kernelBlurVaryingDeclaration: {
  82250. name: string;
  82251. shader: string;
  82252. };
  82253. }
  82254. declare module BABYLON {
  82255. /** @hidden */
  82256. export var kernelBlurFragment: {
  82257. name: string;
  82258. shader: string;
  82259. };
  82260. }
  82261. declare module BABYLON {
  82262. /** @hidden */
  82263. export var kernelBlurFragment2: {
  82264. name: string;
  82265. shader: string;
  82266. };
  82267. }
  82268. declare module BABYLON {
  82269. /** @hidden */
  82270. export var kernelBlurPixelShader: {
  82271. name: string;
  82272. shader: string;
  82273. };
  82274. }
  82275. declare module BABYLON {
  82276. /** @hidden */
  82277. export var kernelBlurVertex: {
  82278. name: string;
  82279. shader: string;
  82280. };
  82281. }
  82282. declare module BABYLON {
  82283. /** @hidden */
  82284. export var kernelBlurVertexShader: {
  82285. name: string;
  82286. shader: string;
  82287. };
  82288. }
  82289. declare module BABYLON {
  82290. /**
  82291. * The Blur Post Process which blurs an image based on a kernel and direction.
  82292. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  82293. */
  82294. export class BlurPostProcess extends PostProcess {
  82295. /** The direction in which to blur the image. */
  82296. direction: Vector2;
  82297. private blockCompilation;
  82298. protected _kernel: number;
  82299. protected _idealKernel: number;
  82300. protected _packedFloat: boolean;
  82301. private _staticDefines;
  82302. /**
  82303. * Sets the length in pixels of the blur sample region
  82304. */
  82305. /**
  82306. * Gets the length in pixels of the blur sample region
  82307. */
  82308. kernel: number;
  82309. /**
  82310. * Sets wether or not the blur needs to unpack/repack floats
  82311. */
  82312. /**
  82313. * Gets wether or not the blur is unpacking/repacking floats
  82314. */
  82315. packedFloat: boolean;
  82316. /**
  82317. * Creates a new instance BlurPostProcess
  82318. * @param name The name of the effect.
  82319. * @param direction The direction in which to blur the image.
  82320. * @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.
  82321. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  82322. * @param camera The camera to apply the render pass to.
  82323. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  82324. * @param engine The engine which the post process will be applied. (default: current engine)
  82325. * @param reusable If the post process can be reused on the same frame. (default: false)
  82326. * @param textureType Type of textures used when performing the post process. (default: 0)
  82327. * @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)
  82328. */
  82329. constructor(name: string,
  82330. /** The direction in which to blur the image. */
  82331. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  82332. /**
  82333. * Updates the effect with the current post process compile time values and recompiles the shader.
  82334. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  82335. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  82336. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  82337. * @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
  82338. * @param onCompiled Called when the shader has been compiled.
  82339. * @param onError Called if there is an error when compiling a shader.
  82340. */
  82341. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  82342. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  82343. /**
  82344. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  82345. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  82346. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  82347. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  82348. * The gaps between physical kernels are compensated for in the weighting of the samples
  82349. * @param idealKernel Ideal blur kernel.
  82350. * @return Nearest best kernel.
  82351. */
  82352. protected _nearestBestKernel(idealKernel: number): number;
  82353. /**
  82354. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  82355. * @param x The point on the Gaussian distribution to sample.
  82356. * @return the value of the Gaussian function at x.
  82357. */
  82358. protected _gaussianWeight(x: number): number;
  82359. /**
  82360. * Generates a string that can be used as a floating point number in GLSL.
  82361. * @param x Value to print.
  82362. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  82363. * @return GLSL float string.
  82364. */
  82365. protected _glslFloat(x: number, decimalFigures?: number): string;
  82366. }
  82367. }
  82368. declare module BABYLON {
  82369. /**
  82370. * Mirror texture can be used to simulate the view from a mirror in a scene.
  82371. * It will dynamically be rendered every frame to adapt to the camera point of view.
  82372. * You can then easily use it as a reflectionTexture on a flat surface.
  82373. * In case the surface is not a plane, please consider relying on reflection probes.
  82374. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  82375. */
  82376. export class MirrorTexture extends RenderTargetTexture {
  82377. private scene;
  82378. /**
  82379. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  82380. * 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.
  82381. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  82382. */
  82383. mirrorPlane: Plane;
  82384. /**
  82385. * Define the blur ratio used to blur the reflection if needed.
  82386. */
  82387. blurRatio: number;
  82388. /**
  82389. * Define the adaptive blur kernel used to blur the reflection if needed.
  82390. * This will autocompute the closest best match for the `blurKernel`
  82391. */
  82392. adaptiveBlurKernel: number;
  82393. /**
  82394. * Define the blur kernel used to blur the reflection if needed.
  82395. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  82396. */
  82397. blurKernel: number;
  82398. /**
  82399. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  82400. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  82401. */
  82402. blurKernelX: number;
  82403. /**
  82404. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  82405. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  82406. */
  82407. blurKernelY: number;
  82408. private _autoComputeBlurKernel;
  82409. protected _onRatioRescale(): void;
  82410. private _updateGammaSpace;
  82411. private _imageProcessingConfigChangeObserver;
  82412. private _transformMatrix;
  82413. private _mirrorMatrix;
  82414. private _savedViewMatrix;
  82415. private _blurX;
  82416. private _blurY;
  82417. private _adaptiveBlurKernel;
  82418. private _blurKernelX;
  82419. private _blurKernelY;
  82420. private _blurRatio;
  82421. /**
  82422. * Instantiates a Mirror Texture.
  82423. * Mirror texture can be used to simulate the view from a mirror in a scene.
  82424. * It will dynamically be rendered every frame to adapt to the camera point of view.
  82425. * You can then easily use it as a reflectionTexture on a flat surface.
  82426. * In case the surface is not a plane, please consider relying on reflection probes.
  82427. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  82428. * @param name
  82429. * @param size
  82430. * @param scene
  82431. * @param generateMipMaps
  82432. * @param type
  82433. * @param samplingMode
  82434. * @param generateDepthBuffer
  82435. */
  82436. constructor(name: string, size: number | {
  82437. width: number;
  82438. height: number;
  82439. } | {
  82440. ratio: number;
  82441. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  82442. private _preparePostProcesses;
  82443. /**
  82444. * Clone the mirror texture.
  82445. * @returns the cloned texture
  82446. */
  82447. clone(): MirrorTexture;
  82448. /**
  82449. * Serialize the texture to a JSON representation you could use in Parse later on
  82450. * @returns the serialized JSON representation
  82451. */
  82452. serialize(): any;
  82453. /**
  82454. * Dispose the texture and release its associated resources.
  82455. */
  82456. dispose(): void;
  82457. }
  82458. }
  82459. declare module BABYLON {
  82460. /**
  82461. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  82462. * @see http://doc.babylonjs.com/babylon101/materials#texture
  82463. */
  82464. export class Texture extends BaseTexture {
  82465. /**
  82466. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  82467. */
  82468. static SerializeBuffers: boolean;
  82469. /** @hidden */
  82470. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  82471. /** @hidden */
  82472. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  82473. /** @hidden */
  82474. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  82475. /** nearest is mag = nearest and min = nearest and mip = linear */
  82476. static readonly NEAREST_SAMPLINGMODE: number;
  82477. /** nearest is mag = nearest and min = nearest and mip = linear */
  82478. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  82479. /** Bilinear is mag = linear and min = linear and mip = nearest */
  82480. static readonly BILINEAR_SAMPLINGMODE: number;
  82481. /** Bilinear is mag = linear and min = linear and mip = nearest */
  82482. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  82483. /** Trilinear is mag = linear and min = linear and mip = linear */
  82484. static readonly TRILINEAR_SAMPLINGMODE: number;
  82485. /** Trilinear is mag = linear and min = linear and mip = linear */
  82486. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  82487. /** mag = nearest and min = nearest and mip = nearest */
  82488. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  82489. /** mag = nearest and min = linear and mip = nearest */
  82490. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  82491. /** mag = nearest and min = linear and mip = linear */
  82492. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  82493. /** mag = nearest and min = linear and mip = none */
  82494. static readonly NEAREST_LINEAR: number;
  82495. /** mag = nearest and min = nearest and mip = none */
  82496. static readonly NEAREST_NEAREST: number;
  82497. /** mag = linear and min = nearest and mip = nearest */
  82498. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  82499. /** mag = linear and min = nearest and mip = linear */
  82500. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  82501. /** mag = linear and min = linear and mip = none */
  82502. static readonly LINEAR_LINEAR: number;
  82503. /** mag = linear and min = nearest and mip = none */
  82504. static readonly LINEAR_NEAREST: number;
  82505. /** Explicit coordinates mode */
  82506. static readonly EXPLICIT_MODE: number;
  82507. /** Spherical coordinates mode */
  82508. static readonly SPHERICAL_MODE: number;
  82509. /** Planar coordinates mode */
  82510. static readonly PLANAR_MODE: number;
  82511. /** Cubic coordinates mode */
  82512. static readonly CUBIC_MODE: number;
  82513. /** Projection coordinates mode */
  82514. static readonly PROJECTION_MODE: number;
  82515. /** Inverse Cubic coordinates mode */
  82516. static readonly SKYBOX_MODE: number;
  82517. /** Inverse Cubic coordinates mode */
  82518. static readonly INVCUBIC_MODE: number;
  82519. /** Equirectangular coordinates mode */
  82520. static readonly EQUIRECTANGULAR_MODE: number;
  82521. /** Equirectangular Fixed coordinates mode */
  82522. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  82523. /** Equirectangular Fixed Mirrored coordinates mode */
  82524. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  82525. /** Texture is not repeating outside of 0..1 UVs */
  82526. static readonly CLAMP_ADDRESSMODE: number;
  82527. /** Texture is repeating outside of 0..1 UVs */
  82528. static readonly WRAP_ADDRESSMODE: number;
  82529. /** Texture is repeating and mirrored */
  82530. static readonly MIRROR_ADDRESSMODE: number;
  82531. /**
  82532. * 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
  82533. */
  82534. static UseSerializedUrlIfAny: boolean;
  82535. /**
  82536. * Define the url of the texture.
  82537. */
  82538. url: Nullable<string>;
  82539. /**
  82540. * Define an offset on the texture to offset the u coordinates of the UVs
  82541. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  82542. */
  82543. uOffset: number;
  82544. /**
  82545. * Define an offset on the texture to offset the v coordinates of the UVs
  82546. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  82547. */
  82548. vOffset: number;
  82549. /**
  82550. * Define an offset on the texture to scale the u coordinates of the UVs
  82551. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  82552. */
  82553. uScale: number;
  82554. /**
  82555. * Define an offset on the texture to scale the v coordinates of the UVs
  82556. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  82557. */
  82558. vScale: number;
  82559. /**
  82560. * Define an offset on the texture to rotate around the u coordinates of the UVs
  82561. * @see http://doc.babylonjs.com/how_to/more_materials
  82562. */
  82563. uAng: number;
  82564. /**
  82565. * Define an offset on the texture to rotate around the v coordinates of the UVs
  82566. * @see http://doc.babylonjs.com/how_to/more_materials
  82567. */
  82568. vAng: number;
  82569. /**
  82570. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  82571. * @see http://doc.babylonjs.com/how_to/more_materials
  82572. */
  82573. wAng: number;
  82574. /**
  82575. * Defines the center of rotation (U)
  82576. */
  82577. uRotationCenter: number;
  82578. /**
  82579. * Defines the center of rotation (V)
  82580. */
  82581. vRotationCenter: number;
  82582. /**
  82583. * Defines the center of rotation (W)
  82584. */
  82585. wRotationCenter: number;
  82586. /**
  82587. * Are mip maps generated for this texture or not.
  82588. */
  82589. readonly noMipmap: boolean;
  82590. /**
  82591. * List of inspectable custom properties (used by the Inspector)
  82592. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  82593. */
  82594. inspectableCustomProperties: Nullable<IInspectable[]>;
  82595. private _noMipmap;
  82596. /** @hidden */
  82597. _invertY: boolean;
  82598. private _rowGenerationMatrix;
  82599. private _cachedTextureMatrix;
  82600. private _projectionModeMatrix;
  82601. private _t0;
  82602. private _t1;
  82603. private _t2;
  82604. private _cachedUOffset;
  82605. private _cachedVOffset;
  82606. private _cachedUScale;
  82607. private _cachedVScale;
  82608. private _cachedUAng;
  82609. private _cachedVAng;
  82610. private _cachedWAng;
  82611. private _cachedProjectionMatrixId;
  82612. private _cachedCoordinatesMode;
  82613. /** @hidden */
  82614. protected _initialSamplingMode: number;
  82615. /** @hidden */
  82616. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  82617. private _deleteBuffer;
  82618. protected _format: Nullable<number>;
  82619. private _delayedOnLoad;
  82620. private _delayedOnError;
  82621. /**
  82622. * Observable triggered once the texture has been loaded.
  82623. */
  82624. onLoadObservable: Observable<Texture>;
  82625. protected _isBlocking: boolean;
  82626. /**
  82627. * Is the texture preventing material to render while loading.
  82628. * If false, a default texture will be used instead of the loading one during the preparation step.
  82629. */
  82630. isBlocking: boolean;
  82631. /**
  82632. * Get the current sampling mode associated with the texture.
  82633. */
  82634. readonly samplingMode: number;
  82635. /**
  82636. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  82637. */
  82638. readonly invertY: boolean;
  82639. /**
  82640. * Instantiates a new texture.
  82641. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  82642. * @see http://doc.babylonjs.com/babylon101/materials#texture
  82643. * @param url define the url of the picture to load as a texture
  82644. * @param scene define the scene or engine the texture will belong to
  82645. * @param noMipmap define if the texture will require mip maps or not
  82646. * @param invertY define if the texture needs to be inverted on the y axis during loading
  82647. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  82648. * @param onLoad define a callback triggered when the texture has been loaded
  82649. * @param onError define a callback triggered when an error occurred during the loading session
  82650. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  82651. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  82652. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  82653. */
  82654. 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);
  82655. /**
  82656. * Update the url (and optional buffer) of this texture if url was null during construction.
  82657. * @param url the url of the texture
  82658. * @param buffer the buffer of the texture (defaults to null)
  82659. * @param onLoad callback called when the texture is loaded (defaults to null)
  82660. */
  82661. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  82662. /**
  82663. * Finish the loading sequence of a texture flagged as delayed load.
  82664. * @hidden
  82665. */
  82666. delayLoad(): void;
  82667. private _prepareRowForTextureGeneration;
  82668. /**
  82669. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  82670. * @returns the transform matrix of the texture.
  82671. */
  82672. getTextureMatrix(): Matrix;
  82673. /**
  82674. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  82675. * @returns The reflection texture transform
  82676. */
  82677. getReflectionTextureMatrix(): Matrix;
  82678. /**
  82679. * Clones the texture.
  82680. * @returns the cloned texture
  82681. */
  82682. clone(): Texture;
  82683. /**
  82684. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  82685. * @returns The JSON representation of the texture
  82686. */
  82687. serialize(): any;
  82688. /**
  82689. * Get the current class name of the texture useful for serialization or dynamic coding.
  82690. * @returns "Texture"
  82691. */
  82692. getClassName(): string;
  82693. /**
  82694. * Dispose the texture and release its associated resources.
  82695. */
  82696. dispose(): void;
  82697. /**
  82698. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  82699. * @param parsedTexture Define the JSON representation of the texture
  82700. * @param scene Define the scene the parsed texture should be instantiated in
  82701. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  82702. * @returns The parsed texture if successful
  82703. */
  82704. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  82705. /**
  82706. * Creates a texture from its base 64 representation.
  82707. * @param data Define the base64 payload without the data: prefix
  82708. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  82709. * @param scene Define the scene the texture should belong to
  82710. * @param noMipmap Forces the texture to not create mip map information if true
  82711. * @param invertY define if the texture needs to be inverted on the y axis during loading
  82712. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  82713. * @param onLoad define a callback triggered when the texture has been loaded
  82714. * @param onError define a callback triggered when an error occurred during the loading session
  82715. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  82716. * @returns the created texture
  82717. */
  82718. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  82719. /**
  82720. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  82721. * @param data Define the base64 payload without the data: prefix
  82722. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  82723. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  82724. * @param scene Define the scene the texture should belong to
  82725. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  82726. * @param noMipmap Forces the texture to not create mip map information if true
  82727. * @param invertY define if the texture needs to be inverted on the y axis during loading
  82728. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  82729. * @param onLoad define a callback triggered when the texture has been loaded
  82730. * @param onError define a callback triggered when an error occurred during the loading session
  82731. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  82732. * @returns the created texture
  82733. */
  82734. 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;
  82735. }
  82736. }
  82737. declare module BABYLON {
  82738. /**
  82739. * PostProcessManager is used to manage one or more post processes or post process pipelines
  82740. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  82741. */
  82742. export class PostProcessManager {
  82743. private _scene;
  82744. private _indexBuffer;
  82745. private _vertexBuffers;
  82746. /**
  82747. * Creates a new instance PostProcess
  82748. * @param scene The scene that the post process is associated with.
  82749. */
  82750. constructor(scene: Scene);
  82751. private _prepareBuffers;
  82752. private _buildIndexBuffer;
  82753. /**
  82754. * Rebuilds the vertex buffers of the manager.
  82755. * @hidden
  82756. */
  82757. _rebuild(): void;
  82758. /**
  82759. * Prepares a frame to be run through a post process.
  82760. * @param sourceTexture The input texture to the post procesess. (default: null)
  82761. * @param postProcesses An array of post processes to be run. (default: null)
  82762. * @returns True if the post processes were able to be run.
  82763. * @hidden
  82764. */
  82765. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  82766. /**
  82767. * Manually render a set of post processes to a texture.
  82768. * @param postProcesses An array of post processes to be run.
  82769. * @param targetTexture The target texture to render to.
  82770. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  82771. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  82772. * @param lodLevel defines which lod of the texture to render to
  82773. */
  82774. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  82775. /**
  82776. * Finalize the result of the output of the postprocesses.
  82777. * @param doNotPresent If true the result will not be displayed to the screen.
  82778. * @param targetTexture The target texture to render to.
  82779. * @param faceIndex The index of the face to bind the target texture to.
  82780. * @param postProcesses The array of post processes to render.
  82781. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  82782. * @hidden
  82783. */
  82784. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  82785. /**
  82786. * Disposes of the post process manager.
  82787. */
  82788. dispose(): void;
  82789. }
  82790. }
  82791. declare module BABYLON {
  82792. /** Interface used by value gradients (color, factor, ...) */
  82793. export interface IValueGradient {
  82794. /**
  82795. * Gets or sets the gradient value (between 0 and 1)
  82796. */
  82797. gradient: number;
  82798. }
  82799. /** Class used to store color4 gradient */
  82800. export class ColorGradient implements IValueGradient {
  82801. /**
  82802. * Gets or sets the gradient value (between 0 and 1)
  82803. */
  82804. gradient: number;
  82805. /**
  82806. * Gets or sets first associated color
  82807. */
  82808. color1: Color4;
  82809. /**
  82810. * Gets or sets second associated color
  82811. */
  82812. color2?: Color4;
  82813. /**
  82814. * Will get a color picked randomly between color1 and color2.
  82815. * If color2 is undefined then color1 will be used
  82816. * @param result defines the target Color4 to store the result in
  82817. */
  82818. getColorToRef(result: Color4): void;
  82819. }
  82820. /** Class used to store color 3 gradient */
  82821. export class Color3Gradient implements IValueGradient {
  82822. /**
  82823. * Gets or sets the gradient value (between 0 and 1)
  82824. */
  82825. gradient: number;
  82826. /**
  82827. * Gets or sets the associated color
  82828. */
  82829. color: Color3;
  82830. }
  82831. /** Class used to store factor gradient */
  82832. export class FactorGradient implements IValueGradient {
  82833. /**
  82834. * Gets or sets the gradient value (between 0 and 1)
  82835. */
  82836. gradient: number;
  82837. /**
  82838. * Gets or sets first associated factor
  82839. */
  82840. factor1: number;
  82841. /**
  82842. * Gets or sets second associated factor
  82843. */
  82844. factor2?: number;
  82845. /**
  82846. * Will get a number picked randomly between factor1 and factor2.
  82847. * If factor2 is undefined then factor1 will be used
  82848. * @returns the picked number
  82849. */
  82850. getFactor(): number;
  82851. }
  82852. /**
  82853. * Helper used to simplify some generic gradient tasks
  82854. */
  82855. export class GradientHelper {
  82856. /**
  82857. * Gets the current gradient from an array of IValueGradient
  82858. * @param ratio defines the current ratio to get
  82859. * @param gradients defines the array of IValueGradient
  82860. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  82861. */
  82862. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  82863. }
  82864. }
  82865. declare module BABYLON {
  82866. interface ThinEngine {
  82867. /**
  82868. * Creates a dynamic texture
  82869. * @param width defines the width of the texture
  82870. * @param height defines the height of the texture
  82871. * @param generateMipMaps defines if the engine should generate the mip levels
  82872. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  82873. * @returns the dynamic texture inside an InternalTexture
  82874. */
  82875. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  82876. /**
  82877. * Update the content of a dynamic texture
  82878. * @param texture defines the texture to update
  82879. * @param canvas defines the canvas containing the source
  82880. * @param invertY defines if data must be stored with Y axis inverted
  82881. * @param premulAlpha defines if alpha is stored as premultiplied
  82882. * @param format defines the format of the data
  82883. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  82884. */
  82885. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  82886. }
  82887. }
  82888. declare module BABYLON {
  82889. /**
  82890. * A class extending Texture allowing drawing on a texture
  82891. * @see http://doc.babylonjs.com/how_to/dynamictexture
  82892. */
  82893. export class DynamicTexture extends Texture {
  82894. private _generateMipMaps;
  82895. private _canvas;
  82896. private _context;
  82897. private _engine;
  82898. /**
  82899. * Creates a DynamicTexture
  82900. * @param name defines the name of the texture
  82901. * @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
  82902. * @param scene defines the scene where you want the texture
  82903. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  82904. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  82905. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  82906. */
  82907. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  82908. /**
  82909. * Get the current class name of the texture useful for serialization or dynamic coding.
  82910. * @returns "DynamicTexture"
  82911. */
  82912. getClassName(): string;
  82913. /**
  82914. * Gets the current state of canRescale
  82915. */
  82916. readonly canRescale: boolean;
  82917. private _recreate;
  82918. /**
  82919. * Scales the texture
  82920. * @param ratio the scale factor to apply to both width and height
  82921. */
  82922. scale(ratio: number): void;
  82923. /**
  82924. * Resizes the texture
  82925. * @param width the new width
  82926. * @param height the new height
  82927. */
  82928. scaleTo(width: number, height: number): void;
  82929. /**
  82930. * Gets the context of the canvas used by the texture
  82931. * @returns the canvas context of the dynamic texture
  82932. */
  82933. getContext(): CanvasRenderingContext2D;
  82934. /**
  82935. * Clears the texture
  82936. */
  82937. clear(): void;
  82938. /**
  82939. * Updates the texture
  82940. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  82941. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  82942. */
  82943. update(invertY?: boolean, premulAlpha?: boolean): void;
  82944. /**
  82945. * Draws text onto the texture
  82946. * @param text defines the text to be drawn
  82947. * @param x defines the placement of the text from the left
  82948. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  82949. * @param font defines the font to be used with font-style, font-size, font-name
  82950. * @param color defines the color used for the text
  82951. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  82952. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  82953. * @param update defines whether texture is immediately update (default is true)
  82954. */
  82955. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  82956. /**
  82957. * Clones the texture
  82958. * @returns the clone of the texture.
  82959. */
  82960. clone(): DynamicTexture;
  82961. /**
  82962. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  82963. * @returns a serialized dynamic texture object
  82964. */
  82965. serialize(): any;
  82966. /** @hidden */
  82967. _rebuild(): void;
  82968. }
  82969. }
  82970. declare module BABYLON {
  82971. interface AbstractScene {
  82972. /**
  82973. * The list of procedural textures added to the scene
  82974. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  82975. */
  82976. proceduralTextures: Array<ProceduralTexture>;
  82977. }
  82978. /**
  82979. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  82980. * in a given scene.
  82981. */
  82982. export class ProceduralTextureSceneComponent implements ISceneComponent {
  82983. /**
  82984. * The component name helpfull to identify the component in the list of scene components.
  82985. */
  82986. readonly name: string;
  82987. /**
  82988. * The scene the component belongs to.
  82989. */
  82990. scene: Scene;
  82991. /**
  82992. * Creates a new instance of the component for the given scene
  82993. * @param scene Defines the scene to register the component in
  82994. */
  82995. constructor(scene: Scene);
  82996. /**
  82997. * Registers the component in a given scene
  82998. */
  82999. register(): void;
  83000. /**
  83001. * Rebuilds the elements related to this component in case of
  83002. * context lost for instance.
  83003. */
  83004. rebuild(): void;
  83005. /**
  83006. * Disposes the component and the associated ressources.
  83007. */
  83008. dispose(): void;
  83009. private _beforeClear;
  83010. }
  83011. }
  83012. declare module BABYLON {
  83013. interface ThinEngine {
  83014. /**
  83015. * Creates a new render target cube texture
  83016. * @param size defines the size of the texture
  83017. * @param options defines the options used to create the texture
  83018. * @returns a new render target cube texture stored in an InternalTexture
  83019. */
  83020. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  83021. }
  83022. }
  83023. declare module BABYLON {
  83024. /** @hidden */
  83025. export var proceduralVertexShader: {
  83026. name: string;
  83027. shader: string;
  83028. };
  83029. }
  83030. declare module BABYLON {
  83031. /**
  83032. * 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.
  83033. * This is the base class of any Procedural texture and contains most of the shareable code.
  83034. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  83035. */
  83036. export class ProceduralTexture extends Texture {
  83037. isCube: boolean;
  83038. /**
  83039. * Define if the texture is enabled or not (disabled texture will not render)
  83040. */
  83041. isEnabled: boolean;
  83042. /**
  83043. * Define if the texture must be cleared before rendering (default is true)
  83044. */
  83045. autoClear: boolean;
  83046. /**
  83047. * Callback called when the texture is generated
  83048. */
  83049. onGenerated: () => void;
  83050. /**
  83051. * Event raised when the texture is generated
  83052. */
  83053. onGeneratedObservable: Observable<ProceduralTexture>;
  83054. /** @hidden */
  83055. _generateMipMaps: boolean;
  83056. /** @hidden **/
  83057. _effect: Effect;
  83058. /** @hidden */
  83059. _textures: {
  83060. [key: string]: Texture;
  83061. };
  83062. private _size;
  83063. private _currentRefreshId;
  83064. private _refreshRate;
  83065. private _vertexBuffers;
  83066. private _indexBuffer;
  83067. private _uniforms;
  83068. private _samplers;
  83069. private _fragment;
  83070. private _floats;
  83071. private _ints;
  83072. private _floatsArrays;
  83073. private _colors3;
  83074. private _colors4;
  83075. private _vectors2;
  83076. private _vectors3;
  83077. private _matrices;
  83078. private _fallbackTexture;
  83079. private _fallbackTextureUsed;
  83080. private _engine;
  83081. private _cachedDefines;
  83082. private _contentUpdateId;
  83083. private _contentData;
  83084. /**
  83085. * Instantiates a new procedural texture.
  83086. * 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.
  83087. * This is the base class of any Procedural texture and contains most of the shareable code.
  83088. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  83089. * @param name Define the name of the texture
  83090. * @param size Define the size of the texture to create
  83091. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  83092. * @param scene Define the scene the texture belongs to
  83093. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  83094. * @param generateMipMaps Define if the texture should creates mip maps or not
  83095. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  83096. */
  83097. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  83098. /**
  83099. * The effect that is created when initializing the post process.
  83100. * @returns The created effect corresponding the the postprocess.
  83101. */
  83102. getEffect(): Effect;
  83103. /**
  83104. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  83105. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  83106. */
  83107. getContent(): Nullable<ArrayBufferView>;
  83108. private _createIndexBuffer;
  83109. /** @hidden */
  83110. _rebuild(): void;
  83111. /**
  83112. * Resets the texture in order to recreate its associated resources.
  83113. * This can be called in case of context loss
  83114. */
  83115. reset(): void;
  83116. protected _getDefines(): string;
  83117. /**
  83118. * Is the texture ready to be used ? (rendered at least once)
  83119. * @returns true if ready, otherwise, false.
  83120. */
  83121. isReady(): boolean;
  83122. /**
  83123. * Resets the refresh counter of the texture and start bak from scratch.
  83124. * Could be useful to regenerate the texture if it is setup to render only once.
  83125. */
  83126. resetRefreshCounter(): void;
  83127. /**
  83128. * Set the fragment shader to use in order to render the texture.
  83129. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  83130. */
  83131. setFragment(fragment: any): void;
  83132. /**
  83133. * Define the refresh rate of the texture or the rendering frequency.
  83134. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  83135. */
  83136. refreshRate: number;
  83137. /** @hidden */
  83138. _shouldRender(): boolean;
  83139. /**
  83140. * Get the size the texture is rendering at.
  83141. * @returns the size (texture is always squared)
  83142. */
  83143. getRenderSize(): number;
  83144. /**
  83145. * Resize the texture to new value.
  83146. * @param size Define the new size the texture should have
  83147. * @param generateMipMaps Define whether the new texture should create mip maps
  83148. */
  83149. resize(size: number, generateMipMaps: boolean): void;
  83150. private _checkUniform;
  83151. /**
  83152. * Set a texture in the shader program used to render.
  83153. * @param name Define the name of the uniform samplers as defined in the shader
  83154. * @param texture Define the texture to bind to this sampler
  83155. * @return the texture itself allowing "fluent" like uniform updates
  83156. */
  83157. setTexture(name: string, texture: Texture): ProceduralTexture;
  83158. /**
  83159. * Set a float in the shader.
  83160. * @param name Define the name of the uniform as defined in the shader
  83161. * @param value Define the value to give to the uniform
  83162. * @return the texture itself allowing "fluent" like uniform updates
  83163. */
  83164. setFloat(name: string, value: number): ProceduralTexture;
  83165. /**
  83166. * Set a int in the shader.
  83167. * @param name Define the name of the uniform as defined in the shader
  83168. * @param value Define the value to give to the uniform
  83169. * @return the texture itself allowing "fluent" like uniform updates
  83170. */
  83171. setInt(name: string, value: number): ProceduralTexture;
  83172. /**
  83173. * Set an array of floats in the shader.
  83174. * @param name Define the name of the uniform as defined in the shader
  83175. * @param value Define the value to give to the uniform
  83176. * @return the texture itself allowing "fluent" like uniform updates
  83177. */
  83178. setFloats(name: string, value: number[]): ProceduralTexture;
  83179. /**
  83180. * Set a vec3 in the shader from a Color3.
  83181. * @param name Define the name of the uniform as defined in the shader
  83182. * @param value Define the value to give to the uniform
  83183. * @return the texture itself allowing "fluent" like uniform updates
  83184. */
  83185. setColor3(name: string, value: Color3): ProceduralTexture;
  83186. /**
  83187. * Set a vec4 in the shader from a Color4.
  83188. * @param name Define the name of the uniform as defined in the shader
  83189. * @param value Define the value to give to the uniform
  83190. * @return the texture itself allowing "fluent" like uniform updates
  83191. */
  83192. setColor4(name: string, value: Color4): ProceduralTexture;
  83193. /**
  83194. * Set a vec2 in the shader from a Vector2.
  83195. * @param name Define the name of the uniform as defined in the shader
  83196. * @param value Define the value to give to the uniform
  83197. * @return the texture itself allowing "fluent" like uniform updates
  83198. */
  83199. setVector2(name: string, value: Vector2): ProceduralTexture;
  83200. /**
  83201. * Set a vec3 in the shader from a Vector3.
  83202. * @param name Define the name of the uniform as defined in the shader
  83203. * @param value Define the value to give to the uniform
  83204. * @return the texture itself allowing "fluent" like uniform updates
  83205. */
  83206. setVector3(name: string, value: Vector3): ProceduralTexture;
  83207. /**
  83208. * Set a mat4 in the shader from a MAtrix.
  83209. * @param name Define the name of the uniform as defined in the shader
  83210. * @param value Define the value to give to the uniform
  83211. * @return the texture itself allowing "fluent" like uniform updates
  83212. */
  83213. setMatrix(name: string, value: Matrix): ProceduralTexture;
  83214. /**
  83215. * Render the texture to its associated render target.
  83216. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  83217. */
  83218. render(useCameraPostProcess?: boolean): void;
  83219. /**
  83220. * Clone the texture.
  83221. * @returns the cloned texture
  83222. */
  83223. clone(): ProceduralTexture;
  83224. /**
  83225. * Dispose the texture and release its asoociated resources.
  83226. */
  83227. dispose(): void;
  83228. }
  83229. }
  83230. declare module BABYLON {
  83231. /**
  83232. * This represents the base class for particle system in Babylon.
  83233. * 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.
  83234. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  83235. * @example https://doc.babylonjs.com/babylon101/particles
  83236. */
  83237. export class BaseParticleSystem {
  83238. /**
  83239. * Source color is added to the destination color without alpha affecting the result
  83240. */
  83241. static BLENDMODE_ONEONE: number;
  83242. /**
  83243. * Blend current color and particle color using particle’s alpha
  83244. */
  83245. static BLENDMODE_STANDARD: number;
  83246. /**
  83247. * Add current color and particle color multiplied by particle’s alpha
  83248. */
  83249. static BLENDMODE_ADD: number;
  83250. /**
  83251. * Multiply current color with particle color
  83252. */
  83253. static BLENDMODE_MULTIPLY: number;
  83254. /**
  83255. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  83256. */
  83257. static BLENDMODE_MULTIPLYADD: number;
  83258. /**
  83259. * List of animations used by the particle system.
  83260. */
  83261. animations: Animation[];
  83262. /**
  83263. * The id of the Particle system.
  83264. */
  83265. id: string;
  83266. /**
  83267. * The friendly name of the Particle system.
  83268. */
  83269. name: string;
  83270. /**
  83271. * The rendering group used by the Particle system to chose when to render.
  83272. */
  83273. renderingGroupId: number;
  83274. /**
  83275. * The emitter represents the Mesh or position we are attaching the particle system to.
  83276. */
  83277. emitter: Nullable<AbstractMesh | Vector3>;
  83278. /**
  83279. * The maximum number of particles to emit per frame
  83280. */
  83281. emitRate: number;
  83282. /**
  83283. * If you want to launch only a few particles at once, that can be done, as well.
  83284. */
  83285. manualEmitCount: number;
  83286. /**
  83287. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  83288. */
  83289. updateSpeed: number;
  83290. /**
  83291. * The amount of time the particle system is running (depends of the overall update speed).
  83292. */
  83293. targetStopDuration: number;
  83294. /**
  83295. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  83296. */
  83297. disposeOnStop: boolean;
  83298. /**
  83299. * Minimum power of emitting particles.
  83300. */
  83301. minEmitPower: number;
  83302. /**
  83303. * Maximum power of emitting particles.
  83304. */
  83305. maxEmitPower: number;
  83306. /**
  83307. * Minimum life time of emitting particles.
  83308. */
  83309. minLifeTime: number;
  83310. /**
  83311. * Maximum life time of emitting particles.
  83312. */
  83313. maxLifeTime: number;
  83314. /**
  83315. * Minimum Size of emitting particles.
  83316. */
  83317. minSize: number;
  83318. /**
  83319. * Maximum Size of emitting particles.
  83320. */
  83321. maxSize: number;
  83322. /**
  83323. * Minimum scale of emitting particles on X axis.
  83324. */
  83325. minScaleX: number;
  83326. /**
  83327. * Maximum scale of emitting particles on X axis.
  83328. */
  83329. maxScaleX: number;
  83330. /**
  83331. * Minimum scale of emitting particles on Y axis.
  83332. */
  83333. minScaleY: number;
  83334. /**
  83335. * Maximum scale of emitting particles on Y axis.
  83336. */
  83337. maxScaleY: number;
  83338. /**
  83339. * Gets or sets the minimal initial rotation in radians.
  83340. */
  83341. minInitialRotation: number;
  83342. /**
  83343. * Gets or sets the maximal initial rotation in radians.
  83344. */
  83345. maxInitialRotation: number;
  83346. /**
  83347. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  83348. */
  83349. minAngularSpeed: number;
  83350. /**
  83351. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  83352. */
  83353. maxAngularSpeed: number;
  83354. /**
  83355. * The texture used to render each particle. (this can be a spritesheet)
  83356. */
  83357. particleTexture: Nullable<Texture>;
  83358. /**
  83359. * The layer mask we are rendering the particles through.
  83360. */
  83361. layerMask: number;
  83362. /**
  83363. * This can help using your own shader to render the particle system.
  83364. * The according effect will be created
  83365. */
  83366. customShader: any;
  83367. /**
  83368. * By default particle system starts as soon as they are created. This prevents the
  83369. * automatic start to happen and let you decide when to start emitting particles.
  83370. */
  83371. preventAutoStart: boolean;
  83372. private _noiseTexture;
  83373. /**
  83374. * Gets or sets a texture used to add random noise to particle positions
  83375. */
  83376. noiseTexture: Nullable<ProceduralTexture>;
  83377. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  83378. noiseStrength: Vector3;
  83379. /**
  83380. * Callback triggered when the particle animation is ending.
  83381. */
  83382. onAnimationEnd: Nullable<() => void>;
  83383. /**
  83384. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  83385. */
  83386. blendMode: number;
  83387. /**
  83388. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  83389. * to override the particles.
  83390. */
  83391. forceDepthWrite: boolean;
  83392. /** 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 */
  83393. preWarmCycles: number;
  83394. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  83395. preWarmStepOffset: number;
  83396. /**
  83397. * 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)
  83398. */
  83399. spriteCellChangeSpeed: number;
  83400. /**
  83401. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  83402. */
  83403. startSpriteCellID: number;
  83404. /**
  83405. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  83406. */
  83407. endSpriteCellID: number;
  83408. /**
  83409. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  83410. */
  83411. spriteCellWidth: number;
  83412. /**
  83413. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  83414. */
  83415. spriteCellHeight: number;
  83416. /**
  83417. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  83418. */
  83419. spriteRandomStartCell: boolean;
  83420. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  83421. translationPivot: Vector2;
  83422. /** @hidden */
  83423. protected _isAnimationSheetEnabled: boolean;
  83424. /**
  83425. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  83426. */
  83427. beginAnimationOnStart: boolean;
  83428. /**
  83429. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  83430. */
  83431. beginAnimationFrom: number;
  83432. /**
  83433. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  83434. */
  83435. beginAnimationTo: number;
  83436. /**
  83437. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  83438. */
  83439. beginAnimationLoop: boolean;
  83440. /**
  83441. * Gets or sets a world offset applied to all particles
  83442. */
  83443. worldOffset: Vector3;
  83444. /**
  83445. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  83446. */
  83447. isAnimationSheetEnabled: boolean;
  83448. /**
  83449. * Get hosting scene
  83450. * @returns the scene
  83451. */
  83452. getScene(): Scene;
  83453. /**
  83454. * You can use gravity if you want to give an orientation to your particles.
  83455. */
  83456. gravity: Vector3;
  83457. protected _colorGradients: Nullable<Array<ColorGradient>>;
  83458. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  83459. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  83460. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  83461. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  83462. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  83463. protected _dragGradients: Nullable<Array<FactorGradient>>;
  83464. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  83465. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  83466. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  83467. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  83468. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  83469. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  83470. /**
  83471. * Defines the delay in milliseconds before starting the system (0 by default)
  83472. */
  83473. startDelay: number;
  83474. /**
  83475. * Gets the current list of drag gradients.
  83476. * You must use addDragGradient and removeDragGradient to udpate this list
  83477. * @returns the list of drag gradients
  83478. */
  83479. getDragGradients(): Nullable<Array<FactorGradient>>;
  83480. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  83481. limitVelocityDamping: number;
  83482. /**
  83483. * Gets the current list of limit velocity gradients.
  83484. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  83485. * @returns the list of limit velocity gradients
  83486. */
  83487. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  83488. /**
  83489. * Gets the current list of color gradients.
  83490. * You must use addColorGradient and removeColorGradient to udpate this list
  83491. * @returns the list of color gradients
  83492. */
  83493. getColorGradients(): Nullable<Array<ColorGradient>>;
  83494. /**
  83495. * Gets the current list of size gradients.
  83496. * You must use addSizeGradient and removeSizeGradient to udpate this list
  83497. * @returns the list of size gradients
  83498. */
  83499. getSizeGradients(): Nullable<Array<FactorGradient>>;
  83500. /**
  83501. * Gets the current list of color remap gradients.
  83502. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  83503. * @returns the list of color remap gradients
  83504. */
  83505. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  83506. /**
  83507. * Gets the current list of alpha remap gradients.
  83508. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  83509. * @returns the list of alpha remap gradients
  83510. */
  83511. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  83512. /**
  83513. * Gets the current list of life time gradients.
  83514. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  83515. * @returns the list of life time gradients
  83516. */
  83517. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  83518. /**
  83519. * Gets the current list of angular speed gradients.
  83520. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  83521. * @returns the list of angular speed gradients
  83522. */
  83523. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  83524. /**
  83525. * Gets the current list of velocity gradients.
  83526. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  83527. * @returns the list of velocity gradients
  83528. */
  83529. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  83530. /**
  83531. * Gets the current list of start size gradients.
  83532. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  83533. * @returns the list of start size gradients
  83534. */
  83535. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  83536. /**
  83537. * Gets the current list of emit rate gradients.
  83538. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  83539. * @returns the list of emit rate gradients
  83540. */
  83541. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  83542. /**
  83543. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83544. * This only works when particleEmitterTyps is a BoxParticleEmitter
  83545. */
  83546. direction1: Vector3;
  83547. /**
  83548. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83549. * This only works when particleEmitterTyps is a BoxParticleEmitter
  83550. */
  83551. direction2: Vector3;
  83552. /**
  83553. * 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.
  83554. * This only works when particleEmitterTyps is a BoxParticleEmitter
  83555. */
  83556. minEmitBox: Vector3;
  83557. /**
  83558. * 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.
  83559. * This only works when particleEmitterTyps is a BoxParticleEmitter
  83560. */
  83561. maxEmitBox: Vector3;
  83562. /**
  83563. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  83564. */
  83565. color1: Color4;
  83566. /**
  83567. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  83568. */
  83569. color2: Color4;
  83570. /**
  83571. * Color the particle will have at the end of its lifetime
  83572. */
  83573. colorDead: Color4;
  83574. /**
  83575. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  83576. */
  83577. textureMask: Color4;
  83578. /**
  83579. * The particle emitter type defines the emitter used by the particle system.
  83580. * It can be for example box, sphere, or cone...
  83581. */
  83582. particleEmitterType: IParticleEmitterType;
  83583. /** @hidden */
  83584. _isSubEmitter: boolean;
  83585. /**
  83586. * Gets or sets the billboard mode to use when isBillboardBased = true.
  83587. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  83588. */
  83589. billboardMode: number;
  83590. protected _isBillboardBased: boolean;
  83591. /**
  83592. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  83593. */
  83594. isBillboardBased: boolean;
  83595. /**
  83596. * The scene the particle system belongs to.
  83597. */
  83598. protected _scene: Scene;
  83599. /**
  83600. * Local cache of defines for image processing.
  83601. */
  83602. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  83603. /**
  83604. * Default configuration related to image processing available in the standard Material.
  83605. */
  83606. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  83607. /**
  83608. * Gets the image processing configuration used either in this material.
  83609. */
  83610. /**
  83611. * Sets the Default image processing configuration used either in the this material.
  83612. *
  83613. * If sets to null, the scene one is in use.
  83614. */
  83615. imageProcessingConfiguration: ImageProcessingConfiguration;
  83616. /**
  83617. * Attaches a new image processing configuration to the Standard Material.
  83618. * @param configuration
  83619. */
  83620. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  83621. /** @hidden */
  83622. protected _reset(): void;
  83623. /** @hidden */
  83624. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  83625. /**
  83626. * Instantiates a particle system.
  83627. * 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.
  83628. * @param name The name of the particle system
  83629. */
  83630. constructor(name: string);
  83631. /**
  83632. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  83633. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  83634. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  83635. * @returns the emitter
  83636. */
  83637. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  83638. /**
  83639. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  83640. * @param radius The radius of the hemisphere to emit from
  83641. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  83642. * @returns the emitter
  83643. */
  83644. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  83645. /**
  83646. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  83647. * @param radius The radius of the sphere to emit from
  83648. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  83649. * @returns the emitter
  83650. */
  83651. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  83652. /**
  83653. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  83654. * @param radius The radius of the sphere to emit from
  83655. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  83656. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  83657. * @returns the emitter
  83658. */
  83659. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  83660. /**
  83661. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  83662. * @param radius The radius of the emission cylinder
  83663. * @param height The height of the emission cylinder
  83664. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  83665. * @param directionRandomizer How much to randomize the particle direction [0-1]
  83666. * @returns the emitter
  83667. */
  83668. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  83669. /**
  83670. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  83671. * @param radius The radius of the cylinder to emit from
  83672. * @param height The height of the emission cylinder
  83673. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83674. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  83675. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  83676. * @returns the emitter
  83677. */
  83678. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  83679. /**
  83680. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  83681. * @param radius The radius of the cone to emit from
  83682. * @param angle The base angle of the cone
  83683. * @returns the emitter
  83684. */
  83685. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  83686. /**
  83687. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  83688. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  83689. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  83690. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  83691. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  83692. * @returns the emitter
  83693. */
  83694. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  83695. }
  83696. }
  83697. declare module BABYLON {
  83698. /**
  83699. * Type of sub emitter
  83700. */
  83701. export enum SubEmitterType {
  83702. /**
  83703. * Attached to the particle over it's lifetime
  83704. */
  83705. ATTACHED = 0,
  83706. /**
  83707. * Created when the particle dies
  83708. */
  83709. END = 1
  83710. }
  83711. /**
  83712. * Sub emitter class used to emit particles from an existing particle
  83713. */
  83714. export class SubEmitter {
  83715. /**
  83716. * the particle system to be used by the sub emitter
  83717. */
  83718. particleSystem: ParticleSystem;
  83719. /**
  83720. * Type of the submitter (Default: END)
  83721. */
  83722. type: SubEmitterType;
  83723. /**
  83724. * 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)
  83725. * Note: This only is supported when using an emitter of type Mesh
  83726. */
  83727. inheritDirection: boolean;
  83728. /**
  83729. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  83730. */
  83731. inheritedVelocityAmount: number;
  83732. /**
  83733. * Creates a sub emitter
  83734. * @param particleSystem the particle system to be used by the sub emitter
  83735. */
  83736. constructor(
  83737. /**
  83738. * the particle system to be used by the sub emitter
  83739. */
  83740. particleSystem: ParticleSystem);
  83741. /**
  83742. * Clones the sub emitter
  83743. * @returns the cloned sub emitter
  83744. */
  83745. clone(): SubEmitter;
  83746. /**
  83747. * Serialize current object to a JSON object
  83748. * @returns the serialized object
  83749. */
  83750. serialize(): any;
  83751. /** @hidden */
  83752. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  83753. /**
  83754. * Creates a new SubEmitter from a serialized JSON version
  83755. * @param serializationObject defines the JSON object to read from
  83756. * @param scene defines the hosting scene
  83757. * @param rootUrl defines the rootUrl for data loading
  83758. * @returns a new SubEmitter
  83759. */
  83760. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  83761. /** Release associated resources */
  83762. dispose(): void;
  83763. }
  83764. }
  83765. declare module BABYLON {
  83766. /** @hidden */
  83767. export var clipPlaneFragmentDeclaration: {
  83768. name: string;
  83769. shader: string;
  83770. };
  83771. }
  83772. declare module BABYLON {
  83773. /** @hidden */
  83774. export var imageProcessingDeclaration: {
  83775. name: string;
  83776. shader: string;
  83777. };
  83778. }
  83779. declare module BABYLON {
  83780. /** @hidden */
  83781. export var imageProcessingFunctions: {
  83782. name: string;
  83783. shader: string;
  83784. };
  83785. }
  83786. declare module BABYLON {
  83787. /** @hidden */
  83788. export var clipPlaneFragment: {
  83789. name: string;
  83790. shader: string;
  83791. };
  83792. }
  83793. declare module BABYLON {
  83794. /** @hidden */
  83795. export var particlesPixelShader: {
  83796. name: string;
  83797. shader: string;
  83798. };
  83799. }
  83800. declare module BABYLON {
  83801. /** @hidden */
  83802. export var clipPlaneVertexDeclaration: {
  83803. name: string;
  83804. shader: string;
  83805. };
  83806. }
  83807. declare module BABYLON {
  83808. /** @hidden */
  83809. export var clipPlaneVertex: {
  83810. name: string;
  83811. shader: string;
  83812. };
  83813. }
  83814. declare module BABYLON {
  83815. /** @hidden */
  83816. export var particlesVertexShader: {
  83817. name: string;
  83818. shader: string;
  83819. };
  83820. }
  83821. declare module BABYLON {
  83822. /**
  83823. * This represents a particle system in Babylon.
  83824. * 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.
  83825. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  83826. * @example https://doc.babylonjs.com/babylon101/particles
  83827. */
  83828. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  83829. /**
  83830. * Billboard mode will only apply to Y axis
  83831. */
  83832. static readonly BILLBOARDMODE_Y: number;
  83833. /**
  83834. * Billboard mode will apply to all axes
  83835. */
  83836. static readonly BILLBOARDMODE_ALL: number;
  83837. /**
  83838. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  83839. */
  83840. static readonly BILLBOARDMODE_STRETCHED: number;
  83841. /**
  83842. * This function can be defined to provide custom update for active particles.
  83843. * This function will be called instead of regular update (age, position, color, etc.).
  83844. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  83845. */
  83846. updateFunction: (particles: Particle[]) => void;
  83847. private _emitterWorldMatrix;
  83848. /**
  83849. * This function can be defined to specify initial direction for every new particle.
  83850. * It by default use the emitterType defined function
  83851. */
  83852. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  83853. /**
  83854. * This function can be defined to specify initial position for every new particle.
  83855. * It by default use the emitterType defined function
  83856. */
  83857. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  83858. /**
  83859. * @hidden
  83860. */
  83861. _inheritedVelocityOffset: Vector3;
  83862. /**
  83863. * An event triggered when the system is disposed
  83864. */
  83865. onDisposeObservable: Observable<ParticleSystem>;
  83866. private _onDisposeObserver;
  83867. /**
  83868. * Sets a callback that will be triggered when the system is disposed
  83869. */
  83870. onDispose: () => void;
  83871. private _particles;
  83872. private _epsilon;
  83873. private _capacity;
  83874. private _stockParticles;
  83875. private _newPartsExcess;
  83876. private _vertexData;
  83877. private _vertexBuffer;
  83878. private _vertexBuffers;
  83879. private _spriteBuffer;
  83880. private _indexBuffer;
  83881. private _effect;
  83882. private _customEffect;
  83883. private _cachedDefines;
  83884. private _scaledColorStep;
  83885. private _colorDiff;
  83886. private _scaledDirection;
  83887. private _scaledGravity;
  83888. private _currentRenderId;
  83889. private _alive;
  83890. private _useInstancing;
  83891. private _started;
  83892. private _stopped;
  83893. private _actualFrame;
  83894. private _scaledUpdateSpeed;
  83895. private _vertexBufferSize;
  83896. /** @hidden */
  83897. _currentEmitRateGradient: Nullable<FactorGradient>;
  83898. /** @hidden */
  83899. _currentEmitRate1: number;
  83900. /** @hidden */
  83901. _currentEmitRate2: number;
  83902. /** @hidden */
  83903. _currentStartSizeGradient: Nullable<FactorGradient>;
  83904. /** @hidden */
  83905. _currentStartSize1: number;
  83906. /** @hidden */
  83907. _currentStartSize2: number;
  83908. private readonly _rawTextureWidth;
  83909. private _rampGradientsTexture;
  83910. private _useRampGradients;
  83911. /** Gets or sets a boolean indicating that ramp gradients must be used
  83912. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  83913. */
  83914. useRampGradients: boolean;
  83915. /**
  83916. * 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.
  83917. * 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: [])
  83918. */
  83919. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  83920. private _subEmitters;
  83921. /**
  83922. * @hidden
  83923. * If the particle systems emitter should be disposed when the particle system is disposed
  83924. */
  83925. _disposeEmitterOnDispose: boolean;
  83926. /**
  83927. * The current active Sub-systems, this property is used by the root particle system only.
  83928. */
  83929. activeSubSystems: Array<ParticleSystem>;
  83930. private _rootParticleSystem;
  83931. /**
  83932. * Gets the current list of active particles
  83933. */
  83934. readonly particles: Particle[];
  83935. /**
  83936. * Returns the string "ParticleSystem"
  83937. * @returns a string containing the class name
  83938. */
  83939. getClassName(): string;
  83940. /**
  83941. * Instantiates a particle system.
  83942. * 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.
  83943. * @param name The name of the particle system
  83944. * @param capacity The max number of particles alive at the same time
  83945. * @param scene The scene the particle system belongs to
  83946. * @param customEffect a custom effect used to change the way particles are rendered by default
  83947. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  83948. * @param epsilon Offset used to render the particles
  83949. */
  83950. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  83951. private _addFactorGradient;
  83952. private _removeFactorGradient;
  83953. /**
  83954. * Adds a new life time gradient
  83955. * @param gradient defines the gradient to use (between 0 and 1)
  83956. * @param factor defines the life time factor to affect to the specified gradient
  83957. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83958. * @returns the current particle system
  83959. */
  83960. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83961. /**
  83962. * Remove a specific life time gradient
  83963. * @param gradient defines the gradient to remove
  83964. * @returns the current particle system
  83965. */
  83966. removeLifeTimeGradient(gradient: number): IParticleSystem;
  83967. /**
  83968. * Adds a new size gradient
  83969. * @param gradient defines the gradient to use (between 0 and 1)
  83970. * @param factor defines the size factor to affect to the specified gradient
  83971. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83972. * @returns the current particle system
  83973. */
  83974. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83975. /**
  83976. * Remove a specific size gradient
  83977. * @param gradient defines the gradient to remove
  83978. * @returns the current particle system
  83979. */
  83980. removeSizeGradient(gradient: number): IParticleSystem;
  83981. /**
  83982. * Adds a new color remap gradient
  83983. * @param gradient defines the gradient to use (between 0 and 1)
  83984. * @param min defines the color remap minimal range
  83985. * @param max defines the color remap maximal range
  83986. * @returns the current particle system
  83987. */
  83988. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  83989. /**
  83990. * Remove a specific color remap gradient
  83991. * @param gradient defines the gradient to remove
  83992. * @returns the current particle system
  83993. */
  83994. removeColorRemapGradient(gradient: number): IParticleSystem;
  83995. /**
  83996. * Adds a new alpha remap gradient
  83997. * @param gradient defines the gradient to use (between 0 and 1)
  83998. * @param min defines the alpha remap minimal range
  83999. * @param max defines the alpha remap maximal range
  84000. * @returns the current particle system
  84001. */
  84002. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  84003. /**
  84004. * Remove a specific alpha remap gradient
  84005. * @param gradient defines the gradient to remove
  84006. * @returns the current particle system
  84007. */
  84008. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  84009. /**
  84010. * Adds a new angular speed gradient
  84011. * @param gradient defines the gradient to use (between 0 and 1)
  84012. * @param factor defines the angular speed to affect to the specified gradient
  84013. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84014. * @returns the current particle system
  84015. */
  84016. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84017. /**
  84018. * Remove a specific angular speed gradient
  84019. * @param gradient defines the gradient to remove
  84020. * @returns the current particle system
  84021. */
  84022. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  84023. /**
  84024. * Adds a new velocity gradient
  84025. * @param gradient defines the gradient to use (between 0 and 1)
  84026. * @param factor defines the velocity to affect to the specified gradient
  84027. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84028. * @returns the current particle system
  84029. */
  84030. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84031. /**
  84032. * Remove a specific velocity gradient
  84033. * @param gradient defines the gradient to remove
  84034. * @returns the current particle system
  84035. */
  84036. removeVelocityGradient(gradient: number): IParticleSystem;
  84037. /**
  84038. * Adds a new limit velocity gradient
  84039. * @param gradient defines the gradient to use (between 0 and 1)
  84040. * @param factor defines the limit velocity value to affect to the specified gradient
  84041. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84042. * @returns the current particle system
  84043. */
  84044. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84045. /**
  84046. * Remove a specific limit velocity gradient
  84047. * @param gradient defines the gradient to remove
  84048. * @returns the current particle system
  84049. */
  84050. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  84051. /**
  84052. * Adds a new drag gradient
  84053. * @param gradient defines the gradient to use (between 0 and 1)
  84054. * @param factor defines the drag value to affect to the specified gradient
  84055. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84056. * @returns the current particle system
  84057. */
  84058. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84059. /**
  84060. * Remove a specific drag gradient
  84061. * @param gradient defines the gradient to remove
  84062. * @returns the current particle system
  84063. */
  84064. removeDragGradient(gradient: number): IParticleSystem;
  84065. /**
  84066. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  84067. * @param gradient defines the gradient to use (between 0 and 1)
  84068. * @param factor defines the emit rate value to affect to the specified gradient
  84069. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84070. * @returns the current particle system
  84071. */
  84072. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84073. /**
  84074. * Remove a specific emit rate gradient
  84075. * @param gradient defines the gradient to remove
  84076. * @returns the current particle system
  84077. */
  84078. removeEmitRateGradient(gradient: number): IParticleSystem;
  84079. /**
  84080. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  84081. * @param gradient defines the gradient to use (between 0 and 1)
  84082. * @param factor defines the start size value to affect to the specified gradient
  84083. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84084. * @returns the current particle system
  84085. */
  84086. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84087. /**
  84088. * Remove a specific start size gradient
  84089. * @param gradient defines the gradient to remove
  84090. * @returns the current particle system
  84091. */
  84092. removeStartSizeGradient(gradient: number): IParticleSystem;
  84093. private _createRampGradientTexture;
  84094. /**
  84095. * Gets the current list of ramp gradients.
  84096. * You must use addRampGradient and removeRampGradient to udpate this list
  84097. * @returns the list of ramp gradients
  84098. */
  84099. getRampGradients(): Nullable<Array<Color3Gradient>>;
  84100. /**
  84101. * Adds a new ramp gradient used to remap particle colors
  84102. * @param gradient defines the gradient to use (between 0 and 1)
  84103. * @param color defines the color to affect to the specified gradient
  84104. * @returns the current particle system
  84105. */
  84106. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  84107. /**
  84108. * Remove a specific ramp gradient
  84109. * @param gradient defines the gradient to remove
  84110. * @returns the current particle system
  84111. */
  84112. removeRampGradient(gradient: number): ParticleSystem;
  84113. /**
  84114. * Adds a new color gradient
  84115. * @param gradient defines the gradient to use (between 0 and 1)
  84116. * @param color1 defines the color to affect to the specified gradient
  84117. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  84118. * @returns this particle system
  84119. */
  84120. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  84121. /**
  84122. * Remove a specific color gradient
  84123. * @param gradient defines the gradient to remove
  84124. * @returns this particle system
  84125. */
  84126. removeColorGradient(gradient: number): IParticleSystem;
  84127. private _fetchR;
  84128. protected _reset(): void;
  84129. private _resetEffect;
  84130. private _createVertexBuffers;
  84131. private _createIndexBuffer;
  84132. /**
  84133. * Gets the maximum number of particles active at the same time.
  84134. * @returns The max number of active particles.
  84135. */
  84136. getCapacity(): number;
  84137. /**
  84138. * Gets whether there are still active particles in the system.
  84139. * @returns True if it is alive, otherwise false.
  84140. */
  84141. isAlive(): boolean;
  84142. /**
  84143. * Gets if the system has been started. (Note: this will still be true after stop is called)
  84144. * @returns True if it has been started, otherwise false.
  84145. */
  84146. isStarted(): boolean;
  84147. private _prepareSubEmitterInternalArray;
  84148. /**
  84149. * Starts the particle system and begins to emit
  84150. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  84151. */
  84152. start(delay?: number): void;
  84153. /**
  84154. * Stops the particle system.
  84155. * @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.
  84156. */
  84157. stop(stopSubEmitters?: boolean): void;
  84158. /**
  84159. * Remove all active particles
  84160. */
  84161. reset(): void;
  84162. /**
  84163. * @hidden (for internal use only)
  84164. */
  84165. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  84166. /**
  84167. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  84168. * Its lifetime will start back at 0.
  84169. */
  84170. recycleParticle: (particle: Particle) => void;
  84171. private _stopSubEmitters;
  84172. private _createParticle;
  84173. private _removeFromRoot;
  84174. private _emitFromParticle;
  84175. private _update;
  84176. /** @hidden */
  84177. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  84178. /** @hidden */
  84179. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  84180. /** @hidden */
  84181. private _getEffect;
  84182. /**
  84183. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  84184. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  84185. */
  84186. animate(preWarmOnly?: boolean): void;
  84187. private _appendParticleVertices;
  84188. /**
  84189. * Rebuilds the particle system.
  84190. */
  84191. rebuild(): void;
  84192. /**
  84193. * Is this system ready to be used/rendered
  84194. * @return true if the system is ready
  84195. */
  84196. isReady(): boolean;
  84197. private _render;
  84198. /**
  84199. * Renders the particle system in its current state.
  84200. * @returns the current number of particles
  84201. */
  84202. render(): number;
  84203. /**
  84204. * Disposes the particle system and free the associated resources
  84205. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  84206. */
  84207. dispose(disposeTexture?: boolean): void;
  84208. /**
  84209. * Clones the particle system.
  84210. * @param name The name of the cloned object
  84211. * @param newEmitter The new emitter to use
  84212. * @returns the cloned particle system
  84213. */
  84214. clone(name: string, newEmitter: any): ParticleSystem;
  84215. /**
  84216. * Serializes the particle system to a JSON object.
  84217. * @returns the JSON object
  84218. */
  84219. serialize(): any;
  84220. /** @hidden */
  84221. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  84222. /** @hidden */
  84223. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  84224. /**
  84225. * Parses a JSON object to create a particle system.
  84226. * @param parsedParticleSystem The JSON object to parse
  84227. * @param scene The scene to create the particle system in
  84228. * @param rootUrl The root url to use to load external dependencies like texture
  84229. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  84230. * @returns the Parsed particle system
  84231. */
  84232. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  84233. }
  84234. }
  84235. declare module BABYLON {
  84236. /**
  84237. * A particle represents one of the element emitted by a particle system.
  84238. * This is mainly define by its coordinates, direction, velocity and age.
  84239. */
  84240. export class Particle {
  84241. /**
  84242. * The particle system the particle belongs to.
  84243. */
  84244. particleSystem: ParticleSystem;
  84245. private static _Count;
  84246. /**
  84247. * Unique ID of the particle
  84248. */
  84249. id: number;
  84250. /**
  84251. * The world position of the particle in the scene.
  84252. */
  84253. position: Vector3;
  84254. /**
  84255. * The world direction of the particle in the scene.
  84256. */
  84257. direction: Vector3;
  84258. /**
  84259. * The color of the particle.
  84260. */
  84261. color: Color4;
  84262. /**
  84263. * The color change of the particle per step.
  84264. */
  84265. colorStep: Color4;
  84266. /**
  84267. * Defines how long will the life of the particle be.
  84268. */
  84269. lifeTime: number;
  84270. /**
  84271. * The current age of the particle.
  84272. */
  84273. age: number;
  84274. /**
  84275. * The current size of the particle.
  84276. */
  84277. size: number;
  84278. /**
  84279. * The current scale of the particle.
  84280. */
  84281. scale: Vector2;
  84282. /**
  84283. * The current angle of the particle.
  84284. */
  84285. angle: number;
  84286. /**
  84287. * Defines how fast is the angle changing.
  84288. */
  84289. angularSpeed: number;
  84290. /**
  84291. * Defines the cell index used by the particle to be rendered from a sprite.
  84292. */
  84293. cellIndex: number;
  84294. /**
  84295. * The information required to support color remapping
  84296. */
  84297. remapData: Vector4;
  84298. /** @hidden */
  84299. _randomCellOffset?: number;
  84300. /** @hidden */
  84301. _initialDirection: Nullable<Vector3>;
  84302. /** @hidden */
  84303. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  84304. /** @hidden */
  84305. _initialStartSpriteCellID: number;
  84306. /** @hidden */
  84307. _initialEndSpriteCellID: number;
  84308. /** @hidden */
  84309. _currentColorGradient: Nullable<ColorGradient>;
  84310. /** @hidden */
  84311. _currentColor1: Color4;
  84312. /** @hidden */
  84313. _currentColor2: Color4;
  84314. /** @hidden */
  84315. _currentSizeGradient: Nullable<FactorGradient>;
  84316. /** @hidden */
  84317. _currentSize1: number;
  84318. /** @hidden */
  84319. _currentSize2: number;
  84320. /** @hidden */
  84321. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  84322. /** @hidden */
  84323. _currentAngularSpeed1: number;
  84324. /** @hidden */
  84325. _currentAngularSpeed2: number;
  84326. /** @hidden */
  84327. _currentVelocityGradient: Nullable<FactorGradient>;
  84328. /** @hidden */
  84329. _currentVelocity1: number;
  84330. /** @hidden */
  84331. _currentVelocity2: number;
  84332. /** @hidden */
  84333. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  84334. /** @hidden */
  84335. _currentLimitVelocity1: number;
  84336. /** @hidden */
  84337. _currentLimitVelocity2: number;
  84338. /** @hidden */
  84339. _currentDragGradient: Nullable<FactorGradient>;
  84340. /** @hidden */
  84341. _currentDrag1: number;
  84342. /** @hidden */
  84343. _currentDrag2: number;
  84344. /** @hidden */
  84345. _randomNoiseCoordinates1: Vector3;
  84346. /** @hidden */
  84347. _randomNoiseCoordinates2: Vector3;
  84348. /**
  84349. * Creates a new instance Particle
  84350. * @param particleSystem the particle system the particle belongs to
  84351. */
  84352. constructor(
  84353. /**
  84354. * The particle system the particle belongs to.
  84355. */
  84356. particleSystem: ParticleSystem);
  84357. private updateCellInfoFromSystem;
  84358. /**
  84359. * Defines how the sprite cell index is updated for the particle
  84360. */
  84361. updateCellIndex(): void;
  84362. /** @hidden */
  84363. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  84364. /** @hidden */
  84365. _inheritParticleInfoToSubEmitters(): void;
  84366. /** @hidden */
  84367. _reset(): void;
  84368. /**
  84369. * Copy the properties of particle to another one.
  84370. * @param other the particle to copy the information to.
  84371. */
  84372. copyTo(other: Particle): void;
  84373. }
  84374. }
  84375. declare module BABYLON {
  84376. /**
  84377. * Particle emitter represents a volume emitting particles.
  84378. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  84379. */
  84380. export interface IParticleEmitterType {
  84381. /**
  84382. * Called by the particle System when the direction is computed for the created particle.
  84383. * @param worldMatrix is the world matrix of the particle system
  84384. * @param directionToUpdate is the direction vector to update with the result
  84385. * @param particle is the particle we are computed the direction for
  84386. */
  84387. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84388. /**
  84389. * Called by the particle System when the position is computed for the created particle.
  84390. * @param worldMatrix is the world matrix of the particle system
  84391. * @param positionToUpdate is the position vector to update with the result
  84392. * @param particle is the particle we are computed the position for
  84393. */
  84394. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84395. /**
  84396. * Clones the current emitter and returns a copy of it
  84397. * @returns the new emitter
  84398. */
  84399. clone(): IParticleEmitterType;
  84400. /**
  84401. * Called by the GPUParticleSystem to setup the update shader
  84402. * @param effect defines the update shader
  84403. */
  84404. applyToShader(effect: Effect): void;
  84405. /**
  84406. * Returns a string to use to update the GPU particles update shader
  84407. * @returns the effect defines string
  84408. */
  84409. getEffectDefines(): string;
  84410. /**
  84411. * Returns a string representing the class name
  84412. * @returns a string containing the class name
  84413. */
  84414. getClassName(): string;
  84415. /**
  84416. * Serializes the particle system to a JSON object.
  84417. * @returns the JSON object
  84418. */
  84419. serialize(): any;
  84420. /**
  84421. * Parse properties from a JSON object
  84422. * @param serializationObject defines the JSON object
  84423. */
  84424. parse(serializationObject: any): void;
  84425. }
  84426. }
  84427. declare module BABYLON {
  84428. /**
  84429. * Particle emitter emitting particles from the inside of a box.
  84430. * It emits the particles randomly between 2 given directions.
  84431. */
  84432. export class BoxParticleEmitter implements IParticleEmitterType {
  84433. /**
  84434. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84435. */
  84436. direction1: Vector3;
  84437. /**
  84438. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84439. */
  84440. direction2: Vector3;
  84441. /**
  84442. * 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.
  84443. */
  84444. minEmitBox: Vector3;
  84445. /**
  84446. * 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.
  84447. */
  84448. maxEmitBox: Vector3;
  84449. /**
  84450. * Creates a new instance BoxParticleEmitter
  84451. */
  84452. constructor();
  84453. /**
  84454. * Called by the particle System when the direction is computed for the created particle.
  84455. * @param worldMatrix is the world matrix of the particle system
  84456. * @param directionToUpdate is the direction vector to update with the result
  84457. * @param particle is the particle we are computed the direction for
  84458. */
  84459. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84460. /**
  84461. * Called by the particle System when the position is computed for the created particle.
  84462. * @param worldMatrix is the world matrix of the particle system
  84463. * @param positionToUpdate is the position vector to update with the result
  84464. * @param particle is the particle we are computed the position for
  84465. */
  84466. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84467. /**
  84468. * Clones the current emitter and returns a copy of it
  84469. * @returns the new emitter
  84470. */
  84471. clone(): BoxParticleEmitter;
  84472. /**
  84473. * Called by the GPUParticleSystem to setup the update shader
  84474. * @param effect defines the update shader
  84475. */
  84476. applyToShader(effect: Effect): void;
  84477. /**
  84478. * Returns a string to use to update the GPU particles update shader
  84479. * @returns a string containng the defines string
  84480. */
  84481. getEffectDefines(): string;
  84482. /**
  84483. * Returns the string "BoxParticleEmitter"
  84484. * @returns a string containing the class name
  84485. */
  84486. getClassName(): string;
  84487. /**
  84488. * Serializes the particle system to a JSON object.
  84489. * @returns the JSON object
  84490. */
  84491. serialize(): any;
  84492. /**
  84493. * Parse properties from a JSON object
  84494. * @param serializationObject defines the JSON object
  84495. */
  84496. parse(serializationObject: any): void;
  84497. }
  84498. }
  84499. declare module BABYLON {
  84500. /**
  84501. * Particle emitter emitting particles from the inside of a cone.
  84502. * It emits the particles alongside the cone volume from the base to the particle.
  84503. * The emission direction might be randomized.
  84504. */
  84505. export class ConeParticleEmitter implements IParticleEmitterType {
  84506. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  84507. directionRandomizer: number;
  84508. private _radius;
  84509. private _angle;
  84510. private _height;
  84511. /**
  84512. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  84513. */
  84514. radiusRange: number;
  84515. /**
  84516. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  84517. */
  84518. heightRange: number;
  84519. /**
  84520. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  84521. */
  84522. emitFromSpawnPointOnly: boolean;
  84523. /**
  84524. * Gets or sets the radius of the emission cone
  84525. */
  84526. radius: number;
  84527. /**
  84528. * Gets or sets the angle of the emission cone
  84529. */
  84530. angle: number;
  84531. private _buildHeight;
  84532. /**
  84533. * Creates a new instance ConeParticleEmitter
  84534. * @param radius the radius of the emission cone (1 by default)
  84535. * @param angle the cone base angle (PI by default)
  84536. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  84537. */
  84538. constructor(radius?: number, angle?: number,
  84539. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  84540. directionRandomizer?: number);
  84541. /**
  84542. * Called by the particle System when the direction is computed for the created particle.
  84543. * @param worldMatrix is the world matrix of the particle system
  84544. * @param directionToUpdate is the direction vector to update with the result
  84545. * @param particle is the particle we are computed the direction for
  84546. */
  84547. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84548. /**
  84549. * Called by the particle System when the position is computed for the created particle.
  84550. * @param worldMatrix is the world matrix of the particle system
  84551. * @param positionToUpdate is the position vector to update with the result
  84552. * @param particle is the particle we are computed the position for
  84553. */
  84554. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84555. /**
  84556. * Clones the current emitter and returns a copy of it
  84557. * @returns the new emitter
  84558. */
  84559. clone(): ConeParticleEmitter;
  84560. /**
  84561. * Called by the GPUParticleSystem to setup the update shader
  84562. * @param effect defines the update shader
  84563. */
  84564. applyToShader(effect: Effect): void;
  84565. /**
  84566. * Returns a string to use to update the GPU particles update shader
  84567. * @returns a string containng the defines string
  84568. */
  84569. getEffectDefines(): string;
  84570. /**
  84571. * Returns the string "ConeParticleEmitter"
  84572. * @returns a string containing the class name
  84573. */
  84574. getClassName(): string;
  84575. /**
  84576. * Serializes the particle system to a JSON object.
  84577. * @returns the JSON object
  84578. */
  84579. serialize(): any;
  84580. /**
  84581. * Parse properties from a JSON object
  84582. * @param serializationObject defines the JSON object
  84583. */
  84584. parse(serializationObject: any): void;
  84585. }
  84586. }
  84587. declare module BABYLON {
  84588. /**
  84589. * Particle emitter emitting particles from the inside of a cylinder.
  84590. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  84591. */
  84592. export class CylinderParticleEmitter implements IParticleEmitterType {
  84593. /**
  84594. * The radius of the emission cylinder.
  84595. */
  84596. radius: number;
  84597. /**
  84598. * The height of the emission cylinder.
  84599. */
  84600. height: number;
  84601. /**
  84602. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84603. */
  84604. radiusRange: number;
  84605. /**
  84606. * How much to randomize the particle direction [0-1].
  84607. */
  84608. directionRandomizer: number;
  84609. /**
  84610. * Creates a new instance CylinderParticleEmitter
  84611. * @param radius the radius of the emission cylinder (1 by default)
  84612. * @param height the height of the emission cylinder (1 by default)
  84613. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84614. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  84615. */
  84616. constructor(
  84617. /**
  84618. * The radius of the emission cylinder.
  84619. */
  84620. radius?: number,
  84621. /**
  84622. * The height of the emission cylinder.
  84623. */
  84624. height?: number,
  84625. /**
  84626. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84627. */
  84628. radiusRange?: number,
  84629. /**
  84630. * How much to randomize the particle direction [0-1].
  84631. */
  84632. directionRandomizer?: number);
  84633. /**
  84634. * Called by the particle System when the direction is computed for the created particle.
  84635. * @param worldMatrix is the world matrix of the particle system
  84636. * @param directionToUpdate is the direction vector to update with the result
  84637. * @param particle is the particle we are computed the direction for
  84638. */
  84639. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84640. /**
  84641. * Called by the particle System when the position is computed for the created particle.
  84642. * @param worldMatrix is the world matrix of the particle system
  84643. * @param positionToUpdate is the position vector to update with the result
  84644. * @param particle is the particle we are computed the position for
  84645. */
  84646. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84647. /**
  84648. * Clones the current emitter and returns a copy of it
  84649. * @returns the new emitter
  84650. */
  84651. clone(): CylinderParticleEmitter;
  84652. /**
  84653. * Called by the GPUParticleSystem to setup the update shader
  84654. * @param effect defines the update shader
  84655. */
  84656. applyToShader(effect: Effect): void;
  84657. /**
  84658. * Returns a string to use to update the GPU particles update shader
  84659. * @returns a string containng the defines string
  84660. */
  84661. getEffectDefines(): string;
  84662. /**
  84663. * Returns the string "CylinderParticleEmitter"
  84664. * @returns a string containing the class name
  84665. */
  84666. getClassName(): string;
  84667. /**
  84668. * Serializes the particle system to a JSON object.
  84669. * @returns the JSON object
  84670. */
  84671. serialize(): any;
  84672. /**
  84673. * Parse properties from a JSON object
  84674. * @param serializationObject defines the JSON object
  84675. */
  84676. parse(serializationObject: any): void;
  84677. }
  84678. /**
  84679. * Particle emitter emitting particles from the inside of a cylinder.
  84680. * It emits the particles randomly between two vectors.
  84681. */
  84682. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  84683. /**
  84684. * The min limit of the emission direction.
  84685. */
  84686. direction1: Vector3;
  84687. /**
  84688. * The max limit of the emission direction.
  84689. */
  84690. direction2: Vector3;
  84691. /**
  84692. * Creates a new instance CylinderDirectedParticleEmitter
  84693. * @param radius the radius of the emission cylinder (1 by default)
  84694. * @param height the height of the emission cylinder (1 by default)
  84695. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84696. * @param direction1 the min limit of the emission direction (up vector by default)
  84697. * @param direction2 the max limit of the emission direction (up vector by default)
  84698. */
  84699. constructor(radius?: number, height?: number, radiusRange?: number,
  84700. /**
  84701. * The min limit of the emission direction.
  84702. */
  84703. direction1?: Vector3,
  84704. /**
  84705. * The max limit of the emission direction.
  84706. */
  84707. direction2?: Vector3);
  84708. /**
  84709. * Called by the particle System when the direction is computed for the created particle.
  84710. * @param worldMatrix is the world matrix of the particle system
  84711. * @param directionToUpdate is the direction vector to update with the result
  84712. * @param particle is the particle we are computed the direction for
  84713. */
  84714. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84715. /**
  84716. * Clones the current emitter and returns a copy of it
  84717. * @returns the new emitter
  84718. */
  84719. clone(): CylinderDirectedParticleEmitter;
  84720. /**
  84721. * Called by the GPUParticleSystem to setup the update shader
  84722. * @param effect defines the update shader
  84723. */
  84724. applyToShader(effect: Effect): void;
  84725. /**
  84726. * Returns a string to use to update the GPU particles update shader
  84727. * @returns a string containng the defines string
  84728. */
  84729. getEffectDefines(): string;
  84730. /**
  84731. * Returns the string "CylinderDirectedParticleEmitter"
  84732. * @returns a string containing the class name
  84733. */
  84734. getClassName(): string;
  84735. /**
  84736. * Serializes the particle system to a JSON object.
  84737. * @returns the JSON object
  84738. */
  84739. serialize(): any;
  84740. /**
  84741. * Parse properties from a JSON object
  84742. * @param serializationObject defines the JSON object
  84743. */
  84744. parse(serializationObject: any): void;
  84745. }
  84746. }
  84747. declare module BABYLON {
  84748. /**
  84749. * Particle emitter emitting particles from the inside of a hemisphere.
  84750. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  84751. */
  84752. export class HemisphericParticleEmitter implements IParticleEmitterType {
  84753. /**
  84754. * The radius of the emission hemisphere.
  84755. */
  84756. radius: number;
  84757. /**
  84758. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84759. */
  84760. radiusRange: number;
  84761. /**
  84762. * How much to randomize the particle direction [0-1].
  84763. */
  84764. directionRandomizer: number;
  84765. /**
  84766. * Creates a new instance HemisphericParticleEmitter
  84767. * @param radius the radius of the emission hemisphere (1 by default)
  84768. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84769. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  84770. */
  84771. constructor(
  84772. /**
  84773. * The radius of the emission hemisphere.
  84774. */
  84775. radius?: number,
  84776. /**
  84777. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84778. */
  84779. radiusRange?: number,
  84780. /**
  84781. * How much to randomize the particle direction [0-1].
  84782. */
  84783. directionRandomizer?: number);
  84784. /**
  84785. * Called by the particle System when the direction is computed for the created particle.
  84786. * @param worldMatrix is the world matrix of the particle system
  84787. * @param directionToUpdate is the direction vector to update with the result
  84788. * @param particle is the particle we are computed the direction for
  84789. */
  84790. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84791. /**
  84792. * Called by the particle System when the position is computed for the created particle.
  84793. * @param worldMatrix is the world matrix of the particle system
  84794. * @param positionToUpdate is the position vector to update with the result
  84795. * @param particle is the particle we are computed the position for
  84796. */
  84797. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84798. /**
  84799. * Clones the current emitter and returns a copy of it
  84800. * @returns the new emitter
  84801. */
  84802. clone(): HemisphericParticleEmitter;
  84803. /**
  84804. * Called by the GPUParticleSystem to setup the update shader
  84805. * @param effect defines the update shader
  84806. */
  84807. applyToShader(effect: Effect): void;
  84808. /**
  84809. * Returns a string to use to update the GPU particles update shader
  84810. * @returns a string containng the defines string
  84811. */
  84812. getEffectDefines(): string;
  84813. /**
  84814. * Returns the string "HemisphericParticleEmitter"
  84815. * @returns a string containing the class name
  84816. */
  84817. getClassName(): string;
  84818. /**
  84819. * Serializes the particle system to a JSON object.
  84820. * @returns the JSON object
  84821. */
  84822. serialize(): any;
  84823. /**
  84824. * Parse properties from a JSON object
  84825. * @param serializationObject defines the JSON object
  84826. */
  84827. parse(serializationObject: any): void;
  84828. }
  84829. }
  84830. declare module BABYLON {
  84831. /**
  84832. * Particle emitter emitting particles from a point.
  84833. * It emits the particles randomly between 2 given directions.
  84834. */
  84835. export class PointParticleEmitter implements IParticleEmitterType {
  84836. /**
  84837. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84838. */
  84839. direction1: Vector3;
  84840. /**
  84841. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84842. */
  84843. direction2: Vector3;
  84844. /**
  84845. * Creates a new instance PointParticleEmitter
  84846. */
  84847. constructor();
  84848. /**
  84849. * Called by the particle System when the direction is computed for the created particle.
  84850. * @param worldMatrix is the world matrix of the particle system
  84851. * @param directionToUpdate is the direction vector to update with the result
  84852. * @param particle is the particle we are computed the direction for
  84853. */
  84854. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84855. /**
  84856. * Called by the particle System when the position is computed for the created particle.
  84857. * @param worldMatrix is the world matrix of the particle system
  84858. * @param positionToUpdate is the position vector to update with the result
  84859. * @param particle is the particle we are computed the position for
  84860. */
  84861. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84862. /**
  84863. * Clones the current emitter and returns a copy of it
  84864. * @returns the new emitter
  84865. */
  84866. clone(): PointParticleEmitter;
  84867. /**
  84868. * Called by the GPUParticleSystem to setup the update shader
  84869. * @param effect defines the update shader
  84870. */
  84871. applyToShader(effect: Effect): void;
  84872. /**
  84873. * Returns a string to use to update the GPU particles update shader
  84874. * @returns a string containng the defines string
  84875. */
  84876. getEffectDefines(): string;
  84877. /**
  84878. * Returns the string "PointParticleEmitter"
  84879. * @returns a string containing the class name
  84880. */
  84881. getClassName(): string;
  84882. /**
  84883. * Serializes the particle system to a JSON object.
  84884. * @returns the JSON object
  84885. */
  84886. serialize(): any;
  84887. /**
  84888. * Parse properties from a JSON object
  84889. * @param serializationObject defines the JSON object
  84890. */
  84891. parse(serializationObject: any): void;
  84892. }
  84893. }
  84894. declare module BABYLON {
  84895. /**
  84896. * Particle emitter emitting particles from the inside of a sphere.
  84897. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  84898. */
  84899. export class SphereParticleEmitter implements IParticleEmitterType {
  84900. /**
  84901. * The radius of the emission sphere.
  84902. */
  84903. radius: number;
  84904. /**
  84905. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84906. */
  84907. radiusRange: number;
  84908. /**
  84909. * How much to randomize the particle direction [0-1].
  84910. */
  84911. directionRandomizer: number;
  84912. /**
  84913. * Creates a new instance SphereParticleEmitter
  84914. * @param radius the radius of the emission sphere (1 by default)
  84915. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84916. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  84917. */
  84918. constructor(
  84919. /**
  84920. * The radius of the emission sphere.
  84921. */
  84922. radius?: number,
  84923. /**
  84924. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84925. */
  84926. radiusRange?: number,
  84927. /**
  84928. * How much to randomize the particle direction [0-1].
  84929. */
  84930. directionRandomizer?: number);
  84931. /**
  84932. * Called by the particle System when the direction is computed for the created particle.
  84933. * @param worldMatrix is the world matrix of the particle system
  84934. * @param directionToUpdate is the direction vector to update with the result
  84935. * @param particle is the particle we are computed the direction for
  84936. */
  84937. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84938. /**
  84939. * Called by the particle System when the position is computed for the created particle.
  84940. * @param worldMatrix is the world matrix of the particle system
  84941. * @param positionToUpdate is the position vector to update with the result
  84942. * @param particle is the particle we are computed the position for
  84943. */
  84944. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84945. /**
  84946. * Clones the current emitter and returns a copy of it
  84947. * @returns the new emitter
  84948. */
  84949. clone(): SphereParticleEmitter;
  84950. /**
  84951. * Called by the GPUParticleSystem to setup the update shader
  84952. * @param effect defines the update shader
  84953. */
  84954. applyToShader(effect: Effect): void;
  84955. /**
  84956. * Returns a string to use to update the GPU particles update shader
  84957. * @returns a string containng the defines string
  84958. */
  84959. getEffectDefines(): string;
  84960. /**
  84961. * Returns the string "SphereParticleEmitter"
  84962. * @returns a string containing the class name
  84963. */
  84964. getClassName(): string;
  84965. /**
  84966. * Serializes the particle system to a JSON object.
  84967. * @returns the JSON object
  84968. */
  84969. serialize(): any;
  84970. /**
  84971. * Parse properties from a JSON object
  84972. * @param serializationObject defines the JSON object
  84973. */
  84974. parse(serializationObject: any): void;
  84975. }
  84976. /**
  84977. * Particle emitter emitting particles from the inside of a sphere.
  84978. * It emits the particles randomly between two vectors.
  84979. */
  84980. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  84981. /**
  84982. * The min limit of the emission direction.
  84983. */
  84984. direction1: Vector3;
  84985. /**
  84986. * The max limit of the emission direction.
  84987. */
  84988. direction2: Vector3;
  84989. /**
  84990. * Creates a new instance SphereDirectedParticleEmitter
  84991. * @param radius the radius of the emission sphere (1 by default)
  84992. * @param direction1 the min limit of the emission direction (up vector by default)
  84993. * @param direction2 the max limit of the emission direction (up vector by default)
  84994. */
  84995. constructor(radius?: number,
  84996. /**
  84997. * The min limit of the emission direction.
  84998. */
  84999. direction1?: Vector3,
  85000. /**
  85001. * The max limit of the emission direction.
  85002. */
  85003. direction2?: Vector3);
  85004. /**
  85005. * Called by the particle System when the direction is computed for the created particle.
  85006. * @param worldMatrix is the world matrix of the particle system
  85007. * @param directionToUpdate is the direction vector to update with the result
  85008. * @param particle is the particle we are computed the direction for
  85009. */
  85010. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85011. /**
  85012. * Clones the current emitter and returns a copy of it
  85013. * @returns the new emitter
  85014. */
  85015. clone(): SphereDirectedParticleEmitter;
  85016. /**
  85017. * Called by the GPUParticleSystem to setup the update shader
  85018. * @param effect defines the update shader
  85019. */
  85020. applyToShader(effect: Effect): void;
  85021. /**
  85022. * Returns a string to use to update the GPU particles update shader
  85023. * @returns a string containng the defines string
  85024. */
  85025. getEffectDefines(): string;
  85026. /**
  85027. * Returns the string "SphereDirectedParticleEmitter"
  85028. * @returns a string containing the class name
  85029. */
  85030. getClassName(): string;
  85031. /**
  85032. * Serializes the particle system to a JSON object.
  85033. * @returns the JSON object
  85034. */
  85035. serialize(): any;
  85036. /**
  85037. * Parse properties from a JSON object
  85038. * @param serializationObject defines the JSON object
  85039. */
  85040. parse(serializationObject: any): void;
  85041. }
  85042. }
  85043. declare module BABYLON {
  85044. /**
  85045. * Interface representing a particle system in Babylon.js.
  85046. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  85047. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  85048. */
  85049. export interface IParticleSystem {
  85050. /**
  85051. * List of animations used by the particle system.
  85052. */
  85053. animations: Animation[];
  85054. /**
  85055. * The id of the Particle system.
  85056. */
  85057. id: string;
  85058. /**
  85059. * The name of the Particle system.
  85060. */
  85061. name: string;
  85062. /**
  85063. * The emitter represents the Mesh or position we are attaching the particle system to.
  85064. */
  85065. emitter: Nullable<AbstractMesh | Vector3>;
  85066. /**
  85067. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  85068. */
  85069. isBillboardBased: boolean;
  85070. /**
  85071. * The rendering group used by the Particle system to chose when to render.
  85072. */
  85073. renderingGroupId: number;
  85074. /**
  85075. * The layer mask we are rendering the particles through.
  85076. */
  85077. layerMask: number;
  85078. /**
  85079. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  85080. */
  85081. updateSpeed: number;
  85082. /**
  85083. * The amount of time the particle system is running (depends of the overall update speed).
  85084. */
  85085. targetStopDuration: number;
  85086. /**
  85087. * The texture used to render each particle. (this can be a spritesheet)
  85088. */
  85089. particleTexture: Nullable<Texture>;
  85090. /**
  85091. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  85092. */
  85093. blendMode: number;
  85094. /**
  85095. * Minimum life time of emitting particles.
  85096. */
  85097. minLifeTime: number;
  85098. /**
  85099. * Maximum life time of emitting particles.
  85100. */
  85101. maxLifeTime: number;
  85102. /**
  85103. * Minimum Size of emitting particles.
  85104. */
  85105. minSize: number;
  85106. /**
  85107. * Maximum Size of emitting particles.
  85108. */
  85109. maxSize: number;
  85110. /**
  85111. * Minimum scale of emitting particles on X axis.
  85112. */
  85113. minScaleX: number;
  85114. /**
  85115. * Maximum scale of emitting particles on X axis.
  85116. */
  85117. maxScaleX: number;
  85118. /**
  85119. * Minimum scale of emitting particles on Y axis.
  85120. */
  85121. minScaleY: number;
  85122. /**
  85123. * Maximum scale of emitting particles on Y axis.
  85124. */
  85125. maxScaleY: number;
  85126. /**
  85127. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  85128. */
  85129. color1: Color4;
  85130. /**
  85131. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  85132. */
  85133. color2: Color4;
  85134. /**
  85135. * Color the particle will have at the end of its lifetime.
  85136. */
  85137. colorDead: Color4;
  85138. /**
  85139. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  85140. */
  85141. emitRate: number;
  85142. /**
  85143. * You can use gravity if you want to give an orientation to your particles.
  85144. */
  85145. gravity: Vector3;
  85146. /**
  85147. * Minimum power of emitting particles.
  85148. */
  85149. minEmitPower: number;
  85150. /**
  85151. * Maximum power of emitting particles.
  85152. */
  85153. maxEmitPower: number;
  85154. /**
  85155. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  85156. */
  85157. minAngularSpeed: number;
  85158. /**
  85159. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  85160. */
  85161. maxAngularSpeed: number;
  85162. /**
  85163. * Gets or sets the minimal initial rotation in radians.
  85164. */
  85165. minInitialRotation: number;
  85166. /**
  85167. * Gets or sets the maximal initial rotation in radians.
  85168. */
  85169. maxInitialRotation: number;
  85170. /**
  85171. * The particle emitter type defines the emitter used by the particle system.
  85172. * It can be for example box, sphere, or cone...
  85173. */
  85174. particleEmitterType: Nullable<IParticleEmitterType>;
  85175. /**
  85176. * Defines the delay in milliseconds before starting the system (0 by default)
  85177. */
  85178. startDelay: number;
  85179. /**
  85180. * 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
  85181. */
  85182. preWarmCycles: number;
  85183. /**
  85184. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  85185. */
  85186. preWarmStepOffset: number;
  85187. /**
  85188. * 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)
  85189. */
  85190. spriteCellChangeSpeed: number;
  85191. /**
  85192. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  85193. */
  85194. startSpriteCellID: number;
  85195. /**
  85196. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  85197. */
  85198. endSpriteCellID: number;
  85199. /**
  85200. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  85201. */
  85202. spriteCellWidth: number;
  85203. /**
  85204. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  85205. */
  85206. spriteCellHeight: number;
  85207. /**
  85208. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  85209. */
  85210. spriteRandomStartCell: boolean;
  85211. /**
  85212. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  85213. */
  85214. isAnimationSheetEnabled: boolean;
  85215. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  85216. translationPivot: Vector2;
  85217. /**
  85218. * Gets or sets a texture used to add random noise to particle positions
  85219. */
  85220. noiseTexture: Nullable<BaseTexture>;
  85221. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  85222. noiseStrength: Vector3;
  85223. /**
  85224. * Gets or sets the billboard mode to use when isBillboardBased = true.
  85225. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  85226. */
  85227. billboardMode: number;
  85228. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  85229. limitVelocityDamping: number;
  85230. /**
  85231. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  85232. */
  85233. beginAnimationOnStart: boolean;
  85234. /**
  85235. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  85236. */
  85237. beginAnimationFrom: number;
  85238. /**
  85239. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  85240. */
  85241. beginAnimationTo: number;
  85242. /**
  85243. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  85244. */
  85245. beginAnimationLoop: boolean;
  85246. /**
  85247. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  85248. */
  85249. disposeOnStop: boolean;
  85250. /**
  85251. * Gets the maximum number of particles active at the same time.
  85252. * @returns The max number of active particles.
  85253. */
  85254. getCapacity(): number;
  85255. /**
  85256. * Gets if the system has been started. (Note: this will still be true after stop is called)
  85257. * @returns True if it has been started, otherwise false.
  85258. */
  85259. isStarted(): boolean;
  85260. /**
  85261. * Animates the particle system for this frame.
  85262. */
  85263. animate(): void;
  85264. /**
  85265. * Renders the particle system in its current state.
  85266. * @returns the current number of particles
  85267. */
  85268. render(): number;
  85269. /**
  85270. * Dispose the particle system and frees its associated resources.
  85271. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  85272. */
  85273. dispose(disposeTexture?: boolean): void;
  85274. /**
  85275. * Clones the particle system.
  85276. * @param name The name of the cloned object
  85277. * @param newEmitter The new emitter to use
  85278. * @returns the cloned particle system
  85279. */
  85280. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  85281. /**
  85282. * Serializes the particle system to a JSON object.
  85283. * @returns the JSON object
  85284. */
  85285. serialize(): any;
  85286. /**
  85287. * Rebuild the particle system
  85288. */
  85289. rebuild(): void;
  85290. /**
  85291. * Starts the particle system and begins to emit
  85292. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  85293. */
  85294. start(delay?: number): void;
  85295. /**
  85296. * Stops the particle system.
  85297. */
  85298. stop(): void;
  85299. /**
  85300. * Remove all active particles
  85301. */
  85302. reset(): void;
  85303. /**
  85304. * Is this system ready to be used/rendered
  85305. * @return true if the system is ready
  85306. */
  85307. isReady(): boolean;
  85308. /**
  85309. * Adds a new color gradient
  85310. * @param gradient defines the gradient to use (between 0 and 1)
  85311. * @param color1 defines the color to affect to the specified gradient
  85312. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  85313. * @returns the current particle system
  85314. */
  85315. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  85316. /**
  85317. * Remove a specific color gradient
  85318. * @param gradient defines the gradient to remove
  85319. * @returns the current particle system
  85320. */
  85321. removeColorGradient(gradient: number): IParticleSystem;
  85322. /**
  85323. * Adds a new size gradient
  85324. * @param gradient defines the gradient to use (between 0 and 1)
  85325. * @param factor defines the size factor to affect to the specified gradient
  85326. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85327. * @returns the current particle system
  85328. */
  85329. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85330. /**
  85331. * Remove a specific size gradient
  85332. * @param gradient defines the gradient to remove
  85333. * @returns the current particle system
  85334. */
  85335. removeSizeGradient(gradient: number): IParticleSystem;
  85336. /**
  85337. * Gets the current list of color gradients.
  85338. * You must use addColorGradient and removeColorGradient to udpate this list
  85339. * @returns the list of color gradients
  85340. */
  85341. getColorGradients(): Nullable<Array<ColorGradient>>;
  85342. /**
  85343. * Gets the current list of size gradients.
  85344. * You must use addSizeGradient and removeSizeGradient to udpate this list
  85345. * @returns the list of size gradients
  85346. */
  85347. getSizeGradients(): Nullable<Array<FactorGradient>>;
  85348. /**
  85349. * Gets the current list of angular speed gradients.
  85350. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  85351. * @returns the list of angular speed gradients
  85352. */
  85353. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  85354. /**
  85355. * Adds a new angular speed gradient
  85356. * @param gradient defines the gradient to use (between 0 and 1)
  85357. * @param factor defines the angular speed to affect to the specified gradient
  85358. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85359. * @returns the current particle system
  85360. */
  85361. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85362. /**
  85363. * Remove a specific angular speed gradient
  85364. * @param gradient defines the gradient to remove
  85365. * @returns the current particle system
  85366. */
  85367. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  85368. /**
  85369. * Gets the current list of velocity gradients.
  85370. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  85371. * @returns the list of velocity gradients
  85372. */
  85373. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  85374. /**
  85375. * Adds a new velocity gradient
  85376. * @param gradient defines the gradient to use (between 0 and 1)
  85377. * @param factor defines the velocity to affect to the specified gradient
  85378. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85379. * @returns the current particle system
  85380. */
  85381. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85382. /**
  85383. * Remove a specific velocity gradient
  85384. * @param gradient defines the gradient to remove
  85385. * @returns the current particle system
  85386. */
  85387. removeVelocityGradient(gradient: number): IParticleSystem;
  85388. /**
  85389. * Gets the current list of limit velocity gradients.
  85390. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  85391. * @returns the list of limit velocity gradients
  85392. */
  85393. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  85394. /**
  85395. * Adds a new limit velocity gradient
  85396. * @param gradient defines the gradient to use (between 0 and 1)
  85397. * @param factor defines the limit velocity to affect to the specified gradient
  85398. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85399. * @returns the current particle system
  85400. */
  85401. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85402. /**
  85403. * Remove a specific limit velocity gradient
  85404. * @param gradient defines the gradient to remove
  85405. * @returns the current particle system
  85406. */
  85407. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  85408. /**
  85409. * Adds a new drag gradient
  85410. * @param gradient defines the gradient to use (between 0 and 1)
  85411. * @param factor defines the drag to affect to the specified gradient
  85412. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85413. * @returns the current particle system
  85414. */
  85415. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85416. /**
  85417. * Remove a specific drag gradient
  85418. * @param gradient defines the gradient to remove
  85419. * @returns the current particle system
  85420. */
  85421. removeDragGradient(gradient: number): IParticleSystem;
  85422. /**
  85423. * Gets the current list of drag gradients.
  85424. * You must use addDragGradient and removeDragGradient to udpate this list
  85425. * @returns the list of drag gradients
  85426. */
  85427. getDragGradients(): Nullable<Array<FactorGradient>>;
  85428. /**
  85429. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  85430. * @param gradient defines the gradient to use (between 0 and 1)
  85431. * @param factor defines the emit rate to affect to the specified gradient
  85432. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85433. * @returns the current particle system
  85434. */
  85435. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85436. /**
  85437. * Remove a specific emit rate gradient
  85438. * @param gradient defines the gradient to remove
  85439. * @returns the current particle system
  85440. */
  85441. removeEmitRateGradient(gradient: number): IParticleSystem;
  85442. /**
  85443. * Gets the current list of emit rate gradients.
  85444. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  85445. * @returns the list of emit rate gradients
  85446. */
  85447. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  85448. /**
  85449. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  85450. * @param gradient defines the gradient to use (between 0 and 1)
  85451. * @param factor defines the start size to affect to the specified gradient
  85452. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85453. * @returns the current particle system
  85454. */
  85455. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85456. /**
  85457. * Remove a specific start size gradient
  85458. * @param gradient defines the gradient to remove
  85459. * @returns the current particle system
  85460. */
  85461. removeStartSizeGradient(gradient: number): IParticleSystem;
  85462. /**
  85463. * Gets the current list of start size gradients.
  85464. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  85465. * @returns the list of start size gradients
  85466. */
  85467. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  85468. /**
  85469. * Adds a new life time gradient
  85470. * @param gradient defines the gradient to use (between 0 and 1)
  85471. * @param factor defines the life time factor to affect to the specified gradient
  85472. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85473. * @returns the current particle system
  85474. */
  85475. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85476. /**
  85477. * Remove a specific life time gradient
  85478. * @param gradient defines the gradient to remove
  85479. * @returns the current particle system
  85480. */
  85481. removeLifeTimeGradient(gradient: number): IParticleSystem;
  85482. /**
  85483. * Gets the current list of life time gradients.
  85484. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  85485. * @returns the list of life time gradients
  85486. */
  85487. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  85488. /**
  85489. * Gets the current list of color gradients.
  85490. * You must use addColorGradient and removeColorGradient to udpate this list
  85491. * @returns the list of color gradients
  85492. */
  85493. getColorGradients(): Nullable<Array<ColorGradient>>;
  85494. /**
  85495. * Adds a new ramp gradient used to remap particle colors
  85496. * @param gradient defines the gradient to use (between 0 and 1)
  85497. * @param color defines the color to affect to the specified gradient
  85498. * @returns the current particle system
  85499. */
  85500. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  85501. /**
  85502. * Gets the current list of ramp gradients.
  85503. * You must use addRampGradient and removeRampGradient to udpate this list
  85504. * @returns the list of ramp gradients
  85505. */
  85506. getRampGradients(): Nullable<Array<Color3Gradient>>;
  85507. /** Gets or sets a boolean indicating that ramp gradients must be used
  85508. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  85509. */
  85510. useRampGradients: boolean;
  85511. /**
  85512. * Adds a new color remap gradient
  85513. * @param gradient defines the gradient to use (between 0 and 1)
  85514. * @param min defines the color remap minimal range
  85515. * @param max defines the color remap maximal range
  85516. * @returns the current particle system
  85517. */
  85518. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  85519. /**
  85520. * Gets the current list of color remap gradients.
  85521. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  85522. * @returns the list of color remap gradients
  85523. */
  85524. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  85525. /**
  85526. * Adds a new alpha remap gradient
  85527. * @param gradient defines the gradient to use (between 0 and 1)
  85528. * @param min defines the alpha remap minimal range
  85529. * @param max defines the alpha remap maximal range
  85530. * @returns the current particle system
  85531. */
  85532. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  85533. /**
  85534. * Gets the current list of alpha remap gradients.
  85535. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  85536. * @returns the list of alpha remap gradients
  85537. */
  85538. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  85539. /**
  85540. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  85541. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  85542. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  85543. * @returns the emitter
  85544. */
  85545. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  85546. /**
  85547. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  85548. * @param radius The radius of the hemisphere to emit from
  85549. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  85550. * @returns the emitter
  85551. */
  85552. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  85553. /**
  85554. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  85555. * @param radius The radius of the sphere to emit from
  85556. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  85557. * @returns the emitter
  85558. */
  85559. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  85560. /**
  85561. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  85562. * @param radius The radius of the sphere to emit from
  85563. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  85564. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  85565. * @returns the emitter
  85566. */
  85567. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  85568. /**
  85569. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  85570. * @param radius The radius of the emission cylinder
  85571. * @param height The height of the emission cylinder
  85572. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  85573. * @param directionRandomizer How much to randomize the particle direction [0-1]
  85574. * @returns the emitter
  85575. */
  85576. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  85577. /**
  85578. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  85579. * @param radius The radius of the cylinder to emit from
  85580. * @param height The height of the emission cylinder
  85581. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85582. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  85583. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  85584. * @returns the emitter
  85585. */
  85586. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  85587. /**
  85588. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  85589. * @param radius The radius of the cone to emit from
  85590. * @param angle The base angle of the cone
  85591. * @returns the emitter
  85592. */
  85593. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  85594. /**
  85595. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  85596. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  85597. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  85598. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  85599. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  85600. * @returns the emitter
  85601. */
  85602. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  85603. /**
  85604. * Get hosting scene
  85605. * @returns the scene
  85606. */
  85607. getScene(): Scene;
  85608. }
  85609. }
  85610. declare module BABYLON {
  85611. /**
  85612. * Creates an instance based on a source mesh.
  85613. */
  85614. export class InstancedMesh extends AbstractMesh {
  85615. private _sourceMesh;
  85616. private _currentLOD;
  85617. /** @hidden */
  85618. _indexInSourceMeshInstanceArray: number;
  85619. constructor(name: string, source: Mesh);
  85620. /**
  85621. * Returns the string "InstancedMesh".
  85622. */
  85623. getClassName(): string;
  85624. /** Gets the list of lights affecting that mesh */
  85625. readonly lightSources: Light[];
  85626. _resyncLightSources(): void;
  85627. _resyncLighSource(light: Light): void;
  85628. _removeLightSource(light: Light, dispose: boolean): void;
  85629. /**
  85630. * If the source mesh receives shadows
  85631. */
  85632. readonly receiveShadows: boolean;
  85633. /**
  85634. * The material of the source mesh
  85635. */
  85636. readonly material: Nullable<Material>;
  85637. /**
  85638. * Visibility of the source mesh
  85639. */
  85640. readonly visibility: number;
  85641. /**
  85642. * Skeleton of the source mesh
  85643. */
  85644. readonly skeleton: Nullable<Skeleton>;
  85645. /**
  85646. * Rendering ground id of the source mesh
  85647. */
  85648. renderingGroupId: number;
  85649. /**
  85650. * Returns the total number of vertices (integer).
  85651. */
  85652. getTotalVertices(): number;
  85653. /**
  85654. * Returns a positive integer : the total number of indices in this mesh geometry.
  85655. * @returns the numner of indices or zero if the mesh has no geometry.
  85656. */
  85657. getTotalIndices(): number;
  85658. /**
  85659. * The source mesh of the instance
  85660. */
  85661. readonly sourceMesh: Mesh;
  85662. /**
  85663. * Is this node ready to be used/rendered
  85664. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  85665. * @return {boolean} is it ready
  85666. */
  85667. isReady(completeCheck?: boolean): boolean;
  85668. /**
  85669. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  85670. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  85671. * @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.
  85672. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  85673. */
  85674. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  85675. /**
  85676. * Sets the vertex data of the mesh geometry for the requested `kind`.
  85677. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  85678. * The `data` are either a numeric array either a Float32Array.
  85679. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  85680. * 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).
  85681. * Note that a new underlying VertexBuffer object is created each call.
  85682. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  85683. *
  85684. * Possible `kind` values :
  85685. * - VertexBuffer.PositionKind
  85686. * - VertexBuffer.UVKind
  85687. * - VertexBuffer.UV2Kind
  85688. * - VertexBuffer.UV3Kind
  85689. * - VertexBuffer.UV4Kind
  85690. * - VertexBuffer.UV5Kind
  85691. * - VertexBuffer.UV6Kind
  85692. * - VertexBuffer.ColorKind
  85693. * - VertexBuffer.MatricesIndicesKind
  85694. * - VertexBuffer.MatricesIndicesExtraKind
  85695. * - VertexBuffer.MatricesWeightsKind
  85696. * - VertexBuffer.MatricesWeightsExtraKind
  85697. *
  85698. * Returns the Mesh.
  85699. */
  85700. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  85701. /**
  85702. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  85703. * If the mesh has no geometry, it is simply returned as it is.
  85704. * The `data` are either a numeric array either a Float32Array.
  85705. * No new underlying VertexBuffer object is created.
  85706. * 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.
  85707. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  85708. *
  85709. * Possible `kind` values :
  85710. * - VertexBuffer.PositionKind
  85711. * - VertexBuffer.UVKind
  85712. * - VertexBuffer.UV2Kind
  85713. * - VertexBuffer.UV3Kind
  85714. * - VertexBuffer.UV4Kind
  85715. * - VertexBuffer.UV5Kind
  85716. * - VertexBuffer.UV6Kind
  85717. * - VertexBuffer.ColorKind
  85718. * - VertexBuffer.MatricesIndicesKind
  85719. * - VertexBuffer.MatricesIndicesExtraKind
  85720. * - VertexBuffer.MatricesWeightsKind
  85721. * - VertexBuffer.MatricesWeightsExtraKind
  85722. *
  85723. * Returns the Mesh.
  85724. */
  85725. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  85726. /**
  85727. * Sets the mesh indices.
  85728. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  85729. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  85730. * This method creates a new index buffer each call.
  85731. * Returns the Mesh.
  85732. */
  85733. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  85734. /**
  85735. * Boolean : True if the mesh owns the requested kind of data.
  85736. */
  85737. isVerticesDataPresent(kind: string): boolean;
  85738. /**
  85739. * Returns an array of indices (IndicesArray).
  85740. */
  85741. getIndices(): Nullable<IndicesArray>;
  85742. readonly _positions: Nullable<Vector3[]>;
  85743. /**
  85744. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  85745. * This means the mesh underlying bounding box and sphere are recomputed.
  85746. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  85747. * @returns the current mesh
  85748. */
  85749. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  85750. /** @hidden */
  85751. _preActivate(): InstancedMesh;
  85752. /** @hidden */
  85753. _activate(renderId: number, intermediateRendering: boolean): boolean;
  85754. /** @hidden */
  85755. _postActivate(): void;
  85756. getWorldMatrix(): Matrix;
  85757. readonly isAnInstance: boolean;
  85758. /**
  85759. * Returns the current associated LOD AbstractMesh.
  85760. */
  85761. getLOD(camera: Camera): AbstractMesh;
  85762. /** @hidden */
  85763. _syncSubMeshes(): InstancedMesh;
  85764. /** @hidden */
  85765. _generatePointsArray(): boolean;
  85766. /**
  85767. * Creates a new InstancedMesh from the current mesh.
  85768. * - name (string) : the cloned mesh name
  85769. * - newParent (optional Node) : the optional Node to parent the clone to.
  85770. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  85771. *
  85772. * Returns the clone.
  85773. */
  85774. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  85775. /**
  85776. * Disposes the InstancedMesh.
  85777. * Returns nothing.
  85778. */
  85779. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  85780. }
  85781. }
  85782. declare module BABYLON {
  85783. /**
  85784. * Defines the options associated with the creation of a shader material.
  85785. */
  85786. export interface IShaderMaterialOptions {
  85787. /**
  85788. * Does the material work in alpha blend mode
  85789. */
  85790. needAlphaBlending: boolean;
  85791. /**
  85792. * Does the material work in alpha test mode
  85793. */
  85794. needAlphaTesting: boolean;
  85795. /**
  85796. * The list of attribute names used in the shader
  85797. */
  85798. attributes: string[];
  85799. /**
  85800. * The list of unifrom names used in the shader
  85801. */
  85802. uniforms: string[];
  85803. /**
  85804. * The list of UBO names used in the shader
  85805. */
  85806. uniformBuffers: string[];
  85807. /**
  85808. * The list of sampler names used in the shader
  85809. */
  85810. samplers: string[];
  85811. /**
  85812. * The list of defines used in the shader
  85813. */
  85814. defines: string[];
  85815. }
  85816. /**
  85817. * 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.
  85818. *
  85819. * This returned material effects how the mesh will look based on the code in the shaders.
  85820. *
  85821. * @see http://doc.babylonjs.com/how_to/shader_material
  85822. */
  85823. export class ShaderMaterial extends Material {
  85824. private _shaderPath;
  85825. private _options;
  85826. private _textures;
  85827. private _textureArrays;
  85828. private _floats;
  85829. private _ints;
  85830. private _floatsArrays;
  85831. private _colors3;
  85832. private _colors3Arrays;
  85833. private _colors4;
  85834. private _colors4Arrays;
  85835. private _vectors2;
  85836. private _vectors3;
  85837. private _vectors4;
  85838. private _matrices;
  85839. private _matrices3x3;
  85840. private _matrices2x2;
  85841. private _vectors2Arrays;
  85842. private _vectors3Arrays;
  85843. private _vectors4Arrays;
  85844. private _cachedWorldViewMatrix;
  85845. private _cachedWorldViewProjectionMatrix;
  85846. private _renderId;
  85847. /**
  85848. * Instantiate a new shader material.
  85849. * 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.
  85850. * This returned material effects how the mesh will look based on the code in the shaders.
  85851. * @see http://doc.babylonjs.com/how_to/shader_material
  85852. * @param name Define the name of the material in the scene
  85853. * @param scene Define the scene the material belongs to
  85854. * @param shaderPath Defines the route to the shader code in one of three ways:
  85855. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  85856. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  85857. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  85858. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  85859. * @param options Define the options used to create the shader
  85860. */
  85861. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  85862. /**
  85863. * Gets the options used to compile the shader.
  85864. * They can be modified to trigger a new compilation
  85865. */
  85866. readonly options: IShaderMaterialOptions;
  85867. /**
  85868. * Gets the current class name of the material e.g. "ShaderMaterial"
  85869. * Mainly use in serialization.
  85870. * @returns the class name
  85871. */
  85872. getClassName(): string;
  85873. /**
  85874. * Specifies if the material will require alpha blending
  85875. * @returns a boolean specifying if alpha blending is needed
  85876. */
  85877. needAlphaBlending(): boolean;
  85878. /**
  85879. * Specifies if this material should be rendered in alpha test mode
  85880. * @returns a boolean specifying if an alpha test is needed.
  85881. */
  85882. needAlphaTesting(): boolean;
  85883. private _checkUniform;
  85884. /**
  85885. * Set a texture in the shader.
  85886. * @param name Define the name of the uniform samplers as defined in the shader
  85887. * @param texture Define the texture to bind to this sampler
  85888. * @return the material itself allowing "fluent" like uniform updates
  85889. */
  85890. setTexture(name: string, texture: Texture): ShaderMaterial;
  85891. /**
  85892. * Set a texture array in the shader.
  85893. * @param name Define the name of the uniform sampler array as defined in the shader
  85894. * @param textures Define the list of textures to bind to this sampler
  85895. * @return the material itself allowing "fluent" like uniform updates
  85896. */
  85897. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  85898. /**
  85899. * Set a float in the shader.
  85900. * @param name Define the name of the uniform as defined in the shader
  85901. * @param value Define the value to give to the uniform
  85902. * @return the material itself allowing "fluent" like uniform updates
  85903. */
  85904. setFloat(name: string, value: number): ShaderMaterial;
  85905. /**
  85906. * Set a int in the shader.
  85907. * @param name Define the name of the uniform as defined in the shader
  85908. * @param value Define the value to give to the uniform
  85909. * @return the material itself allowing "fluent" like uniform updates
  85910. */
  85911. setInt(name: string, value: number): ShaderMaterial;
  85912. /**
  85913. * Set an array of floats in the shader.
  85914. * @param name Define the name of the uniform as defined in the shader
  85915. * @param value Define the value to give to the uniform
  85916. * @return the material itself allowing "fluent" like uniform updates
  85917. */
  85918. setFloats(name: string, value: number[]): ShaderMaterial;
  85919. /**
  85920. * Set a vec3 in the shader from a Color3.
  85921. * @param name Define the name of the uniform as defined in the shader
  85922. * @param value Define the value to give to the uniform
  85923. * @return the material itself allowing "fluent" like uniform updates
  85924. */
  85925. setColor3(name: string, value: Color3): ShaderMaterial;
  85926. /**
  85927. * Set a vec3 array in the shader from a Color3 array.
  85928. * @param name Define the name of the uniform as defined in the shader
  85929. * @param value Define the value to give to the uniform
  85930. * @return the material itself allowing "fluent" like uniform updates
  85931. */
  85932. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  85933. /**
  85934. * Set a vec4 in the shader from a Color4.
  85935. * @param name Define the name of the uniform as defined in the shader
  85936. * @param value Define the value to give to the uniform
  85937. * @return the material itself allowing "fluent" like uniform updates
  85938. */
  85939. setColor4(name: string, value: Color4): ShaderMaterial;
  85940. /**
  85941. * Set a vec4 array in the shader from a Color4 array.
  85942. * @param name Define the name of the uniform as defined in the shader
  85943. * @param value Define the value to give to the uniform
  85944. * @return the material itself allowing "fluent" like uniform updates
  85945. */
  85946. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  85947. /**
  85948. * Set a vec2 in the shader from a Vector2.
  85949. * @param name Define the name of the uniform as defined in the shader
  85950. * @param value Define the value to give to the uniform
  85951. * @return the material itself allowing "fluent" like uniform updates
  85952. */
  85953. setVector2(name: string, value: Vector2): ShaderMaterial;
  85954. /**
  85955. * Set a vec3 in the shader from a Vector3.
  85956. * @param name Define the name of the uniform as defined in the shader
  85957. * @param value Define the value to give to the uniform
  85958. * @return the material itself allowing "fluent" like uniform updates
  85959. */
  85960. setVector3(name: string, value: Vector3): ShaderMaterial;
  85961. /**
  85962. * Set a vec4 in the shader from a Vector4.
  85963. * @param name Define the name of the uniform as defined in the shader
  85964. * @param value Define the value to give to the uniform
  85965. * @return the material itself allowing "fluent" like uniform updates
  85966. */
  85967. setVector4(name: string, value: Vector4): ShaderMaterial;
  85968. /**
  85969. * Set a mat4 in the shader from a Matrix.
  85970. * @param name Define the name of the uniform as defined in the shader
  85971. * @param value Define the value to give to the uniform
  85972. * @return the material itself allowing "fluent" like uniform updates
  85973. */
  85974. setMatrix(name: string, value: Matrix): ShaderMaterial;
  85975. /**
  85976. * Set a mat3 in the shader from a Float32Array.
  85977. * @param name Define the name of the uniform as defined in the shader
  85978. * @param value Define the value to give to the uniform
  85979. * @return the material itself allowing "fluent" like uniform updates
  85980. */
  85981. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  85982. /**
  85983. * Set a mat2 in the shader from a Float32Array.
  85984. * @param name Define the name of the uniform as defined in the shader
  85985. * @param value Define the value to give to the uniform
  85986. * @return the material itself allowing "fluent" like uniform updates
  85987. */
  85988. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  85989. /**
  85990. * Set a vec2 array in the shader from a number array.
  85991. * @param name Define the name of the uniform as defined in the shader
  85992. * @param value Define the value to give to the uniform
  85993. * @return the material itself allowing "fluent" like uniform updates
  85994. */
  85995. setArray2(name: string, value: number[]): ShaderMaterial;
  85996. /**
  85997. * Set a vec3 array in the shader from a number array.
  85998. * @param name Define the name of the uniform as defined in the shader
  85999. * @param value Define the value to give to the uniform
  86000. * @return the material itself allowing "fluent" like uniform updates
  86001. */
  86002. setArray3(name: string, value: number[]): ShaderMaterial;
  86003. /**
  86004. * Set a vec4 array in the shader from a number array.
  86005. * @param name Define the name of the uniform as defined in the shader
  86006. * @param value Define the value to give to the uniform
  86007. * @return the material itself allowing "fluent" like uniform updates
  86008. */
  86009. setArray4(name: string, value: number[]): ShaderMaterial;
  86010. private _checkCache;
  86011. /**
  86012. * Specifies that the submesh is ready to be used
  86013. * @param mesh defines the mesh to check
  86014. * @param subMesh defines which submesh to check
  86015. * @param useInstances specifies that instances should be used
  86016. * @returns a boolean indicating that the submesh is ready or not
  86017. */
  86018. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  86019. /**
  86020. * Checks if the material is ready to render the requested mesh
  86021. * @param mesh Define the mesh to render
  86022. * @param useInstances Define whether or not the material is used with instances
  86023. * @returns true if ready, otherwise false
  86024. */
  86025. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  86026. /**
  86027. * Binds the world matrix to the material
  86028. * @param world defines the world transformation matrix
  86029. */
  86030. bindOnlyWorldMatrix(world: Matrix): void;
  86031. /**
  86032. * Binds the material to the mesh
  86033. * @param world defines the world transformation matrix
  86034. * @param mesh defines the mesh to bind the material to
  86035. */
  86036. bind(world: Matrix, mesh?: Mesh): void;
  86037. /**
  86038. * Gets the active textures from the material
  86039. * @returns an array of textures
  86040. */
  86041. getActiveTextures(): BaseTexture[];
  86042. /**
  86043. * Specifies if the material uses a texture
  86044. * @param texture defines the texture to check against the material
  86045. * @returns a boolean specifying if the material uses the texture
  86046. */
  86047. hasTexture(texture: BaseTexture): boolean;
  86048. /**
  86049. * Makes a duplicate of the material, and gives it a new name
  86050. * @param name defines the new name for the duplicated material
  86051. * @returns the cloned material
  86052. */
  86053. clone(name: string): ShaderMaterial;
  86054. /**
  86055. * Disposes the material
  86056. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  86057. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  86058. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  86059. */
  86060. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  86061. /**
  86062. * Serializes this material in a JSON representation
  86063. * @returns the serialized material object
  86064. */
  86065. serialize(): any;
  86066. /**
  86067. * Creates a shader material from parsed shader material data
  86068. * @param source defines the JSON represnetation of the material
  86069. * @param scene defines the hosting scene
  86070. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  86071. * @returns a new material
  86072. */
  86073. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  86074. }
  86075. }
  86076. declare module BABYLON {
  86077. /** @hidden */
  86078. export var colorPixelShader: {
  86079. name: string;
  86080. shader: string;
  86081. };
  86082. }
  86083. declare module BABYLON {
  86084. /** @hidden */
  86085. export var colorVertexShader: {
  86086. name: string;
  86087. shader: string;
  86088. };
  86089. }
  86090. declare module BABYLON {
  86091. /**
  86092. * Line mesh
  86093. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  86094. */
  86095. export class LinesMesh extends Mesh {
  86096. /**
  86097. * If vertex color should be applied to the mesh
  86098. */
  86099. readonly useVertexColor?: boolean | undefined;
  86100. /**
  86101. * If vertex alpha should be applied to the mesh
  86102. */
  86103. readonly useVertexAlpha?: boolean | undefined;
  86104. /**
  86105. * Color of the line (Default: White)
  86106. */
  86107. color: Color3;
  86108. /**
  86109. * Alpha of the line (Default: 1)
  86110. */
  86111. alpha: number;
  86112. /**
  86113. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  86114. * This margin is expressed in world space coordinates, so its value may vary.
  86115. * Default value is 0.1
  86116. */
  86117. intersectionThreshold: number;
  86118. private _colorShader;
  86119. private color4;
  86120. /**
  86121. * Creates a new LinesMesh
  86122. * @param name defines the name
  86123. * @param scene defines the hosting scene
  86124. * @param parent defines the parent mesh if any
  86125. * @param source defines the optional source LinesMesh used to clone data from
  86126. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  86127. * When false, achieved by calling a clone(), also passing False.
  86128. * This will make creation of children, recursive.
  86129. * @param useVertexColor defines if this LinesMesh supports vertex color
  86130. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  86131. */
  86132. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  86133. /**
  86134. * If vertex color should be applied to the mesh
  86135. */
  86136. useVertexColor?: boolean | undefined,
  86137. /**
  86138. * If vertex alpha should be applied to the mesh
  86139. */
  86140. useVertexAlpha?: boolean | undefined);
  86141. private _addClipPlaneDefine;
  86142. private _removeClipPlaneDefine;
  86143. isReady(): boolean;
  86144. /**
  86145. * Returns the string "LineMesh"
  86146. */
  86147. getClassName(): string;
  86148. /**
  86149. * @hidden
  86150. */
  86151. /**
  86152. * @hidden
  86153. */
  86154. material: Material;
  86155. /**
  86156. * @hidden
  86157. */
  86158. readonly checkCollisions: boolean;
  86159. /** @hidden */
  86160. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  86161. /** @hidden */
  86162. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  86163. /**
  86164. * Disposes of the line mesh
  86165. * @param doNotRecurse If children should be disposed
  86166. */
  86167. dispose(doNotRecurse?: boolean): void;
  86168. /**
  86169. * Returns a new LineMesh object cloned from the current one.
  86170. */
  86171. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  86172. /**
  86173. * Creates a new InstancedLinesMesh object from the mesh model.
  86174. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  86175. * @param name defines the name of the new instance
  86176. * @returns a new InstancedLinesMesh
  86177. */
  86178. createInstance(name: string): InstancedLinesMesh;
  86179. }
  86180. /**
  86181. * Creates an instance based on a source LinesMesh
  86182. */
  86183. export class InstancedLinesMesh extends InstancedMesh {
  86184. /**
  86185. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  86186. * This margin is expressed in world space coordinates, so its value may vary.
  86187. * Initilized with the intersectionThreshold value of the source LinesMesh
  86188. */
  86189. intersectionThreshold: number;
  86190. constructor(name: string, source: LinesMesh);
  86191. /**
  86192. * Returns the string "InstancedLinesMesh".
  86193. */
  86194. getClassName(): string;
  86195. }
  86196. }
  86197. declare module BABYLON {
  86198. /** @hidden */
  86199. export var linePixelShader: {
  86200. name: string;
  86201. shader: string;
  86202. };
  86203. }
  86204. declare module BABYLON {
  86205. /** @hidden */
  86206. export var lineVertexShader: {
  86207. name: string;
  86208. shader: string;
  86209. };
  86210. }
  86211. declare module BABYLON {
  86212. interface AbstractMesh {
  86213. /**
  86214. * Gets the edgesRenderer associated with the mesh
  86215. */
  86216. edgesRenderer: Nullable<EdgesRenderer>;
  86217. }
  86218. interface LinesMesh {
  86219. /**
  86220. * Enables the edge rendering mode on the mesh.
  86221. * This mode makes the mesh edges visible
  86222. * @param epsilon defines the maximal distance between two angles to detect a face
  86223. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  86224. * @returns the currentAbstractMesh
  86225. * @see https://www.babylonjs-playground.com/#19O9TU#0
  86226. */
  86227. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  86228. }
  86229. interface InstancedLinesMesh {
  86230. /**
  86231. * Enables the edge rendering mode on the mesh.
  86232. * This mode makes the mesh edges visible
  86233. * @param epsilon defines the maximal distance between two angles to detect a face
  86234. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  86235. * @returns the current InstancedLinesMesh
  86236. * @see https://www.babylonjs-playground.com/#19O9TU#0
  86237. */
  86238. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  86239. }
  86240. /**
  86241. * Defines the minimum contract an Edges renderer should follow.
  86242. */
  86243. export interface IEdgesRenderer extends IDisposable {
  86244. /**
  86245. * Gets or sets a boolean indicating if the edgesRenderer is active
  86246. */
  86247. isEnabled: boolean;
  86248. /**
  86249. * Renders the edges of the attached mesh,
  86250. */
  86251. render(): void;
  86252. /**
  86253. * Checks wether or not the edges renderer is ready to render.
  86254. * @return true if ready, otherwise false.
  86255. */
  86256. isReady(): boolean;
  86257. }
  86258. /**
  86259. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  86260. */
  86261. export class EdgesRenderer implements IEdgesRenderer {
  86262. /**
  86263. * Define the size of the edges with an orthographic camera
  86264. */
  86265. edgesWidthScalerForOrthographic: number;
  86266. /**
  86267. * Define the size of the edges with a perspective camera
  86268. */
  86269. edgesWidthScalerForPerspective: number;
  86270. protected _source: AbstractMesh;
  86271. protected _linesPositions: number[];
  86272. protected _linesNormals: number[];
  86273. protected _linesIndices: number[];
  86274. protected _epsilon: number;
  86275. protected _indicesCount: number;
  86276. protected _lineShader: ShaderMaterial;
  86277. protected _ib: DataBuffer;
  86278. protected _buffers: {
  86279. [key: string]: Nullable<VertexBuffer>;
  86280. };
  86281. protected _checkVerticesInsteadOfIndices: boolean;
  86282. private _meshRebuildObserver;
  86283. private _meshDisposeObserver;
  86284. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  86285. isEnabled: boolean;
  86286. /**
  86287. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  86288. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  86289. * @param source Mesh used to create edges
  86290. * @param epsilon sum of angles in adjacency to check for edge
  86291. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  86292. * @param generateEdgesLines - should generate Lines or only prepare resources.
  86293. */
  86294. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  86295. protected _prepareRessources(): void;
  86296. /** @hidden */
  86297. _rebuild(): void;
  86298. /**
  86299. * Releases the required resources for the edges renderer
  86300. */
  86301. dispose(): void;
  86302. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  86303. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  86304. /**
  86305. * Checks if the pair of p0 and p1 is en edge
  86306. * @param faceIndex
  86307. * @param edge
  86308. * @param faceNormals
  86309. * @param p0
  86310. * @param p1
  86311. * @private
  86312. */
  86313. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  86314. /**
  86315. * push line into the position, normal and index buffer
  86316. * @protected
  86317. */
  86318. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  86319. /**
  86320. * Generates lines edges from adjacencjes
  86321. * @private
  86322. */
  86323. _generateEdgesLines(): void;
  86324. /**
  86325. * Checks wether or not the edges renderer is ready to render.
  86326. * @return true if ready, otherwise false.
  86327. */
  86328. isReady(): boolean;
  86329. /**
  86330. * Renders the edges of the attached mesh,
  86331. */
  86332. render(): void;
  86333. }
  86334. /**
  86335. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  86336. */
  86337. export class LineEdgesRenderer extends EdgesRenderer {
  86338. /**
  86339. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  86340. * @param source LineMesh used to generate edges
  86341. * @param epsilon not important (specified angle for edge detection)
  86342. * @param checkVerticesInsteadOfIndices not important for LineMesh
  86343. */
  86344. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  86345. /**
  86346. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  86347. */
  86348. _generateEdgesLines(): void;
  86349. }
  86350. }
  86351. declare module BABYLON {
  86352. /**
  86353. * This represents the object necessary to create a rendering group.
  86354. * This is exclusively used and created by the rendering manager.
  86355. * To modify the behavior, you use the available helpers in your scene or meshes.
  86356. * @hidden
  86357. */
  86358. export class RenderingGroup {
  86359. index: number;
  86360. private static _zeroVector;
  86361. private _scene;
  86362. private _opaqueSubMeshes;
  86363. private _transparentSubMeshes;
  86364. private _alphaTestSubMeshes;
  86365. private _depthOnlySubMeshes;
  86366. private _particleSystems;
  86367. private _spriteManagers;
  86368. private _opaqueSortCompareFn;
  86369. private _alphaTestSortCompareFn;
  86370. private _transparentSortCompareFn;
  86371. private _renderOpaque;
  86372. private _renderAlphaTest;
  86373. private _renderTransparent;
  86374. /** @hidden */
  86375. _edgesRenderers: SmartArray<IEdgesRenderer>;
  86376. onBeforeTransparentRendering: () => void;
  86377. /**
  86378. * Set the opaque sort comparison function.
  86379. * If null the sub meshes will be render in the order they were created
  86380. */
  86381. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  86382. /**
  86383. * Set the alpha test sort comparison function.
  86384. * If null the sub meshes will be render in the order they were created
  86385. */
  86386. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  86387. /**
  86388. * Set the transparent sort comparison function.
  86389. * If null the sub meshes will be render in the order they were created
  86390. */
  86391. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  86392. /**
  86393. * Creates a new rendering group.
  86394. * @param index The rendering group index
  86395. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  86396. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  86397. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  86398. */
  86399. 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>);
  86400. /**
  86401. * Render all the sub meshes contained in the group.
  86402. * @param customRenderFunction Used to override the default render behaviour of the group.
  86403. * @returns true if rendered some submeshes.
  86404. */
  86405. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  86406. /**
  86407. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  86408. * @param subMeshes The submeshes to render
  86409. */
  86410. private renderOpaqueSorted;
  86411. /**
  86412. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  86413. * @param subMeshes The submeshes to render
  86414. */
  86415. private renderAlphaTestSorted;
  86416. /**
  86417. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  86418. * @param subMeshes The submeshes to render
  86419. */
  86420. private renderTransparentSorted;
  86421. /**
  86422. * Renders the submeshes in a specified order.
  86423. * @param subMeshes The submeshes to sort before render
  86424. * @param sortCompareFn The comparison function use to sort
  86425. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  86426. * @param transparent Specifies to activate blending if true
  86427. */
  86428. private static renderSorted;
  86429. /**
  86430. * Renders the submeshes in the order they were dispatched (no sort applied).
  86431. * @param subMeshes The submeshes to render
  86432. */
  86433. private static renderUnsorted;
  86434. /**
  86435. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  86436. * are rendered back to front if in the same alpha index.
  86437. *
  86438. * @param a The first submesh
  86439. * @param b The second submesh
  86440. * @returns The result of the comparison
  86441. */
  86442. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  86443. /**
  86444. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  86445. * are rendered back to front.
  86446. *
  86447. * @param a The first submesh
  86448. * @param b The second submesh
  86449. * @returns The result of the comparison
  86450. */
  86451. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  86452. /**
  86453. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  86454. * are rendered front to back (prevent overdraw).
  86455. *
  86456. * @param a The first submesh
  86457. * @param b The second submesh
  86458. * @returns The result of the comparison
  86459. */
  86460. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  86461. /**
  86462. * Resets the different lists of submeshes to prepare a new frame.
  86463. */
  86464. prepare(): void;
  86465. dispose(): void;
  86466. /**
  86467. * Inserts the submesh in its correct queue depending on its material.
  86468. * @param subMesh The submesh to dispatch
  86469. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  86470. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  86471. */
  86472. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  86473. dispatchSprites(spriteManager: ISpriteManager): void;
  86474. dispatchParticles(particleSystem: IParticleSystem): void;
  86475. private _renderParticles;
  86476. private _renderSprites;
  86477. }
  86478. }
  86479. declare module BABYLON {
  86480. /**
  86481. * Interface describing the different options available in the rendering manager
  86482. * regarding Auto Clear between groups.
  86483. */
  86484. export interface IRenderingManagerAutoClearSetup {
  86485. /**
  86486. * Defines whether or not autoclear is enable.
  86487. */
  86488. autoClear: boolean;
  86489. /**
  86490. * Defines whether or not to autoclear the depth buffer.
  86491. */
  86492. depth: boolean;
  86493. /**
  86494. * Defines whether or not to autoclear the stencil buffer.
  86495. */
  86496. stencil: boolean;
  86497. }
  86498. /**
  86499. * This class is used by the onRenderingGroupObservable
  86500. */
  86501. export class RenderingGroupInfo {
  86502. /**
  86503. * The Scene that being rendered
  86504. */
  86505. scene: Scene;
  86506. /**
  86507. * The camera currently used for the rendering pass
  86508. */
  86509. camera: Nullable<Camera>;
  86510. /**
  86511. * The ID of the renderingGroup being processed
  86512. */
  86513. renderingGroupId: number;
  86514. }
  86515. /**
  86516. * This is the manager responsible of all the rendering for meshes sprites and particles.
  86517. * It is enable to manage the different groups as well as the different necessary sort functions.
  86518. * This should not be used directly aside of the few static configurations
  86519. */
  86520. export class RenderingManager {
  86521. /**
  86522. * The max id used for rendering groups (not included)
  86523. */
  86524. static MAX_RENDERINGGROUPS: number;
  86525. /**
  86526. * The min id used for rendering groups (included)
  86527. */
  86528. static MIN_RENDERINGGROUPS: number;
  86529. /**
  86530. * Used to globally prevent autoclearing scenes.
  86531. */
  86532. static AUTOCLEAR: boolean;
  86533. /**
  86534. * @hidden
  86535. */
  86536. _useSceneAutoClearSetup: boolean;
  86537. private _scene;
  86538. private _renderingGroups;
  86539. private _depthStencilBufferAlreadyCleaned;
  86540. private _autoClearDepthStencil;
  86541. private _customOpaqueSortCompareFn;
  86542. private _customAlphaTestSortCompareFn;
  86543. private _customTransparentSortCompareFn;
  86544. private _renderingGroupInfo;
  86545. /**
  86546. * Instantiates a new rendering group for a particular scene
  86547. * @param scene Defines the scene the groups belongs to
  86548. */
  86549. constructor(scene: Scene);
  86550. private _clearDepthStencilBuffer;
  86551. /**
  86552. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  86553. * @hidden
  86554. */
  86555. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  86556. /**
  86557. * Resets the different information of the group to prepare a new frame
  86558. * @hidden
  86559. */
  86560. reset(): void;
  86561. /**
  86562. * Dispose and release the group and its associated resources.
  86563. * @hidden
  86564. */
  86565. dispose(): void;
  86566. /**
  86567. * Clear the info related to rendering groups preventing retention points during dispose.
  86568. */
  86569. freeRenderingGroups(): void;
  86570. private _prepareRenderingGroup;
  86571. /**
  86572. * Add a sprite manager to the rendering manager in order to render it this frame.
  86573. * @param spriteManager Define the sprite manager to render
  86574. */
  86575. dispatchSprites(spriteManager: ISpriteManager): void;
  86576. /**
  86577. * Add a particle system to the rendering manager in order to render it this frame.
  86578. * @param particleSystem Define the particle system to render
  86579. */
  86580. dispatchParticles(particleSystem: IParticleSystem): void;
  86581. /**
  86582. * Add a submesh to the manager in order to render it this frame
  86583. * @param subMesh The submesh to dispatch
  86584. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  86585. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  86586. */
  86587. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  86588. /**
  86589. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  86590. * This allowed control for front to back rendering or reversly depending of the special needs.
  86591. *
  86592. * @param renderingGroupId The rendering group id corresponding to its index
  86593. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  86594. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  86595. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  86596. */
  86597. 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;
  86598. /**
  86599. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  86600. *
  86601. * @param renderingGroupId The rendering group id corresponding to its index
  86602. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  86603. * @param depth Automatically clears depth between groups if true and autoClear is true.
  86604. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  86605. */
  86606. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  86607. /**
  86608. * Gets the current auto clear configuration for one rendering group of the rendering
  86609. * manager.
  86610. * @param index the rendering group index to get the information for
  86611. * @returns The auto clear setup for the requested rendering group
  86612. */
  86613. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  86614. }
  86615. }
  86616. declare module BABYLON {
  86617. /**
  86618. * This Helps creating a texture that will be created from a camera in your scene.
  86619. * It is basically a dynamic texture that could be used to create special effects for instance.
  86620. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  86621. */
  86622. export class RenderTargetTexture extends Texture {
  86623. isCube: boolean;
  86624. /**
  86625. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  86626. */
  86627. static readonly REFRESHRATE_RENDER_ONCE: number;
  86628. /**
  86629. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  86630. */
  86631. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  86632. /**
  86633. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  86634. * the central point of your effect and can save a lot of performances.
  86635. */
  86636. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  86637. /**
  86638. * Use this predicate to dynamically define the list of mesh you want to render.
  86639. * If set, the renderList property will be overwritten.
  86640. */
  86641. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  86642. private _renderList;
  86643. /**
  86644. * Use this list to define the list of mesh you want to render.
  86645. */
  86646. renderList: Nullable<Array<AbstractMesh>>;
  86647. private _hookArray;
  86648. /**
  86649. * Define if particles should be rendered in your texture.
  86650. */
  86651. renderParticles: boolean;
  86652. /**
  86653. * Define if sprites should be rendered in your texture.
  86654. */
  86655. renderSprites: boolean;
  86656. /**
  86657. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  86658. */
  86659. coordinatesMode: number;
  86660. /**
  86661. * Define the camera used to render the texture.
  86662. */
  86663. activeCamera: Nullable<Camera>;
  86664. /**
  86665. * Override the render function of the texture with your own one.
  86666. */
  86667. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  86668. /**
  86669. * Define if camera post processes should be use while rendering the texture.
  86670. */
  86671. useCameraPostProcesses: boolean;
  86672. /**
  86673. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  86674. */
  86675. ignoreCameraViewport: boolean;
  86676. private _postProcessManager;
  86677. private _postProcesses;
  86678. private _resizeObserver;
  86679. /**
  86680. * An event triggered when the texture is unbind.
  86681. */
  86682. onBeforeBindObservable: Observable<RenderTargetTexture>;
  86683. /**
  86684. * An event triggered when the texture is unbind.
  86685. */
  86686. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  86687. private _onAfterUnbindObserver;
  86688. /**
  86689. * Set a after unbind callback in the texture.
  86690. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  86691. */
  86692. onAfterUnbind: () => void;
  86693. /**
  86694. * An event triggered before rendering the texture
  86695. */
  86696. onBeforeRenderObservable: Observable<number>;
  86697. private _onBeforeRenderObserver;
  86698. /**
  86699. * Set a before render callback in the texture.
  86700. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  86701. */
  86702. onBeforeRender: (faceIndex: number) => void;
  86703. /**
  86704. * An event triggered after rendering the texture
  86705. */
  86706. onAfterRenderObservable: Observable<number>;
  86707. private _onAfterRenderObserver;
  86708. /**
  86709. * Set a after render callback in the texture.
  86710. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  86711. */
  86712. onAfterRender: (faceIndex: number) => void;
  86713. /**
  86714. * An event triggered after the texture clear
  86715. */
  86716. onClearObservable: Observable<Engine>;
  86717. private _onClearObserver;
  86718. /**
  86719. * Set a clear callback in the texture.
  86720. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  86721. */
  86722. onClear: (Engine: Engine) => void;
  86723. /**
  86724. * An event triggered when the texture is resized.
  86725. */
  86726. onResizeObservable: Observable<RenderTargetTexture>;
  86727. /**
  86728. * Define the clear color of the Render Target if it should be different from the scene.
  86729. */
  86730. clearColor: Color4;
  86731. protected _size: number | {
  86732. width: number;
  86733. height: number;
  86734. };
  86735. protected _initialSizeParameter: number | {
  86736. width: number;
  86737. height: number;
  86738. } | {
  86739. ratio: number;
  86740. };
  86741. protected _sizeRatio: Nullable<number>;
  86742. /** @hidden */
  86743. _generateMipMaps: boolean;
  86744. protected _renderingManager: RenderingManager;
  86745. /** @hidden */
  86746. _waitingRenderList: string[];
  86747. protected _doNotChangeAspectRatio: boolean;
  86748. protected _currentRefreshId: number;
  86749. protected _refreshRate: number;
  86750. protected _textureMatrix: Matrix;
  86751. protected _samples: number;
  86752. protected _renderTargetOptions: RenderTargetCreationOptions;
  86753. /**
  86754. * Gets render target creation options that were used.
  86755. */
  86756. readonly renderTargetOptions: RenderTargetCreationOptions;
  86757. protected _engine: Engine;
  86758. protected _onRatioRescale(): void;
  86759. /**
  86760. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  86761. * It must define where the camera used to render the texture is set
  86762. */
  86763. boundingBoxPosition: Vector3;
  86764. private _boundingBoxSize;
  86765. /**
  86766. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  86767. * When defined, the cubemap will switch to local mode
  86768. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  86769. * @example https://www.babylonjs-playground.com/#RNASML
  86770. */
  86771. boundingBoxSize: Vector3;
  86772. /**
  86773. * In case the RTT has been created with a depth texture, get the associated
  86774. * depth texture.
  86775. * Otherwise, return null.
  86776. */
  86777. depthStencilTexture: Nullable<InternalTexture>;
  86778. /**
  86779. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  86780. * or used a shadow, depth texture...
  86781. * @param name The friendly name of the texture
  86782. * @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)
  86783. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  86784. * @param generateMipMaps True if mip maps need to be generated after render.
  86785. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  86786. * @param type The type of the buffer in the RTT (int, half float, float...)
  86787. * @param isCube True if a cube texture needs to be created
  86788. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  86789. * @param generateDepthBuffer True to generate a depth buffer
  86790. * @param generateStencilBuffer True to generate a stencil buffer
  86791. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  86792. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  86793. * @param delayAllocation if the texture allocation should be delayed (default: false)
  86794. */
  86795. constructor(name: string, size: number | {
  86796. width: number;
  86797. height: number;
  86798. } | {
  86799. ratio: number;
  86800. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  86801. /**
  86802. * Creates a depth stencil texture.
  86803. * This is only available in WebGL 2 or with the depth texture extension available.
  86804. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  86805. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  86806. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  86807. */
  86808. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  86809. private _processSizeParameter;
  86810. /**
  86811. * Define the number of samples to use in case of MSAA.
  86812. * It defaults to one meaning no MSAA has been enabled.
  86813. */
  86814. samples: number;
  86815. /**
  86816. * Resets the refresh counter of the texture and start bak from scratch.
  86817. * Could be useful to regenerate the texture if it is setup to render only once.
  86818. */
  86819. resetRefreshCounter(): void;
  86820. /**
  86821. * Define the refresh rate of the texture or the rendering frequency.
  86822. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  86823. */
  86824. refreshRate: number;
  86825. /**
  86826. * Adds a post process to the render target rendering passes.
  86827. * @param postProcess define the post process to add
  86828. */
  86829. addPostProcess(postProcess: PostProcess): void;
  86830. /**
  86831. * Clear all the post processes attached to the render target
  86832. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  86833. */
  86834. clearPostProcesses(dispose?: boolean): void;
  86835. /**
  86836. * Remove one of the post process from the list of attached post processes to the texture
  86837. * @param postProcess define the post process to remove from the list
  86838. */
  86839. removePostProcess(postProcess: PostProcess): void;
  86840. /** @hidden */
  86841. _shouldRender(): boolean;
  86842. /**
  86843. * Gets the actual render size of the texture.
  86844. * @returns the width of the render size
  86845. */
  86846. getRenderSize(): number;
  86847. /**
  86848. * Gets the actual render width of the texture.
  86849. * @returns the width of the render size
  86850. */
  86851. getRenderWidth(): number;
  86852. /**
  86853. * Gets the actual render height of the texture.
  86854. * @returns the height of the render size
  86855. */
  86856. getRenderHeight(): number;
  86857. /**
  86858. * Get if the texture can be rescaled or not.
  86859. */
  86860. readonly canRescale: boolean;
  86861. /**
  86862. * Resize the texture using a ratio.
  86863. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  86864. */
  86865. scale(ratio: number): void;
  86866. /**
  86867. * Get the texture reflection matrix used to rotate/transform the reflection.
  86868. * @returns the reflection matrix
  86869. */
  86870. getReflectionTextureMatrix(): Matrix;
  86871. /**
  86872. * Resize the texture to a new desired size.
  86873. * Be carrefull as it will recreate all the data in the new texture.
  86874. * @param size Define the new size. It can be:
  86875. * - a number for squared texture,
  86876. * - an object containing { width: number, height: number }
  86877. * - or an object containing a ratio { ratio: number }
  86878. */
  86879. resize(size: number | {
  86880. width: number;
  86881. height: number;
  86882. } | {
  86883. ratio: number;
  86884. }): void;
  86885. /**
  86886. * Renders all the objects from the render list into the texture.
  86887. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  86888. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  86889. */
  86890. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  86891. private _bestReflectionRenderTargetDimension;
  86892. /**
  86893. * @hidden
  86894. * @param faceIndex face index to bind to if this is a cubetexture
  86895. */
  86896. _bindFrameBuffer(faceIndex?: number): void;
  86897. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  86898. private renderToTarget;
  86899. /**
  86900. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  86901. * This allowed control for front to back rendering or reversly depending of the special needs.
  86902. *
  86903. * @param renderingGroupId The rendering group id corresponding to its index
  86904. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  86905. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  86906. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  86907. */
  86908. 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;
  86909. /**
  86910. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  86911. *
  86912. * @param renderingGroupId The rendering group id corresponding to its index
  86913. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  86914. */
  86915. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  86916. /**
  86917. * Clones the texture.
  86918. * @returns the cloned texture
  86919. */
  86920. clone(): RenderTargetTexture;
  86921. /**
  86922. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  86923. * @returns The JSON representation of the texture
  86924. */
  86925. serialize(): any;
  86926. /**
  86927. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  86928. */
  86929. disposeFramebufferObjects(): void;
  86930. /**
  86931. * Dispose the texture and release its associated resources.
  86932. */
  86933. dispose(): void;
  86934. /** @hidden */
  86935. _rebuild(): void;
  86936. /**
  86937. * Clear the info related to rendering groups preventing retention point in material dispose.
  86938. */
  86939. freeRenderingGroups(): void;
  86940. /**
  86941. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  86942. * @returns the view count
  86943. */
  86944. getViewCount(): number;
  86945. }
  86946. }
  86947. declare module BABYLON {
  86948. /**
  86949. * Base class for the main features of a material in Babylon.js
  86950. */
  86951. export class Material implements IAnimatable {
  86952. /**
  86953. * Returns the triangle fill mode
  86954. */
  86955. static readonly TriangleFillMode: number;
  86956. /**
  86957. * Returns the wireframe mode
  86958. */
  86959. static readonly WireFrameFillMode: number;
  86960. /**
  86961. * Returns the point fill mode
  86962. */
  86963. static readonly PointFillMode: number;
  86964. /**
  86965. * Returns the point list draw mode
  86966. */
  86967. static readonly PointListDrawMode: number;
  86968. /**
  86969. * Returns the line list draw mode
  86970. */
  86971. static readonly LineListDrawMode: number;
  86972. /**
  86973. * Returns the line loop draw mode
  86974. */
  86975. static readonly LineLoopDrawMode: number;
  86976. /**
  86977. * Returns the line strip draw mode
  86978. */
  86979. static readonly LineStripDrawMode: number;
  86980. /**
  86981. * Returns the triangle strip draw mode
  86982. */
  86983. static readonly TriangleStripDrawMode: number;
  86984. /**
  86985. * Returns the triangle fan draw mode
  86986. */
  86987. static readonly TriangleFanDrawMode: number;
  86988. /**
  86989. * Stores the clock-wise side orientation
  86990. */
  86991. static readonly ClockWiseSideOrientation: number;
  86992. /**
  86993. * Stores the counter clock-wise side orientation
  86994. */
  86995. static readonly CounterClockWiseSideOrientation: number;
  86996. /**
  86997. * The dirty texture flag value
  86998. */
  86999. static readonly TextureDirtyFlag: number;
  87000. /**
  87001. * The dirty light flag value
  87002. */
  87003. static readonly LightDirtyFlag: number;
  87004. /**
  87005. * The dirty fresnel flag value
  87006. */
  87007. static readonly FresnelDirtyFlag: number;
  87008. /**
  87009. * The dirty attribute flag value
  87010. */
  87011. static readonly AttributesDirtyFlag: number;
  87012. /**
  87013. * The dirty misc flag value
  87014. */
  87015. static readonly MiscDirtyFlag: number;
  87016. /**
  87017. * The all dirty flag value
  87018. */
  87019. static readonly AllDirtyFlag: number;
  87020. /**
  87021. * The ID of the material
  87022. */
  87023. id: string;
  87024. /**
  87025. * Gets or sets the unique id of the material
  87026. */
  87027. uniqueId: number;
  87028. /**
  87029. * The name of the material
  87030. */
  87031. name: string;
  87032. /**
  87033. * Gets or sets user defined metadata
  87034. */
  87035. metadata: any;
  87036. /**
  87037. * For internal use only. Please do not use.
  87038. */
  87039. reservedDataStore: any;
  87040. /**
  87041. * Specifies if the ready state should be checked on each call
  87042. */
  87043. checkReadyOnEveryCall: boolean;
  87044. /**
  87045. * Specifies if the ready state should be checked once
  87046. */
  87047. checkReadyOnlyOnce: boolean;
  87048. /**
  87049. * The state of the material
  87050. */
  87051. state: string;
  87052. /**
  87053. * The alpha value of the material
  87054. */
  87055. protected _alpha: number;
  87056. /**
  87057. * List of inspectable custom properties (used by the Inspector)
  87058. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  87059. */
  87060. inspectableCustomProperties: IInspectable[];
  87061. /**
  87062. * Sets the alpha value of the material
  87063. */
  87064. /**
  87065. * Gets the alpha value of the material
  87066. */
  87067. alpha: number;
  87068. /**
  87069. * Specifies if back face culling is enabled
  87070. */
  87071. protected _backFaceCulling: boolean;
  87072. /**
  87073. * Sets the back-face culling state
  87074. */
  87075. /**
  87076. * Gets the back-face culling state
  87077. */
  87078. backFaceCulling: boolean;
  87079. /**
  87080. * Stores the value for side orientation
  87081. */
  87082. sideOrientation: number;
  87083. /**
  87084. * Callback triggered when the material is compiled
  87085. */
  87086. onCompiled: Nullable<(effect: Effect) => void>;
  87087. /**
  87088. * Callback triggered when an error occurs
  87089. */
  87090. onError: Nullable<(effect: Effect, errors: string) => void>;
  87091. /**
  87092. * Callback triggered to get the render target textures
  87093. */
  87094. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  87095. /**
  87096. * Gets a boolean indicating that current material needs to register RTT
  87097. */
  87098. readonly hasRenderTargetTextures: boolean;
  87099. /**
  87100. * Specifies if the material should be serialized
  87101. */
  87102. doNotSerialize: boolean;
  87103. /**
  87104. * @hidden
  87105. */
  87106. _storeEffectOnSubMeshes: boolean;
  87107. /**
  87108. * Stores the animations for the material
  87109. */
  87110. animations: Nullable<Array<Animation>>;
  87111. /**
  87112. * An event triggered when the material is disposed
  87113. */
  87114. onDisposeObservable: Observable<Material>;
  87115. /**
  87116. * An observer which watches for dispose events
  87117. */
  87118. private _onDisposeObserver;
  87119. private _onUnBindObservable;
  87120. /**
  87121. * Called during a dispose event
  87122. */
  87123. onDispose: () => void;
  87124. private _onBindObservable;
  87125. /**
  87126. * An event triggered when the material is bound
  87127. */
  87128. readonly onBindObservable: Observable<AbstractMesh>;
  87129. /**
  87130. * An observer which watches for bind events
  87131. */
  87132. private _onBindObserver;
  87133. /**
  87134. * Called during a bind event
  87135. */
  87136. onBind: (Mesh: AbstractMesh) => void;
  87137. /**
  87138. * An event triggered when the material is unbound
  87139. */
  87140. readonly onUnBindObservable: Observable<Material>;
  87141. /**
  87142. * Stores the value of the alpha mode
  87143. */
  87144. private _alphaMode;
  87145. /**
  87146. * Sets the value of the alpha mode.
  87147. *
  87148. * | Value | Type | Description |
  87149. * | --- | --- | --- |
  87150. * | 0 | ALPHA_DISABLE | |
  87151. * | 1 | ALPHA_ADD | |
  87152. * | 2 | ALPHA_COMBINE | |
  87153. * | 3 | ALPHA_SUBTRACT | |
  87154. * | 4 | ALPHA_MULTIPLY | |
  87155. * | 5 | ALPHA_MAXIMIZED | |
  87156. * | 6 | ALPHA_ONEONE | |
  87157. * | 7 | ALPHA_PREMULTIPLIED | |
  87158. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  87159. * | 9 | ALPHA_INTERPOLATE | |
  87160. * | 10 | ALPHA_SCREENMODE | |
  87161. *
  87162. */
  87163. /**
  87164. * Gets the value of the alpha mode
  87165. */
  87166. alphaMode: number;
  87167. /**
  87168. * Stores the state of the need depth pre-pass value
  87169. */
  87170. private _needDepthPrePass;
  87171. /**
  87172. * Sets the need depth pre-pass value
  87173. */
  87174. /**
  87175. * Gets the depth pre-pass value
  87176. */
  87177. needDepthPrePass: boolean;
  87178. /**
  87179. * Specifies if depth writing should be disabled
  87180. */
  87181. disableDepthWrite: boolean;
  87182. /**
  87183. * Specifies if depth writing should be forced
  87184. */
  87185. forceDepthWrite: boolean;
  87186. /**
  87187. * Specifies if there should be a separate pass for culling
  87188. */
  87189. separateCullingPass: boolean;
  87190. /**
  87191. * Stores the state specifing if fog should be enabled
  87192. */
  87193. private _fogEnabled;
  87194. /**
  87195. * Sets the state for enabling fog
  87196. */
  87197. /**
  87198. * Gets the value of the fog enabled state
  87199. */
  87200. fogEnabled: boolean;
  87201. /**
  87202. * Stores the size of points
  87203. */
  87204. pointSize: number;
  87205. /**
  87206. * Stores the z offset value
  87207. */
  87208. zOffset: number;
  87209. /**
  87210. * Gets a value specifying if wireframe mode is enabled
  87211. */
  87212. /**
  87213. * Sets the state of wireframe mode
  87214. */
  87215. wireframe: boolean;
  87216. /**
  87217. * Gets the value specifying if point clouds are enabled
  87218. */
  87219. /**
  87220. * Sets the state of point cloud mode
  87221. */
  87222. pointsCloud: boolean;
  87223. /**
  87224. * Gets the material fill mode
  87225. */
  87226. /**
  87227. * Sets the material fill mode
  87228. */
  87229. fillMode: number;
  87230. /**
  87231. * @hidden
  87232. * Stores the effects for the material
  87233. */
  87234. _effect: Nullable<Effect>;
  87235. /**
  87236. * @hidden
  87237. * Specifies if the material was previously ready
  87238. */
  87239. _wasPreviouslyReady: boolean;
  87240. /**
  87241. * Specifies if uniform buffers should be used
  87242. */
  87243. private _useUBO;
  87244. /**
  87245. * Stores a reference to the scene
  87246. */
  87247. private _scene;
  87248. /**
  87249. * Stores the fill mode state
  87250. */
  87251. private _fillMode;
  87252. /**
  87253. * Specifies if the depth write state should be cached
  87254. */
  87255. private _cachedDepthWriteState;
  87256. /**
  87257. * Stores the uniform buffer
  87258. */
  87259. protected _uniformBuffer: UniformBuffer;
  87260. /** @hidden */
  87261. _indexInSceneMaterialArray: number;
  87262. /** @hidden */
  87263. meshMap: Nullable<{
  87264. [id: string]: AbstractMesh | undefined;
  87265. }>;
  87266. /**
  87267. * Creates a material instance
  87268. * @param name defines the name of the material
  87269. * @param scene defines the scene to reference
  87270. * @param doNotAdd specifies if the material should be added to the scene
  87271. */
  87272. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  87273. /**
  87274. * Returns a string representation of the current material
  87275. * @param fullDetails defines a boolean indicating which levels of logging is desired
  87276. * @returns a string with material information
  87277. */
  87278. toString(fullDetails?: boolean): string;
  87279. /**
  87280. * Gets the class name of the material
  87281. * @returns a string with the class name of the material
  87282. */
  87283. getClassName(): string;
  87284. /**
  87285. * Specifies if updates for the material been locked
  87286. */
  87287. readonly isFrozen: boolean;
  87288. /**
  87289. * Locks updates for the material
  87290. */
  87291. freeze(): void;
  87292. /**
  87293. * Unlocks updates for the material
  87294. */
  87295. unfreeze(): void;
  87296. /**
  87297. * Specifies if the material is ready to be used
  87298. * @param mesh defines the mesh to check
  87299. * @param useInstances specifies if instances should be used
  87300. * @returns a boolean indicating if the material is ready to be used
  87301. */
  87302. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  87303. /**
  87304. * Specifies that the submesh is ready to be used
  87305. * @param mesh defines the mesh to check
  87306. * @param subMesh defines which submesh to check
  87307. * @param useInstances specifies that instances should be used
  87308. * @returns a boolean indicating that the submesh is ready or not
  87309. */
  87310. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  87311. /**
  87312. * Returns the material effect
  87313. * @returns the effect associated with the material
  87314. */
  87315. getEffect(): Nullable<Effect>;
  87316. /**
  87317. * Returns the current scene
  87318. * @returns a Scene
  87319. */
  87320. getScene(): Scene;
  87321. /**
  87322. * Specifies if the material will require alpha blending
  87323. * @returns a boolean specifying if alpha blending is needed
  87324. */
  87325. needAlphaBlending(): boolean;
  87326. /**
  87327. * Specifies if the mesh will require alpha blending
  87328. * @param mesh defines the mesh to check
  87329. * @returns a boolean specifying if alpha blending is needed for the mesh
  87330. */
  87331. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  87332. /**
  87333. * Specifies if this material should be rendered in alpha test mode
  87334. * @returns a boolean specifying if an alpha test is needed.
  87335. */
  87336. needAlphaTesting(): boolean;
  87337. /**
  87338. * Gets the texture used for the alpha test
  87339. * @returns the texture to use for alpha testing
  87340. */
  87341. getAlphaTestTexture(): Nullable<BaseTexture>;
  87342. /**
  87343. * Marks the material to indicate that it needs to be re-calculated
  87344. */
  87345. markDirty(): void;
  87346. /** @hidden */
  87347. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  87348. /**
  87349. * Binds the material to the mesh
  87350. * @param world defines the world transformation matrix
  87351. * @param mesh defines the mesh to bind the material to
  87352. */
  87353. bind(world: Matrix, mesh?: Mesh): void;
  87354. /**
  87355. * Binds the submesh to the material
  87356. * @param world defines the world transformation matrix
  87357. * @param mesh defines the mesh containing the submesh
  87358. * @param subMesh defines the submesh to bind the material to
  87359. */
  87360. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  87361. /**
  87362. * Binds the world matrix to the material
  87363. * @param world defines the world transformation matrix
  87364. */
  87365. bindOnlyWorldMatrix(world: Matrix): void;
  87366. /**
  87367. * Binds the scene's uniform buffer to the effect.
  87368. * @param effect defines the effect to bind to the scene uniform buffer
  87369. * @param sceneUbo defines the uniform buffer storing scene data
  87370. */
  87371. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  87372. /**
  87373. * Binds the view matrix to the effect
  87374. * @param effect defines the effect to bind the view matrix to
  87375. */
  87376. bindView(effect: Effect): void;
  87377. /**
  87378. * Binds the view projection matrix to the effect
  87379. * @param effect defines the effect to bind the view projection matrix to
  87380. */
  87381. bindViewProjection(effect: Effect): void;
  87382. /**
  87383. * Specifies if material alpha testing should be turned on for the mesh
  87384. * @param mesh defines the mesh to check
  87385. */
  87386. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  87387. /**
  87388. * Processes to execute after binding the material to a mesh
  87389. * @param mesh defines the rendered mesh
  87390. */
  87391. protected _afterBind(mesh?: Mesh): void;
  87392. /**
  87393. * Unbinds the material from the mesh
  87394. */
  87395. unbind(): void;
  87396. /**
  87397. * Gets the active textures from the material
  87398. * @returns an array of textures
  87399. */
  87400. getActiveTextures(): BaseTexture[];
  87401. /**
  87402. * Specifies if the material uses a texture
  87403. * @param texture defines the texture to check against the material
  87404. * @returns a boolean specifying if the material uses the texture
  87405. */
  87406. hasTexture(texture: BaseTexture): boolean;
  87407. /**
  87408. * Makes a duplicate of the material, and gives it a new name
  87409. * @param name defines the new name for the duplicated material
  87410. * @returns the cloned material
  87411. */
  87412. clone(name: string): Nullable<Material>;
  87413. /**
  87414. * Gets the meshes bound to the material
  87415. * @returns an array of meshes bound to the material
  87416. */
  87417. getBindedMeshes(): AbstractMesh[];
  87418. /**
  87419. * Force shader compilation
  87420. * @param mesh defines the mesh associated with this material
  87421. * @param onCompiled defines a function to execute once the material is compiled
  87422. * @param options defines the options to configure the compilation
  87423. */
  87424. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  87425. clipPlane: boolean;
  87426. }>): void;
  87427. /**
  87428. * Force shader compilation
  87429. * @param mesh defines the mesh that will use this material
  87430. * @param options defines additional options for compiling the shaders
  87431. * @returns a promise that resolves when the compilation completes
  87432. */
  87433. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  87434. clipPlane: boolean;
  87435. }>): Promise<void>;
  87436. private static readonly _AllDirtyCallBack;
  87437. private static readonly _ImageProcessingDirtyCallBack;
  87438. private static readonly _TextureDirtyCallBack;
  87439. private static readonly _FresnelDirtyCallBack;
  87440. private static readonly _MiscDirtyCallBack;
  87441. private static readonly _LightsDirtyCallBack;
  87442. private static readonly _AttributeDirtyCallBack;
  87443. private static _FresnelAndMiscDirtyCallBack;
  87444. private static _TextureAndMiscDirtyCallBack;
  87445. private static readonly _DirtyCallbackArray;
  87446. private static readonly _RunDirtyCallBacks;
  87447. /**
  87448. * Marks a define in the material to indicate that it needs to be re-computed
  87449. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  87450. */
  87451. markAsDirty(flag: number): void;
  87452. /**
  87453. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  87454. * @param func defines a function which checks material defines against the submeshes
  87455. */
  87456. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  87457. /**
  87458. * Indicates that we need to re-calculated for all submeshes
  87459. */
  87460. protected _markAllSubMeshesAsAllDirty(): void;
  87461. /**
  87462. * Indicates that image processing needs to be re-calculated for all submeshes
  87463. */
  87464. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  87465. /**
  87466. * Indicates that textures need to be re-calculated for all submeshes
  87467. */
  87468. protected _markAllSubMeshesAsTexturesDirty(): void;
  87469. /**
  87470. * Indicates that fresnel needs to be re-calculated for all submeshes
  87471. */
  87472. protected _markAllSubMeshesAsFresnelDirty(): void;
  87473. /**
  87474. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  87475. */
  87476. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  87477. /**
  87478. * Indicates that lights need to be re-calculated for all submeshes
  87479. */
  87480. protected _markAllSubMeshesAsLightsDirty(): void;
  87481. /**
  87482. * Indicates that attributes need to be re-calculated for all submeshes
  87483. */
  87484. protected _markAllSubMeshesAsAttributesDirty(): void;
  87485. /**
  87486. * Indicates that misc needs to be re-calculated for all submeshes
  87487. */
  87488. protected _markAllSubMeshesAsMiscDirty(): void;
  87489. /**
  87490. * Indicates that textures and misc need to be re-calculated for all submeshes
  87491. */
  87492. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  87493. /**
  87494. * Disposes the material
  87495. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  87496. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  87497. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  87498. */
  87499. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  87500. /** @hidden */
  87501. private releaseVertexArrayObject;
  87502. /**
  87503. * Serializes this material
  87504. * @returns the serialized material object
  87505. */
  87506. serialize(): any;
  87507. /**
  87508. * Creates a material from parsed material data
  87509. * @param parsedMaterial defines parsed material data
  87510. * @param scene defines the hosting scene
  87511. * @param rootUrl defines the root URL to use to load textures
  87512. * @returns a new material
  87513. */
  87514. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  87515. }
  87516. }
  87517. declare module BABYLON {
  87518. /**
  87519. * A multi-material is used to apply different materials to different parts of the same object without the need of
  87520. * separate meshes. This can be use to improve performances.
  87521. * @see http://doc.babylonjs.com/how_to/multi_materials
  87522. */
  87523. export class MultiMaterial extends Material {
  87524. private _subMaterials;
  87525. /**
  87526. * Gets or Sets the list of Materials used within the multi material.
  87527. * They need to be ordered according to the submeshes order in the associated mesh
  87528. */
  87529. subMaterials: Nullable<Material>[];
  87530. /**
  87531. * Function used to align with Node.getChildren()
  87532. * @returns the list of Materials used within the multi material
  87533. */
  87534. getChildren(): Nullable<Material>[];
  87535. /**
  87536. * Instantiates a new Multi Material
  87537. * A multi-material is used to apply different materials to different parts of the same object without the need of
  87538. * separate meshes. This can be use to improve performances.
  87539. * @see http://doc.babylonjs.com/how_to/multi_materials
  87540. * @param name Define the name in the scene
  87541. * @param scene Define the scene the material belongs to
  87542. */
  87543. constructor(name: string, scene: Scene);
  87544. private _hookArray;
  87545. /**
  87546. * Get one of the submaterial by its index in the submaterials array
  87547. * @param index The index to look the sub material at
  87548. * @returns The Material if the index has been defined
  87549. */
  87550. getSubMaterial(index: number): Nullable<Material>;
  87551. /**
  87552. * Get the list of active textures for the whole sub materials list.
  87553. * @returns All the textures that will be used during the rendering
  87554. */
  87555. getActiveTextures(): BaseTexture[];
  87556. /**
  87557. * Gets the current class name of the material e.g. "MultiMaterial"
  87558. * Mainly use in serialization.
  87559. * @returns the class name
  87560. */
  87561. getClassName(): string;
  87562. /**
  87563. * Checks if the material is ready to render the requested sub mesh
  87564. * @param mesh Define the mesh the submesh belongs to
  87565. * @param subMesh Define the sub mesh to look readyness for
  87566. * @param useInstances Define whether or not the material is used with instances
  87567. * @returns true if ready, otherwise false
  87568. */
  87569. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  87570. /**
  87571. * Clones the current material and its related sub materials
  87572. * @param name Define the name of the newly cloned material
  87573. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  87574. * @returns the cloned material
  87575. */
  87576. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  87577. /**
  87578. * Serializes the materials into a JSON representation.
  87579. * @returns the JSON representation
  87580. */
  87581. serialize(): any;
  87582. /**
  87583. * Dispose the material and release its associated resources
  87584. * @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)
  87585. * @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)
  87586. * @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)
  87587. */
  87588. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  87589. /**
  87590. * Creates a MultiMaterial from parsed MultiMaterial data.
  87591. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  87592. * @param scene defines the hosting scene
  87593. * @returns a new MultiMaterial
  87594. */
  87595. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  87596. }
  87597. }
  87598. declare module BABYLON {
  87599. /**
  87600. * Base class for submeshes
  87601. */
  87602. export class BaseSubMesh {
  87603. /** @hidden */
  87604. _materialDefines: Nullable<MaterialDefines>;
  87605. /** @hidden */
  87606. _materialEffect: Nullable<Effect>;
  87607. /**
  87608. * Gets associated effect
  87609. */
  87610. readonly effect: Nullable<Effect>;
  87611. /**
  87612. * Sets associated effect (effect used to render this submesh)
  87613. * @param effect defines the effect to associate with
  87614. * @param defines defines the set of defines used to compile this effect
  87615. */
  87616. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  87617. }
  87618. /**
  87619. * Defines a subdivision inside a mesh
  87620. */
  87621. export class SubMesh extends BaseSubMesh implements ICullable {
  87622. /** the material index to use */
  87623. materialIndex: number;
  87624. /** vertex index start */
  87625. verticesStart: number;
  87626. /** vertices count */
  87627. verticesCount: number;
  87628. /** index start */
  87629. indexStart: number;
  87630. /** indices count */
  87631. indexCount: number;
  87632. /** @hidden */
  87633. _linesIndexCount: number;
  87634. private _mesh;
  87635. private _renderingMesh;
  87636. private _boundingInfo;
  87637. private _linesIndexBuffer;
  87638. /** @hidden */
  87639. _lastColliderWorldVertices: Nullable<Vector3[]>;
  87640. /** @hidden */
  87641. _trianglePlanes: Plane[];
  87642. /** @hidden */
  87643. _lastColliderTransformMatrix: Nullable<Matrix>;
  87644. /** @hidden */
  87645. _renderId: number;
  87646. /** @hidden */
  87647. _alphaIndex: number;
  87648. /** @hidden */
  87649. _distanceToCamera: number;
  87650. /** @hidden */
  87651. _id: number;
  87652. private _currentMaterial;
  87653. /**
  87654. * Add a new submesh to a mesh
  87655. * @param materialIndex defines the material index to use
  87656. * @param verticesStart defines vertex index start
  87657. * @param verticesCount defines vertices count
  87658. * @param indexStart defines index start
  87659. * @param indexCount defines indices count
  87660. * @param mesh defines the parent mesh
  87661. * @param renderingMesh defines an optional rendering mesh
  87662. * @param createBoundingBox defines if bounding box should be created for this submesh
  87663. * @returns the new submesh
  87664. */
  87665. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  87666. /**
  87667. * Creates a new submesh
  87668. * @param materialIndex defines the material index to use
  87669. * @param verticesStart defines vertex index start
  87670. * @param verticesCount defines vertices count
  87671. * @param indexStart defines index start
  87672. * @param indexCount defines indices count
  87673. * @param mesh defines the parent mesh
  87674. * @param renderingMesh defines an optional rendering mesh
  87675. * @param createBoundingBox defines if bounding box should be created for this submesh
  87676. */
  87677. constructor(
  87678. /** the material index to use */
  87679. materialIndex: number,
  87680. /** vertex index start */
  87681. verticesStart: number,
  87682. /** vertices count */
  87683. verticesCount: number,
  87684. /** index start */
  87685. indexStart: number,
  87686. /** indices count */
  87687. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  87688. /**
  87689. * Returns true if this submesh covers the entire parent mesh
  87690. * @ignorenaming
  87691. */
  87692. readonly IsGlobal: boolean;
  87693. /**
  87694. * Returns the submesh BoudingInfo object
  87695. * @returns current bounding info (or mesh's one if the submesh is global)
  87696. */
  87697. getBoundingInfo(): BoundingInfo;
  87698. /**
  87699. * Sets the submesh BoundingInfo
  87700. * @param boundingInfo defines the new bounding info to use
  87701. * @returns the SubMesh
  87702. */
  87703. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  87704. /**
  87705. * Returns the mesh of the current submesh
  87706. * @return the parent mesh
  87707. */
  87708. getMesh(): AbstractMesh;
  87709. /**
  87710. * Returns the rendering mesh of the submesh
  87711. * @returns the rendering mesh (could be different from parent mesh)
  87712. */
  87713. getRenderingMesh(): Mesh;
  87714. /**
  87715. * Returns the submesh material
  87716. * @returns null or the current material
  87717. */
  87718. getMaterial(): Nullable<Material>;
  87719. /**
  87720. * Sets a new updated BoundingInfo object to the submesh
  87721. * @param data defines an optional position array to use to determine the bounding info
  87722. * @returns the SubMesh
  87723. */
  87724. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  87725. /** @hidden */
  87726. _checkCollision(collider: Collider): boolean;
  87727. /**
  87728. * Updates the submesh BoundingInfo
  87729. * @param world defines the world matrix to use to update the bounding info
  87730. * @returns the submesh
  87731. */
  87732. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  87733. /**
  87734. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  87735. * @param frustumPlanes defines the frustum planes
  87736. * @returns true if the submesh is intersecting with the frustum
  87737. */
  87738. isInFrustum(frustumPlanes: Plane[]): boolean;
  87739. /**
  87740. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  87741. * @param frustumPlanes defines the frustum planes
  87742. * @returns true if the submesh is inside the frustum
  87743. */
  87744. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  87745. /**
  87746. * Renders the submesh
  87747. * @param enableAlphaMode defines if alpha needs to be used
  87748. * @returns the submesh
  87749. */
  87750. render(enableAlphaMode: boolean): SubMesh;
  87751. /**
  87752. * @hidden
  87753. */
  87754. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  87755. /**
  87756. * Checks if the submesh intersects with a ray
  87757. * @param ray defines the ray to test
  87758. * @returns true is the passed ray intersects the submesh bounding box
  87759. */
  87760. canIntersects(ray: Ray): boolean;
  87761. /**
  87762. * Intersects current submesh with a ray
  87763. * @param ray defines the ray to test
  87764. * @param positions defines mesh's positions array
  87765. * @param indices defines mesh's indices array
  87766. * @param fastCheck defines if only bounding info should be used
  87767. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  87768. * @returns intersection info or null if no intersection
  87769. */
  87770. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  87771. /** @hidden */
  87772. private _intersectLines;
  87773. /** @hidden */
  87774. private _intersectUnIndexedLines;
  87775. /** @hidden */
  87776. private _intersectTriangles;
  87777. /** @hidden */
  87778. private _intersectUnIndexedTriangles;
  87779. /** @hidden */
  87780. _rebuild(): void;
  87781. /**
  87782. * Creates a new submesh from the passed mesh
  87783. * @param newMesh defines the new hosting mesh
  87784. * @param newRenderingMesh defines an optional rendering mesh
  87785. * @returns the new submesh
  87786. */
  87787. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  87788. /**
  87789. * Release associated resources
  87790. */
  87791. dispose(): void;
  87792. /**
  87793. * Gets the class name
  87794. * @returns the string "SubMesh".
  87795. */
  87796. getClassName(): string;
  87797. /**
  87798. * Creates a new submesh from indices data
  87799. * @param materialIndex the index of the main mesh material
  87800. * @param startIndex the index where to start the copy in the mesh indices array
  87801. * @param indexCount the number of indices to copy then from the startIndex
  87802. * @param mesh the main mesh to create the submesh from
  87803. * @param renderingMesh the optional rendering mesh
  87804. * @returns a new submesh
  87805. */
  87806. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  87807. }
  87808. }
  87809. declare module BABYLON {
  87810. /**
  87811. * Class used to represent data loading progression
  87812. */
  87813. export class SceneLoaderFlags {
  87814. private static _ForceFullSceneLoadingForIncremental;
  87815. private static _ShowLoadingScreen;
  87816. private static _CleanBoneMatrixWeights;
  87817. private static _loggingLevel;
  87818. /**
  87819. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  87820. */
  87821. static ForceFullSceneLoadingForIncremental: boolean;
  87822. /**
  87823. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  87824. */
  87825. static ShowLoadingScreen: boolean;
  87826. /**
  87827. * Defines the current logging level (while loading the scene)
  87828. * @ignorenaming
  87829. */
  87830. static loggingLevel: number;
  87831. /**
  87832. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  87833. */
  87834. static CleanBoneMatrixWeights: boolean;
  87835. }
  87836. }
  87837. declare module BABYLON {
  87838. /**
  87839. * Class used to store geometry data (vertex buffers + index buffer)
  87840. */
  87841. export class Geometry implements IGetSetVerticesData {
  87842. /**
  87843. * Gets or sets the ID of the geometry
  87844. */
  87845. id: string;
  87846. /**
  87847. * Gets or sets the unique ID of the geometry
  87848. */
  87849. uniqueId: number;
  87850. /**
  87851. * Gets the delay loading state of the geometry (none by default which means not delayed)
  87852. */
  87853. delayLoadState: number;
  87854. /**
  87855. * Gets the file containing the data to load when running in delay load state
  87856. */
  87857. delayLoadingFile: Nullable<string>;
  87858. /**
  87859. * Callback called when the geometry is updated
  87860. */
  87861. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  87862. private _scene;
  87863. private _engine;
  87864. private _meshes;
  87865. private _totalVertices;
  87866. /** @hidden */
  87867. _indices: IndicesArray;
  87868. /** @hidden */
  87869. _vertexBuffers: {
  87870. [key: string]: VertexBuffer;
  87871. };
  87872. private _isDisposed;
  87873. private _extend;
  87874. private _boundingBias;
  87875. /** @hidden */
  87876. _delayInfo: Array<string>;
  87877. private _indexBuffer;
  87878. private _indexBufferIsUpdatable;
  87879. /** @hidden */
  87880. _boundingInfo: Nullable<BoundingInfo>;
  87881. /** @hidden */
  87882. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  87883. /** @hidden */
  87884. _softwareSkinningFrameId: number;
  87885. private _vertexArrayObjects;
  87886. private _updatable;
  87887. /** @hidden */
  87888. _positions: Nullable<Vector3[]>;
  87889. /**
  87890. * 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
  87891. */
  87892. /**
  87893. * 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
  87894. */
  87895. boundingBias: Vector2;
  87896. /**
  87897. * Static function used to attach a new empty geometry to a mesh
  87898. * @param mesh defines the mesh to attach the geometry to
  87899. * @returns the new Geometry
  87900. */
  87901. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  87902. /**
  87903. * Creates a new geometry
  87904. * @param id defines the unique ID
  87905. * @param scene defines the hosting scene
  87906. * @param vertexData defines the VertexData used to get geometry data
  87907. * @param updatable defines if geometry must be updatable (false by default)
  87908. * @param mesh defines the mesh that will be associated with the geometry
  87909. */
  87910. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  87911. /**
  87912. * Gets the current extend of the geometry
  87913. */
  87914. readonly extend: {
  87915. minimum: Vector3;
  87916. maximum: Vector3;
  87917. };
  87918. /**
  87919. * Gets the hosting scene
  87920. * @returns the hosting Scene
  87921. */
  87922. getScene(): Scene;
  87923. /**
  87924. * Gets the hosting engine
  87925. * @returns the hosting Engine
  87926. */
  87927. getEngine(): Engine;
  87928. /**
  87929. * Defines if the geometry is ready to use
  87930. * @returns true if the geometry is ready to be used
  87931. */
  87932. isReady(): boolean;
  87933. /**
  87934. * Gets a value indicating that the geometry should not be serialized
  87935. */
  87936. readonly doNotSerialize: boolean;
  87937. /** @hidden */
  87938. _rebuild(): void;
  87939. /**
  87940. * Affects all geometry data in one call
  87941. * @param vertexData defines the geometry data
  87942. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  87943. */
  87944. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  87945. /**
  87946. * Set specific vertex data
  87947. * @param kind defines the data kind (Position, normal, etc...)
  87948. * @param data defines the vertex data to use
  87949. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  87950. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  87951. */
  87952. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  87953. /**
  87954. * Removes a specific vertex data
  87955. * @param kind defines the data kind (Position, normal, etc...)
  87956. */
  87957. removeVerticesData(kind: string): void;
  87958. /**
  87959. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  87960. * @param buffer defines the vertex buffer to use
  87961. * @param totalVertices defines the total number of vertices for position kind (could be null)
  87962. */
  87963. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  87964. /**
  87965. * Update a specific vertex buffer
  87966. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  87967. * It will do nothing if the buffer is not updatable
  87968. * @param kind defines the data kind (Position, normal, etc...)
  87969. * @param data defines the data to use
  87970. * @param offset defines the offset in the target buffer where to store the data
  87971. * @param useBytes set to true if the offset is in bytes
  87972. */
  87973. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  87974. /**
  87975. * Update a specific vertex buffer
  87976. * This function will create a new buffer if the current one is not updatable
  87977. * @param kind defines the data kind (Position, normal, etc...)
  87978. * @param data defines the data to use
  87979. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  87980. */
  87981. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  87982. private _updateBoundingInfo;
  87983. /** @hidden */
  87984. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  87985. /**
  87986. * Gets total number of vertices
  87987. * @returns the total number of vertices
  87988. */
  87989. getTotalVertices(): number;
  87990. /**
  87991. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  87992. * @param kind defines the data kind (Position, normal, etc...)
  87993. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  87994. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  87995. * @returns a float array containing vertex data
  87996. */
  87997. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  87998. /**
  87999. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  88000. * @param kind defines the data kind (Position, normal, etc...)
  88001. * @returns true if the vertex buffer with the specified kind is updatable
  88002. */
  88003. isVertexBufferUpdatable(kind: string): boolean;
  88004. /**
  88005. * Gets a specific vertex buffer
  88006. * @param kind defines the data kind (Position, normal, etc...)
  88007. * @returns a VertexBuffer
  88008. */
  88009. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  88010. /**
  88011. * Returns all vertex buffers
  88012. * @return an object holding all vertex buffers indexed by kind
  88013. */
  88014. getVertexBuffers(): Nullable<{
  88015. [key: string]: VertexBuffer;
  88016. }>;
  88017. /**
  88018. * Gets a boolean indicating if specific vertex buffer is present
  88019. * @param kind defines the data kind (Position, normal, etc...)
  88020. * @returns true if data is present
  88021. */
  88022. isVerticesDataPresent(kind: string): boolean;
  88023. /**
  88024. * Gets a list of all attached data kinds (Position, normal, etc...)
  88025. * @returns a list of string containing all kinds
  88026. */
  88027. getVerticesDataKinds(): string[];
  88028. /**
  88029. * Update index buffer
  88030. * @param indices defines the indices to store in the index buffer
  88031. * @param offset defines the offset in the target buffer where to store the data
  88032. * @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)
  88033. */
  88034. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  88035. /**
  88036. * Creates a new index buffer
  88037. * @param indices defines the indices to store in the index buffer
  88038. * @param totalVertices defines the total number of vertices (could be null)
  88039. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  88040. */
  88041. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  88042. /**
  88043. * Return the total number of indices
  88044. * @returns the total number of indices
  88045. */
  88046. getTotalIndices(): number;
  88047. /**
  88048. * Gets the index buffer array
  88049. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  88050. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  88051. * @returns the index buffer array
  88052. */
  88053. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  88054. /**
  88055. * Gets the index buffer
  88056. * @return the index buffer
  88057. */
  88058. getIndexBuffer(): Nullable<DataBuffer>;
  88059. /** @hidden */
  88060. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  88061. /**
  88062. * Release the associated resources for a specific mesh
  88063. * @param mesh defines the source mesh
  88064. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  88065. */
  88066. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  88067. /**
  88068. * Apply current geometry to a given mesh
  88069. * @param mesh defines the mesh to apply geometry to
  88070. */
  88071. applyToMesh(mesh: Mesh): void;
  88072. private _updateExtend;
  88073. private _applyToMesh;
  88074. private notifyUpdate;
  88075. /**
  88076. * Load the geometry if it was flagged as delay loaded
  88077. * @param scene defines the hosting scene
  88078. * @param onLoaded defines a callback called when the geometry is loaded
  88079. */
  88080. load(scene: Scene, onLoaded?: () => void): void;
  88081. private _queueLoad;
  88082. /**
  88083. * Invert the geometry to move from a right handed system to a left handed one.
  88084. */
  88085. toLeftHanded(): void;
  88086. /** @hidden */
  88087. _resetPointsArrayCache(): void;
  88088. /** @hidden */
  88089. _generatePointsArray(): boolean;
  88090. /**
  88091. * Gets a value indicating if the geometry is disposed
  88092. * @returns true if the geometry was disposed
  88093. */
  88094. isDisposed(): boolean;
  88095. private _disposeVertexArrayObjects;
  88096. /**
  88097. * Free all associated resources
  88098. */
  88099. dispose(): void;
  88100. /**
  88101. * Clone the current geometry into a new geometry
  88102. * @param id defines the unique ID of the new geometry
  88103. * @returns a new geometry object
  88104. */
  88105. copy(id: string): Geometry;
  88106. /**
  88107. * Serialize the current geometry info (and not the vertices data) into a JSON object
  88108. * @return a JSON representation of the current geometry data (without the vertices data)
  88109. */
  88110. serialize(): any;
  88111. private toNumberArray;
  88112. /**
  88113. * Serialize all vertices data into a JSON oject
  88114. * @returns a JSON representation of the current geometry data
  88115. */
  88116. serializeVerticeData(): any;
  88117. /**
  88118. * Extracts a clone of a mesh geometry
  88119. * @param mesh defines the source mesh
  88120. * @param id defines the unique ID of the new geometry object
  88121. * @returns the new geometry object
  88122. */
  88123. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  88124. /**
  88125. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  88126. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  88127. * Be aware Math.random() could cause collisions, but:
  88128. * "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"
  88129. * @returns a string containing a new GUID
  88130. */
  88131. static RandomId(): string;
  88132. /** @hidden */
  88133. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  88134. private static _CleanMatricesWeights;
  88135. /**
  88136. * Create a new geometry from persisted data (Using .babylon file format)
  88137. * @param parsedVertexData defines the persisted data
  88138. * @param scene defines the hosting scene
  88139. * @param rootUrl defines the root url to use to load assets (like delayed data)
  88140. * @returns the new geometry object
  88141. */
  88142. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  88143. }
  88144. }
  88145. declare module BABYLON {
  88146. /**
  88147. * Define an interface for all classes that will get and set the data on vertices
  88148. */
  88149. export interface IGetSetVerticesData {
  88150. /**
  88151. * Gets a boolean indicating if specific vertex data is present
  88152. * @param kind defines the vertex data kind to use
  88153. * @returns true is data kind is present
  88154. */
  88155. isVerticesDataPresent(kind: string): boolean;
  88156. /**
  88157. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  88158. * @param kind defines the data kind (Position, normal, etc...)
  88159. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  88160. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  88161. * @returns a float array containing vertex data
  88162. */
  88163. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  88164. /**
  88165. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  88166. * @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.
  88167. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  88168. * @returns the indices array or an empty array if the mesh has no geometry
  88169. */
  88170. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  88171. /**
  88172. * Set specific vertex data
  88173. * @param kind defines the data kind (Position, normal, etc...)
  88174. * @param data defines the vertex data to use
  88175. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  88176. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  88177. */
  88178. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  88179. /**
  88180. * Update a specific associated vertex buffer
  88181. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  88182. * - VertexBuffer.PositionKind
  88183. * - VertexBuffer.UVKind
  88184. * - VertexBuffer.UV2Kind
  88185. * - VertexBuffer.UV3Kind
  88186. * - VertexBuffer.UV4Kind
  88187. * - VertexBuffer.UV5Kind
  88188. * - VertexBuffer.UV6Kind
  88189. * - VertexBuffer.ColorKind
  88190. * - VertexBuffer.MatricesIndicesKind
  88191. * - VertexBuffer.MatricesIndicesExtraKind
  88192. * - VertexBuffer.MatricesWeightsKind
  88193. * - VertexBuffer.MatricesWeightsExtraKind
  88194. * @param data defines the data source
  88195. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  88196. * @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)
  88197. */
  88198. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  88199. /**
  88200. * Creates a new index buffer
  88201. * @param indices defines the indices to store in the index buffer
  88202. * @param totalVertices defines the total number of vertices (could be null)
  88203. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  88204. */
  88205. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  88206. }
  88207. /**
  88208. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  88209. */
  88210. export class VertexData {
  88211. /**
  88212. * Mesh side orientation : usually the external or front surface
  88213. */
  88214. static readonly FRONTSIDE: number;
  88215. /**
  88216. * Mesh side orientation : usually the internal or back surface
  88217. */
  88218. static readonly BACKSIDE: number;
  88219. /**
  88220. * Mesh side orientation : both internal and external or front and back surfaces
  88221. */
  88222. static readonly DOUBLESIDE: number;
  88223. /**
  88224. * Mesh side orientation : by default, `FRONTSIDE`
  88225. */
  88226. static readonly DEFAULTSIDE: number;
  88227. /**
  88228. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  88229. */
  88230. positions: Nullable<FloatArray>;
  88231. /**
  88232. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  88233. */
  88234. normals: Nullable<FloatArray>;
  88235. /**
  88236. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  88237. */
  88238. tangents: Nullable<FloatArray>;
  88239. /**
  88240. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88241. */
  88242. uvs: Nullable<FloatArray>;
  88243. /**
  88244. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88245. */
  88246. uvs2: Nullable<FloatArray>;
  88247. /**
  88248. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88249. */
  88250. uvs3: Nullable<FloatArray>;
  88251. /**
  88252. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88253. */
  88254. uvs4: Nullable<FloatArray>;
  88255. /**
  88256. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88257. */
  88258. uvs5: Nullable<FloatArray>;
  88259. /**
  88260. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88261. */
  88262. uvs6: Nullable<FloatArray>;
  88263. /**
  88264. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  88265. */
  88266. colors: Nullable<FloatArray>;
  88267. /**
  88268. * 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).
  88269. */
  88270. matricesIndices: Nullable<FloatArray>;
  88271. /**
  88272. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  88273. */
  88274. matricesWeights: Nullable<FloatArray>;
  88275. /**
  88276. * An array extending the number of possible indices
  88277. */
  88278. matricesIndicesExtra: Nullable<FloatArray>;
  88279. /**
  88280. * An array extending the number of possible weights when the number of indices is extended
  88281. */
  88282. matricesWeightsExtra: Nullable<FloatArray>;
  88283. /**
  88284. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  88285. */
  88286. indices: Nullable<IndicesArray>;
  88287. /**
  88288. * Uses the passed data array to set the set the values for the specified kind of data
  88289. * @param data a linear array of floating numbers
  88290. * @param kind the type of data that is being set, eg positions, colors etc
  88291. */
  88292. set(data: FloatArray, kind: string): void;
  88293. /**
  88294. * Associates the vertexData to the passed Mesh.
  88295. * Sets it as updatable or not (default `false`)
  88296. * @param mesh the mesh the vertexData is applied to
  88297. * @param updatable when used and having the value true allows new data to update the vertexData
  88298. * @returns the VertexData
  88299. */
  88300. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  88301. /**
  88302. * Associates the vertexData to the passed Geometry.
  88303. * Sets it as updatable or not (default `false`)
  88304. * @param geometry the geometry the vertexData is applied to
  88305. * @param updatable when used and having the value true allows new data to update the vertexData
  88306. * @returns VertexData
  88307. */
  88308. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  88309. /**
  88310. * Updates the associated mesh
  88311. * @param mesh the mesh to be updated
  88312. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  88313. * @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
  88314. * @returns VertexData
  88315. */
  88316. updateMesh(mesh: Mesh): VertexData;
  88317. /**
  88318. * Updates the associated geometry
  88319. * @param geometry the geometry to be updated
  88320. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  88321. * @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
  88322. * @returns VertexData.
  88323. */
  88324. updateGeometry(geometry: Geometry): VertexData;
  88325. private _applyTo;
  88326. private _update;
  88327. /**
  88328. * Transforms each position and each normal of the vertexData according to the passed Matrix
  88329. * @param matrix the transforming matrix
  88330. * @returns the VertexData
  88331. */
  88332. transform(matrix: Matrix): VertexData;
  88333. /**
  88334. * Merges the passed VertexData into the current one
  88335. * @param other the VertexData to be merged into the current one
  88336. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  88337. * @returns the modified VertexData
  88338. */
  88339. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  88340. private _mergeElement;
  88341. private _validate;
  88342. /**
  88343. * Serializes the VertexData
  88344. * @returns a serialized object
  88345. */
  88346. serialize(): any;
  88347. /**
  88348. * Extracts the vertexData from a mesh
  88349. * @param mesh the mesh from which to extract the VertexData
  88350. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  88351. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  88352. * @returns the object VertexData associated to the passed mesh
  88353. */
  88354. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  88355. /**
  88356. * Extracts the vertexData from the geometry
  88357. * @param geometry the geometry from which to extract the VertexData
  88358. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  88359. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  88360. * @returns the object VertexData associated to the passed mesh
  88361. */
  88362. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  88363. private static _ExtractFrom;
  88364. /**
  88365. * Creates the VertexData for a Ribbon
  88366. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  88367. * * pathArray array of paths, each of which an array of successive Vector3
  88368. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  88369. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  88370. * * 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
  88371. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88372. * * 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)
  88373. * * 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)
  88374. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  88375. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  88376. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  88377. * @returns the VertexData of the ribbon
  88378. */
  88379. static CreateRibbon(options: {
  88380. pathArray: Vector3[][];
  88381. closeArray?: boolean;
  88382. closePath?: boolean;
  88383. offset?: number;
  88384. sideOrientation?: number;
  88385. frontUVs?: Vector4;
  88386. backUVs?: Vector4;
  88387. invertUV?: boolean;
  88388. uvs?: Vector2[];
  88389. colors?: Color4[];
  88390. }): VertexData;
  88391. /**
  88392. * Creates the VertexData for a box
  88393. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88394. * * size sets the width, height and depth of the box to the value of size, optional default 1
  88395. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  88396. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  88397. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  88398. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  88399. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  88400. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88401. * * 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)
  88402. * * 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)
  88403. * @returns the VertexData of the box
  88404. */
  88405. static CreateBox(options: {
  88406. size?: number;
  88407. width?: number;
  88408. height?: number;
  88409. depth?: number;
  88410. faceUV?: Vector4[];
  88411. faceColors?: Color4[];
  88412. sideOrientation?: number;
  88413. frontUVs?: Vector4;
  88414. backUVs?: Vector4;
  88415. }): VertexData;
  88416. /**
  88417. * Creates the VertexData for a tiled box
  88418. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88419. * * faceTiles sets the pattern, tile size and number of tiles for a face
  88420. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  88421. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  88422. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88423. * @returns the VertexData of the box
  88424. */
  88425. static CreateTiledBox(options: {
  88426. pattern?: number;
  88427. width?: number;
  88428. height?: number;
  88429. depth?: number;
  88430. tileSize?: number;
  88431. tileWidth?: number;
  88432. tileHeight?: number;
  88433. alignHorizontal?: number;
  88434. alignVertical?: number;
  88435. faceUV?: Vector4[];
  88436. faceColors?: Color4[];
  88437. sideOrientation?: number;
  88438. }): VertexData;
  88439. /**
  88440. * Creates the VertexData for a tiled plane
  88441. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88442. * * pattern a limited pattern arrangement depending on the number
  88443. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  88444. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  88445. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  88446. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88447. * * 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)
  88448. * * 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)
  88449. * @returns the VertexData of the tiled plane
  88450. */
  88451. static CreateTiledPlane(options: {
  88452. pattern?: number;
  88453. tileSize?: number;
  88454. tileWidth?: number;
  88455. tileHeight?: number;
  88456. size?: number;
  88457. width?: number;
  88458. height?: number;
  88459. alignHorizontal?: number;
  88460. alignVertical?: number;
  88461. sideOrientation?: number;
  88462. frontUVs?: Vector4;
  88463. backUVs?: Vector4;
  88464. }): VertexData;
  88465. /**
  88466. * Creates the VertexData for an ellipsoid, defaults to a sphere
  88467. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88468. * * segments sets the number of horizontal strips optional, default 32
  88469. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  88470. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  88471. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  88472. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  88473. * * 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
  88474. * * 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
  88475. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88476. * * 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)
  88477. * * 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)
  88478. * @returns the VertexData of the ellipsoid
  88479. */
  88480. static CreateSphere(options: {
  88481. segments?: number;
  88482. diameter?: number;
  88483. diameterX?: number;
  88484. diameterY?: number;
  88485. diameterZ?: number;
  88486. arc?: number;
  88487. slice?: number;
  88488. sideOrientation?: number;
  88489. frontUVs?: Vector4;
  88490. backUVs?: Vector4;
  88491. }): VertexData;
  88492. /**
  88493. * Creates the VertexData for a cylinder, cone or prism
  88494. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88495. * * height sets the height (y direction) of the cylinder, optional, default 2
  88496. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  88497. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  88498. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  88499. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  88500. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  88501. * * 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
  88502. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  88503. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  88504. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  88505. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  88506. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88507. * * 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)
  88508. * * 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)
  88509. * @returns the VertexData of the cylinder, cone or prism
  88510. */
  88511. static CreateCylinder(options: {
  88512. height?: number;
  88513. diameterTop?: number;
  88514. diameterBottom?: number;
  88515. diameter?: number;
  88516. tessellation?: number;
  88517. subdivisions?: number;
  88518. arc?: number;
  88519. faceColors?: Color4[];
  88520. faceUV?: Vector4[];
  88521. hasRings?: boolean;
  88522. enclose?: boolean;
  88523. sideOrientation?: number;
  88524. frontUVs?: Vector4;
  88525. backUVs?: Vector4;
  88526. }): VertexData;
  88527. /**
  88528. * Creates the VertexData for a torus
  88529. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88530. * * diameter the diameter of the torus, optional default 1
  88531. * * thickness the diameter of the tube forming the torus, optional default 0.5
  88532. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  88533. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88534. * * 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)
  88535. * * 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)
  88536. * @returns the VertexData of the torus
  88537. */
  88538. static CreateTorus(options: {
  88539. diameter?: number;
  88540. thickness?: number;
  88541. tessellation?: number;
  88542. sideOrientation?: number;
  88543. frontUVs?: Vector4;
  88544. backUVs?: Vector4;
  88545. }): VertexData;
  88546. /**
  88547. * Creates the VertexData of the LineSystem
  88548. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  88549. * - lines an array of lines, each line being an array of successive Vector3
  88550. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  88551. * @returns the VertexData of the LineSystem
  88552. */
  88553. static CreateLineSystem(options: {
  88554. lines: Vector3[][];
  88555. colors?: Nullable<Color4[][]>;
  88556. }): VertexData;
  88557. /**
  88558. * Create the VertexData for a DashedLines
  88559. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  88560. * - points an array successive Vector3
  88561. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  88562. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  88563. * - dashNb the intended total number of dashes, optional, default 200
  88564. * @returns the VertexData for the DashedLines
  88565. */
  88566. static CreateDashedLines(options: {
  88567. points: Vector3[];
  88568. dashSize?: number;
  88569. gapSize?: number;
  88570. dashNb?: number;
  88571. }): VertexData;
  88572. /**
  88573. * Creates the VertexData for a Ground
  88574. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  88575. * - width the width (x direction) of the ground, optional, default 1
  88576. * - height the height (z direction) of the ground, optional, default 1
  88577. * - subdivisions the number of subdivisions per side, optional, default 1
  88578. * @returns the VertexData of the Ground
  88579. */
  88580. static CreateGround(options: {
  88581. width?: number;
  88582. height?: number;
  88583. subdivisions?: number;
  88584. subdivisionsX?: number;
  88585. subdivisionsY?: number;
  88586. }): VertexData;
  88587. /**
  88588. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  88589. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  88590. * * xmin the ground minimum X coordinate, optional, default -1
  88591. * * zmin the ground minimum Z coordinate, optional, default -1
  88592. * * xmax the ground maximum X coordinate, optional, default 1
  88593. * * zmax the ground maximum Z coordinate, optional, default 1
  88594. * * 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}
  88595. * * 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}
  88596. * @returns the VertexData of the TiledGround
  88597. */
  88598. static CreateTiledGround(options: {
  88599. xmin: number;
  88600. zmin: number;
  88601. xmax: number;
  88602. zmax: number;
  88603. subdivisions?: {
  88604. w: number;
  88605. h: number;
  88606. };
  88607. precision?: {
  88608. w: number;
  88609. h: number;
  88610. };
  88611. }): VertexData;
  88612. /**
  88613. * Creates the VertexData of the Ground designed from a heightmap
  88614. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  88615. * * width the width (x direction) of the ground
  88616. * * height the height (z direction) of the ground
  88617. * * subdivisions the number of subdivisions per side
  88618. * * minHeight the minimum altitude on the ground, optional, default 0
  88619. * * maxHeight the maximum altitude on the ground, optional default 1
  88620. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  88621. * * buffer the array holding the image color data
  88622. * * bufferWidth the width of image
  88623. * * bufferHeight the height of image
  88624. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  88625. * @returns the VertexData of the Ground designed from a heightmap
  88626. */
  88627. static CreateGroundFromHeightMap(options: {
  88628. width: number;
  88629. height: number;
  88630. subdivisions: number;
  88631. minHeight: number;
  88632. maxHeight: number;
  88633. colorFilter: Color3;
  88634. buffer: Uint8Array;
  88635. bufferWidth: number;
  88636. bufferHeight: number;
  88637. alphaFilter: number;
  88638. }): VertexData;
  88639. /**
  88640. * Creates the VertexData for a Plane
  88641. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  88642. * * size sets the width and height of the plane to the value of size, optional default 1
  88643. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  88644. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  88645. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88646. * * 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)
  88647. * * 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)
  88648. * @returns the VertexData of the box
  88649. */
  88650. static CreatePlane(options: {
  88651. size?: number;
  88652. width?: number;
  88653. height?: number;
  88654. sideOrientation?: number;
  88655. frontUVs?: Vector4;
  88656. backUVs?: Vector4;
  88657. }): VertexData;
  88658. /**
  88659. * Creates the VertexData of the Disc or regular Polygon
  88660. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  88661. * * radius the radius of the disc, optional default 0.5
  88662. * * tessellation the number of polygon sides, optional, default 64
  88663. * * 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
  88664. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88665. * * 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)
  88666. * * 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)
  88667. * @returns the VertexData of the box
  88668. */
  88669. static CreateDisc(options: {
  88670. radius?: number;
  88671. tessellation?: number;
  88672. arc?: number;
  88673. sideOrientation?: number;
  88674. frontUVs?: Vector4;
  88675. backUVs?: Vector4;
  88676. }): VertexData;
  88677. /**
  88678. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  88679. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  88680. * @param polygon a mesh built from polygonTriangulation.build()
  88681. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88682. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  88683. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  88684. * @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)
  88685. * @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)
  88686. * @returns the VertexData of the Polygon
  88687. */
  88688. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  88689. /**
  88690. * Creates the VertexData of the IcoSphere
  88691. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  88692. * * radius the radius of the IcoSphere, optional default 1
  88693. * * radiusX allows stretching in the x direction, optional, default radius
  88694. * * radiusY allows stretching in the y direction, optional, default radius
  88695. * * radiusZ allows stretching in the z direction, optional, default radius
  88696. * * flat when true creates a flat shaded mesh, optional, default true
  88697. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  88698. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88699. * * 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)
  88700. * * 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)
  88701. * @returns the VertexData of the IcoSphere
  88702. */
  88703. static CreateIcoSphere(options: {
  88704. radius?: number;
  88705. radiusX?: number;
  88706. radiusY?: number;
  88707. radiusZ?: number;
  88708. flat?: boolean;
  88709. subdivisions?: number;
  88710. sideOrientation?: number;
  88711. frontUVs?: Vector4;
  88712. backUVs?: Vector4;
  88713. }): VertexData;
  88714. /**
  88715. * Creates the VertexData for a Polyhedron
  88716. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  88717. * * type provided types are:
  88718. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  88719. * * 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)
  88720. * * size the size of the IcoSphere, optional default 1
  88721. * * sizeX allows stretching in the x direction, optional, default size
  88722. * * sizeY allows stretching in the y direction, optional, default size
  88723. * * sizeZ allows stretching in the z direction, optional, default size
  88724. * * 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
  88725. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  88726. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  88727. * * flat when true creates a flat shaded mesh, optional, default true
  88728. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  88729. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88730. * * 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)
  88731. * * 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)
  88732. * @returns the VertexData of the Polyhedron
  88733. */
  88734. static CreatePolyhedron(options: {
  88735. type?: number;
  88736. size?: number;
  88737. sizeX?: number;
  88738. sizeY?: number;
  88739. sizeZ?: number;
  88740. custom?: any;
  88741. faceUV?: Vector4[];
  88742. faceColors?: Color4[];
  88743. flat?: boolean;
  88744. sideOrientation?: number;
  88745. frontUVs?: Vector4;
  88746. backUVs?: Vector4;
  88747. }): VertexData;
  88748. /**
  88749. * Creates the VertexData for a TorusKnot
  88750. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  88751. * * radius the radius of the torus knot, optional, default 2
  88752. * * tube the thickness of the tube, optional, default 0.5
  88753. * * radialSegments the number of sides on each tube segments, optional, default 32
  88754. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  88755. * * p the number of windings around the z axis, optional, default 2
  88756. * * q the number of windings around the x axis, optional, default 3
  88757. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88758. * * 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)
  88759. * * 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)
  88760. * @returns the VertexData of the Torus Knot
  88761. */
  88762. static CreateTorusKnot(options: {
  88763. radius?: number;
  88764. tube?: number;
  88765. radialSegments?: number;
  88766. tubularSegments?: number;
  88767. p?: number;
  88768. q?: number;
  88769. sideOrientation?: number;
  88770. frontUVs?: Vector4;
  88771. backUVs?: Vector4;
  88772. }): VertexData;
  88773. /**
  88774. * Compute normals for given positions and indices
  88775. * @param positions an array of vertex positions, [...., x, y, z, ......]
  88776. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  88777. * @param normals an array of vertex normals, [...., x, y, z, ......]
  88778. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  88779. * * facetNormals : optional array of facet normals (vector3)
  88780. * * facetPositions : optional array of facet positions (vector3)
  88781. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  88782. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  88783. * * bInfo : optional bounding info, required for facetPartitioning computation
  88784. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  88785. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  88786. * * useRightHandedSystem: optional boolean to for right handed system computation
  88787. * * depthSort : optional boolean to enable the facet depth sort computation
  88788. * * distanceTo : optional Vector3 to compute the facet depth from this location
  88789. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  88790. */
  88791. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  88792. facetNormals?: any;
  88793. facetPositions?: any;
  88794. facetPartitioning?: any;
  88795. ratio?: number;
  88796. bInfo?: any;
  88797. bbSize?: Vector3;
  88798. subDiv?: any;
  88799. useRightHandedSystem?: boolean;
  88800. depthSort?: boolean;
  88801. distanceTo?: Vector3;
  88802. depthSortedFacets?: any;
  88803. }): void;
  88804. /** @hidden */
  88805. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  88806. /**
  88807. * Applies VertexData created from the imported parameters to the geometry
  88808. * @param parsedVertexData the parsed data from an imported file
  88809. * @param geometry the geometry to apply the VertexData to
  88810. */
  88811. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  88812. }
  88813. }
  88814. declare module BABYLON {
  88815. /**
  88816. * Defines a target to use with MorphTargetManager
  88817. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  88818. */
  88819. export class MorphTarget implements IAnimatable {
  88820. /** defines the name of the target */
  88821. name: string;
  88822. /**
  88823. * Gets or sets the list of animations
  88824. */
  88825. animations: Animation[];
  88826. private _scene;
  88827. private _positions;
  88828. private _normals;
  88829. private _tangents;
  88830. private _uvs;
  88831. private _influence;
  88832. /**
  88833. * Observable raised when the influence changes
  88834. */
  88835. onInfluenceChanged: Observable<boolean>;
  88836. /** @hidden */
  88837. _onDataLayoutChanged: Observable<void>;
  88838. /**
  88839. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  88840. */
  88841. influence: number;
  88842. /**
  88843. * Gets or sets the id of the morph Target
  88844. */
  88845. id: string;
  88846. private _animationPropertiesOverride;
  88847. /**
  88848. * Gets or sets the animation properties override
  88849. */
  88850. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  88851. /**
  88852. * Creates a new MorphTarget
  88853. * @param name defines the name of the target
  88854. * @param influence defines the influence to use
  88855. * @param scene defines the scene the morphtarget belongs to
  88856. */
  88857. constructor(
  88858. /** defines the name of the target */
  88859. name: string, influence?: number, scene?: Nullable<Scene>);
  88860. /**
  88861. * Gets a boolean defining if the target contains position data
  88862. */
  88863. readonly hasPositions: boolean;
  88864. /**
  88865. * Gets a boolean defining if the target contains normal data
  88866. */
  88867. readonly hasNormals: boolean;
  88868. /**
  88869. * Gets a boolean defining if the target contains tangent data
  88870. */
  88871. readonly hasTangents: boolean;
  88872. /**
  88873. * Gets a boolean defining if the target contains texture coordinates data
  88874. */
  88875. readonly hasUVs: boolean;
  88876. /**
  88877. * Affects position data to this target
  88878. * @param data defines the position data to use
  88879. */
  88880. setPositions(data: Nullable<FloatArray>): void;
  88881. /**
  88882. * Gets the position data stored in this target
  88883. * @returns a FloatArray containing the position data (or null if not present)
  88884. */
  88885. getPositions(): Nullable<FloatArray>;
  88886. /**
  88887. * Affects normal data to this target
  88888. * @param data defines the normal data to use
  88889. */
  88890. setNormals(data: Nullable<FloatArray>): void;
  88891. /**
  88892. * Gets the normal data stored in this target
  88893. * @returns a FloatArray containing the normal data (or null if not present)
  88894. */
  88895. getNormals(): Nullable<FloatArray>;
  88896. /**
  88897. * Affects tangent data to this target
  88898. * @param data defines the tangent data to use
  88899. */
  88900. setTangents(data: Nullable<FloatArray>): void;
  88901. /**
  88902. * Gets the tangent data stored in this target
  88903. * @returns a FloatArray containing the tangent data (or null if not present)
  88904. */
  88905. getTangents(): Nullable<FloatArray>;
  88906. /**
  88907. * Affects texture coordinates data to this target
  88908. * @param data defines the texture coordinates data to use
  88909. */
  88910. setUVs(data: Nullable<FloatArray>): void;
  88911. /**
  88912. * Gets the texture coordinates data stored in this target
  88913. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  88914. */
  88915. getUVs(): Nullable<FloatArray>;
  88916. /**
  88917. * Serializes the current target into a Serialization object
  88918. * @returns the serialized object
  88919. */
  88920. serialize(): any;
  88921. /**
  88922. * Returns the string "MorphTarget"
  88923. * @returns "MorphTarget"
  88924. */
  88925. getClassName(): string;
  88926. /**
  88927. * Creates a new target from serialized data
  88928. * @param serializationObject defines the serialized data to use
  88929. * @returns a new MorphTarget
  88930. */
  88931. static Parse(serializationObject: any): MorphTarget;
  88932. /**
  88933. * Creates a MorphTarget from mesh data
  88934. * @param mesh defines the source mesh
  88935. * @param name defines the name to use for the new target
  88936. * @param influence defines the influence to attach to the target
  88937. * @returns a new MorphTarget
  88938. */
  88939. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  88940. }
  88941. }
  88942. declare module BABYLON {
  88943. /**
  88944. * This class is used to deform meshes using morphing between different targets
  88945. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  88946. */
  88947. export class MorphTargetManager {
  88948. private _targets;
  88949. private _targetInfluenceChangedObservers;
  88950. private _targetDataLayoutChangedObservers;
  88951. private _activeTargets;
  88952. private _scene;
  88953. private _influences;
  88954. private _supportsNormals;
  88955. private _supportsTangents;
  88956. private _supportsUVs;
  88957. private _vertexCount;
  88958. private _uniqueId;
  88959. private _tempInfluences;
  88960. /**
  88961. * Gets or sets a boolean indicating if normals must be morphed
  88962. */
  88963. enableNormalMorphing: boolean;
  88964. /**
  88965. * Gets or sets a boolean indicating if tangents must be morphed
  88966. */
  88967. enableTangentMorphing: boolean;
  88968. /**
  88969. * Gets or sets a boolean indicating if UV must be morphed
  88970. */
  88971. enableUVMorphing: boolean;
  88972. /**
  88973. * Creates a new MorphTargetManager
  88974. * @param scene defines the current scene
  88975. */
  88976. constructor(scene?: Nullable<Scene>);
  88977. /**
  88978. * Gets the unique ID of this manager
  88979. */
  88980. readonly uniqueId: number;
  88981. /**
  88982. * Gets the number of vertices handled by this manager
  88983. */
  88984. readonly vertexCount: number;
  88985. /**
  88986. * Gets a boolean indicating if this manager supports morphing of normals
  88987. */
  88988. readonly supportsNormals: boolean;
  88989. /**
  88990. * Gets a boolean indicating if this manager supports morphing of tangents
  88991. */
  88992. readonly supportsTangents: boolean;
  88993. /**
  88994. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  88995. */
  88996. readonly supportsUVs: boolean;
  88997. /**
  88998. * Gets the number of targets stored in this manager
  88999. */
  89000. readonly numTargets: number;
  89001. /**
  89002. * Gets the number of influencers (ie. the number of targets with influences > 0)
  89003. */
  89004. readonly numInfluencers: number;
  89005. /**
  89006. * Gets the list of influences (one per target)
  89007. */
  89008. readonly influences: Float32Array;
  89009. /**
  89010. * Gets the active target at specified index. An active target is a target with an influence > 0
  89011. * @param index defines the index to check
  89012. * @returns the requested target
  89013. */
  89014. getActiveTarget(index: number): MorphTarget;
  89015. /**
  89016. * Gets the target at specified index
  89017. * @param index defines the index to check
  89018. * @returns the requested target
  89019. */
  89020. getTarget(index: number): MorphTarget;
  89021. /**
  89022. * Add a new target to this manager
  89023. * @param target defines the target to add
  89024. */
  89025. addTarget(target: MorphTarget): void;
  89026. /**
  89027. * Removes a target from the manager
  89028. * @param target defines the target to remove
  89029. */
  89030. removeTarget(target: MorphTarget): void;
  89031. /**
  89032. * Serializes the current manager into a Serialization object
  89033. * @returns the serialized object
  89034. */
  89035. serialize(): any;
  89036. private _syncActiveTargets;
  89037. /**
  89038. * Syncrhonize the targets with all the meshes using this morph target manager
  89039. */
  89040. synchronize(): void;
  89041. /**
  89042. * Creates a new MorphTargetManager from serialized data
  89043. * @param serializationObject defines the serialized data
  89044. * @param scene defines the hosting scene
  89045. * @returns the new MorphTargetManager
  89046. */
  89047. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  89048. }
  89049. }
  89050. declare module BABYLON {
  89051. /**
  89052. * Class used to represent a specific level of detail of a mesh
  89053. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  89054. */
  89055. export class MeshLODLevel {
  89056. /** Defines the distance where this level should start being displayed */
  89057. distance: number;
  89058. /** Defines the mesh to use to render this level */
  89059. mesh: Nullable<Mesh>;
  89060. /**
  89061. * Creates a new LOD level
  89062. * @param distance defines the distance where this level should star being displayed
  89063. * @param mesh defines the mesh to use to render this level
  89064. */
  89065. constructor(
  89066. /** Defines the distance where this level should start being displayed */
  89067. distance: number,
  89068. /** Defines the mesh to use to render this level */
  89069. mesh: Nullable<Mesh>);
  89070. }
  89071. }
  89072. declare module BABYLON {
  89073. /**
  89074. * Mesh representing the gorund
  89075. */
  89076. export class GroundMesh extends Mesh {
  89077. /** If octree should be generated */
  89078. generateOctree: boolean;
  89079. private _heightQuads;
  89080. /** @hidden */
  89081. _subdivisionsX: number;
  89082. /** @hidden */
  89083. _subdivisionsY: number;
  89084. /** @hidden */
  89085. _width: number;
  89086. /** @hidden */
  89087. _height: number;
  89088. /** @hidden */
  89089. _minX: number;
  89090. /** @hidden */
  89091. _maxX: number;
  89092. /** @hidden */
  89093. _minZ: number;
  89094. /** @hidden */
  89095. _maxZ: number;
  89096. constructor(name: string, scene: Scene);
  89097. /**
  89098. * "GroundMesh"
  89099. * @returns "GroundMesh"
  89100. */
  89101. getClassName(): string;
  89102. /**
  89103. * The minimum of x and y subdivisions
  89104. */
  89105. readonly subdivisions: number;
  89106. /**
  89107. * X subdivisions
  89108. */
  89109. readonly subdivisionsX: number;
  89110. /**
  89111. * Y subdivisions
  89112. */
  89113. readonly subdivisionsY: number;
  89114. /**
  89115. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  89116. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  89117. * @param chunksCount the number of subdivisions for x and y
  89118. * @param octreeBlocksSize (Default: 32)
  89119. */
  89120. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  89121. /**
  89122. * Returns a height (y) value in the Worl system :
  89123. * the ground altitude at the coordinates (x, z) expressed in the World system.
  89124. * @param x x coordinate
  89125. * @param z z coordinate
  89126. * @returns the ground y position if (x, z) are outside the ground surface.
  89127. */
  89128. getHeightAtCoordinates(x: number, z: number): number;
  89129. /**
  89130. * Returns a normalized vector (Vector3) orthogonal to the ground
  89131. * at the ground coordinates (x, z) expressed in the World system.
  89132. * @param x x coordinate
  89133. * @param z z coordinate
  89134. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  89135. */
  89136. getNormalAtCoordinates(x: number, z: number): Vector3;
  89137. /**
  89138. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  89139. * at the ground coordinates (x, z) expressed in the World system.
  89140. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  89141. * @param x x coordinate
  89142. * @param z z coordinate
  89143. * @param ref vector to store the result
  89144. * @returns the GroundMesh.
  89145. */
  89146. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  89147. /**
  89148. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  89149. * if the ground has been updated.
  89150. * This can be used in the render loop.
  89151. * @returns the GroundMesh.
  89152. */
  89153. updateCoordinateHeights(): GroundMesh;
  89154. private _getFacetAt;
  89155. private _initHeightQuads;
  89156. private _computeHeightQuads;
  89157. /**
  89158. * Serializes this ground mesh
  89159. * @param serializationObject object to write serialization to
  89160. */
  89161. serialize(serializationObject: any): void;
  89162. /**
  89163. * Parses a serialized ground mesh
  89164. * @param parsedMesh the serialized mesh
  89165. * @param scene the scene to create the ground mesh in
  89166. * @returns the created ground mesh
  89167. */
  89168. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  89169. }
  89170. }
  89171. declare module BABYLON {
  89172. /**
  89173. * Interface for Physics-Joint data
  89174. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89175. */
  89176. export interface PhysicsJointData {
  89177. /**
  89178. * The main pivot of the joint
  89179. */
  89180. mainPivot?: Vector3;
  89181. /**
  89182. * The connected pivot of the joint
  89183. */
  89184. connectedPivot?: Vector3;
  89185. /**
  89186. * The main axis of the joint
  89187. */
  89188. mainAxis?: Vector3;
  89189. /**
  89190. * The connected axis of the joint
  89191. */
  89192. connectedAxis?: Vector3;
  89193. /**
  89194. * The collision of the joint
  89195. */
  89196. collision?: boolean;
  89197. /**
  89198. * Native Oimo/Cannon/Energy data
  89199. */
  89200. nativeParams?: any;
  89201. }
  89202. /**
  89203. * This is a holder class for the physics joint created by the physics plugin
  89204. * It holds a set of functions to control the underlying joint
  89205. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89206. */
  89207. export class PhysicsJoint {
  89208. /**
  89209. * The type of the physics joint
  89210. */
  89211. type: number;
  89212. /**
  89213. * The data for the physics joint
  89214. */
  89215. jointData: PhysicsJointData;
  89216. private _physicsJoint;
  89217. protected _physicsPlugin: IPhysicsEnginePlugin;
  89218. /**
  89219. * Initializes the physics joint
  89220. * @param type The type of the physics joint
  89221. * @param jointData The data for the physics joint
  89222. */
  89223. constructor(
  89224. /**
  89225. * The type of the physics joint
  89226. */
  89227. type: number,
  89228. /**
  89229. * The data for the physics joint
  89230. */
  89231. jointData: PhysicsJointData);
  89232. /**
  89233. * Gets the physics joint
  89234. */
  89235. /**
  89236. * Sets the physics joint
  89237. */
  89238. physicsJoint: any;
  89239. /**
  89240. * Sets the physics plugin
  89241. */
  89242. physicsPlugin: IPhysicsEnginePlugin;
  89243. /**
  89244. * Execute a function that is physics-plugin specific.
  89245. * @param {Function} func the function that will be executed.
  89246. * It accepts two parameters: the physics world and the physics joint
  89247. */
  89248. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  89249. /**
  89250. * Distance-Joint type
  89251. */
  89252. static DistanceJoint: number;
  89253. /**
  89254. * Hinge-Joint type
  89255. */
  89256. static HingeJoint: number;
  89257. /**
  89258. * Ball-and-Socket joint type
  89259. */
  89260. static BallAndSocketJoint: number;
  89261. /**
  89262. * Wheel-Joint type
  89263. */
  89264. static WheelJoint: number;
  89265. /**
  89266. * Slider-Joint type
  89267. */
  89268. static SliderJoint: number;
  89269. /**
  89270. * Prismatic-Joint type
  89271. */
  89272. static PrismaticJoint: number;
  89273. /**
  89274. * Universal-Joint type
  89275. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  89276. */
  89277. static UniversalJoint: number;
  89278. /**
  89279. * Hinge-Joint 2 type
  89280. */
  89281. static Hinge2Joint: number;
  89282. /**
  89283. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  89284. */
  89285. static PointToPointJoint: number;
  89286. /**
  89287. * Spring-Joint type
  89288. */
  89289. static SpringJoint: number;
  89290. /**
  89291. * Lock-Joint type
  89292. */
  89293. static LockJoint: number;
  89294. }
  89295. /**
  89296. * A class representing a physics distance joint
  89297. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89298. */
  89299. export class DistanceJoint extends PhysicsJoint {
  89300. /**
  89301. *
  89302. * @param jointData The data for the Distance-Joint
  89303. */
  89304. constructor(jointData: DistanceJointData);
  89305. /**
  89306. * Update the predefined distance.
  89307. * @param maxDistance The maximum preferred distance
  89308. * @param minDistance The minimum preferred distance
  89309. */
  89310. updateDistance(maxDistance: number, minDistance?: number): void;
  89311. }
  89312. /**
  89313. * Represents a Motor-Enabled Joint
  89314. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89315. */
  89316. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  89317. /**
  89318. * Initializes the Motor-Enabled Joint
  89319. * @param type The type of the joint
  89320. * @param jointData The physica joint data for the joint
  89321. */
  89322. constructor(type: number, jointData: PhysicsJointData);
  89323. /**
  89324. * Set the motor values.
  89325. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89326. * @param force the force to apply
  89327. * @param maxForce max force for this motor.
  89328. */
  89329. setMotor(force?: number, maxForce?: number): void;
  89330. /**
  89331. * Set the motor's limits.
  89332. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89333. * @param upperLimit The upper limit of the motor
  89334. * @param lowerLimit The lower limit of the motor
  89335. */
  89336. setLimit(upperLimit: number, lowerLimit?: number): void;
  89337. }
  89338. /**
  89339. * This class represents a single physics Hinge-Joint
  89340. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89341. */
  89342. export class HingeJoint extends MotorEnabledJoint {
  89343. /**
  89344. * Initializes the Hinge-Joint
  89345. * @param jointData The joint data for the Hinge-Joint
  89346. */
  89347. constructor(jointData: PhysicsJointData);
  89348. /**
  89349. * Set the motor values.
  89350. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89351. * @param {number} force the force to apply
  89352. * @param {number} maxForce max force for this motor.
  89353. */
  89354. setMotor(force?: number, maxForce?: number): void;
  89355. /**
  89356. * Set the motor's limits.
  89357. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89358. * @param upperLimit The upper limit of the motor
  89359. * @param lowerLimit The lower limit of the motor
  89360. */
  89361. setLimit(upperLimit: number, lowerLimit?: number): void;
  89362. }
  89363. /**
  89364. * This class represents a dual hinge physics joint (same as wheel joint)
  89365. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89366. */
  89367. export class Hinge2Joint extends MotorEnabledJoint {
  89368. /**
  89369. * Initializes the Hinge2-Joint
  89370. * @param jointData The joint data for the Hinge2-Joint
  89371. */
  89372. constructor(jointData: PhysicsJointData);
  89373. /**
  89374. * Set the motor values.
  89375. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89376. * @param {number} targetSpeed the speed the motor is to reach
  89377. * @param {number} maxForce max force for this motor.
  89378. * @param {motorIndex} the motor's index, 0 or 1.
  89379. */
  89380. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  89381. /**
  89382. * Set the motor limits.
  89383. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89384. * @param {number} upperLimit the upper limit
  89385. * @param {number} lowerLimit lower limit
  89386. * @param {motorIndex} the motor's index, 0 or 1.
  89387. */
  89388. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  89389. }
  89390. /**
  89391. * Interface for a motor enabled joint
  89392. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89393. */
  89394. export interface IMotorEnabledJoint {
  89395. /**
  89396. * Physics joint
  89397. */
  89398. physicsJoint: any;
  89399. /**
  89400. * Sets the motor of the motor-enabled joint
  89401. * @param force The force of the motor
  89402. * @param maxForce The maximum force of the motor
  89403. * @param motorIndex The index of the motor
  89404. */
  89405. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  89406. /**
  89407. * Sets the limit of the motor
  89408. * @param upperLimit The upper limit of the motor
  89409. * @param lowerLimit The lower limit of the motor
  89410. * @param motorIndex The index of the motor
  89411. */
  89412. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  89413. }
  89414. /**
  89415. * Joint data for a Distance-Joint
  89416. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89417. */
  89418. export interface DistanceJointData extends PhysicsJointData {
  89419. /**
  89420. * Max distance the 2 joint objects can be apart
  89421. */
  89422. maxDistance: number;
  89423. }
  89424. /**
  89425. * Joint data from a spring joint
  89426. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89427. */
  89428. export interface SpringJointData extends PhysicsJointData {
  89429. /**
  89430. * Length of the spring
  89431. */
  89432. length: number;
  89433. /**
  89434. * Stiffness of the spring
  89435. */
  89436. stiffness: number;
  89437. /**
  89438. * Damping of the spring
  89439. */
  89440. damping: number;
  89441. /** this callback will be called when applying the force to the impostors. */
  89442. forceApplicationCallback: () => void;
  89443. }
  89444. }
  89445. declare module BABYLON {
  89446. /**
  89447. * Holds the data for the raycast result
  89448. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89449. */
  89450. export class PhysicsRaycastResult {
  89451. private _hasHit;
  89452. private _hitDistance;
  89453. private _hitNormalWorld;
  89454. private _hitPointWorld;
  89455. private _rayFromWorld;
  89456. private _rayToWorld;
  89457. /**
  89458. * Gets if there was a hit
  89459. */
  89460. readonly hasHit: boolean;
  89461. /**
  89462. * Gets the distance from the hit
  89463. */
  89464. readonly hitDistance: number;
  89465. /**
  89466. * Gets the hit normal/direction in the world
  89467. */
  89468. readonly hitNormalWorld: Vector3;
  89469. /**
  89470. * Gets the hit point in the world
  89471. */
  89472. readonly hitPointWorld: Vector3;
  89473. /**
  89474. * Gets the ray "start point" of the ray in the world
  89475. */
  89476. readonly rayFromWorld: Vector3;
  89477. /**
  89478. * Gets the ray "end point" of the ray in the world
  89479. */
  89480. readonly rayToWorld: Vector3;
  89481. /**
  89482. * Sets the hit data (normal & point in world space)
  89483. * @param hitNormalWorld defines the normal in world space
  89484. * @param hitPointWorld defines the point in world space
  89485. */
  89486. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  89487. /**
  89488. * Sets the distance from the start point to the hit point
  89489. * @param distance
  89490. */
  89491. setHitDistance(distance: number): void;
  89492. /**
  89493. * Calculates the distance manually
  89494. */
  89495. calculateHitDistance(): void;
  89496. /**
  89497. * Resets all the values to default
  89498. * @param from The from point on world space
  89499. * @param to The to point on world space
  89500. */
  89501. reset(from?: Vector3, to?: Vector3): void;
  89502. }
  89503. /**
  89504. * Interface for the size containing width and height
  89505. */
  89506. interface IXYZ {
  89507. /**
  89508. * X
  89509. */
  89510. x: number;
  89511. /**
  89512. * Y
  89513. */
  89514. y: number;
  89515. /**
  89516. * Z
  89517. */
  89518. z: number;
  89519. }
  89520. }
  89521. declare module BABYLON {
  89522. /**
  89523. * Interface used to describe a physics joint
  89524. */
  89525. export interface PhysicsImpostorJoint {
  89526. /** Defines the main impostor to which the joint is linked */
  89527. mainImpostor: PhysicsImpostor;
  89528. /** Defines the impostor that is connected to the main impostor using this joint */
  89529. connectedImpostor: PhysicsImpostor;
  89530. /** Defines the joint itself */
  89531. joint: PhysicsJoint;
  89532. }
  89533. /** @hidden */
  89534. export interface IPhysicsEnginePlugin {
  89535. world: any;
  89536. name: string;
  89537. setGravity(gravity: Vector3): void;
  89538. setTimeStep(timeStep: number): void;
  89539. getTimeStep(): number;
  89540. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  89541. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  89542. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  89543. generatePhysicsBody(impostor: PhysicsImpostor): void;
  89544. removePhysicsBody(impostor: PhysicsImpostor): void;
  89545. generateJoint(joint: PhysicsImpostorJoint): void;
  89546. removeJoint(joint: PhysicsImpostorJoint): void;
  89547. isSupported(): boolean;
  89548. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  89549. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  89550. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  89551. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  89552. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  89553. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  89554. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  89555. getBodyMass(impostor: PhysicsImpostor): number;
  89556. getBodyFriction(impostor: PhysicsImpostor): number;
  89557. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  89558. getBodyRestitution(impostor: PhysicsImpostor): number;
  89559. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  89560. getBodyPressure?(impostor: PhysicsImpostor): number;
  89561. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  89562. getBodyStiffness?(impostor: PhysicsImpostor): number;
  89563. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  89564. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  89565. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  89566. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  89567. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  89568. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  89569. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  89570. sleepBody(impostor: PhysicsImpostor): void;
  89571. wakeUpBody(impostor: PhysicsImpostor): void;
  89572. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  89573. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  89574. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  89575. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  89576. getRadius(impostor: PhysicsImpostor): number;
  89577. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  89578. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  89579. dispose(): void;
  89580. }
  89581. /**
  89582. * Interface used to define a physics engine
  89583. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  89584. */
  89585. export interface IPhysicsEngine {
  89586. /**
  89587. * Gets the gravity vector used by the simulation
  89588. */
  89589. gravity: Vector3;
  89590. /**
  89591. * Sets the gravity vector used by the simulation
  89592. * @param gravity defines the gravity vector to use
  89593. */
  89594. setGravity(gravity: Vector3): void;
  89595. /**
  89596. * Set the time step of the physics engine.
  89597. * Default is 1/60.
  89598. * To slow it down, enter 1/600 for example.
  89599. * To speed it up, 1/30
  89600. * @param newTimeStep the new timestep to apply to this world.
  89601. */
  89602. setTimeStep(newTimeStep: number): void;
  89603. /**
  89604. * Get the time step of the physics engine.
  89605. * @returns the current time step
  89606. */
  89607. getTimeStep(): number;
  89608. /**
  89609. * Release all resources
  89610. */
  89611. dispose(): void;
  89612. /**
  89613. * Gets the name of the current physics plugin
  89614. * @returns the name of the plugin
  89615. */
  89616. getPhysicsPluginName(): string;
  89617. /**
  89618. * Adding a new impostor for the impostor tracking.
  89619. * This will be done by the impostor itself.
  89620. * @param impostor the impostor to add
  89621. */
  89622. addImpostor(impostor: PhysicsImpostor): void;
  89623. /**
  89624. * Remove an impostor from the engine.
  89625. * This impostor and its mesh will not longer be updated by the physics engine.
  89626. * @param impostor the impostor to remove
  89627. */
  89628. removeImpostor(impostor: PhysicsImpostor): void;
  89629. /**
  89630. * Add a joint to the physics engine
  89631. * @param mainImpostor defines the main impostor to which the joint is added.
  89632. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  89633. * @param joint defines the joint that will connect both impostors.
  89634. */
  89635. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  89636. /**
  89637. * Removes a joint from the simulation
  89638. * @param mainImpostor defines the impostor used with the joint
  89639. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  89640. * @param joint defines the joint to remove
  89641. */
  89642. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  89643. /**
  89644. * Gets the current plugin used to run the simulation
  89645. * @returns current plugin
  89646. */
  89647. getPhysicsPlugin(): IPhysicsEnginePlugin;
  89648. /**
  89649. * Gets the list of physic impostors
  89650. * @returns an array of PhysicsImpostor
  89651. */
  89652. getImpostors(): Array<PhysicsImpostor>;
  89653. /**
  89654. * Gets the impostor for a physics enabled object
  89655. * @param object defines the object impersonated by the impostor
  89656. * @returns the PhysicsImpostor or null if not found
  89657. */
  89658. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  89659. /**
  89660. * Gets the impostor for a physics body object
  89661. * @param body defines physics body used by the impostor
  89662. * @returns the PhysicsImpostor or null if not found
  89663. */
  89664. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  89665. /**
  89666. * Does a raycast in the physics world
  89667. * @param from when should the ray start?
  89668. * @param to when should the ray end?
  89669. * @returns PhysicsRaycastResult
  89670. */
  89671. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  89672. /**
  89673. * Called by the scene. No need to call it.
  89674. * @param delta defines the timespam between frames
  89675. */
  89676. _step(delta: number): void;
  89677. }
  89678. }
  89679. declare module BABYLON {
  89680. /**
  89681. * The interface for the physics imposter parameters
  89682. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89683. */
  89684. export interface PhysicsImpostorParameters {
  89685. /**
  89686. * The mass of the physics imposter
  89687. */
  89688. mass: number;
  89689. /**
  89690. * The friction of the physics imposter
  89691. */
  89692. friction?: number;
  89693. /**
  89694. * The coefficient of restitution of the physics imposter
  89695. */
  89696. restitution?: number;
  89697. /**
  89698. * The native options of the physics imposter
  89699. */
  89700. nativeOptions?: any;
  89701. /**
  89702. * Specifies if the parent should be ignored
  89703. */
  89704. ignoreParent?: boolean;
  89705. /**
  89706. * Specifies if bi-directional transformations should be disabled
  89707. */
  89708. disableBidirectionalTransformation?: boolean;
  89709. /**
  89710. * The pressure inside the physics imposter, soft object only
  89711. */
  89712. pressure?: number;
  89713. /**
  89714. * The stiffness the physics imposter, soft object only
  89715. */
  89716. stiffness?: number;
  89717. /**
  89718. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  89719. */
  89720. velocityIterations?: number;
  89721. /**
  89722. * The number of iterations used in maintaining consistent vertex positions, soft object only
  89723. */
  89724. positionIterations?: number;
  89725. /**
  89726. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  89727. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  89728. * Add to fix multiple points
  89729. */
  89730. fixedPoints?: number;
  89731. /**
  89732. * The collision margin around a soft object
  89733. */
  89734. margin?: number;
  89735. /**
  89736. * The collision margin around a soft object
  89737. */
  89738. damping?: number;
  89739. /**
  89740. * The path for a rope based on an extrusion
  89741. */
  89742. path?: any;
  89743. /**
  89744. * The shape of an extrusion used for a rope based on an extrusion
  89745. */
  89746. shape?: any;
  89747. }
  89748. /**
  89749. * Interface for a physics-enabled object
  89750. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89751. */
  89752. export interface IPhysicsEnabledObject {
  89753. /**
  89754. * The position of the physics-enabled object
  89755. */
  89756. position: Vector3;
  89757. /**
  89758. * The rotation of the physics-enabled object
  89759. */
  89760. rotationQuaternion: Nullable<Quaternion>;
  89761. /**
  89762. * The scale of the physics-enabled object
  89763. */
  89764. scaling: Vector3;
  89765. /**
  89766. * The rotation of the physics-enabled object
  89767. */
  89768. rotation?: Vector3;
  89769. /**
  89770. * The parent of the physics-enabled object
  89771. */
  89772. parent?: any;
  89773. /**
  89774. * The bounding info of the physics-enabled object
  89775. * @returns The bounding info of the physics-enabled object
  89776. */
  89777. getBoundingInfo(): BoundingInfo;
  89778. /**
  89779. * Computes the world matrix
  89780. * @param force Specifies if the world matrix should be computed by force
  89781. * @returns A world matrix
  89782. */
  89783. computeWorldMatrix(force: boolean): Matrix;
  89784. /**
  89785. * Gets the world matrix
  89786. * @returns A world matrix
  89787. */
  89788. getWorldMatrix?(): Matrix;
  89789. /**
  89790. * Gets the child meshes
  89791. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  89792. * @returns An array of abstract meshes
  89793. */
  89794. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  89795. /**
  89796. * Gets the vertex data
  89797. * @param kind The type of vertex data
  89798. * @returns A nullable array of numbers, or a float32 array
  89799. */
  89800. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  89801. /**
  89802. * Gets the indices from the mesh
  89803. * @returns A nullable array of index arrays
  89804. */
  89805. getIndices?(): Nullable<IndicesArray>;
  89806. /**
  89807. * Gets the scene from the mesh
  89808. * @returns the indices array or null
  89809. */
  89810. getScene?(): Scene;
  89811. /**
  89812. * Gets the absolute position from the mesh
  89813. * @returns the absolute position
  89814. */
  89815. getAbsolutePosition(): Vector3;
  89816. /**
  89817. * Gets the absolute pivot point from the mesh
  89818. * @returns the absolute pivot point
  89819. */
  89820. getAbsolutePivotPoint(): Vector3;
  89821. /**
  89822. * Rotates the mesh
  89823. * @param axis The axis of rotation
  89824. * @param amount The amount of rotation
  89825. * @param space The space of the rotation
  89826. * @returns The rotation transform node
  89827. */
  89828. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  89829. /**
  89830. * Translates the mesh
  89831. * @param axis The axis of translation
  89832. * @param distance The distance of translation
  89833. * @param space The space of the translation
  89834. * @returns The transform node
  89835. */
  89836. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  89837. /**
  89838. * Sets the absolute position of the mesh
  89839. * @param absolutePosition The absolute position of the mesh
  89840. * @returns The transform node
  89841. */
  89842. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  89843. /**
  89844. * Gets the class name of the mesh
  89845. * @returns The class name
  89846. */
  89847. getClassName(): string;
  89848. }
  89849. /**
  89850. * Represents a physics imposter
  89851. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89852. */
  89853. export class PhysicsImpostor {
  89854. /**
  89855. * The physics-enabled object used as the physics imposter
  89856. */
  89857. object: IPhysicsEnabledObject;
  89858. /**
  89859. * The type of the physics imposter
  89860. */
  89861. type: number;
  89862. private _options;
  89863. private _scene?;
  89864. /**
  89865. * The default object size of the imposter
  89866. */
  89867. static DEFAULT_OBJECT_SIZE: Vector3;
  89868. /**
  89869. * The identity quaternion of the imposter
  89870. */
  89871. static IDENTITY_QUATERNION: Quaternion;
  89872. /** @hidden */
  89873. _pluginData: any;
  89874. private _physicsEngine;
  89875. private _physicsBody;
  89876. private _bodyUpdateRequired;
  89877. private _onBeforePhysicsStepCallbacks;
  89878. private _onAfterPhysicsStepCallbacks;
  89879. /** @hidden */
  89880. _onPhysicsCollideCallbacks: Array<{
  89881. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  89882. otherImpostors: Array<PhysicsImpostor>;
  89883. }>;
  89884. private _deltaPosition;
  89885. private _deltaRotation;
  89886. private _deltaRotationConjugated;
  89887. /** @hidden */
  89888. _isFromLine: boolean;
  89889. private _parent;
  89890. private _isDisposed;
  89891. private static _tmpVecs;
  89892. private static _tmpQuat;
  89893. /**
  89894. * Specifies if the physics imposter is disposed
  89895. */
  89896. readonly isDisposed: boolean;
  89897. /**
  89898. * Gets the mass of the physics imposter
  89899. */
  89900. mass: number;
  89901. /**
  89902. * Gets the coefficient of friction
  89903. */
  89904. /**
  89905. * Sets the coefficient of friction
  89906. */
  89907. friction: number;
  89908. /**
  89909. * Gets the coefficient of restitution
  89910. */
  89911. /**
  89912. * Sets the coefficient of restitution
  89913. */
  89914. restitution: number;
  89915. /**
  89916. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  89917. */
  89918. /**
  89919. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  89920. */
  89921. pressure: number;
  89922. /**
  89923. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  89924. */
  89925. /**
  89926. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  89927. */
  89928. stiffness: number;
  89929. /**
  89930. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  89931. */
  89932. /**
  89933. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  89934. */
  89935. velocityIterations: number;
  89936. /**
  89937. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  89938. */
  89939. /**
  89940. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  89941. */
  89942. positionIterations: number;
  89943. /**
  89944. * The unique id of the physics imposter
  89945. * set by the physics engine when adding this impostor to the array
  89946. */
  89947. uniqueId: number;
  89948. /**
  89949. * @hidden
  89950. */
  89951. soft: boolean;
  89952. /**
  89953. * @hidden
  89954. */
  89955. segments: number;
  89956. private _joints;
  89957. /**
  89958. * Initializes the physics imposter
  89959. * @param object The physics-enabled object used as the physics imposter
  89960. * @param type The type of the physics imposter
  89961. * @param _options The options for the physics imposter
  89962. * @param _scene The Babylon scene
  89963. */
  89964. constructor(
  89965. /**
  89966. * The physics-enabled object used as the physics imposter
  89967. */
  89968. object: IPhysicsEnabledObject,
  89969. /**
  89970. * The type of the physics imposter
  89971. */
  89972. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  89973. /**
  89974. * This function will completly initialize this impostor.
  89975. * It will create a new body - but only if this mesh has no parent.
  89976. * If it has, this impostor will not be used other than to define the impostor
  89977. * of the child mesh.
  89978. * @hidden
  89979. */
  89980. _init(): void;
  89981. private _getPhysicsParent;
  89982. /**
  89983. * Should a new body be generated.
  89984. * @returns boolean specifying if body initialization is required
  89985. */
  89986. isBodyInitRequired(): boolean;
  89987. /**
  89988. * Sets the updated scaling
  89989. * @param updated Specifies if the scaling is updated
  89990. */
  89991. setScalingUpdated(): void;
  89992. /**
  89993. * Force a regeneration of this or the parent's impostor's body.
  89994. * Use under cautious - This will remove all joints already implemented.
  89995. */
  89996. forceUpdate(): void;
  89997. /**
  89998. * Gets the body that holds this impostor. Either its own, or its parent.
  89999. */
  90000. /**
  90001. * Set the physics body. Used mainly by the physics engine/plugin
  90002. */
  90003. physicsBody: any;
  90004. /**
  90005. * Get the parent of the physics imposter
  90006. * @returns Physics imposter or null
  90007. */
  90008. /**
  90009. * Sets the parent of the physics imposter
  90010. */
  90011. parent: Nullable<PhysicsImpostor>;
  90012. /**
  90013. * Resets the update flags
  90014. */
  90015. resetUpdateFlags(): void;
  90016. /**
  90017. * Gets the object extend size
  90018. * @returns the object extend size
  90019. */
  90020. getObjectExtendSize(): Vector3;
  90021. /**
  90022. * Gets the object center
  90023. * @returns The object center
  90024. */
  90025. getObjectCenter(): Vector3;
  90026. /**
  90027. * Get a specific parametes from the options parameter
  90028. * @param paramName The object parameter name
  90029. * @returns The object parameter
  90030. */
  90031. getParam(paramName: string): any;
  90032. /**
  90033. * Sets a specific parameter in the options given to the physics plugin
  90034. * @param paramName The parameter name
  90035. * @param value The value of the parameter
  90036. */
  90037. setParam(paramName: string, value: number): void;
  90038. /**
  90039. * Specifically change the body's mass option. Won't recreate the physics body object
  90040. * @param mass The mass of the physics imposter
  90041. */
  90042. setMass(mass: number): void;
  90043. /**
  90044. * Gets the linear velocity
  90045. * @returns linear velocity or null
  90046. */
  90047. getLinearVelocity(): Nullable<Vector3>;
  90048. /**
  90049. * Sets the linear velocity
  90050. * @param velocity linear velocity or null
  90051. */
  90052. setLinearVelocity(velocity: Nullable<Vector3>): void;
  90053. /**
  90054. * Gets the angular velocity
  90055. * @returns angular velocity or null
  90056. */
  90057. getAngularVelocity(): Nullable<Vector3>;
  90058. /**
  90059. * Sets the angular velocity
  90060. * @param velocity The velocity or null
  90061. */
  90062. setAngularVelocity(velocity: Nullable<Vector3>): void;
  90063. /**
  90064. * Execute a function with the physics plugin native code
  90065. * Provide a function the will have two variables - the world object and the physics body object
  90066. * @param func The function to execute with the physics plugin native code
  90067. */
  90068. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  90069. /**
  90070. * Register a function that will be executed before the physics world is stepping forward
  90071. * @param func The function to execute before the physics world is stepped forward
  90072. */
  90073. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  90074. /**
  90075. * Unregister a function that will be executed before the physics world is stepping forward
  90076. * @param func The function to execute before the physics world is stepped forward
  90077. */
  90078. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  90079. /**
  90080. * Register a function that will be executed after the physics step
  90081. * @param func The function to execute after physics step
  90082. */
  90083. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  90084. /**
  90085. * Unregisters a function that will be executed after the physics step
  90086. * @param func The function to execute after physics step
  90087. */
  90088. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  90089. /**
  90090. * register a function that will be executed when this impostor collides against a different body
  90091. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  90092. * @param func Callback that is executed on collision
  90093. */
  90094. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  90095. /**
  90096. * Unregisters the physics imposter on contact
  90097. * @param collideAgainst The physics object to collide against
  90098. * @param func Callback to execute on collision
  90099. */
  90100. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  90101. private _tmpQuat;
  90102. private _tmpQuat2;
  90103. /**
  90104. * Get the parent rotation
  90105. * @returns The parent rotation
  90106. */
  90107. getParentsRotation(): Quaternion;
  90108. /**
  90109. * this function is executed by the physics engine.
  90110. */
  90111. beforeStep: () => void;
  90112. /**
  90113. * this function is executed by the physics engine
  90114. */
  90115. afterStep: () => void;
  90116. /**
  90117. * Legacy collision detection event support
  90118. */
  90119. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  90120. /**
  90121. * event and body object due to cannon's event-based architecture.
  90122. */
  90123. onCollide: (e: {
  90124. body: any;
  90125. }) => void;
  90126. /**
  90127. * Apply a force
  90128. * @param force The force to apply
  90129. * @param contactPoint The contact point for the force
  90130. * @returns The physics imposter
  90131. */
  90132. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  90133. /**
  90134. * Apply an impulse
  90135. * @param force The impulse force
  90136. * @param contactPoint The contact point for the impulse force
  90137. * @returns The physics imposter
  90138. */
  90139. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  90140. /**
  90141. * A help function to create a joint
  90142. * @param otherImpostor A physics imposter used to create a joint
  90143. * @param jointType The type of joint
  90144. * @param jointData The data for the joint
  90145. * @returns The physics imposter
  90146. */
  90147. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  90148. /**
  90149. * Add a joint to this impostor with a different impostor
  90150. * @param otherImpostor A physics imposter used to add a joint
  90151. * @param joint The joint to add
  90152. * @returns The physics imposter
  90153. */
  90154. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  90155. /**
  90156. * Add an anchor to a cloth impostor
  90157. * @param otherImpostor rigid impostor to anchor to
  90158. * @param width ratio across width from 0 to 1
  90159. * @param height ratio up height from 0 to 1
  90160. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  90161. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  90162. * @returns impostor the soft imposter
  90163. */
  90164. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  90165. /**
  90166. * Add a hook to a rope impostor
  90167. * @param otherImpostor rigid impostor to anchor to
  90168. * @param length ratio across rope from 0 to 1
  90169. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  90170. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  90171. * @returns impostor the rope imposter
  90172. */
  90173. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  90174. /**
  90175. * Will keep this body still, in a sleep mode.
  90176. * @returns the physics imposter
  90177. */
  90178. sleep(): PhysicsImpostor;
  90179. /**
  90180. * Wake the body up.
  90181. * @returns The physics imposter
  90182. */
  90183. wakeUp(): PhysicsImpostor;
  90184. /**
  90185. * Clones the physics imposter
  90186. * @param newObject The physics imposter clones to this physics-enabled object
  90187. * @returns A nullable physics imposter
  90188. */
  90189. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  90190. /**
  90191. * Disposes the physics imposter
  90192. */
  90193. dispose(): void;
  90194. /**
  90195. * Sets the delta position
  90196. * @param position The delta position amount
  90197. */
  90198. setDeltaPosition(position: Vector3): void;
  90199. /**
  90200. * Sets the delta rotation
  90201. * @param rotation The delta rotation amount
  90202. */
  90203. setDeltaRotation(rotation: Quaternion): void;
  90204. /**
  90205. * Gets the box size of the physics imposter and stores the result in the input parameter
  90206. * @param result Stores the box size
  90207. * @returns The physics imposter
  90208. */
  90209. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  90210. /**
  90211. * Gets the radius of the physics imposter
  90212. * @returns Radius of the physics imposter
  90213. */
  90214. getRadius(): number;
  90215. /**
  90216. * Sync a bone with this impostor
  90217. * @param bone The bone to sync to the impostor.
  90218. * @param boneMesh The mesh that the bone is influencing.
  90219. * @param jointPivot The pivot of the joint / bone in local space.
  90220. * @param distToJoint Optional distance from the impostor to the joint.
  90221. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  90222. */
  90223. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  90224. /**
  90225. * Sync impostor to a bone
  90226. * @param bone The bone that the impostor will be synced to.
  90227. * @param boneMesh The mesh that the bone is influencing.
  90228. * @param jointPivot The pivot of the joint / bone in local space.
  90229. * @param distToJoint Optional distance from the impostor to the joint.
  90230. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  90231. * @param boneAxis Optional vector3 axis the bone is aligned with
  90232. */
  90233. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  90234. /**
  90235. * No-Imposter type
  90236. */
  90237. static NoImpostor: number;
  90238. /**
  90239. * Sphere-Imposter type
  90240. */
  90241. static SphereImpostor: number;
  90242. /**
  90243. * Box-Imposter type
  90244. */
  90245. static BoxImpostor: number;
  90246. /**
  90247. * Plane-Imposter type
  90248. */
  90249. static PlaneImpostor: number;
  90250. /**
  90251. * Mesh-imposter type
  90252. */
  90253. static MeshImpostor: number;
  90254. /**
  90255. * Capsule-Impostor type (Ammo.js plugin only)
  90256. */
  90257. static CapsuleImpostor: number;
  90258. /**
  90259. * Cylinder-Imposter type
  90260. */
  90261. static CylinderImpostor: number;
  90262. /**
  90263. * Particle-Imposter type
  90264. */
  90265. static ParticleImpostor: number;
  90266. /**
  90267. * Heightmap-Imposter type
  90268. */
  90269. static HeightmapImpostor: number;
  90270. /**
  90271. * ConvexHull-Impostor type (Ammo.js plugin only)
  90272. */
  90273. static ConvexHullImpostor: number;
  90274. /**
  90275. * Rope-Imposter type
  90276. */
  90277. static RopeImpostor: number;
  90278. /**
  90279. * Cloth-Imposter type
  90280. */
  90281. static ClothImpostor: number;
  90282. /**
  90283. * Softbody-Imposter type
  90284. */
  90285. static SoftbodyImpostor: number;
  90286. }
  90287. }
  90288. declare module BABYLON {
  90289. /**
  90290. * @hidden
  90291. **/
  90292. export class _CreationDataStorage {
  90293. closePath?: boolean;
  90294. closeArray?: boolean;
  90295. idx: number[];
  90296. dashSize: number;
  90297. gapSize: number;
  90298. path3D: Path3D;
  90299. pathArray: Vector3[][];
  90300. arc: number;
  90301. radius: number;
  90302. cap: number;
  90303. tessellation: number;
  90304. }
  90305. /**
  90306. * @hidden
  90307. **/
  90308. class _InstanceDataStorage {
  90309. visibleInstances: any;
  90310. batchCache: _InstancesBatch;
  90311. instancesBufferSize: number;
  90312. instancesBuffer: Nullable<Buffer>;
  90313. instancesData: Float32Array;
  90314. overridenInstanceCount: number;
  90315. isFrozen: boolean;
  90316. previousBatch: Nullable<_InstancesBatch>;
  90317. hardwareInstancedRendering: boolean;
  90318. sideOrientation: number;
  90319. }
  90320. /**
  90321. * @hidden
  90322. **/
  90323. export class _InstancesBatch {
  90324. mustReturn: boolean;
  90325. visibleInstances: Nullable<InstancedMesh[]>[];
  90326. renderSelf: boolean[];
  90327. hardwareInstancedRendering: boolean[];
  90328. }
  90329. /**
  90330. * Class used to represent renderable models
  90331. */
  90332. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  90333. /**
  90334. * Mesh side orientation : usually the external or front surface
  90335. */
  90336. static readonly FRONTSIDE: number;
  90337. /**
  90338. * Mesh side orientation : usually the internal or back surface
  90339. */
  90340. static readonly BACKSIDE: number;
  90341. /**
  90342. * Mesh side orientation : both internal and external or front and back surfaces
  90343. */
  90344. static readonly DOUBLESIDE: number;
  90345. /**
  90346. * Mesh side orientation : by default, `FRONTSIDE`
  90347. */
  90348. static readonly DEFAULTSIDE: number;
  90349. /**
  90350. * Mesh cap setting : no cap
  90351. */
  90352. static readonly NO_CAP: number;
  90353. /**
  90354. * Mesh cap setting : one cap at the beginning of the mesh
  90355. */
  90356. static readonly CAP_START: number;
  90357. /**
  90358. * Mesh cap setting : one cap at the end of the mesh
  90359. */
  90360. static readonly CAP_END: number;
  90361. /**
  90362. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  90363. */
  90364. static readonly CAP_ALL: number;
  90365. /**
  90366. * Mesh pattern setting : no flip or rotate
  90367. */
  90368. static readonly NO_FLIP: number;
  90369. /**
  90370. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  90371. */
  90372. static readonly FLIP_TILE: number;
  90373. /**
  90374. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  90375. */
  90376. static readonly ROTATE_TILE: number;
  90377. /**
  90378. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  90379. */
  90380. static readonly FLIP_ROW: number;
  90381. /**
  90382. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  90383. */
  90384. static readonly ROTATE_ROW: number;
  90385. /**
  90386. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  90387. */
  90388. static readonly FLIP_N_ROTATE_TILE: number;
  90389. /**
  90390. * Mesh pattern setting : rotate pattern and rotate
  90391. */
  90392. static readonly FLIP_N_ROTATE_ROW: number;
  90393. /**
  90394. * Mesh tile positioning : part tiles same on left/right or top/bottom
  90395. */
  90396. static readonly CENTER: number;
  90397. /**
  90398. * Mesh tile positioning : part tiles on left
  90399. */
  90400. static readonly LEFT: number;
  90401. /**
  90402. * Mesh tile positioning : part tiles on right
  90403. */
  90404. static readonly RIGHT: number;
  90405. /**
  90406. * Mesh tile positioning : part tiles on top
  90407. */
  90408. static readonly TOP: number;
  90409. /**
  90410. * Mesh tile positioning : part tiles on bottom
  90411. */
  90412. static readonly BOTTOM: number;
  90413. /**
  90414. * Gets the default side orientation.
  90415. * @param orientation the orientation to value to attempt to get
  90416. * @returns the default orientation
  90417. * @hidden
  90418. */
  90419. static _GetDefaultSideOrientation(orientation?: number): number;
  90420. private _internalMeshDataInfo;
  90421. /**
  90422. * An event triggered before rendering the mesh
  90423. */
  90424. readonly onBeforeRenderObservable: Observable<Mesh>;
  90425. /**
  90426. * An event triggered before binding the mesh
  90427. */
  90428. readonly onBeforeBindObservable: Observable<Mesh>;
  90429. /**
  90430. * An event triggered after rendering the mesh
  90431. */
  90432. readonly onAfterRenderObservable: Observable<Mesh>;
  90433. /**
  90434. * An event triggered before drawing the mesh
  90435. */
  90436. readonly onBeforeDrawObservable: Observable<Mesh>;
  90437. private _onBeforeDrawObserver;
  90438. /**
  90439. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  90440. */
  90441. onBeforeDraw: () => void;
  90442. readonly hasInstances: boolean;
  90443. /**
  90444. * Gets the delay loading state of the mesh (when delay loading is turned on)
  90445. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  90446. */
  90447. delayLoadState: number;
  90448. /**
  90449. * Gets the list of instances created from this mesh
  90450. * it is not supposed to be modified manually.
  90451. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  90452. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  90453. */
  90454. instances: InstancedMesh[];
  90455. /**
  90456. * Gets the file containing delay loading data for this mesh
  90457. */
  90458. delayLoadingFile: string;
  90459. /** @hidden */
  90460. _binaryInfo: any;
  90461. /**
  90462. * User defined function used to change how LOD level selection is done
  90463. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  90464. */
  90465. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  90466. /**
  90467. * Gets or sets the morph target manager
  90468. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  90469. */
  90470. morphTargetManager: Nullable<MorphTargetManager>;
  90471. /** @hidden */
  90472. _creationDataStorage: Nullable<_CreationDataStorage>;
  90473. /** @hidden */
  90474. _geometry: Nullable<Geometry>;
  90475. /** @hidden */
  90476. _delayInfo: Array<string>;
  90477. /** @hidden */
  90478. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  90479. /** @hidden */
  90480. _instanceDataStorage: _InstanceDataStorage;
  90481. private _effectiveMaterial;
  90482. /** @hidden */
  90483. _shouldGenerateFlatShading: boolean;
  90484. /** @hidden */
  90485. _originalBuilderSideOrientation: number;
  90486. /**
  90487. * Use this property to change the original side orientation defined at construction time
  90488. */
  90489. overrideMaterialSideOrientation: Nullable<number>;
  90490. /**
  90491. * Gets the source mesh (the one used to clone this one from)
  90492. */
  90493. readonly source: Nullable<Mesh>;
  90494. /**
  90495. * Gets or sets a boolean indicating that this mesh does not use index buffer
  90496. */
  90497. isUnIndexed: boolean;
  90498. /**
  90499. * @constructor
  90500. * @param name The value used by scene.getMeshByName() to do a lookup.
  90501. * @param scene The scene to add this mesh to.
  90502. * @param parent The parent of this mesh, if it has one
  90503. * @param source An optional Mesh from which geometry is shared, cloned.
  90504. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  90505. * When false, achieved by calling a clone(), also passing False.
  90506. * This will make creation of children, recursive.
  90507. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  90508. */
  90509. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  90510. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  90511. /**
  90512. * Gets the class name
  90513. * @returns the string "Mesh".
  90514. */
  90515. getClassName(): string;
  90516. /** @hidden */
  90517. readonly _isMesh: boolean;
  90518. /**
  90519. * Returns a description of this mesh
  90520. * @param fullDetails define if full details about this mesh must be used
  90521. * @returns a descriptive string representing this mesh
  90522. */
  90523. toString(fullDetails?: boolean): string;
  90524. /** @hidden */
  90525. _unBindEffect(): void;
  90526. /**
  90527. * Gets a boolean indicating if this mesh has LOD
  90528. */
  90529. readonly hasLODLevels: boolean;
  90530. /**
  90531. * Gets the list of MeshLODLevel associated with the current mesh
  90532. * @returns an array of MeshLODLevel
  90533. */
  90534. getLODLevels(): MeshLODLevel[];
  90535. private _sortLODLevels;
  90536. /**
  90537. * Add a mesh as LOD level triggered at the given distance.
  90538. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  90539. * @param distance The distance from the center of the object to show this level
  90540. * @param mesh The mesh to be added as LOD level (can be null)
  90541. * @return This mesh (for chaining)
  90542. */
  90543. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  90544. /**
  90545. * Returns the LOD level mesh at the passed distance or null if not found.
  90546. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  90547. * @param distance The distance from the center of the object to show this level
  90548. * @returns a Mesh or `null`
  90549. */
  90550. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  90551. /**
  90552. * Remove a mesh from the LOD array
  90553. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  90554. * @param mesh defines the mesh to be removed
  90555. * @return This mesh (for chaining)
  90556. */
  90557. removeLODLevel(mesh: Mesh): Mesh;
  90558. /**
  90559. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  90560. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  90561. * @param camera defines the camera to use to compute distance
  90562. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  90563. * @return This mesh (for chaining)
  90564. */
  90565. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  90566. /**
  90567. * Gets the mesh internal Geometry object
  90568. */
  90569. readonly geometry: Nullable<Geometry>;
  90570. /**
  90571. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  90572. * @returns the total number of vertices
  90573. */
  90574. getTotalVertices(): number;
  90575. /**
  90576. * Returns the content of an associated vertex buffer
  90577. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  90578. * - VertexBuffer.PositionKind
  90579. * - VertexBuffer.UVKind
  90580. * - VertexBuffer.UV2Kind
  90581. * - VertexBuffer.UV3Kind
  90582. * - VertexBuffer.UV4Kind
  90583. * - VertexBuffer.UV5Kind
  90584. * - VertexBuffer.UV6Kind
  90585. * - VertexBuffer.ColorKind
  90586. * - VertexBuffer.MatricesIndicesKind
  90587. * - VertexBuffer.MatricesIndicesExtraKind
  90588. * - VertexBuffer.MatricesWeightsKind
  90589. * - VertexBuffer.MatricesWeightsExtraKind
  90590. * @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
  90591. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  90592. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  90593. */
  90594. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  90595. /**
  90596. * Returns the mesh VertexBuffer object from the requested `kind`
  90597. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  90598. * - VertexBuffer.PositionKind
  90599. * - VertexBuffer.NormalKind
  90600. * - VertexBuffer.UVKind
  90601. * - VertexBuffer.UV2Kind
  90602. * - VertexBuffer.UV3Kind
  90603. * - VertexBuffer.UV4Kind
  90604. * - VertexBuffer.UV5Kind
  90605. * - VertexBuffer.UV6Kind
  90606. * - VertexBuffer.ColorKind
  90607. * - VertexBuffer.MatricesIndicesKind
  90608. * - VertexBuffer.MatricesIndicesExtraKind
  90609. * - VertexBuffer.MatricesWeightsKind
  90610. * - VertexBuffer.MatricesWeightsExtraKind
  90611. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  90612. */
  90613. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  90614. /**
  90615. * Tests if a specific vertex buffer is associated with this mesh
  90616. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  90617. * - VertexBuffer.PositionKind
  90618. * - VertexBuffer.NormalKind
  90619. * - VertexBuffer.UVKind
  90620. * - VertexBuffer.UV2Kind
  90621. * - VertexBuffer.UV3Kind
  90622. * - VertexBuffer.UV4Kind
  90623. * - VertexBuffer.UV5Kind
  90624. * - VertexBuffer.UV6Kind
  90625. * - VertexBuffer.ColorKind
  90626. * - VertexBuffer.MatricesIndicesKind
  90627. * - VertexBuffer.MatricesIndicesExtraKind
  90628. * - VertexBuffer.MatricesWeightsKind
  90629. * - VertexBuffer.MatricesWeightsExtraKind
  90630. * @returns a boolean
  90631. */
  90632. isVerticesDataPresent(kind: string): boolean;
  90633. /**
  90634. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  90635. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  90636. * - VertexBuffer.PositionKind
  90637. * - VertexBuffer.UVKind
  90638. * - VertexBuffer.UV2Kind
  90639. * - VertexBuffer.UV3Kind
  90640. * - VertexBuffer.UV4Kind
  90641. * - VertexBuffer.UV5Kind
  90642. * - VertexBuffer.UV6Kind
  90643. * - VertexBuffer.ColorKind
  90644. * - VertexBuffer.MatricesIndicesKind
  90645. * - VertexBuffer.MatricesIndicesExtraKind
  90646. * - VertexBuffer.MatricesWeightsKind
  90647. * - VertexBuffer.MatricesWeightsExtraKind
  90648. * @returns a boolean
  90649. */
  90650. isVertexBufferUpdatable(kind: string): boolean;
  90651. /**
  90652. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  90653. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  90654. * - VertexBuffer.PositionKind
  90655. * - VertexBuffer.NormalKind
  90656. * - VertexBuffer.UVKind
  90657. * - VertexBuffer.UV2Kind
  90658. * - VertexBuffer.UV3Kind
  90659. * - VertexBuffer.UV4Kind
  90660. * - VertexBuffer.UV5Kind
  90661. * - VertexBuffer.UV6Kind
  90662. * - VertexBuffer.ColorKind
  90663. * - VertexBuffer.MatricesIndicesKind
  90664. * - VertexBuffer.MatricesIndicesExtraKind
  90665. * - VertexBuffer.MatricesWeightsKind
  90666. * - VertexBuffer.MatricesWeightsExtraKind
  90667. * @returns an array of strings
  90668. */
  90669. getVerticesDataKinds(): string[];
  90670. /**
  90671. * Returns a positive integer : the total number of indices in this mesh geometry.
  90672. * @returns the numner of indices or zero if the mesh has no geometry.
  90673. */
  90674. getTotalIndices(): number;
  90675. /**
  90676. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  90677. * @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.
  90678. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  90679. * @returns the indices array or an empty array if the mesh has no geometry
  90680. */
  90681. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  90682. readonly isBlocked: boolean;
  90683. /**
  90684. * Determine if the current mesh is ready to be rendered
  90685. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  90686. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  90687. * @returns true if all associated assets are ready (material, textures, shaders)
  90688. */
  90689. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  90690. /**
  90691. * 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.
  90692. */
  90693. readonly areNormalsFrozen: boolean;
  90694. /**
  90695. * 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.
  90696. * @returns the current mesh
  90697. */
  90698. freezeNormals(): Mesh;
  90699. /**
  90700. * 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
  90701. * @returns the current mesh
  90702. */
  90703. unfreezeNormals(): Mesh;
  90704. /**
  90705. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  90706. */
  90707. overridenInstanceCount: number;
  90708. /** @hidden */
  90709. _preActivate(): Mesh;
  90710. /** @hidden */
  90711. _preActivateForIntermediateRendering(renderId: number): Mesh;
  90712. /** @hidden */
  90713. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  90714. /**
  90715. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  90716. * This means the mesh underlying bounding box and sphere are recomputed.
  90717. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  90718. * @returns the current mesh
  90719. */
  90720. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  90721. /** @hidden */
  90722. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  90723. /**
  90724. * This function will subdivide the mesh into multiple submeshes
  90725. * @param count defines the expected number of submeshes
  90726. */
  90727. subdivide(count: number): void;
  90728. /**
  90729. * Copy a FloatArray into a specific associated vertex buffer
  90730. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  90731. * - VertexBuffer.PositionKind
  90732. * - VertexBuffer.UVKind
  90733. * - VertexBuffer.UV2Kind
  90734. * - VertexBuffer.UV3Kind
  90735. * - VertexBuffer.UV4Kind
  90736. * - VertexBuffer.UV5Kind
  90737. * - VertexBuffer.UV6Kind
  90738. * - VertexBuffer.ColorKind
  90739. * - VertexBuffer.MatricesIndicesKind
  90740. * - VertexBuffer.MatricesIndicesExtraKind
  90741. * - VertexBuffer.MatricesWeightsKind
  90742. * - VertexBuffer.MatricesWeightsExtraKind
  90743. * @param data defines the data source
  90744. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  90745. * @param stride defines the data stride size (can be null)
  90746. * @returns the current mesh
  90747. */
  90748. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  90749. /**
  90750. * Flags an associated vertex buffer as updatable
  90751. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  90752. * - VertexBuffer.PositionKind
  90753. * - VertexBuffer.UVKind
  90754. * - VertexBuffer.UV2Kind
  90755. * - VertexBuffer.UV3Kind
  90756. * - VertexBuffer.UV4Kind
  90757. * - VertexBuffer.UV5Kind
  90758. * - VertexBuffer.UV6Kind
  90759. * - VertexBuffer.ColorKind
  90760. * - VertexBuffer.MatricesIndicesKind
  90761. * - VertexBuffer.MatricesIndicesExtraKind
  90762. * - VertexBuffer.MatricesWeightsKind
  90763. * - VertexBuffer.MatricesWeightsExtraKind
  90764. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  90765. */
  90766. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  90767. /**
  90768. * Sets the mesh global Vertex Buffer
  90769. * @param buffer defines the buffer to use
  90770. * @returns the current mesh
  90771. */
  90772. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  90773. /**
  90774. * Update a specific associated vertex buffer
  90775. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  90776. * - VertexBuffer.PositionKind
  90777. * - VertexBuffer.UVKind
  90778. * - VertexBuffer.UV2Kind
  90779. * - VertexBuffer.UV3Kind
  90780. * - VertexBuffer.UV4Kind
  90781. * - VertexBuffer.UV5Kind
  90782. * - VertexBuffer.UV6Kind
  90783. * - VertexBuffer.ColorKind
  90784. * - VertexBuffer.MatricesIndicesKind
  90785. * - VertexBuffer.MatricesIndicesExtraKind
  90786. * - VertexBuffer.MatricesWeightsKind
  90787. * - VertexBuffer.MatricesWeightsExtraKind
  90788. * @param data defines the data source
  90789. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  90790. * @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)
  90791. * @returns the current mesh
  90792. */
  90793. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  90794. /**
  90795. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  90796. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  90797. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  90798. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  90799. * @returns the current mesh
  90800. */
  90801. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  90802. /**
  90803. * Creates a un-shared specific occurence of the geometry for the mesh.
  90804. * @returns the current mesh
  90805. */
  90806. makeGeometryUnique(): Mesh;
  90807. /**
  90808. * Set the index buffer of this mesh
  90809. * @param indices defines the source data
  90810. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  90811. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  90812. * @returns the current mesh
  90813. */
  90814. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  90815. /**
  90816. * Update the current index buffer
  90817. * @param indices defines the source data
  90818. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  90819. * @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)
  90820. * @returns the current mesh
  90821. */
  90822. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  90823. /**
  90824. * Invert the geometry to move from a right handed system to a left handed one.
  90825. * @returns the current mesh
  90826. */
  90827. toLeftHanded(): Mesh;
  90828. /** @hidden */
  90829. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  90830. /** @hidden */
  90831. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  90832. /**
  90833. * Registers for this mesh a javascript function called just before the rendering process
  90834. * @param func defines the function to call before rendering this mesh
  90835. * @returns the current mesh
  90836. */
  90837. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  90838. /**
  90839. * Disposes a previously registered javascript function called before the rendering
  90840. * @param func defines the function to remove
  90841. * @returns the current mesh
  90842. */
  90843. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  90844. /**
  90845. * Registers for this mesh a javascript function called just after the rendering is complete
  90846. * @param func defines the function to call after rendering this mesh
  90847. * @returns the current mesh
  90848. */
  90849. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  90850. /**
  90851. * Disposes a previously registered javascript function called after the rendering.
  90852. * @param func defines the function to remove
  90853. * @returns the current mesh
  90854. */
  90855. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  90856. /** @hidden */
  90857. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  90858. /** @hidden */
  90859. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  90860. /** @hidden */
  90861. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  90862. /** @hidden */
  90863. _rebuild(): void;
  90864. /** @hidden */
  90865. _freeze(): void;
  90866. /** @hidden */
  90867. _unFreeze(): void;
  90868. /**
  90869. * 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
  90870. * @param subMesh defines the subMesh to render
  90871. * @param enableAlphaMode defines if alpha mode can be changed
  90872. * @returns the current mesh
  90873. */
  90874. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  90875. private _onBeforeDraw;
  90876. /**
  90877. * Renormalize the mesh and patch it up if there are no weights
  90878. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  90879. * However in the case of zero weights then we set just a single influence to 1.
  90880. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  90881. */
  90882. cleanMatrixWeights(): void;
  90883. private normalizeSkinFourWeights;
  90884. private normalizeSkinWeightsAndExtra;
  90885. /**
  90886. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  90887. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  90888. * the user know there was an issue with importing the mesh
  90889. * @returns a validation object with skinned, valid and report string
  90890. */
  90891. validateSkinning(): {
  90892. skinned: boolean;
  90893. valid: boolean;
  90894. report: string;
  90895. };
  90896. /** @hidden */
  90897. _checkDelayState(): Mesh;
  90898. private _queueLoad;
  90899. /**
  90900. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  90901. * A mesh is in the frustum if its bounding box intersects the frustum
  90902. * @param frustumPlanes defines the frustum to test
  90903. * @returns true if the mesh is in the frustum planes
  90904. */
  90905. isInFrustum(frustumPlanes: Plane[]): boolean;
  90906. /**
  90907. * Sets the mesh material by the material or multiMaterial `id` property
  90908. * @param id is a string identifying the material or the multiMaterial
  90909. * @returns the current mesh
  90910. */
  90911. setMaterialByID(id: string): Mesh;
  90912. /**
  90913. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  90914. * @returns an array of IAnimatable
  90915. */
  90916. getAnimatables(): IAnimatable[];
  90917. /**
  90918. * Modifies the mesh geometry according to the passed transformation matrix.
  90919. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  90920. * The mesh normals are modified using the same transformation.
  90921. * Note that, under the hood, this method sets a new VertexBuffer each call.
  90922. * @param transform defines the transform matrix to use
  90923. * @see http://doc.babylonjs.com/resources/baking_transformations
  90924. * @returns the current mesh
  90925. */
  90926. bakeTransformIntoVertices(transform: Matrix): Mesh;
  90927. /**
  90928. * Modifies the mesh geometry according to its own current World Matrix.
  90929. * The mesh World Matrix is then reset.
  90930. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  90931. * Note that, under the hood, this method sets a new VertexBuffer each call.
  90932. * @see http://doc.babylonjs.com/resources/baking_transformations
  90933. * @returns the current mesh
  90934. */
  90935. bakeCurrentTransformIntoVertices(): Mesh;
  90936. /** @hidden */
  90937. readonly _positions: Nullable<Vector3[]>;
  90938. /** @hidden */
  90939. _resetPointsArrayCache(): Mesh;
  90940. /** @hidden */
  90941. _generatePointsArray(): boolean;
  90942. /**
  90943. * Returns a new Mesh object generated from the current mesh properties.
  90944. * This method must not get confused with createInstance()
  90945. * @param name is a string, the name given to the new mesh
  90946. * @param newParent can be any Node object (default `null`)
  90947. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  90948. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  90949. * @returns a new mesh
  90950. */
  90951. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  90952. /**
  90953. * Releases resources associated with this mesh.
  90954. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90955. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90956. */
  90957. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90958. /**
  90959. * Modifies the mesh geometry according to a displacement map.
  90960. * 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.
  90961. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  90962. * @param url is a string, the URL from the image file is to be downloaded.
  90963. * @param minHeight is the lower limit of the displacement.
  90964. * @param maxHeight is the upper limit of the displacement.
  90965. * @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.
  90966. * @param uvOffset is an optional vector2 used to offset UV.
  90967. * @param uvScale is an optional vector2 used to scale UV.
  90968. * @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.
  90969. * @returns the Mesh.
  90970. */
  90971. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  90972. /**
  90973. * Modifies the mesh geometry according to a displacementMap buffer.
  90974. * 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.
  90975. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  90976. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  90977. * @param heightMapWidth is the width of the buffer image.
  90978. * @param heightMapHeight is the height of the buffer image.
  90979. * @param minHeight is the lower limit of the displacement.
  90980. * @param maxHeight is the upper limit of the displacement.
  90981. * @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.
  90982. * @param uvOffset is an optional vector2 used to offset UV.
  90983. * @param uvScale is an optional vector2 used to scale UV.
  90984. * @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.
  90985. * @returns the Mesh.
  90986. */
  90987. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  90988. /**
  90989. * Modify the mesh to get a flat shading rendering.
  90990. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  90991. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  90992. * @returns current mesh
  90993. */
  90994. convertToFlatShadedMesh(): Mesh;
  90995. /**
  90996. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  90997. * In other words, more vertices, no more indices and a single bigger VBO.
  90998. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  90999. * @returns current mesh
  91000. */
  91001. convertToUnIndexedMesh(): Mesh;
  91002. /**
  91003. * Inverses facet orientations.
  91004. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  91005. * @param flipNormals will also inverts the normals
  91006. * @returns current mesh
  91007. */
  91008. flipFaces(flipNormals?: boolean): Mesh;
  91009. /**
  91010. * Increase the number of facets and hence vertices in a mesh
  91011. * Vertex normals are interpolated from existing vertex normals
  91012. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  91013. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  91014. */
  91015. increaseVertices(numberPerEdge: number): void;
  91016. /**
  91017. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  91018. * This will undo any application of covertToFlatShadedMesh
  91019. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  91020. */
  91021. forceSharedVertices(): void;
  91022. /** @hidden */
  91023. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  91024. /** @hidden */
  91025. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  91026. /**
  91027. * Creates a new InstancedMesh object from the mesh model.
  91028. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  91029. * @param name defines the name of the new instance
  91030. * @returns a new InstancedMesh
  91031. */
  91032. createInstance(name: string): InstancedMesh;
  91033. /**
  91034. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  91035. * After this call, all the mesh instances have the same submeshes than the current mesh.
  91036. * @returns the current mesh
  91037. */
  91038. synchronizeInstances(): Mesh;
  91039. /**
  91040. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  91041. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  91042. * This should be used together with the simplification to avoid disappearing triangles.
  91043. * @param successCallback an optional success callback to be called after the optimization finished.
  91044. * @returns the current mesh
  91045. */
  91046. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  91047. /**
  91048. * Serialize current mesh
  91049. * @param serializationObject defines the object which will receive the serialization data
  91050. */
  91051. serialize(serializationObject: any): void;
  91052. /** @hidden */
  91053. _syncGeometryWithMorphTargetManager(): void;
  91054. /** @hidden */
  91055. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  91056. /**
  91057. * Returns a new Mesh object parsed from the source provided.
  91058. * @param parsedMesh is the source
  91059. * @param scene defines the hosting scene
  91060. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  91061. * @returns a new Mesh
  91062. */
  91063. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  91064. /**
  91065. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  91066. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  91067. * @param name defines the name of the mesh to create
  91068. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  91069. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  91070. * @param closePath creates a seam between the first and the last points of each path of the path array
  91071. * @param offset is taken in account only if the `pathArray` is containing a single path
  91072. * @param scene defines the hosting scene
  91073. * @param updatable defines if the mesh must be flagged as updatable
  91074. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91075. * @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)
  91076. * @returns a new Mesh
  91077. */
  91078. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  91079. /**
  91080. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  91081. * @param name defines the name of the mesh to create
  91082. * @param radius sets the radius size (float) of the polygon (default 0.5)
  91083. * @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
  91084. * @param scene defines the hosting scene
  91085. * @param updatable defines if the mesh must be flagged as updatable
  91086. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91087. * @returns a new Mesh
  91088. */
  91089. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  91090. /**
  91091. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  91092. * @param name defines the name of the mesh to create
  91093. * @param size sets the size (float) of each box side (default 1)
  91094. * @param scene defines the hosting scene
  91095. * @param updatable defines if the mesh must be flagged as updatable
  91096. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91097. * @returns a new Mesh
  91098. */
  91099. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  91100. /**
  91101. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  91102. * @param name defines the name of the mesh to create
  91103. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  91104. * @param diameter sets the diameter size (float) of the sphere (default 1)
  91105. * @param scene defines the hosting scene
  91106. * @param updatable defines if the mesh must be flagged as updatable
  91107. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91108. * @returns a new Mesh
  91109. */
  91110. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91111. /**
  91112. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  91113. * @param name defines the name of the mesh to create
  91114. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  91115. * @param diameter sets the diameter size (float) of the sphere (default 1)
  91116. * @param scene defines the hosting scene
  91117. * @returns a new Mesh
  91118. */
  91119. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  91120. /**
  91121. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  91122. * @param name defines the name of the mesh to create
  91123. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  91124. * @param diameterTop set the top cap diameter (floats, default 1)
  91125. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  91126. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  91127. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  91128. * @param scene defines the hosting scene
  91129. * @param updatable defines if the mesh must be flagged as updatable
  91130. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91131. * @returns a new Mesh
  91132. */
  91133. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  91134. /**
  91135. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  91136. * @param name defines the name of the mesh to create
  91137. * @param diameter sets the diameter size (float) of the torus (default 1)
  91138. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  91139. * @param tessellation sets the number of torus sides (postive integer, default 16)
  91140. * @param scene defines the hosting scene
  91141. * @param updatable defines if the mesh must be flagged as updatable
  91142. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91143. * @returns a new Mesh
  91144. */
  91145. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91146. /**
  91147. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  91148. * @param name defines the name of the mesh to create
  91149. * @param radius sets the global radius size (float) of the torus knot (default 2)
  91150. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  91151. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  91152. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  91153. * @param p the number of windings on X axis (positive integers, default 2)
  91154. * @param q the number of windings on Y axis (positive integers, default 3)
  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 CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91161. /**
  91162. * Creates a line 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 points is an array successive Vector3
  91165. * @param scene defines the hosting scene
  91166. * @param updatable defines if the mesh must be flagged as updatable
  91167. * @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).
  91168. * @returns a new Mesh
  91169. */
  91170. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  91171. /**
  91172. * Creates a dashed line 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 points is an array successive Vector3
  91175. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  91176. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  91177. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  91178. * @param scene defines the hosting scene
  91179. * @param updatable defines if the mesh must be flagged as updatable
  91180. * @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)
  91181. * @returns a new Mesh
  91182. */
  91183. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  91184. /**
  91185. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  91186. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  91187. * 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.
  91188. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91189. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  91190. * Remember you can only change the shape positions, not their number when updating a polygon.
  91191. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  91192. * @param name defines the name of the mesh to create
  91193. * @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
  91194. * @param scene defines the hosting scene
  91195. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  91196. * @param updatable defines if the mesh must be flagged as updatable
  91197. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91198. * @param earcutInjection can be used to inject your own earcut reference
  91199. * @returns a new Mesh
  91200. */
  91201. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  91202. /**
  91203. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  91204. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  91205. * @param name defines the name of the mesh to create
  91206. * @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
  91207. * @param depth defines the height of extrusion
  91208. * @param scene defines the hosting scene
  91209. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  91210. * @param updatable defines if the mesh must be flagged as updatable
  91211. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91212. * @param earcutInjection can be used to inject your own earcut reference
  91213. * @returns a new Mesh
  91214. */
  91215. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  91216. /**
  91217. * Creates an extruded shape mesh.
  91218. * 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
  91219. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  91220. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  91221. * @param name defines the name of the mesh to create
  91222. * @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
  91223. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  91224. * @param scale is the value to scale the shape
  91225. * @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
  91226. * @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
  91227. * @param scene defines the hosting scene
  91228. * @param updatable defines if the mesh must be flagged as updatable
  91229. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91230. * @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)
  91231. * @returns a new Mesh
  91232. */
  91233. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  91234. /**
  91235. * Creates an custom extruded shape mesh.
  91236. * The custom extrusion is a parametric shape.
  91237. * It has no predefined shape. Its final shape will depend on the input parameters.
  91238. * Please consider using the same method from the MeshBuilder class instead
  91239. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  91240. * @param name defines the name of the mesh to create
  91241. * @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
  91242. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  91243. * @param scaleFunction is a custom Javascript function called on each path point
  91244. * @param rotationFunction is a custom Javascript function called on each path point
  91245. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  91246. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  91247. * @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
  91248. * @param scene defines the hosting scene
  91249. * @param updatable defines if the mesh must be flagged as updatable
  91250. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91251. * @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)
  91252. * @returns a new Mesh
  91253. */
  91254. 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;
  91255. /**
  91256. * Creates lathe mesh.
  91257. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  91258. * Please consider using the same method from the MeshBuilder class instead
  91259. * @param name defines the name of the mesh to create
  91260. * @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
  91261. * @param radius is the radius value of the lathe
  91262. * @param tessellation is the side number of the lathe.
  91263. * @param scene defines the hosting scene
  91264. * @param updatable defines if the mesh must be flagged as updatable
  91265. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91266. * @returns a new Mesh
  91267. */
  91268. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91269. /**
  91270. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  91271. * @param name defines the name of the mesh to create
  91272. * @param size sets the size (float) of both sides of the plane at once (default 1)
  91273. * @param scene defines the hosting scene
  91274. * @param updatable defines if the mesh must be flagged as updatable
  91275. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91276. * @returns a new Mesh
  91277. */
  91278. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91279. /**
  91280. * Creates a ground mesh.
  91281. * Please consider using the same method from the MeshBuilder class instead
  91282. * @param name defines the name of the mesh to create
  91283. * @param width set the width of the ground
  91284. * @param height set the height of the ground
  91285. * @param subdivisions sets the number of subdivisions per side
  91286. * @param scene defines the hosting scene
  91287. * @param updatable defines if the mesh must be flagged as updatable
  91288. * @returns a new Mesh
  91289. */
  91290. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  91291. /**
  91292. * Creates a tiled ground mesh.
  91293. * Please consider using the same method from the MeshBuilder class instead
  91294. * @param name defines the name of the mesh to create
  91295. * @param xmin set the ground minimum X coordinate
  91296. * @param zmin set the ground minimum Y coordinate
  91297. * @param xmax set the ground maximum X coordinate
  91298. * @param zmax set the ground maximum Z coordinate
  91299. * @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
  91300. * @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
  91301. * @param scene defines the hosting scene
  91302. * @param updatable defines if the mesh must be flagged as updatable
  91303. * @returns a new Mesh
  91304. */
  91305. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  91306. w: number;
  91307. h: number;
  91308. }, precision: {
  91309. w: number;
  91310. h: number;
  91311. }, scene: Scene, updatable?: boolean): Mesh;
  91312. /**
  91313. * Creates a ground mesh from a height map.
  91314. * Please consider using the same method from the MeshBuilder class instead
  91315. * @see http://doc.babylonjs.com/babylon101/height_map
  91316. * @param name defines the name of the mesh to create
  91317. * @param url sets the URL of the height map image resource
  91318. * @param width set the ground width size
  91319. * @param height set the ground height size
  91320. * @param subdivisions sets the number of subdivision per side
  91321. * @param minHeight is the minimum altitude on the ground
  91322. * @param maxHeight is the maximum altitude on the ground
  91323. * @param scene defines the hosting scene
  91324. * @param updatable defines if the mesh must be flagged as updatable
  91325. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  91326. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  91327. * @returns a new Mesh
  91328. */
  91329. 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;
  91330. /**
  91331. * Creates a tube mesh.
  91332. * The tube is a parametric shape.
  91333. * It has no predefined shape. Its final shape will depend on the input parameters.
  91334. * Please consider using the same method from the MeshBuilder class instead
  91335. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  91336. * @param name defines the name of the mesh to create
  91337. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  91338. * @param radius sets the tube radius size
  91339. * @param tessellation is the number of sides on the tubular surface
  91340. * @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
  91341. * @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
  91342. * @param scene defines the hosting scene
  91343. * @param updatable defines if the mesh must be flagged as updatable
  91344. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91345. * @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)
  91346. * @returns a new Mesh
  91347. */
  91348. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  91349. (i: number, distance: number): number;
  91350. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  91351. /**
  91352. * Creates a polyhedron mesh.
  91353. * Please consider using the same method from the MeshBuilder class instead.
  91354. * * 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
  91355. * * The parameter `size` (positive float, default 1) sets the polygon size
  91356. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  91357. * * 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`
  91358. * * 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
  91359. * * 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)`)
  91360. * * 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
  91361. * * 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
  91362. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91363. * * If you create a double-sided mesh, you can choose what parts of 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
  91364. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  91365. * @param name defines the name of the mesh to create
  91366. * @param options defines the options used to create the mesh
  91367. * @param scene defines the hosting scene
  91368. * @returns a new Mesh
  91369. */
  91370. static CreatePolyhedron(name: string, options: {
  91371. type?: number;
  91372. size?: number;
  91373. sizeX?: number;
  91374. sizeY?: number;
  91375. sizeZ?: number;
  91376. custom?: any;
  91377. faceUV?: Vector4[];
  91378. faceColors?: Color4[];
  91379. updatable?: boolean;
  91380. sideOrientation?: number;
  91381. }, scene: Scene): Mesh;
  91382. /**
  91383. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  91384. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  91385. * * 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`)
  91386. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  91387. * * 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
  91388. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91389. * * If you create a double-sided mesh, you can choose what parts of 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
  91390. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  91391. * @param name defines the name of the mesh
  91392. * @param options defines the options used to create the mesh
  91393. * @param scene defines the hosting scene
  91394. * @returns a new Mesh
  91395. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  91396. */
  91397. static CreateIcoSphere(name: string, options: {
  91398. radius?: number;
  91399. flat?: boolean;
  91400. subdivisions?: number;
  91401. sideOrientation?: number;
  91402. updatable?: boolean;
  91403. }, scene: Scene): Mesh;
  91404. /**
  91405. * Creates a decal mesh.
  91406. * Please consider using the same method from the MeshBuilder class instead.
  91407. * A decal is a mesh usually applied as a model onto the surface of another mesh
  91408. * @param name defines the name of the mesh
  91409. * @param sourceMesh defines the mesh receiving the decal
  91410. * @param position sets the position of the decal in world coordinates
  91411. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  91412. * @param size sets the decal scaling
  91413. * @param angle sets the angle to rotate the decal
  91414. * @returns a new Mesh
  91415. */
  91416. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  91417. /**
  91418. * Prepare internal position array for software CPU skinning
  91419. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  91420. */
  91421. setPositionsForCPUSkinning(): Float32Array;
  91422. /**
  91423. * Prepare internal normal array for software CPU skinning
  91424. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  91425. */
  91426. setNormalsForCPUSkinning(): Float32Array;
  91427. /**
  91428. * Updates the vertex buffer by applying transformation from the bones
  91429. * @param skeleton defines the skeleton to apply to current mesh
  91430. * @returns the current mesh
  91431. */
  91432. applySkeleton(skeleton: Skeleton): Mesh;
  91433. /**
  91434. * 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
  91435. * @param meshes defines the list of meshes to scan
  91436. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  91437. */
  91438. static MinMax(meshes: AbstractMesh[]): {
  91439. min: Vector3;
  91440. max: Vector3;
  91441. };
  91442. /**
  91443. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  91444. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  91445. * @returns a vector3
  91446. */
  91447. static Center(meshesOrMinMaxVector: {
  91448. min: Vector3;
  91449. max: Vector3;
  91450. } | AbstractMesh[]): Vector3;
  91451. /**
  91452. * Merge the array of meshes into a single mesh for performance reasons.
  91453. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  91454. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  91455. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  91456. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  91457. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  91458. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  91459. * @returns a new mesh
  91460. */
  91461. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  91462. /** @hidden */
  91463. addInstance(instance: InstancedMesh): void;
  91464. /** @hidden */
  91465. removeInstance(instance: InstancedMesh): void;
  91466. }
  91467. }
  91468. declare module BABYLON {
  91469. /**
  91470. * This is the base class of all the camera used in the application.
  91471. * @see http://doc.babylonjs.com/features/cameras
  91472. */
  91473. export class Camera extends Node {
  91474. /** @hidden */
  91475. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  91476. /**
  91477. * This is the default projection mode used by the cameras.
  91478. * It helps recreating a feeling of perspective and better appreciate depth.
  91479. * This is the best way to simulate real life cameras.
  91480. */
  91481. static readonly PERSPECTIVE_CAMERA: number;
  91482. /**
  91483. * This helps creating camera with an orthographic mode.
  91484. * 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.
  91485. */
  91486. static readonly ORTHOGRAPHIC_CAMERA: number;
  91487. /**
  91488. * This is the default FOV mode for perspective cameras.
  91489. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  91490. */
  91491. static readonly FOVMODE_VERTICAL_FIXED: number;
  91492. /**
  91493. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  91494. */
  91495. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  91496. /**
  91497. * This specifies ther is no need for a camera rig.
  91498. * Basically only one eye is rendered corresponding to the camera.
  91499. */
  91500. static readonly RIG_MODE_NONE: number;
  91501. /**
  91502. * Simulates a camera Rig with one blue eye and one red eye.
  91503. * This can be use with 3d blue and red glasses.
  91504. */
  91505. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  91506. /**
  91507. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  91508. */
  91509. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  91510. /**
  91511. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  91512. */
  91513. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  91514. /**
  91515. * Defines that both eyes of the camera will be rendered over under each other.
  91516. */
  91517. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  91518. /**
  91519. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  91520. */
  91521. static readonly RIG_MODE_VR: number;
  91522. /**
  91523. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  91524. */
  91525. static readonly RIG_MODE_WEBVR: number;
  91526. /**
  91527. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  91528. */
  91529. static readonly RIG_MODE_CUSTOM: number;
  91530. /**
  91531. * Defines if by default attaching controls should prevent the default javascript event to continue.
  91532. */
  91533. static ForceAttachControlToAlwaysPreventDefault: boolean;
  91534. /**
  91535. * Define the input manager associated with the camera.
  91536. */
  91537. inputs: CameraInputsManager<Camera>;
  91538. /** @hidden */
  91539. _position: Vector3;
  91540. /**
  91541. * Define the current local position of the camera in the scene
  91542. */
  91543. position: Vector3;
  91544. /**
  91545. * The vector the camera should consider as up.
  91546. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  91547. */
  91548. upVector: Vector3;
  91549. /**
  91550. * Define the current limit on the left side for an orthographic camera
  91551. * In scene unit
  91552. */
  91553. orthoLeft: Nullable<number>;
  91554. /**
  91555. * Define the current limit on the right side for an orthographic camera
  91556. * In scene unit
  91557. */
  91558. orthoRight: Nullable<number>;
  91559. /**
  91560. * Define the current limit on the bottom side for an orthographic camera
  91561. * In scene unit
  91562. */
  91563. orthoBottom: Nullable<number>;
  91564. /**
  91565. * Define the current limit on the top side for an orthographic camera
  91566. * In scene unit
  91567. */
  91568. orthoTop: Nullable<number>;
  91569. /**
  91570. * Field Of View is set in Radians. (default is 0.8)
  91571. */
  91572. fov: number;
  91573. /**
  91574. * Define the minimum distance the camera can see from.
  91575. * This is important to note that the depth buffer are not infinite and the closer it starts
  91576. * the more your scene might encounter depth fighting issue.
  91577. */
  91578. minZ: number;
  91579. /**
  91580. * Define the maximum distance the camera can see to.
  91581. * This is important to note that the depth buffer are not infinite and the further it end
  91582. * the more your scene might encounter depth fighting issue.
  91583. */
  91584. maxZ: number;
  91585. /**
  91586. * Define the default inertia of the camera.
  91587. * This helps giving a smooth feeling to the camera movement.
  91588. */
  91589. inertia: number;
  91590. /**
  91591. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  91592. */
  91593. mode: number;
  91594. /**
  91595. * Define wether the camera is intermediate.
  91596. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  91597. */
  91598. isIntermediate: boolean;
  91599. /**
  91600. * Define the viewport of the camera.
  91601. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  91602. */
  91603. viewport: Viewport;
  91604. /**
  91605. * Restricts the camera to viewing objects with the same layerMask.
  91606. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  91607. */
  91608. layerMask: number;
  91609. /**
  91610. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  91611. */
  91612. fovMode: number;
  91613. /**
  91614. * Rig mode of the camera.
  91615. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  91616. * This is normally controlled byt the camera themselves as internal use.
  91617. */
  91618. cameraRigMode: number;
  91619. /**
  91620. * Defines the distance between both "eyes" in case of a RIG
  91621. */
  91622. interaxialDistance: number;
  91623. /**
  91624. * Defines if stereoscopic rendering is done side by side or over under.
  91625. */
  91626. isStereoscopicSideBySide: boolean;
  91627. /**
  91628. * 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
  91629. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  91630. * else in the scene. (Eg. security camera)
  91631. *
  91632. * 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)
  91633. */
  91634. customRenderTargets: RenderTargetTexture[];
  91635. /**
  91636. * When set, the camera will render to this render target instead of the default canvas
  91637. *
  91638. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  91639. */
  91640. outputRenderTarget: Nullable<RenderTargetTexture>;
  91641. /**
  91642. * Observable triggered when the camera view matrix has changed.
  91643. */
  91644. onViewMatrixChangedObservable: Observable<Camera>;
  91645. /**
  91646. * Observable triggered when the camera Projection matrix has changed.
  91647. */
  91648. onProjectionMatrixChangedObservable: Observable<Camera>;
  91649. /**
  91650. * Observable triggered when the inputs have been processed.
  91651. */
  91652. onAfterCheckInputsObservable: Observable<Camera>;
  91653. /**
  91654. * Observable triggered when reset has been called and applied to the camera.
  91655. */
  91656. onRestoreStateObservable: Observable<Camera>;
  91657. /** @hidden */
  91658. _cameraRigParams: any;
  91659. /** @hidden */
  91660. _rigCameras: Camera[];
  91661. /** @hidden */
  91662. _rigPostProcess: Nullable<PostProcess>;
  91663. protected _webvrViewMatrix: Matrix;
  91664. /** @hidden */
  91665. _skipRendering: boolean;
  91666. /** @hidden */
  91667. _projectionMatrix: Matrix;
  91668. /** @hidden */
  91669. _postProcesses: Nullable<PostProcess>[];
  91670. /** @hidden */
  91671. _activeMeshes: SmartArray<AbstractMesh>;
  91672. protected _globalPosition: Vector3;
  91673. /** @hidden */
  91674. _computedViewMatrix: Matrix;
  91675. private _doNotComputeProjectionMatrix;
  91676. private _transformMatrix;
  91677. private _frustumPlanes;
  91678. private _refreshFrustumPlanes;
  91679. private _storedFov;
  91680. private _stateStored;
  91681. /**
  91682. * Instantiates a new camera object.
  91683. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  91684. * @see http://doc.babylonjs.com/features/cameras
  91685. * @param name Defines the name of the camera in the scene
  91686. * @param position Defines the position of the camera
  91687. * @param scene Defines the scene the camera belongs too
  91688. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  91689. */
  91690. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  91691. /**
  91692. * Store current camera state (fov, position, etc..)
  91693. * @returns the camera
  91694. */
  91695. storeState(): Camera;
  91696. /**
  91697. * Restores the camera state values if it has been stored. You must call storeState() first
  91698. */
  91699. protected _restoreStateValues(): boolean;
  91700. /**
  91701. * Restored camera state. You must call storeState() first.
  91702. * @returns true if restored and false otherwise
  91703. */
  91704. restoreState(): boolean;
  91705. /**
  91706. * Gets the class name of the camera.
  91707. * @returns the class name
  91708. */
  91709. getClassName(): string;
  91710. /** @hidden */
  91711. readonly _isCamera: boolean;
  91712. /**
  91713. * Gets a string representation of the camera useful for debug purpose.
  91714. * @param fullDetails Defines that a more verboe level of logging is required
  91715. * @returns the string representation
  91716. */
  91717. toString(fullDetails?: boolean): string;
  91718. /**
  91719. * Gets the current world space position of the camera.
  91720. */
  91721. readonly globalPosition: Vector3;
  91722. /**
  91723. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  91724. * @returns the active meshe list
  91725. */
  91726. getActiveMeshes(): SmartArray<AbstractMesh>;
  91727. /**
  91728. * Check wether a mesh is part of the current active mesh list of the camera
  91729. * @param mesh Defines the mesh to check
  91730. * @returns true if active, false otherwise
  91731. */
  91732. isActiveMesh(mesh: Mesh): boolean;
  91733. /**
  91734. * Is this camera ready to be used/rendered
  91735. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  91736. * @return true if the camera is ready
  91737. */
  91738. isReady(completeCheck?: boolean): boolean;
  91739. /** @hidden */
  91740. _initCache(): void;
  91741. /** @hidden */
  91742. _updateCache(ignoreParentClass?: boolean): void;
  91743. /** @hidden */
  91744. _isSynchronized(): boolean;
  91745. /** @hidden */
  91746. _isSynchronizedViewMatrix(): boolean;
  91747. /** @hidden */
  91748. _isSynchronizedProjectionMatrix(): boolean;
  91749. /**
  91750. * Attach the input controls to a specific dom element to get the input from.
  91751. * @param element Defines the element the controls should be listened from
  91752. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91753. */
  91754. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91755. /**
  91756. * Detach the current controls from the specified dom element.
  91757. * @param element Defines the element to stop listening the inputs from
  91758. */
  91759. detachControl(element: HTMLElement): void;
  91760. /**
  91761. * Update the camera state according to the different inputs gathered during the frame.
  91762. */
  91763. update(): void;
  91764. /** @hidden */
  91765. _checkInputs(): void;
  91766. /** @hidden */
  91767. readonly rigCameras: Camera[];
  91768. /**
  91769. * Gets the post process used by the rig cameras
  91770. */
  91771. readonly rigPostProcess: Nullable<PostProcess>;
  91772. /**
  91773. * Internal, gets the first post proces.
  91774. * @returns the first post process to be run on this camera.
  91775. */
  91776. _getFirstPostProcess(): Nullable<PostProcess>;
  91777. private _cascadePostProcessesToRigCams;
  91778. /**
  91779. * Attach a post process to the camera.
  91780. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  91781. * @param postProcess The post process to attach to the camera
  91782. * @param insertAt The position of the post process in case several of them are in use in the scene
  91783. * @returns the position the post process has been inserted at
  91784. */
  91785. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  91786. /**
  91787. * Detach a post process to the camera.
  91788. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  91789. * @param postProcess The post process to detach from the camera
  91790. */
  91791. detachPostProcess(postProcess: PostProcess): void;
  91792. /**
  91793. * Gets the current world matrix of the camera
  91794. */
  91795. getWorldMatrix(): Matrix;
  91796. /** @hidden */
  91797. _getViewMatrix(): Matrix;
  91798. /**
  91799. * Gets the current view matrix of the camera.
  91800. * @param force forces the camera to recompute the matrix without looking at the cached state
  91801. * @returns the view matrix
  91802. */
  91803. getViewMatrix(force?: boolean): Matrix;
  91804. /**
  91805. * Freeze the projection matrix.
  91806. * It will prevent the cache check of the camera projection compute and can speed up perf
  91807. * if no parameter of the camera are meant to change
  91808. * @param projection Defines manually a projection if necessary
  91809. */
  91810. freezeProjectionMatrix(projection?: Matrix): void;
  91811. /**
  91812. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  91813. */
  91814. unfreezeProjectionMatrix(): void;
  91815. /**
  91816. * Gets the current projection matrix of the camera.
  91817. * @param force forces the camera to recompute the matrix without looking at the cached state
  91818. * @returns the projection matrix
  91819. */
  91820. getProjectionMatrix(force?: boolean): Matrix;
  91821. /**
  91822. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  91823. * @returns a Matrix
  91824. */
  91825. getTransformationMatrix(): Matrix;
  91826. private _updateFrustumPlanes;
  91827. /**
  91828. * Checks if a cullable object (mesh...) is in the camera frustum
  91829. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  91830. * @param target The object to check
  91831. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  91832. * @returns true if the object is in frustum otherwise false
  91833. */
  91834. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  91835. /**
  91836. * Checks if a cullable object (mesh...) is in the camera frustum
  91837. * Unlike isInFrustum this cheks the full bounding box
  91838. * @param target The object to check
  91839. * @returns true if the object is in frustum otherwise false
  91840. */
  91841. isCompletelyInFrustum(target: ICullable): boolean;
  91842. /**
  91843. * Gets a ray in the forward direction from the camera.
  91844. * @param length Defines the length of the ray to create
  91845. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  91846. * @param origin Defines the start point of the ray which defaults to the camera position
  91847. * @returns the forward ray
  91848. */
  91849. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  91850. /**
  91851. * Releases resources associated with this node.
  91852. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  91853. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  91854. */
  91855. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  91856. /** @hidden */
  91857. _isLeftCamera: boolean;
  91858. /**
  91859. * Gets the left camera of a rig setup in case of Rigged Camera
  91860. */
  91861. readonly isLeftCamera: boolean;
  91862. /** @hidden */
  91863. _isRightCamera: boolean;
  91864. /**
  91865. * Gets the right camera of a rig setup in case of Rigged Camera
  91866. */
  91867. readonly isRightCamera: boolean;
  91868. /**
  91869. * Gets the left camera of a rig setup in case of Rigged Camera
  91870. */
  91871. readonly leftCamera: Nullable<FreeCamera>;
  91872. /**
  91873. * Gets the right camera of a rig setup in case of Rigged Camera
  91874. */
  91875. readonly rightCamera: Nullable<FreeCamera>;
  91876. /**
  91877. * Gets the left camera target of a rig setup in case of Rigged Camera
  91878. * @returns the target position
  91879. */
  91880. getLeftTarget(): Nullable<Vector3>;
  91881. /**
  91882. * Gets the right camera target of a rig setup in case of Rigged Camera
  91883. * @returns the target position
  91884. */
  91885. getRightTarget(): Nullable<Vector3>;
  91886. /**
  91887. * @hidden
  91888. */
  91889. setCameraRigMode(mode: number, rigParams: any): void;
  91890. /** @hidden */
  91891. static _setStereoscopicRigMode(camera: Camera): void;
  91892. /** @hidden */
  91893. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  91894. /** @hidden */
  91895. static _setVRRigMode(camera: Camera, rigParams: any): void;
  91896. /** @hidden */
  91897. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  91898. /** @hidden */
  91899. _getVRProjectionMatrix(): Matrix;
  91900. protected _updateCameraRotationMatrix(): void;
  91901. protected _updateWebVRCameraRotationMatrix(): void;
  91902. /**
  91903. * This function MUST be overwritten by the different WebVR cameras available.
  91904. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  91905. * @hidden
  91906. */
  91907. _getWebVRProjectionMatrix(): Matrix;
  91908. /**
  91909. * This function MUST be overwritten by the different WebVR cameras available.
  91910. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  91911. * @hidden
  91912. */
  91913. _getWebVRViewMatrix(): Matrix;
  91914. /** @hidden */
  91915. setCameraRigParameter(name: string, value: any): void;
  91916. /**
  91917. * needs to be overridden by children so sub has required properties to be copied
  91918. * @hidden
  91919. */
  91920. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  91921. /**
  91922. * May need to be overridden by children
  91923. * @hidden
  91924. */
  91925. _updateRigCameras(): void;
  91926. /** @hidden */
  91927. _setupInputs(): void;
  91928. /**
  91929. * Serialiaze the camera setup to a json represention
  91930. * @returns the JSON representation
  91931. */
  91932. serialize(): any;
  91933. /**
  91934. * Clones the current camera.
  91935. * @param name The cloned camera name
  91936. * @returns the cloned camera
  91937. */
  91938. clone(name: string): Camera;
  91939. /**
  91940. * Gets the direction of the camera relative to a given local axis.
  91941. * @param localAxis Defines the reference axis to provide a relative direction.
  91942. * @return the direction
  91943. */
  91944. getDirection(localAxis: Vector3): Vector3;
  91945. /**
  91946. * Returns the current camera absolute rotation
  91947. */
  91948. readonly absoluteRotation: Quaternion;
  91949. /**
  91950. * Gets the direction of the camera relative to a given local axis into a passed vector.
  91951. * @param localAxis Defines the reference axis to provide a relative direction.
  91952. * @param result Defines the vector to store the result in
  91953. */
  91954. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  91955. /**
  91956. * Gets a camera constructor for a given camera type
  91957. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  91958. * @param name The name of the camera the result will be able to instantiate
  91959. * @param scene The scene the result will construct the camera in
  91960. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  91961. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  91962. * @returns a factory method to construc the camera
  91963. */
  91964. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  91965. /**
  91966. * Compute the world matrix of the camera.
  91967. * @returns the camera workd matrix
  91968. */
  91969. computeWorldMatrix(): Matrix;
  91970. /**
  91971. * Parse a JSON and creates the camera from the parsed information
  91972. * @param parsedCamera The JSON to parse
  91973. * @param scene The scene to instantiate the camera in
  91974. * @returns the newly constructed camera
  91975. */
  91976. static Parse(parsedCamera: any, scene: Scene): Camera;
  91977. }
  91978. }
  91979. declare module BABYLON {
  91980. /**
  91981. * Class containing static functions to help procedurally build meshes
  91982. */
  91983. export class DiscBuilder {
  91984. /**
  91985. * Creates a plane polygonal mesh. By default, this is a disc
  91986. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  91987. * * 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
  91988. * * 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
  91989. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  91990. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  91991. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  91992. * @param name defines the name of the mesh
  91993. * @param options defines the options used to create the mesh
  91994. * @param scene defines the hosting scene
  91995. * @returns the plane polygonal mesh
  91996. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  91997. */
  91998. static CreateDisc(name: string, options: {
  91999. radius?: number;
  92000. tessellation?: number;
  92001. arc?: number;
  92002. updatable?: boolean;
  92003. sideOrientation?: number;
  92004. frontUVs?: Vector4;
  92005. backUVs?: Vector4;
  92006. }, scene?: Nullable<Scene>): Mesh;
  92007. }
  92008. }
  92009. declare module BABYLON {
  92010. /**
  92011. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  92012. *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.
  92013. * The SPS is also a particle system. It provides some methods to manage the particles.
  92014. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  92015. *
  92016. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  92017. */
  92018. export class SolidParticleSystem implements IDisposable {
  92019. /**
  92020. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  92021. * Example : var p = SPS.particles[i];
  92022. */
  92023. particles: SolidParticle[];
  92024. /**
  92025. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  92026. */
  92027. nbParticles: number;
  92028. /**
  92029. * If the particles must ever face the camera (default false). Useful for planar particles.
  92030. */
  92031. billboard: boolean;
  92032. /**
  92033. * Recompute normals when adding a shape
  92034. */
  92035. recomputeNormals: boolean;
  92036. /**
  92037. * This a counter ofr your own usage. It's not set by any SPS functions.
  92038. */
  92039. counter: number;
  92040. /**
  92041. * The SPS name. This name is also given to the underlying mesh.
  92042. */
  92043. name: string;
  92044. /**
  92045. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  92046. */
  92047. mesh: Mesh;
  92048. /**
  92049. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  92050. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  92051. */
  92052. vars: any;
  92053. /**
  92054. * This array is populated when the SPS is set as 'pickable'.
  92055. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  92056. * Each element of this array is an object `{idx: int, faceId: int}`.
  92057. * `idx` is the picked particle index in the `SPS.particles` array
  92058. * `faceId` is the picked face index counted within this particle.
  92059. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  92060. */
  92061. pickedParticles: {
  92062. idx: number;
  92063. faceId: number;
  92064. }[];
  92065. /**
  92066. * This array is populated when `enableDepthSort` is set to true.
  92067. * Each element of this array is an instance of the class DepthSortedParticle.
  92068. */
  92069. depthSortedParticles: DepthSortedParticle[];
  92070. /**
  92071. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  92072. * @hidden
  92073. */
  92074. _bSphereOnly: boolean;
  92075. /**
  92076. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  92077. * @hidden
  92078. */
  92079. _bSphereRadiusFactor: number;
  92080. private _scene;
  92081. private _positions;
  92082. private _indices;
  92083. private _normals;
  92084. private _colors;
  92085. private _uvs;
  92086. private _indices32;
  92087. private _positions32;
  92088. private _normals32;
  92089. private _fixedNormal32;
  92090. private _colors32;
  92091. private _uvs32;
  92092. private _index;
  92093. private _updatable;
  92094. private _pickable;
  92095. private _isVisibilityBoxLocked;
  92096. private _alwaysVisible;
  92097. private _depthSort;
  92098. private _shapeCounter;
  92099. private _copy;
  92100. private _color;
  92101. private _computeParticleColor;
  92102. private _computeParticleTexture;
  92103. private _computeParticleRotation;
  92104. private _computeParticleVertex;
  92105. private _computeBoundingBox;
  92106. private _depthSortParticles;
  92107. private _camera;
  92108. private _mustUnrotateFixedNormals;
  92109. private _particlesIntersect;
  92110. private _needs32Bits;
  92111. /**
  92112. * Creates a SPS (Solid Particle System) object.
  92113. * @param name (String) is the SPS name, this will be the underlying mesh name.
  92114. * @param scene (Scene) is the scene in which the SPS is added.
  92115. * @param options defines the options of the sps e.g.
  92116. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  92117. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  92118. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  92119. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  92120. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  92121. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  92122. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  92123. */
  92124. constructor(name: string, scene: Scene, options?: {
  92125. updatable?: boolean;
  92126. isPickable?: boolean;
  92127. enableDepthSort?: boolean;
  92128. particleIntersection?: boolean;
  92129. boundingSphereOnly?: boolean;
  92130. bSphereRadiusFactor?: number;
  92131. });
  92132. /**
  92133. * Builds the SPS underlying mesh. Returns a standard Mesh.
  92134. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  92135. * @returns the created mesh
  92136. */
  92137. buildMesh(): Mesh;
  92138. /**
  92139. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  92140. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  92141. * Thus the particles generated from `digest()` have their property `position` set yet.
  92142. * @param mesh ( Mesh ) is the mesh to be digested
  92143. * @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
  92144. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  92145. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  92146. * @returns the current SPS
  92147. */
  92148. digest(mesh: Mesh, options?: {
  92149. facetNb?: number;
  92150. number?: number;
  92151. delta?: number;
  92152. }): SolidParticleSystem;
  92153. private _unrotateFixedNormals;
  92154. private _resetCopy;
  92155. private _meshBuilder;
  92156. private _posToShape;
  92157. private _uvsToShapeUV;
  92158. private _addParticle;
  92159. /**
  92160. * Adds some particles to the SPS from the model shape. Returns the shape id.
  92161. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  92162. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  92163. * @param nb (positive integer) the number of particles to be created from this model
  92164. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  92165. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  92166. * @returns the number of shapes in the system
  92167. */
  92168. addShape(mesh: Mesh, nb: number, options?: {
  92169. positionFunction?: any;
  92170. vertexFunction?: any;
  92171. }): number;
  92172. private _rebuildParticle;
  92173. /**
  92174. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  92175. * @returns the SPS.
  92176. */
  92177. rebuildMesh(): SolidParticleSystem;
  92178. /**
  92179. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  92180. * This method calls `updateParticle()` for each particle of the SPS.
  92181. * For an animated SPS, it is usually called within the render loop.
  92182. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  92183. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  92184. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  92185. * @returns the SPS.
  92186. */
  92187. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  92188. /**
  92189. * Disposes the SPS.
  92190. */
  92191. dispose(): void;
  92192. /**
  92193. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  92194. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92195. * @returns the SPS.
  92196. */
  92197. refreshVisibleSize(): SolidParticleSystem;
  92198. /**
  92199. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  92200. * @param size the size (float) of the visibility box
  92201. * note : this doesn't lock the SPS mesh bounding box.
  92202. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92203. */
  92204. setVisibilityBox(size: number): void;
  92205. /**
  92206. * Gets whether the SPS as always visible or not
  92207. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92208. */
  92209. /**
  92210. * Sets the SPS as always visible or not
  92211. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92212. */
  92213. isAlwaysVisible: boolean;
  92214. /**
  92215. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  92216. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92217. */
  92218. /**
  92219. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  92220. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92221. */
  92222. isVisibilityBoxLocked: boolean;
  92223. /**
  92224. * Tells to `setParticles()` to compute the particle rotations or not.
  92225. * Default value : true. The SPS is faster when it's set to false.
  92226. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  92227. */
  92228. /**
  92229. * Gets if `setParticles()` computes the particle rotations or not.
  92230. * Default value : true. The SPS is faster when it's set to false.
  92231. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  92232. */
  92233. computeParticleRotation: boolean;
  92234. /**
  92235. * Tells to `setParticles()` to compute the particle colors or not.
  92236. * Default value : true. The SPS is faster when it's set to false.
  92237. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  92238. */
  92239. /**
  92240. * Gets if `setParticles()` computes the particle colors or not.
  92241. * Default value : true. The SPS is faster when it's set to false.
  92242. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  92243. */
  92244. computeParticleColor: boolean;
  92245. /**
  92246. * Gets if `setParticles()` computes the particle textures or not.
  92247. * Default value : true. The SPS is faster when it's set to false.
  92248. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  92249. */
  92250. computeParticleTexture: boolean;
  92251. /**
  92252. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  92253. * Default value : false. The SPS is faster when it's set to false.
  92254. * Note : the particle custom vertex positions aren't stored values.
  92255. */
  92256. /**
  92257. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  92258. * Default value : false. The SPS is faster when it's set to false.
  92259. * Note : the particle custom vertex positions aren't stored values.
  92260. */
  92261. computeParticleVertex: boolean;
  92262. /**
  92263. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  92264. */
  92265. /**
  92266. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  92267. */
  92268. computeBoundingBox: boolean;
  92269. /**
  92270. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  92271. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  92272. * Default : `true`
  92273. */
  92274. /**
  92275. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  92276. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  92277. * Default : `true`
  92278. */
  92279. depthSortParticles: boolean;
  92280. /**
  92281. * This function does nothing. It may be overwritten to set all the particle first values.
  92282. * The SPS doesn't call this function, you may have to call it by your own.
  92283. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  92284. */
  92285. initParticles(): void;
  92286. /**
  92287. * This function does nothing. It may be overwritten to recycle a particle.
  92288. * The SPS doesn't call this function, you may have to call it by your own.
  92289. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  92290. * @param particle The particle to recycle
  92291. * @returns the recycled particle
  92292. */
  92293. recycleParticle(particle: SolidParticle): SolidParticle;
  92294. /**
  92295. * Updates a particle : this function should be overwritten by the user.
  92296. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  92297. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  92298. * @example : just set a particle position or velocity and recycle conditions
  92299. * @param particle The particle to update
  92300. * @returns the updated particle
  92301. */
  92302. updateParticle(particle: SolidParticle): SolidParticle;
  92303. /**
  92304. * Updates a vertex of a particle : it can be overwritten by the user.
  92305. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  92306. * @param particle the current particle
  92307. * @param vertex the current index of the current particle
  92308. * @param pt the index of the current vertex in the particle shape
  92309. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  92310. * @example : just set a vertex particle position
  92311. * @returns the updated vertex
  92312. */
  92313. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  92314. /**
  92315. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  92316. * This does nothing and may be overwritten by the user.
  92317. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  92318. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  92319. * @param update the boolean update value actually passed to setParticles()
  92320. */
  92321. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  92322. /**
  92323. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  92324. * This will be passed three parameters.
  92325. * This does nothing and may be overwritten by the user.
  92326. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  92327. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  92328. * @param update the boolean update value actually passed to setParticles()
  92329. */
  92330. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  92331. }
  92332. }
  92333. declare module BABYLON {
  92334. /**
  92335. * Represents one particle of a solid particle system.
  92336. */
  92337. export class SolidParticle {
  92338. /**
  92339. * particle global index
  92340. */
  92341. idx: number;
  92342. /**
  92343. * The color of the particle
  92344. */
  92345. color: Nullable<Color4>;
  92346. /**
  92347. * The world space position of the particle.
  92348. */
  92349. position: Vector3;
  92350. /**
  92351. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  92352. */
  92353. rotation: Vector3;
  92354. /**
  92355. * The world space rotation quaternion of the particle.
  92356. */
  92357. rotationQuaternion: Nullable<Quaternion>;
  92358. /**
  92359. * The scaling of the particle.
  92360. */
  92361. scaling: Vector3;
  92362. /**
  92363. * The uvs of the particle.
  92364. */
  92365. uvs: Vector4;
  92366. /**
  92367. * The current speed of the particle.
  92368. */
  92369. velocity: Vector3;
  92370. /**
  92371. * The pivot point in the particle local space.
  92372. */
  92373. pivot: Vector3;
  92374. /**
  92375. * Must the particle be translated from its pivot point in its local space ?
  92376. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  92377. * Default : false
  92378. */
  92379. translateFromPivot: boolean;
  92380. /**
  92381. * Is the particle active or not ?
  92382. */
  92383. alive: boolean;
  92384. /**
  92385. * Is the particle visible or not ?
  92386. */
  92387. isVisible: boolean;
  92388. /**
  92389. * Index of this particle in the global "positions" array (Internal use)
  92390. * @hidden
  92391. */
  92392. _pos: number;
  92393. /**
  92394. * @hidden Index of this particle in the global "indices" array (Internal use)
  92395. */
  92396. _ind: number;
  92397. /**
  92398. * @hidden ModelShape of this particle (Internal use)
  92399. */
  92400. _model: ModelShape;
  92401. /**
  92402. * ModelShape id of this particle
  92403. */
  92404. shapeId: number;
  92405. /**
  92406. * Index of the particle in its shape id
  92407. */
  92408. idxInShape: number;
  92409. /**
  92410. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  92411. */
  92412. _modelBoundingInfo: BoundingInfo;
  92413. /**
  92414. * @hidden Particle BoundingInfo object (Internal use)
  92415. */
  92416. _boundingInfo: BoundingInfo;
  92417. /**
  92418. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  92419. */
  92420. _sps: SolidParticleSystem;
  92421. /**
  92422. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  92423. */
  92424. _stillInvisible: boolean;
  92425. /**
  92426. * @hidden Last computed particle rotation matrix
  92427. */
  92428. _rotationMatrix: number[];
  92429. /**
  92430. * Parent particle Id, if any.
  92431. * Default null.
  92432. */
  92433. parentId: Nullable<number>;
  92434. /**
  92435. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  92436. * The possible values are :
  92437. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  92438. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  92439. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  92440. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  92441. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  92442. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  92443. * */
  92444. cullingStrategy: number;
  92445. /**
  92446. * @hidden Internal global position in the SPS.
  92447. */
  92448. _globalPosition: Vector3;
  92449. /**
  92450. * Creates a Solid Particle object.
  92451. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  92452. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  92453. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  92454. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  92455. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  92456. * @param shapeId (integer) is the model shape identifier in the SPS.
  92457. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  92458. * @param sps defines the sps it is associated to
  92459. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  92460. */
  92461. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  92462. /**
  92463. * Legacy support, changed scale to scaling
  92464. */
  92465. /**
  92466. * Legacy support, changed scale to scaling
  92467. */
  92468. scale: Vector3;
  92469. /**
  92470. * Legacy support, changed quaternion to rotationQuaternion
  92471. */
  92472. /**
  92473. * Legacy support, changed quaternion to rotationQuaternion
  92474. */
  92475. quaternion: Nullable<Quaternion>;
  92476. /**
  92477. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  92478. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  92479. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  92480. * @returns true if it intersects
  92481. */
  92482. intersectsMesh(target: Mesh | SolidParticle): boolean;
  92483. /**
  92484. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  92485. * A particle is in the frustum if its bounding box intersects the frustum
  92486. * @param frustumPlanes defines the frustum to test
  92487. * @returns true if the particle is in the frustum planes
  92488. */
  92489. isInFrustum(frustumPlanes: Plane[]): boolean;
  92490. /**
  92491. * get the rotation matrix of the particle
  92492. * @hidden
  92493. */
  92494. getRotationMatrix(m: Matrix): void;
  92495. }
  92496. /**
  92497. * Represents the shape of the model used by one particle of a solid particle system.
  92498. * SPS internal tool, don't use it manually.
  92499. */
  92500. export class ModelShape {
  92501. /**
  92502. * The shape id
  92503. * @hidden
  92504. */
  92505. shapeID: number;
  92506. /**
  92507. * flat array of model positions (internal use)
  92508. * @hidden
  92509. */
  92510. _shape: Vector3[];
  92511. /**
  92512. * flat array of model UVs (internal use)
  92513. * @hidden
  92514. */
  92515. _shapeUV: number[];
  92516. /**
  92517. * length of the shape in the model indices array (internal use)
  92518. * @hidden
  92519. */
  92520. _indicesLength: number;
  92521. /**
  92522. * Custom position function (internal use)
  92523. * @hidden
  92524. */
  92525. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  92526. /**
  92527. * Custom vertex function (internal use)
  92528. * @hidden
  92529. */
  92530. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  92531. /**
  92532. * 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.
  92533. * SPS internal tool, don't use it manually.
  92534. * @hidden
  92535. */
  92536. 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>);
  92537. }
  92538. /**
  92539. * Represents a Depth Sorted Particle in the solid particle system.
  92540. */
  92541. export class DepthSortedParticle {
  92542. /**
  92543. * Index of the particle in the "indices" array
  92544. */
  92545. ind: number;
  92546. /**
  92547. * Length of the particle shape in the "indices" array
  92548. */
  92549. indicesLength: number;
  92550. /**
  92551. * Squared distance from the particle to the camera
  92552. */
  92553. sqDistance: number;
  92554. }
  92555. }
  92556. declare module BABYLON {
  92557. /**
  92558. * @hidden
  92559. */
  92560. export class _MeshCollisionData {
  92561. _checkCollisions: boolean;
  92562. _collisionMask: number;
  92563. _collisionGroup: number;
  92564. _collider: Nullable<Collider>;
  92565. _oldPositionForCollisions: Vector3;
  92566. _diffPositionForCollisions: Vector3;
  92567. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  92568. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  92569. }
  92570. }
  92571. declare module BABYLON {
  92572. /** @hidden */
  92573. class _FacetDataStorage {
  92574. facetPositions: Vector3[];
  92575. facetNormals: Vector3[];
  92576. facetPartitioning: number[][];
  92577. facetNb: number;
  92578. partitioningSubdivisions: number;
  92579. partitioningBBoxRatio: number;
  92580. facetDataEnabled: boolean;
  92581. facetParameters: any;
  92582. bbSize: Vector3;
  92583. subDiv: {
  92584. max: number;
  92585. X: number;
  92586. Y: number;
  92587. Z: number;
  92588. };
  92589. facetDepthSort: boolean;
  92590. facetDepthSortEnabled: boolean;
  92591. depthSortedIndices: IndicesArray;
  92592. depthSortedFacets: {
  92593. ind: number;
  92594. sqDistance: number;
  92595. }[];
  92596. facetDepthSortFunction: (f1: {
  92597. ind: number;
  92598. sqDistance: number;
  92599. }, f2: {
  92600. ind: number;
  92601. sqDistance: number;
  92602. }) => number;
  92603. facetDepthSortFrom: Vector3;
  92604. facetDepthSortOrigin: Vector3;
  92605. invertedMatrix: Matrix;
  92606. }
  92607. /**
  92608. * @hidden
  92609. **/
  92610. class _InternalAbstractMeshDataInfo {
  92611. _hasVertexAlpha: boolean;
  92612. _useVertexColors: boolean;
  92613. _numBoneInfluencers: number;
  92614. _applyFog: boolean;
  92615. _receiveShadows: boolean;
  92616. _facetData: _FacetDataStorage;
  92617. _visibility: number;
  92618. _skeleton: Nullable<Skeleton>;
  92619. _layerMask: number;
  92620. _computeBonesUsingShaders: boolean;
  92621. _isActive: boolean;
  92622. _onlyForInstances: boolean;
  92623. _isActiveIntermediate: boolean;
  92624. _onlyForInstancesIntermediate: boolean;
  92625. }
  92626. /**
  92627. * Class used to store all common mesh properties
  92628. */
  92629. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  92630. /** No occlusion */
  92631. static OCCLUSION_TYPE_NONE: number;
  92632. /** Occlusion set to optimisitic */
  92633. static OCCLUSION_TYPE_OPTIMISTIC: number;
  92634. /** Occlusion set to strict */
  92635. static OCCLUSION_TYPE_STRICT: number;
  92636. /** Use an accurante occlusion algorithm */
  92637. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  92638. /** Use a conservative occlusion algorithm */
  92639. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  92640. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  92641. * Test order :
  92642. * Is the bounding sphere outside the frustum ?
  92643. * If not, are the bounding box vertices outside the frustum ?
  92644. * It not, then the cullable object is in the frustum.
  92645. */
  92646. static readonly CULLINGSTRATEGY_STANDARD: number;
  92647. /** Culling strategy : Bounding Sphere Only.
  92648. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  92649. * It's also less accurate than the standard because some not visible objects can still be selected.
  92650. * Test : is the bounding sphere outside the frustum ?
  92651. * If not, then the cullable object is in the frustum.
  92652. */
  92653. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  92654. /** Culling strategy : Optimistic Inclusion.
  92655. * This in an inclusion test first, then the standard exclusion test.
  92656. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  92657. * 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.
  92658. * Anyway, it's as accurate as the standard strategy.
  92659. * Test :
  92660. * Is the cullable object bounding sphere center in the frustum ?
  92661. * If not, apply the default culling strategy.
  92662. */
  92663. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  92664. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  92665. * This in an inclusion test first, then the bounding sphere only exclusion test.
  92666. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  92667. * 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.
  92668. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  92669. * Test :
  92670. * Is the cullable object bounding sphere center in the frustum ?
  92671. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  92672. */
  92673. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  92674. /**
  92675. * No billboard
  92676. */
  92677. static readonly BILLBOARDMODE_NONE: number;
  92678. /** Billboard on X axis */
  92679. static readonly BILLBOARDMODE_X: number;
  92680. /** Billboard on Y axis */
  92681. static readonly BILLBOARDMODE_Y: number;
  92682. /** Billboard on Z axis */
  92683. static readonly BILLBOARDMODE_Z: number;
  92684. /** Billboard on all axes */
  92685. static readonly BILLBOARDMODE_ALL: number;
  92686. /** Billboard on using position instead of orientation */
  92687. static readonly BILLBOARDMODE_USE_POSITION: number;
  92688. /** @hidden */
  92689. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  92690. /**
  92691. * The culling strategy to use to check whether the mesh must be rendered or not.
  92692. * This value can be changed at any time and will be used on the next render mesh selection.
  92693. * The possible values are :
  92694. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  92695. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  92696. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  92697. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  92698. * Please read each static variable documentation to get details about the culling process.
  92699. * */
  92700. cullingStrategy: number;
  92701. /**
  92702. * Gets the number of facets in the mesh
  92703. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  92704. */
  92705. readonly facetNb: number;
  92706. /**
  92707. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  92708. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  92709. */
  92710. partitioningSubdivisions: number;
  92711. /**
  92712. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  92713. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  92714. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  92715. */
  92716. partitioningBBoxRatio: number;
  92717. /**
  92718. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  92719. * Works only for updatable meshes.
  92720. * Doesn't work with multi-materials
  92721. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  92722. */
  92723. mustDepthSortFacets: boolean;
  92724. /**
  92725. * The location (Vector3) where the facet depth sort must be computed from.
  92726. * By default, the active camera position.
  92727. * Used only when facet depth sort is enabled
  92728. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  92729. */
  92730. facetDepthSortFrom: Vector3;
  92731. /**
  92732. * gets a boolean indicating if facetData is enabled
  92733. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  92734. */
  92735. readonly isFacetDataEnabled: boolean;
  92736. /** @hidden */
  92737. _updateNonUniformScalingState(value: boolean): boolean;
  92738. /**
  92739. * An event triggered when this mesh collides with another one
  92740. */
  92741. onCollideObservable: Observable<AbstractMesh>;
  92742. /** Set a function to call when this mesh collides with another one */
  92743. onCollide: () => void;
  92744. /**
  92745. * An event triggered when the collision's position changes
  92746. */
  92747. onCollisionPositionChangeObservable: Observable<Vector3>;
  92748. /** Set a function to call when the collision's position changes */
  92749. onCollisionPositionChange: () => void;
  92750. /**
  92751. * An event triggered when material is changed
  92752. */
  92753. onMaterialChangedObservable: Observable<AbstractMesh>;
  92754. /**
  92755. * Gets or sets the orientation for POV movement & rotation
  92756. */
  92757. definedFacingForward: boolean;
  92758. /** @hidden */
  92759. _occlusionQuery: Nullable<WebGLQuery>;
  92760. /** @hidden */
  92761. _renderingGroup: Nullable<RenderingGroup>;
  92762. /**
  92763. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  92764. */
  92765. /**
  92766. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  92767. */
  92768. visibility: number;
  92769. /** Gets or sets the alpha index used to sort transparent meshes
  92770. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  92771. */
  92772. alphaIndex: number;
  92773. /**
  92774. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  92775. */
  92776. isVisible: boolean;
  92777. /**
  92778. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  92779. */
  92780. isPickable: boolean;
  92781. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  92782. showSubMeshesBoundingBox: boolean;
  92783. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  92784. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  92785. */
  92786. isBlocker: boolean;
  92787. /**
  92788. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  92789. */
  92790. enablePointerMoveEvents: boolean;
  92791. /**
  92792. * Specifies the rendering group id for this mesh (0 by default)
  92793. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  92794. */
  92795. renderingGroupId: number;
  92796. private _material;
  92797. /** Gets or sets current material */
  92798. material: Nullable<Material>;
  92799. /**
  92800. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  92801. * @see http://doc.babylonjs.com/babylon101/shadows
  92802. */
  92803. receiveShadows: boolean;
  92804. /** Defines color to use when rendering outline */
  92805. outlineColor: Color3;
  92806. /** Define width to use when rendering outline */
  92807. outlineWidth: number;
  92808. /** Defines color to use when rendering overlay */
  92809. overlayColor: Color3;
  92810. /** Defines alpha to use when rendering overlay */
  92811. overlayAlpha: number;
  92812. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  92813. hasVertexAlpha: boolean;
  92814. /** 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) */
  92815. useVertexColors: boolean;
  92816. /**
  92817. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  92818. */
  92819. computeBonesUsingShaders: boolean;
  92820. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  92821. numBoneInfluencers: number;
  92822. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  92823. applyFog: boolean;
  92824. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  92825. useOctreeForRenderingSelection: boolean;
  92826. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  92827. useOctreeForPicking: boolean;
  92828. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  92829. useOctreeForCollisions: boolean;
  92830. /**
  92831. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  92832. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  92833. */
  92834. layerMask: number;
  92835. /**
  92836. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  92837. */
  92838. alwaysSelectAsActiveMesh: boolean;
  92839. /**
  92840. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  92841. */
  92842. doNotSyncBoundingInfo: boolean;
  92843. /**
  92844. * Gets or sets the current action manager
  92845. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92846. */
  92847. actionManager: Nullable<AbstractActionManager>;
  92848. private _meshCollisionData;
  92849. /**
  92850. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  92851. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92852. */
  92853. ellipsoid: Vector3;
  92854. /**
  92855. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  92856. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92857. */
  92858. ellipsoidOffset: Vector3;
  92859. /**
  92860. * Gets or sets a collision mask used to mask collisions (default is -1).
  92861. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  92862. */
  92863. collisionMask: number;
  92864. /**
  92865. * Gets or sets the current collision group mask (-1 by default).
  92866. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  92867. */
  92868. collisionGroup: number;
  92869. /**
  92870. * Defines edge width used when edgesRenderer is enabled
  92871. * @see https://www.babylonjs-playground.com/#10OJSG#13
  92872. */
  92873. edgesWidth: number;
  92874. /**
  92875. * Defines edge color used when edgesRenderer is enabled
  92876. * @see https://www.babylonjs-playground.com/#10OJSG#13
  92877. */
  92878. edgesColor: Color4;
  92879. /** @hidden */
  92880. _edgesRenderer: Nullable<IEdgesRenderer>;
  92881. /** @hidden */
  92882. _masterMesh: Nullable<AbstractMesh>;
  92883. /** @hidden */
  92884. _boundingInfo: Nullable<BoundingInfo>;
  92885. /** @hidden */
  92886. _renderId: number;
  92887. /**
  92888. * Gets or sets the list of subMeshes
  92889. * @see http://doc.babylonjs.com/how_to/multi_materials
  92890. */
  92891. subMeshes: SubMesh[];
  92892. /** @hidden */
  92893. _intersectionsInProgress: AbstractMesh[];
  92894. /** @hidden */
  92895. _unIndexed: boolean;
  92896. /** @hidden */
  92897. _lightSources: Light[];
  92898. /** Gets the list of lights affecting that mesh */
  92899. readonly lightSources: Light[];
  92900. /** @hidden */
  92901. readonly _positions: Nullable<Vector3[]>;
  92902. /** @hidden */
  92903. _waitingData: {
  92904. lods: Nullable<any>;
  92905. actions: Nullable<any>;
  92906. freezeWorldMatrix: Nullable<boolean>;
  92907. };
  92908. /** @hidden */
  92909. _bonesTransformMatrices: Nullable<Float32Array>;
  92910. /** @hidden */
  92911. _transformMatrixTexture: Nullable<RawTexture>;
  92912. /**
  92913. * Gets or sets a skeleton to apply skining transformations
  92914. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  92915. */
  92916. skeleton: Nullable<Skeleton>;
  92917. /**
  92918. * An event triggered when the mesh is rebuilt.
  92919. */
  92920. onRebuildObservable: Observable<AbstractMesh>;
  92921. /**
  92922. * Creates a new AbstractMesh
  92923. * @param name defines the name of the mesh
  92924. * @param scene defines the hosting scene
  92925. */
  92926. constructor(name: string, scene?: Nullable<Scene>);
  92927. /**
  92928. * Returns the string "AbstractMesh"
  92929. * @returns "AbstractMesh"
  92930. */
  92931. getClassName(): string;
  92932. /**
  92933. * Gets a string representation of the current mesh
  92934. * @param fullDetails defines a boolean indicating if full details must be included
  92935. * @returns a string representation of the current mesh
  92936. */
  92937. toString(fullDetails?: boolean): string;
  92938. /**
  92939. * @hidden
  92940. */
  92941. protected _getEffectiveParent(): Nullable<Node>;
  92942. /** @hidden */
  92943. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  92944. /** @hidden */
  92945. _rebuild(): void;
  92946. /** @hidden */
  92947. _resyncLightSources(): void;
  92948. /** @hidden */
  92949. _resyncLighSource(light: Light): void;
  92950. /** @hidden */
  92951. _unBindEffect(): void;
  92952. /** @hidden */
  92953. _removeLightSource(light: Light, dispose: boolean): void;
  92954. private _markSubMeshesAsDirty;
  92955. /** @hidden */
  92956. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  92957. /** @hidden */
  92958. _markSubMeshesAsAttributesDirty(): void;
  92959. /** @hidden */
  92960. _markSubMeshesAsMiscDirty(): void;
  92961. /**
  92962. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  92963. */
  92964. scaling: Vector3;
  92965. /**
  92966. * Returns true if the mesh is blocked. Implemented by child classes
  92967. */
  92968. readonly isBlocked: boolean;
  92969. /**
  92970. * Returns the mesh itself by default. Implemented by child classes
  92971. * @param camera defines the camera to use to pick the right LOD level
  92972. * @returns the currentAbstractMesh
  92973. */
  92974. getLOD(camera: Camera): Nullable<AbstractMesh>;
  92975. /**
  92976. * Returns 0 by default. Implemented by child classes
  92977. * @returns an integer
  92978. */
  92979. getTotalVertices(): number;
  92980. /**
  92981. * Returns a positive integer : the total number of indices in this mesh geometry.
  92982. * @returns the numner of indices or zero if the mesh has no geometry.
  92983. */
  92984. getTotalIndices(): number;
  92985. /**
  92986. * Returns null by default. Implemented by child classes
  92987. * @returns null
  92988. */
  92989. getIndices(): Nullable<IndicesArray>;
  92990. /**
  92991. * Returns the array of the requested vertex data kind. Implemented by child classes
  92992. * @param kind defines the vertex data kind to use
  92993. * @returns null
  92994. */
  92995. getVerticesData(kind: string): Nullable<FloatArray>;
  92996. /**
  92997. * Sets the vertex data of the mesh geometry for the requested `kind`.
  92998. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  92999. * Note that a new underlying VertexBuffer object is created each call.
  93000. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  93001. * @param kind defines vertex data kind:
  93002. * * VertexBuffer.PositionKind
  93003. * * VertexBuffer.UVKind
  93004. * * VertexBuffer.UV2Kind
  93005. * * VertexBuffer.UV3Kind
  93006. * * VertexBuffer.UV4Kind
  93007. * * VertexBuffer.UV5Kind
  93008. * * VertexBuffer.UV6Kind
  93009. * * VertexBuffer.ColorKind
  93010. * * VertexBuffer.MatricesIndicesKind
  93011. * * VertexBuffer.MatricesIndicesExtraKind
  93012. * * VertexBuffer.MatricesWeightsKind
  93013. * * VertexBuffer.MatricesWeightsExtraKind
  93014. * @param data defines the data source
  93015. * @param updatable defines if the data must be flagged as updatable (or static)
  93016. * @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
  93017. * @returns the current mesh
  93018. */
  93019. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  93020. /**
  93021. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  93022. * If the mesh has no geometry, it is simply returned as it is.
  93023. * @param kind defines vertex data kind:
  93024. * * VertexBuffer.PositionKind
  93025. * * VertexBuffer.UVKind
  93026. * * VertexBuffer.UV2Kind
  93027. * * VertexBuffer.UV3Kind
  93028. * * VertexBuffer.UV4Kind
  93029. * * VertexBuffer.UV5Kind
  93030. * * VertexBuffer.UV6Kind
  93031. * * VertexBuffer.ColorKind
  93032. * * VertexBuffer.MatricesIndicesKind
  93033. * * VertexBuffer.MatricesIndicesExtraKind
  93034. * * VertexBuffer.MatricesWeightsKind
  93035. * * VertexBuffer.MatricesWeightsExtraKind
  93036. * @param data defines the data source
  93037. * @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
  93038. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  93039. * @returns the current mesh
  93040. */
  93041. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  93042. /**
  93043. * Sets the mesh indices,
  93044. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  93045. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  93046. * @param totalVertices Defines the total number of vertices
  93047. * @returns the current mesh
  93048. */
  93049. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  93050. /**
  93051. * Gets a boolean indicating if specific vertex data is present
  93052. * @param kind defines the vertex data kind to use
  93053. * @returns true is data kind is present
  93054. */
  93055. isVerticesDataPresent(kind: string): boolean;
  93056. /**
  93057. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  93058. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  93059. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  93060. * @returns a BoundingInfo
  93061. */
  93062. getBoundingInfo(): BoundingInfo;
  93063. /**
  93064. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  93065. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  93066. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  93067. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  93068. * @returns the current mesh
  93069. */
  93070. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  93071. /**
  93072. * Overwrite the current bounding info
  93073. * @param boundingInfo defines the new bounding info
  93074. * @returns the current mesh
  93075. */
  93076. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  93077. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  93078. readonly useBones: boolean;
  93079. /** @hidden */
  93080. _preActivate(): void;
  93081. /** @hidden */
  93082. _preActivateForIntermediateRendering(renderId: number): void;
  93083. /** @hidden */
  93084. _activate(renderId: number, intermediateRendering: boolean): boolean;
  93085. /** @hidden */
  93086. _postActivate(): void;
  93087. /** @hidden */
  93088. _freeze(): void;
  93089. /** @hidden */
  93090. _unFreeze(): void;
  93091. /**
  93092. * Gets the current world matrix
  93093. * @returns a Matrix
  93094. */
  93095. getWorldMatrix(): Matrix;
  93096. /** @hidden */
  93097. _getWorldMatrixDeterminant(): number;
  93098. /**
  93099. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  93100. */
  93101. readonly isAnInstance: boolean;
  93102. /**
  93103. * Gets a boolean indicating if this mesh has instances
  93104. */
  93105. readonly hasInstances: boolean;
  93106. /**
  93107. * Perform relative position change from the point of view of behind the front of the mesh.
  93108. * This is performed taking into account the meshes current rotation, so you do not have to care.
  93109. * Supports definition of mesh facing forward or backward
  93110. * @param amountRight defines the distance on the right axis
  93111. * @param amountUp defines the distance on the up axis
  93112. * @param amountForward defines the distance on the forward axis
  93113. * @returns the current mesh
  93114. */
  93115. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  93116. /**
  93117. * Calculate relative position change from the point of view of behind the front of the mesh.
  93118. * This is performed taking into account the meshes current rotation, so you do not have to care.
  93119. * Supports definition of mesh facing forward or backward
  93120. * @param amountRight defines the distance on the right axis
  93121. * @param amountUp defines the distance on the up axis
  93122. * @param amountForward defines the distance on the forward axis
  93123. * @returns the new displacement vector
  93124. */
  93125. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  93126. /**
  93127. * Perform relative rotation change from the point of view of behind the front of the mesh.
  93128. * Supports definition of mesh facing forward or backward
  93129. * @param flipBack defines the flip
  93130. * @param twirlClockwise defines the twirl
  93131. * @param tiltRight defines the tilt
  93132. * @returns the current mesh
  93133. */
  93134. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  93135. /**
  93136. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  93137. * Supports definition of mesh facing forward or backward.
  93138. * @param flipBack defines the flip
  93139. * @param twirlClockwise defines the twirl
  93140. * @param tiltRight defines the tilt
  93141. * @returns the new rotation vector
  93142. */
  93143. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  93144. /**
  93145. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  93146. * This means the mesh underlying bounding box and sphere are recomputed.
  93147. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  93148. * @returns the current mesh
  93149. */
  93150. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  93151. /** @hidden */
  93152. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  93153. /** @hidden */
  93154. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  93155. /** @hidden */
  93156. _updateBoundingInfo(): AbstractMesh;
  93157. /** @hidden */
  93158. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  93159. /** @hidden */
  93160. protected _afterComputeWorldMatrix(): void;
  93161. /** @hidden */
  93162. readonly _effectiveMesh: AbstractMesh;
  93163. /**
  93164. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  93165. * A mesh is in the frustum if its bounding box intersects the frustum
  93166. * @param frustumPlanes defines the frustum to test
  93167. * @returns true if the mesh is in the frustum planes
  93168. */
  93169. isInFrustum(frustumPlanes: Plane[]): boolean;
  93170. /**
  93171. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  93172. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  93173. * @param frustumPlanes defines the frustum to test
  93174. * @returns true if the mesh is completely in the frustum planes
  93175. */
  93176. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  93177. /**
  93178. * True if the mesh intersects another mesh or a SolidParticle object
  93179. * @param mesh defines a target mesh or SolidParticle to test
  93180. * @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)
  93181. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  93182. * @returns true if there is an intersection
  93183. */
  93184. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  93185. /**
  93186. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  93187. * @param point defines the point to test
  93188. * @returns true if there is an intersection
  93189. */
  93190. intersectsPoint(point: Vector3): boolean;
  93191. /**
  93192. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  93193. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  93194. */
  93195. checkCollisions: boolean;
  93196. /**
  93197. * Gets Collider object used to compute collisions (not physics)
  93198. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  93199. */
  93200. readonly collider: Nullable<Collider>;
  93201. /**
  93202. * Move the mesh using collision engine
  93203. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  93204. * @param displacement defines the requested displacement vector
  93205. * @returns the current mesh
  93206. */
  93207. moveWithCollisions(displacement: Vector3): AbstractMesh;
  93208. private _onCollisionPositionChange;
  93209. /** @hidden */
  93210. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  93211. /** @hidden */
  93212. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  93213. /** @hidden */
  93214. _checkCollision(collider: Collider): AbstractMesh;
  93215. /** @hidden */
  93216. _generatePointsArray(): boolean;
  93217. /**
  93218. * Checks if the passed Ray intersects with the mesh
  93219. * @param ray defines the ray to use
  93220. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  93221. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  93222. * @returns the picking info
  93223. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  93224. */
  93225. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  93226. /**
  93227. * Clones the current mesh
  93228. * @param name defines the mesh name
  93229. * @param newParent defines the new mesh parent
  93230. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  93231. * @returns the new mesh
  93232. */
  93233. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  93234. /**
  93235. * Disposes all the submeshes of the current meshnp
  93236. * @returns the current mesh
  93237. */
  93238. releaseSubMeshes(): AbstractMesh;
  93239. /**
  93240. * Releases resources associated with this abstract mesh.
  93241. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93242. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93243. */
  93244. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93245. /**
  93246. * Adds the passed mesh as a child to the current mesh
  93247. * @param mesh defines the child mesh
  93248. * @returns the current mesh
  93249. */
  93250. addChild(mesh: AbstractMesh): AbstractMesh;
  93251. /**
  93252. * Removes the passed mesh from the current mesh children list
  93253. * @param mesh defines the child mesh
  93254. * @returns the current mesh
  93255. */
  93256. removeChild(mesh: AbstractMesh): AbstractMesh;
  93257. /** @hidden */
  93258. private _initFacetData;
  93259. /**
  93260. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  93261. * This method can be called within the render loop.
  93262. * 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
  93263. * @returns the current mesh
  93264. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93265. */
  93266. updateFacetData(): AbstractMesh;
  93267. /**
  93268. * Returns the facetLocalNormals array.
  93269. * The normals are expressed in the mesh local spac
  93270. * @returns an array of Vector3
  93271. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93272. */
  93273. getFacetLocalNormals(): Vector3[];
  93274. /**
  93275. * Returns the facetLocalPositions array.
  93276. * The facet positions are expressed in the mesh local space
  93277. * @returns an array of Vector3
  93278. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93279. */
  93280. getFacetLocalPositions(): Vector3[];
  93281. /**
  93282. * Returns the facetLocalPartioning array
  93283. * @returns an array of array of numbers
  93284. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93285. */
  93286. getFacetLocalPartitioning(): number[][];
  93287. /**
  93288. * Returns the i-th facet position in the world system.
  93289. * This method allocates a new Vector3 per call
  93290. * @param i defines the facet index
  93291. * @returns a new Vector3
  93292. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93293. */
  93294. getFacetPosition(i: number): Vector3;
  93295. /**
  93296. * Sets the reference Vector3 with the i-th facet position in the world system
  93297. * @param i defines the facet index
  93298. * @param ref defines the target vector
  93299. * @returns the current mesh
  93300. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93301. */
  93302. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  93303. /**
  93304. * Returns the i-th facet normal in the world system.
  93305. * This method allocates a new Vector3 per call
  93306. * @param i defines the facet index
  93307. * @returns a new Vector3
  93308. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93309. */
  93310. getFacetNormal(i: number): Vector3;
  93311. /**
  93312. * Sets the reference Vector3 with the i-th facet normal in the world system
  93313. * @param i defines the facet index
  93314. * @param ref defines the target vector
  93315. * @returns the current mesh
  93316. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93317. */
  93318. getFacetNormalToRef(i: number, ref: Vector3): this;
  93319. /**
  93320. * 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)
  93321. * @param x defines x coordinate
  93322. * @param y defines y coordinate
  93323. * @param z defines z coordinate
  93324. * @returns the array of facet indexes
  93325. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93326. */
  93327. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  93328. /**
  93329. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  93330. * @param projected sets as the (x,y,z) world projection on the facet
  93331. * @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
  93332. * @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
  93333. * @param x defines x coordinate
  93334. * @param y defines y coordinate
  93335. * @param z defines z coordinate
  93336. * @returns the face index if found (or null instead)
  93337. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93338. */
  93339. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  93340. /**
  93341. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  93342. * @param projected sets as the (x,y,z) local projection on the facet
  93343. * @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
  93344. * @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
  93345. * @param x defines x coordinate
  93346. * @param y defines y coordinate
  93347. * @param z defines z coordinate
  93348. * @returns the face index if found (or null instead)
  93349. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93350. */
  93351. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  93352. /**
  93353. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  93354. * @returns the parameters
  93355. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93356. */
  93357. getFacetDataParameters(): any;
  93358. /**
  93359. * Disables the feature FacetData and frees the related memory
  93360. * @returns the current mesh
  93361. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93362. */
  93363. disableFacetData(): AbstractMesh;
  93364. /**
  93365. * Updates the AbstractMesh indices array
  93366. * @param indices defines the data source
  93367. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  93368. * @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)
  93369. * @returns the current mesh
  93370. */
  93371. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  93372. /**
  93373. * Creates new normals data for the mesh
  93374. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  93375. * @returns the current mesh
  93376. */
  93377. createNormals(updatable: boolean): AbstractMesh;
  93378. /**
  93379. * Align the mesh with a normal
  93380. * @param normal defines the normal to use
  93381. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  93382. * @returns the current mesh
  93383. */
  93384. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  93385. /** @hidden */
  93386. _checkOcclusionQuery(): boolean;
  93387. /**
  93388. * Disables the mesh edge rendering mode
  93389. * @returns the currentAbstractMesh
  93390. */
  93391. disableEdgesRendering(): AbstractMesh;
  93392. /**
  93393. * Enables the edge rendering mode on the mesh.
  93394. * This mode makes the mesh edges visible
  93395. * @param epsilon defines the maximal distance between two angles to detect a face
  93396. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  93397. * @returns the currentAbstractMesh
  93398. * @see https://www.babylonjs-playground.com/#19O9TU#0
  93399. */
  93400. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  93401. }
  93402. }
  93403. declare module BABYLON {
  93404. /**
  93405. * Interface used to define ActionEvent
  93406. */
  93407. export interface IActionEvent {
  93408. /** The mesh or sprite that triggered the action */
  93409. source: any;
  93410. /** The X mouse cursor position at the time of the event */
  93411. pointerX: number;
  93412. /** The Y mouse cursor position at the time of the event */
  93413. pointerY: number;
  93414. /** The mesh that is currently pointed at (can be null) */
  93415. meshUnderPointer: Nullable<AbstractMesh>;
  93416. /** the original (browser) event that triggered the ActionEvent */
  93417. sourceEvent?: any;
  93418. /** additional data for the event */
  93419. additionalData?: any;
  93420. }
  93421. /**
  93422. * ActionEvent is the event being sent when an action is triggered.
  93423. */
  93424. export class ActionEvent implements IActionEvent {
  93425. /** The mesh or sprite that triggered the action */
  93426. source: any;
  93427. /** The X mouse cursor position at the time of the event */
  93428. pointerX: number;
  93429. /** The Y mouse cursor position at the time of the event */
  93430. pointerY: number;
  93431. /** The mesh that is currently pointed at (can be null) */
  93432. meshUnderPointer: Nullable<AbstractMesh>;
  93433. /** the original (browser) event that triggered the ActionEvent */
  93434. sourceEvent?: any;
  93435. /** additional data for the event */
  93436. additionalData?: any;
  93437. /**
  93438. * Creates a new ActionEvent
  93439. * @param source The mesh or sprite that triggered the action
  93440. * @param pointerX The X mouse cursor position at the time of the event
  93441. * @param pointerY The Y mouse cursor position at the time of the event
  93442. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  93443. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  93444. * @param additionalData additional data for the event
  93445. */
  93446. constructor(
  93447. /** The mesh or sprite that triggered the action */
  93448. source: any,
  93449. /** The X mouse cursor position at the time of the event */
  93450. pointerX: number,
  93451. /** The Y mouse cursor position at the time of the event */
  93452. pointerY: number,
  93453. /** The mesh that is currently pointed at (can be null) */
  93454. meshUnderPointer: Nullable<AbstractMesh>,
  93455. /** the original (browser) event that triggered the ActionEvent */
  93456. sourceEvent?: any,
  93457. /** additional data for the event */
  93458. additionalData?: any);
  93459. /**
  93460. * Helper function to auto-create an ActionEvent from a source mesh.
  93461. * @param source The source mesh that triggered the event
  93462. * @param evt The original (browser) event
  93463. * @param additionalData additional data for the event
  93464. * @returns the new ActionEvent
  93465. */
  93466. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  93467. /**
  93468. * Helper function to auto-create an ActionEvent from a source sprite
  93469. * @param source The source sprite that triggered the event
  93470. * @param scene Scene associated with the sprite
  93471. * @param evt The original (browser) event
  93472. * @param additionalData additional data for the event
  93473. * @returns the new ActionEvent
  93474. */
  93475. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  93476. /**
  93477. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  93478. * @param scene the scene where the event occurred
  93479. * @param evt The original (browser) event
  93480. * @returns the new ActionEvent
  93481. */
  93482. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  93483. /**
  93484. * Helper function to auto-create an ActionEvent from a primitive
  93485. * @param prim defines the target primitive
  93486. * @param pointerPos defines the pointer position
  93487. * @param evt The original (browser) event
  93488. * @param additionalData additional data for the event
  93489. * @returns the new ActionEvent
  93490. */
  93491. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  93492. }
  93493. }
  93494. declare module BABYLON {
  93495. /**
  93496. * Abstract class used to decouple action Manager from scene and meshes.
  93497. * Do not instantiate.
  93498. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93499. */
  93500. export abstract class AbstractActionManager implements IDisposable {
  93501. /** Gets the list of active triggers */
  93502. static Triggers: {
  93503. [key: string]: number;
  93504. };
  93505. /** Gets the cursor to use when hovering items */
  93506. hoverCursor: string;
  93507. /** Gets the list of actions */
  93508. actions: IAction[];
  93509. /**
  93510. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  93511. */
  93512. isRecursive: boolean;
  93513. /**
  93514. * Releases all associated resources
  93515. */
  93516. abstract dispose(): void;
  93517. /**
  93518. * Does this action manager has pointer triggers
  93519. */
  93520. abstract readonly hasPointerTriggers: boolean;
  93521. /**
  93522. * Does this action manager has pick triggers
  93523. */
  93524. abstract readonly hasPickTriggers: boolean;
  93525. /**
  93526. * Process a specific trigger
  93527. * @param trigger defines the trigger to process
  93528. * @param evt defines the event details to be processed
  93529. */
  93530. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  93531. /**
  93532. * Does this action manager handles actions of any of the given triggers
  93533. * @param triggers defines the triggers to be tested
  93534. * @return a boolean indicating whether one (or more) of the triggers is handled
  93535. */
  93536. abstract hasSpecificTriggers(triggers: number[]): boolean;
  93537. /**
  93538. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  93539. * speed.
  93540. * @param triggerA defines the trigger to be tested
  93541. * @param triggerB defines the trigger to be tested
  93542. * @return a boolean indicating whether one (or more) of the triggers is handled
  93543. */
  93544. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  93545. /**
  93546. * Does this action manager handles actions of a given trigger
  93547. * @param trigger defines the trigger to be tested
  93548. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  93549. * @return whether the trigger is handled
  93550. */
  93551. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  93552. /**
  93553. * Serialize this manager to a JSON object
  93554. * @param name defines the property name to store this manager
  93555. * @returns a JSON representation of this manager
  93556. */
  93557. abstract serialize(name: string): any;
  93558. /**
  93559. * Registers an action to this action manager
  93560. * @param action defines the action to be registered
  93561. * @return the action amended (prepared) after registration
  93562. */
  93563. abstract registerAction(action: IAction): Nullable<IAction>;
  93564. /**
  93565. * Unregisters an action to this action manager
  93566. * @param action defines the action to be unregistered
  93567. * @return a boolean indicating whether the action has been unregistered
  93568. */
  93569. abstract unregisterAction(action: IAction): Boolean;
  93570. /**
  93571. * Does exist one action manager with at least one trigger
  93572. **/
  93573. static readonly HasTriggers: boolean;
  93574. /**
  93575. * Does exist one action manager with at least one pick trigger
  93576. **/
  93577. static readonly HasPickTriggers: boolean;
  93578. /**
  93579. * Does exist one action manager that handles actions of a given trigger
  93580. * @param trigger defines the trigger to be tested
  93581. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  93582. **/
  93583. static HasSpecificTrigger(trigger: number): boolean;
  93584. }
  93585. }
  93586. declare module BABYLON {
  93587. /**
  93588. * Defines how a node can be built from a string name.
  93589. */
  93590. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  93591. /**
  93592. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  93593. */
  93594. export class Node implements IBehaviorAware<Node> {
  93595. /** @hidden */
  93596. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  93597. private static _NodeConstructors;
  93598. /**
  93599. * Add a new node constructor
  93600. * @param type defines the type name of the node to construct
  93601. * @param constructorFunc defines the constructor function
  93602. */
  93603. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  93604. /**
  93605. * Returns a node constructor based on type name
  93606. * @param type defines the type name
  93607. * @param name defines the new node name
  93608. * @param scene defines the hosting scene
  93609. * @param options defines optional options to transmit to constructors
  93610. * @returns the new constructor or null
  93611. */
  93612. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  93613. /**
  93614. * Gets or sets the name of the node
  93615. */
  93616. name: string;
  93617. /**
  93618. * Gets or sets the id of the node
  93619. */
  93620. id: string;
  93621. /**
  93622. * Gets or sets the unique id of the node
  93623. */
  93624. uniqueId: number;
  93625. /**
  93626. * Gets or sets a string used to store user defined state for the node
  93627. */
  93628. state: string;
  93629. /**
  93630. * Gets or sets an object used to store user defined information for the node
  93631. */
  93632. metadata: any;
  93633. /**
  93634. * For internal use only. Please do not use.
  93635. */
  93636. reservedDataStore: any;
  93637. /**
  93638. * List of inspectable custom properties (used by the Inspector)
  93639. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  93640. */
  93641. inspectableCustomProperties: IInspectable[];
  93642. private _doNotSerialize;
  93643. /**
  93644. * Gets or sets a boolean used to define if the node must be serialized
  93645. */
  93646. doNotSerialize: boolean;
  93647. /** @hidden */
  93648. _isDisposed: boolean;
  93649. /**
  93650. * Gets a list of Animations associated with the node
  93651. */
  93652. animations: Animation[];
  93653. protected _ranges: {
  93654. [name: string]: Nullable<AnimationRange>;
  93655. };
  93656. /**
  93657. * Callback raised when the node is ready to be used
  93658. */
  93659. onReady: Nullable<(node: Node) => void>;
  93660. private _isEnabled;
  93661. private _isParentEnabled;
  93662. private _isReady;
  93663. /** @hidden */
  93664. _currentRenderId: number;
  93665. private _parentUpdateId;
  93666. /** @hidden */
  93667. _childUpdateId: number;
  93668. /** @hidden */
  93669. _waitingParentId: Nullable<string>;
  93670. /** @hidden */
  93671. _scene: Scene;
  93672. /** @hidden */
  93673. _cache: any;
  93674. private _parentNode;
  93675. private _children;
  93676. /** @hidden */
  93677. _worldMatrix: Matrix;
  93678. /** @hidden */
  93679. _worldMatrixDeterminant: number;
  93680. /** @hidden */
  93681. _worldMatrixDeterminantIsDirty: boolean;
  93682. /** @hidden */
  93683. private _sceneRootNodesIndex;
  93684. /**
  93685. * Gets a boolean indicating if the node has been disposed
  93686. * @returns true if the node was disposed
  93687. */
  93688. isDisposed(): boolean;
  93689. /**
  93690. * Gets or sets the parent of the node (without keeping the current position in the scene)
  93691. * @see https://doc.babylonjs.com/how_to/parenting
  93692. */
  93693. parent: Nullable<Node>;
  93694. private addToSceneRootNodes;
  93695. private removeFromSceneRootNodes;
  93696. private _animationPropertiesOverride;
  93697. /**
  93698. * Gets or sets the animation properties override
  93699. */
  93700. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  93701. /**
  93702. * Gets a string idenfifying the name of the class
  93703. * @returns "Node" string
  93704. */
  93705. getClassName(): string;
  93706. /** @hidden */
  93707. readonly _isNode: boolean;
  93708. /**
  93709. * An event triggered when the mesh is disposed
  93710. */
  93711. onDisposeObservable: Observable<Node>;
  93712. private _onDisposeObserver;
  93713. /**
  93714. * Sets a callback that will be raised when the node will be disposed
  93715. */
  93716. onDispose: () => void;
  93717. /**
  93718. * Creates a new Node
  93719. * @param name the name and id to be given to this node
  93720. * @param scene the scene this node will be added to
  93721. * @param addToRootNodes the node will be added to scene.rootNodes
  93722. */
  93723. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  93724. /**
  93725. * Gets the scene of the node
  93726. * @returns a scene
  93727. */
  93728. getScene(): Scene;
  93729. /**
  93730. * Gets the engine of the node
  93731. * @returns a Engine
  93732. */
  93733. getEngine(): Engine;
  93734. private _behaviors;
  93735. /**
  93736. * Attach a behavior to the node
  93737. * @see http://doc.babylonjs.com/features/behaviour
  93738. * @param behavior defines the behavior to attach
  93739. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  93740. * @returns the current Node
  93741. */
  93742. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  93743. /**
  93744. * Remove an attached behavior
  93745. * @see http://doc.babylonjs.com/features/behaviour
  93746. * @param behavior defines the behavior to attach
  93747. * @returns the current Node
  93748. */
  93749. removeBehavior(behavior: Behavior<Node>): Node;
  93750. /**
  93751. * Gets the list of attached behaviors
  93752. * @see http://doc.babylonjs.com/features/behaviour
  93753. */
  93754. readonly behaviors: Behavior<Node>[];
  93755. /**
  93756. * Gets an attached behavior by name
  93757. * @param name defines the name of the behavior to look for
  93758. * @see http://doc.babylonjs.com/features/behaviour
  93759. * @returns null if behavior was not found else the requested behavior
  93760. */
  93761. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  93762. /**
  93763. * Returns the latest update of the World matrix
  93764. * @returns a Matrix
  93765. */
  93766. getWorldMatrix(): Matrix;
  93767. /** @hidden */
  93768. _getWorldMatrixDeterminant(): number;
  93769. /**
  93770. * Returns directly the latest state of the mesh World matrix.
  93771. * A Matrix is returned.
  93772. */
  93773. readonly worldMatrixFromCache: Matrix;
  93774. /** @hidden */
  93775. _initCache(): void;
  93776. /** @hidden */
  93777. updateCache(force?: boolean): void;
  93778. /** @hidden */
  93779. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  93780. /** @hidden */
  93781. _updateCache(ignoreParentClass?: boolean): void;
  93782. /** @hidden */
  93783. _isSynchronized(): boolean;
  93784. /** @hidden */
  93785. _markSyncedWithParent(): void;
  93786. /** @hidden */
  93787. isSynchronizedWithParent(): boolean;
  93788. /** @hidden */
  93789. isSynchronized(): boolean;
  93790. /**
  93791. * Is this node ready to be used/rendered
  93792. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  93793. * @return true if the node is ready
  93794. */
  93795. isReady(completeCheck?: boolean): boolean;
  93796. /**
  93797. * Is this node enabled?
  93798. * 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
  93799. * @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
  93800. * @return whether this node (and its parent) is enabled
  93801. */
  93802. isEnabled(checkAncestors?: boolean): boolean;
  93803. /** @hidden */
  93804. protected _syncParentEnabledState(): void;
  93805. /**
  93806. * Set the enabled state of this node
  93807. * @param value defines the new enabled state
  93808. */
  93809. setEnabled(value: boolean): void;
  93810. /**
  93811. * Is this node a descendant of the given node?
  93812. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  93813. * @param ancestor defines the parent node to inspect
  93814. * @returns a boolean indicating if this node is a descendant of the given node
  93815. */
  93816. isDescendantOf(ancestor: Node): boolean;
  93817. /** @hidden */
  93818. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  93819. /**
  93820. * Will return all nodes that have this node as ascendant
  93821. * @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
  93822. * @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
  93823. * @return all children nodes of all types
  93824. */
  93825. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  93826. /**
  93827. * Get all child-meshes of this node
  93828. * @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)
  93829. * @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
  93830. * @returns an array of AbstractMesh
  93831. */
  93832. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  93833. /**
  93834. * Get all direct children of this node
  93835. * @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
  93836. * @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)
  93837. * @returns an array of Node
  93838. */
  93839. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  93840. /** @hidden */
  93841. _setReady(state: boolean): void;
  93842. /**
  93843. * Get an animation by name
  93844. * @param name defines the name of the animation to look for
  93845. * @returns null if not found else the requested animation
  93846. */
  93847. getAnimationByName(name: string): Nullable<Animation>;
  93848. /**
  93849. * Creates an animation range for this node
  93850. * @param name defines the name of the range
  93851. * @param from defines the starting key
  93852. * @param to defines the end key
  93853. */
  93854. createAnimationRange(name: string, from: number, to: number): void;
  93855. /**
  93856. * Delete a specific animation range
  93857. * @param name defines the name of the range to delete
  93858. * @param deleteFrames defines if animation frames from the range must be deleted as well
  93859. */
  93860. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  93861. /**
  93862. * Get an animation range by name
  93863. * @param name defines the name of the animation range to look for
  93864. * @returns null if not found else the requested animation range
  93865. */
  93866. getAnimationRange(name: string): Nullable<AnimationRange>;
  93867. /**
  93868. * Gets the list of all animation ranges defined on this node
  93869. * @returns an array
  93870. */
  93871. getAnimationRanges(): Nullable<AnimationRange>[];
  93872. /**
  93873. * Will start the animation sequence
  93874. * @param name defines the range frames for animation sequence
  93875. * @param loop defines if the animation should loop (false by default)
  93876. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  93877. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  93878. * @returns the object created for this animation. If range does not exist, it will return null
  93879. */
  93880. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  93881. /**
  93882. * Serialize animation ranges into a JSON compatible object
  93883. * @returns serialization object
  93884. */
  93885. serializeAnimationRanges(): any;
  93886. /**
  93887. * Computes the world matrix of the node
  93888. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  93889. * @returns the world matrix
  93890. */
  93891. computeWorldMatrix(force?: boolean): Matrix;
  93892. /**
  93893. * Releases resources associated with this node.
  93894. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93895. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93896. */
  93897. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93898. /**
  93899. * Parse animation range data from a serialization object and store them into a given node
  93900. * @param node defines where to store the animation ranges
  93901. * @param parsedNode defines the serialization object to read data from
  93902. * @param scene defines the hosting scene
  93903. */
  93904. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  93905. /**
  93906. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  93907. * @param includeDescendants Include bounding info from descendants as well (true by default)
  93908. * @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
  93909. * @returns the new bounding vectors
  93910. */
  93911. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  93912. min: Vector3;
  93913. max: Vector3;
  93914. };
  93915. }
  93916. }
  93917. declare module BABYLON {
  93918. /**
  93919. * @hidden
  93920. */
  93921. export class _IAnimationState {
  93922. key: number;
  93923. repeatCount: number;
  93924. workValue?: any;
  93925. loopMode?: number;
  93926. offsetValue?: any;
  93927. highLimitValue?: any;
  93928. }
  93929. /**
  93930. * Class used to store any kind of animation
  93931. */
  93932. export class Animation {
  93933. /**Name of the animation */
  93934. name: string;
  93935. /**Property to animate */
  93936. targetProperty: string;
  93937. /**The frames per second of the animation */
  93938. framePerSecond: number;
  93939. /**The data type of the animation */
  93940. dataType: number;
  93941. /**The loop mode of the animation */
  93942. loopMode?: number | undefined;
  93943. /**Specifies if blending should be enabled */
  93944. enableBlending?: boolean | undefined;
  93945. /**
  93946. * Use matrix interpolation instead of using direct key value when animating matrices
  93947. */
  93948. static AllowMatricesInterpolation: boolean;
  93949. /**
  93950. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  93951. */
  93952. static AllowMatrixDecomposeForInterpolation: boolean;
  93953. /**
  93954. * Stores the key frames of the animation
  93955. */
  93956. private _keys;
  93957. /**
  93958. * Stores the easing function of the animation
  93959. */
  93960. private _easingFunction;
  93961. /**
  93962. * @hidden Internal use only
  93963. */
  93964. _runtimeAnimations: RuntimeAnimation[];
  93965. /**
  93966. * The set of event that will be linked to this animation
  93967. */
  93968. private _events;
  93969. /**
  93970. * Stores an array of target property paths
  93971. */
  93972. targetPropertyPath: string[];
  93973. /**
  93974. * Stores the blending speed of the animation
  93975. */
  93976. blendingSpeed: number;
  93977. /**
  93978. * Stores the animation ranges for the animation
  93979. */
  93980. private _ranges;
  93981. /**
  93982. * @hidden Internal use
  93983. */
  93984. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  93985. /**
  93986. * Sets up an animation
  93987. * @param property The property to animate
  93988. * @param animationType The animation type to apply
  93989. * @param framePerSecond The frames per second of the animation
  93990. * @param easingFunction The easing function used in the animation
  93991. * @returns The created animation
  93992. */
  93993. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  93994. /**
  93995. * Create and start an animation on a node
  93996. * @param name defines the name of the global animation that will be run on all nodes
  93997. * @param node defines the root node where the animation will take place
  93998. * @param targetProperty defines property to animate
  93999. * @param framePerSecond defines the number of frame per second yo use
  94000. * @param totalFrame defines the number of frames in total
  94001. * @param from defines the initial value
  94002. * @param to defines the final value
  94003. * @param loopMode defines which loop mode you want to use (off by default)
  94004. * @param easingFunction defines the easing function to use (linear by default)
  94005. * @param onAnimationEnd defines the callback to call when animation end
  94006. * @returns the animatable created for this animation
  94007. */
  94008. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  94009. /**
  94010. * Create and start an animation on a node and its descendants
  94011. * @param name defines the name of the global animation that will be run on all nodes
  94012. * @param node defines the root node where the animation will take place
  94013. * @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
  94014. * @param targetProperty defines property to animate
  94015. * @param framePerSecond defines the number of frame per second to use
  94016. * @param totalFrame defines the number of frames in total
  94017. * @param from defines the initial value
  94018. * @param to defines the final value
  94019. * @param loopMode defines which loop mode you want to use (off by default)
  94020. * @param easingFunction defines the easing function to use (linear by default)
  94021. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  94022. * @returns the list of animatables created for all nodes
  94023. * @example https://www.babylonjs-playground.com/#MH0VLI
  94024. */
  94025. 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[]>;
  94026. /**
  94027. * Creates a new animation, merges it with the existing animations and starts it
  94028. * @param name Name of the animation
  94029. * @param node Node which contains the scene that begins the animations
  94030. * @param targetProperty Specifies which property to animate
  94031. * @param framePerSecond The frames per second of the animation
  94032. * @param totalFrame The total number of frames
  94033. * @param from The frame at the beginning of the animation
  94034. * @param to The frame at the end of the animation
  94035. * @param loopMode Specifies the loop mode of the animation
  94036. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  94037. * @param onAnimationEnd Callback to run once the animation is complete
  94038. * @returns Nullable animation
  94039. */
  94040. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  94041. /**
  94042. * Transition property of an host to the target Value
  94043. * @param property The property to transition
  94044. * @param targetValue The target Value of the property
  94045. * @param host The object where the property to animate belongs
  94046. * @param scene Scene used to run the animation
  94047. * @param frameRate Framerate (in frame/s) to use
  94048. * @param transition The transition type we want to use
  94049. * @param duration The duration of the animation, in milliseconds
  94050. * @param onAnimationEnd Callback trigger at the end of the animation
  94051. * @returns Nullable animation
  94052. */
  94053. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  94054. /**
  94055. * Return the array of runtime animations currently using this animation
  94056. */
  94057. readonly runtimeAnimations: RuntimeAnimation[];
  94058. /**
  94059. * Specifies if any of the runtime animations are currently running
  94060. */
  94061. readonly hasRunningRuntimeAnimations: boolean;
  94062. /**
  94063. * Initializes the animation
  94064. * @param name Name of the animation
  94065. * @param targetProperty Property to animate
  94066. * @param framePerSecond The frames per second of the animation
  94067. * @param dataType The data type of the animation
  94068. * @param loopMode The loop mode of the animation
  94069. * @param enableBlending Specifies if blending should be enabled
  94070. */
  94071. constructor(
  94072. /**Name of the animation */
  94073. name: string,
  94074. /**Property to animate */
  94075. targetProperty: string,
  94076. /**The frames per second of the animation */
  94077. framePerSecond: number,
  94078. /**The data type of the animation */
  94079. dataType: number,
  94080. /**The loop mode of the animation */
  94081. loopMode?: number | undefined,
  94082. /**Specifies if blending should be enabled */
  94083. enableBlending?: boolean | undefined);
  94084. /**
  94085. * Converts the animation to a string
  94086. * @param fullDetails support for multiple levels of logging within scene loading
  94087. * @returns String form of the animation
  94088. */
  94089. toString(fullDetails?: boolean): string;
  94090. /**
  94091. * Add an event to this animation
  94092. * @param event Event to add
  94093. */
  94094. addEvent(event: AnimationEvent): void;
  94095. /**
  94096. * Remove all events found at the given frame
  94097. * @param frame The frame to remove events from
  94098. */
  94099. removeEvents(frame: number): void;
  94100. /**
  94101. * Retrieves all the events from the animation
  94102. * @returns Events from the animation
  94103. */
  94104. getEvents(): AnimationEvent[];
  94105. /**
  94106. * Creates an animation range
  94107. * @param name Name of the animation range
  94108. * @param from Starting frame of the animation range
  94109. * @param to Ending frame of the animation
  94110. */
  94111. createRange(name: string, from: number, to: number): void;
  94112. /**
  94113. * Deletes an animation range by name
  94114. * @param name Name of the animation range to delete
  94115. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  94116. */
  94117. deleteRange(name: string, deleteFrames?: boolean): void;
  94118. /**
  94119. * Gets the animation range by name, or null if not defined
  94120. * @param name Name of the animation range
  94121. * @returns Nullable animation range
  94122. */
  94123. getRange(name: string): Nullable<AnimationRange>;
  94124. /**
  94125. * Gets the key frames from the animation
  94126. * @returns The key frames of the animation
  94127. */
  94128. getKeys(): Array<IAnimationKey>;
  94129. /**
  94130. * Gets the highest frame rate of the animation
  94131. * @returns Highest frame rate of the animation
  94132. */
  94133. getHighestFrame(): number;
  94134. /**
  94135. * Gets the easing function of the animation
  94136. * @returns Easing function of the animation
  94137. */
  94138. getEasingFunction(): IEasingFunction;
  94139. /**
  94140. * Sets the easing function of the animation
  94141. * @param easingFunction A custom mathematical formula for animation
  94142. */
  94143. setEasingFunction(easingFunction: EasingFunction): void;
  94144. /**
  94145. * Interpolates a scalar linearly
  94146. * @param startValue Start value of the animation curve
  94147. * @param endValue End value of the animation curve
  94148. * @param gradient Scalar amount to interpolate
  94149. * @returns Interpolated scalar value
  94150. */
  94151. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  94152. /**
  94153. * Interpolates a scalar cubically
  94154. * @param startValue Start value of the animation curve
  94155. * @param outTangent End tangent of the animation
  94156. * @param endValue End value of the animation curve
  94157. * @param inTangent Start tangent of the animation curve
  94158. * @param gradient Scalar amount to interpolate
  94159. * @returns Interpolated scalar value
  94160. */
  94161. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  94162. /**
  94163. * Interpolates a quaternion using a spherical linear interpolation
  94164. * @param startValue Start value of the animation curve
  94165. * @param endValue End value of the animation curve
  94166. * @param gradient Scalar amount to interpolate
  94167. * @returns Interpolated quaternion value
  94168. */
  94169. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  94170. /**
  94171. * Interpolates a quaternion cubically
  94172. * @param startValue Start value of the animation curve
  94173. * @param outTangent End tangent of the animation curve
  94174. * @param endValue End value of the animation curve
  94175. * @param inTangent Start tangent of the animation curve
  94176. * @param gradient Scalar amount to interpolate
  94177. * @returns Interpolated quaternion value
  94178. */
  94179. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  94180. /**
  94181. * Interpolates a Vector3 linearl
  94182. * @param startValue Start value of the animation curve
  94183. * @param endValue End value of the animation curve
  94184. * @param gradient Scalar amount to interpolate
  94185. * @returns Interpolated scalar value
  94186. */
  94187. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  94188. /**
  94189. * Interpolates a Vector3 cubically
  94190. * @param startValue Start value of the animation curve
  94191. * @param outTangent End tangent of the animation
  94192. * @param endValue End value of the animation curve
  94193. * @param inTangent Start tangent of the animation curve
  94194. * @param gradient Scalar amount to interpolate
  94195. * @returns InterpolatedVector3 value
  94196. */
  94197. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  94198. /**
  94199. * Interpolates a Vector2 linearly
  94200. * @param startValue Start value of the animation curve
  94201. * @param endValue End value of the animation curve
  94202. * @param gradient Scalar amount to interpolate
  94203. * @returns Interpolated Vector2 value
  94204. */
  94205. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  94206. /**
  94207. * Interpolates a Vector2 cubically
  94208. * @param startValue Start value of the animation curve
  94209. * @param outTangent End tangent of the animation
  94210. * @param endValue End value of the animation curve
  94211. * @param inTangent Start tangent of the animation curve
  94212. * @param gradient Scalar amount to interpolate
  94213. * @returns Interpolated Vector2 value
  94214. */
  94215. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  94216. /**
  94217. * Interpolates a size linearly
  94218. * @param startValue Start value of the animation curve
  94219. * @param endValue End value of the animation curve
  94220. * @param gradient Scalar amount to interpolate
  94221. * @returns Interpolated Size value
  94222. */
  94223. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  94224. /**
  94225. * Interpolates a Color3 linearly
  94226. * @param startValue Start value of the animation curve
  94227. * @param endValue End value of the animation curve
  94228. * @param gradient Scalar amount to interpolate
  94229. * @returns Interpolated Color3 value
  94230. */
  94231. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  94232. /**
  94233. * @hidden Internal use only
  94234. */
  94235. _getKeyValue(value: any): any;
  94236. /**
  94237. * @hidden Internal use only
  94238. */
  94239. _interpolate(currentFrame: number, state: _IAnimationState): any;
  94240. /**
  94241. * Defines the function to use to interpolate matrices
  94242. * @param startValue defines the start matrix
  94243. * @param endValue defines the end matrix
  94244. * @param gradient defines the gradient between both matrices
  94245. * @param result defines an optional target matrix where to store the interpolation
  94246. * @returns the interpolated matrix
  94247. */
  94248. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  94249. /**
  94250. * Makes a copy of the animation
  94251. * @returns Cloned animation
  94252. */
  94253. clone(): Animation;
  94254. /**
  94255. * Sets the key frames of the animation
  94256. * @param values The animation key frames to set
  94257. */
  94258. setKeys(values: Array<IAnimationKey>): void;
  94259. /**
  94260. * Serializes the animation to an object
  94261. * @returns Serialized object
  94262. */
  94263. serialize(): any;
  94264. /**
  94265. * Float animation type
  94266. */
  94267. private static _ANIMATIONTYPE_FLOAT;
  94268. /**
  94269. * Vector3 animation type
  94270. */
  94271. private static _ANIMATIONTYPE_VECTOR3;
  94272. /**
  94273. * Quaternion animation type
  94274. */
  94275. private static _ANIMATIONTYPE_QUATERNION;
  94276. /**
  94277. * Matrix animation type
  94278. */
  94279. private static _ANIMATIONTYPE_MATRIX;
  94280. /**
  94281. * Color3 animation type
  94282. */
  94283. private static _ANIMATIONTYPE_COLOR3;
  94284. /**
  94285. * Vector2 animation type
  94286. */
  94287. private static _ANIMATIONTYPE_VECTOR2;
  94288. /**
  94289. * Size animation type
  94290. */
  94291. private static _ANIMATIONTYPE_SIZE;
  94292. /**
  94293. * Relative Loop Mode
  94294. */
  94295. private static _ANIMATIONLOOPMODE_RELATIVE;
  94296. /**
  94297. * Cycle Loop Mode
  94298. */
  94299. private static _ANIMATIONLOOPMODE_CYCLE;
  94300. /**
  94301. * Constant Loop Mode
  94302. */
  94303. private static _ANIMATIONLOOPMODE_CONSTANT;
  94304. /**
  94305. * Get the float animation type
  94306. */
  94307. static readonly ANIMATIONTYPE_FLOAT: number;
  94308. /**
  94309. * Get the Vector3 animation type
  94310. */
  94311. static readonly ANIMATIONTYPE_VECTOR3: number;
  94312. /**
  94313. * Get the Vector2 animation type
  94314. */
  94315. static readonly ANIMATIONTYPE_VECTOR2: number;
  94316. /**
  94317. * Get the Size animation type
  94318. */
  94319. static readonly ANIMATIONTYPE_SIZE: number;
  94320. /**
  94321. * Get the Quaternion animation type
  94322. */
  94323. static readonly ANIMATIONTYPE_QUATERNION: number;
  94324. /**
  94325. * Get the Matrix animation type
  94326. */
  94327. static readonly ANIMATIONTYPE_MATRIX: number;
  94328. /**
  94329. * Get the Color3 animation type
  94330. */
  94331. static readonly ANIMATIONTYPE_COLOR3: number;
  94332. /**
  94333. * Get the Relative Loop Mode
  94334. */
  94335. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  94336. /**
  94337. * Get the Cycle Loop Mode
  94338. */
  94339. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  94340. /**
  94341. * Get the Constant Loop Mode
  94342. */
  94343. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  94344. /** @hidden */
  94345. static _UniversalLerp(left: any, right: any, amount: number): any;
  94346. /**
  94347. * Parses an animation object and creates an animation
  94348. * @param parsedAnimation Parsed animation object
  94349. * @returns Animation object
  94350. */
  94351. static Parse(parsedAnimation: any): Animation;
  94352. /**
  94353. * Appends the serialized animations from the source animations
  94354. * @param source Source containing the animations
  94355. * @param destination Target to store the animations
  94356. */
  94357. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  94358. }
  94359. }
  94360. declare module BABYLON {
  94361. /**
  94362. * Interface containing an array of animations
  94363. */
  94364. export interface IAnimatable {
  94365. /**
  94366. * Array of animations
  94367. */
  94368. animations: Nullable<Array<Animation>>;
  94369. }
  94370. }
  94371. declare module BABYLON {
  94372. /**
  94373. * This represents all the required information to add a fresnel effect on a material:
  94374. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  94375. */
  94376. export class FresnelParameters {
  94377. private _isEnabled;
  94378. /**
  94379. * Define if the fresnel effect is enable or not.
  94380. */
  94381. isEnabled: boolean;
  94382. /**
  94383. * Define the color used on edges (grazing angle)
  94384. */
  94385. leftColor: Color3;
  94386. /**
  94387. * Define the color used on center
  94388. */
  94389. rightColor: Color3;
  94390. /**
  94391. * Define bias applied to computed fresnel term
  94392. */
  94393. bias: number;
  94394. /**
  94395. * Defined the power exponent applied to fresnel term
  94396. */
  94397. power: number;
  94398. /**
  94399. * Clones the current fresnel and its valuues
  94400. * @returns a clone fresnel configuration
  94401. */
  94402. clone(): FresnelParameters;
  94403. /**
  94404. * Serializes the current fresnel parameters to a JSON representation.
  94405. * @return the JSON serialization
  94406. */
  94407. serialize(): any;
  94408. /**
  94409. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  94410. * @param parsedFresnelParameters Define the JSON representation
  94411. * @returns the parsed parameters
  94412. */
  94413. static Parse(parsedFresnelParameters: any): FresnelParameters;
  94414. }
  94415. }
  94416. declare module BABYLON {
  94417. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  94418. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94419. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94420. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94421. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94422. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94423. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94424. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94425. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94426. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94427. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94428. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94429. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94430. /**
  94431. * Decorator used to define property that can be serialized as reference to a camera
  94432. * @param sourceName defines the name of the property to decorate
  94433. */
  94434. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94435. /**
  94436. * Class used to help serialization objects
  94437. */
  94438. export class SerializationHelper {
  94439. /** @hidden */
  94440. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  94441. /** @hidden */
  94442. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  94443. /** @hidden */
  94444. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  94445. /** @hidden */
  94446. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  94447. /**
  94448. * Appends the serialized animations from the source animations
  94449. * @param source Source containing the animations
  94450. * @param destination Target to store the animations
  94451. */
  94452. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  94453. /**
  94454. * Static function used to serialized a specific entity
  94455. * @param entity defines the entity to serialize
  94456. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  94457. * @returns a JSON compatible object representing the serialization of the entity
  94458. */
  94459. static Serialize<T>(entity: T, serializationObject?: any): any;
  94460. /**
  94461. * Creates a new entity from a serialization data object
  94462. * @param creationFunction defines a function used to instanciated the new entity
  94463. * @param source defines the source serialization data
  94464. * @param scene defines the hosting scene
  94465. * @param rootUrl defines the root url for resources
  94466. * @returns a new entity
  94467. */
  94468. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  94469. /**
  94470. * Clones an object
  94471. * @param creationFunction defines the function used to instanciate the new object
  94472. * @param source defines the source object
  94473. * @returns the cloned object
  94474. */
  94475. static Clone<T>(creationFunction: () => T, source: T): T;
  94476. /**
  94477. * Instanciates a new object based on a source one (some data will be shared between both object)
  94478. * @param creationFunction defines the function used to instanciate the new object
  94479. * @param source defines the source object
  94480. * @returns the new object
  94481. */
  94482. static Instanciate<T>(creationFunction: () => T, source: T): T;
  94483. }
  94484. }
  94485. declare module BABYLON {
  94486. /**
  94487. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  94488. */
  94489. export interface CubeMapInfo {
  94490. /**
  94491. * The pixel array for the front face.
  94492. * This is stored in format, left to right, up to down format.
  94493. */
  94494. front: Nullable<ArrayBufferView>;
  94495. /**
  94496. * The pixel array for the back face.
  94497. * This is stored in format, left to right, up to down format.
  94498. */
  94499. back: Nullable<ArrayBufferView>;
  94500. /**
  94501. * The pixel array for the left face.
  94502. * This is stored in format, left to right, up to down format.
  94503. */
  94504. left: Nullable<ArrayBufferView>;
  94505. /**
  94506. * The pixel array for the right face.
  94507. * This is stored in format, left to right, up to down format.
  94508. */
  94509. right: Nullable<ArrayBufferView>;
  94510. /**
  94511. * The pixel array for the up face.
  94512. * This is stored in format, left to right, up to down format.
  94513. */
  94514. up: Nullable<ArrayBufferView>;
  94515. /**
  94516. * The pixel array for the down face.
  94517. * This is stored in format, left to right, up to down format.
  94518. */
  94519. down: Nullable<ArrayBufferView>;
  94520. /**
  94521. * The size of the cubemap stored.
  94522. *
  94523. * Each faces will be size * size pixels.
  94524. */
  94525. size: number;
  94526. /**
  94527. * The format of the texture.
  94528. *
  94529. * RGBA, RGB.
  94530. */
  94531. format: number;
  94532. /**
  94533. * The type of the texture data.
  94534. *
  94535. * UNSIGNED_INT, FLOAT.
  94536. */
  94537. type: number;
  94538. /**
  94539. * Specifies whether the texture is in gamma space.
  94540. */
  94541. gammaSpace: boolean;
  94542. }
  94543. /**
  94544. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  94545. */
  94546. export class PanoramaToCubeMapTools {
  94547. private static FACE_FRONT;
  94548. private static FACE_BACK;
  94549. private static FACE_RIGHT;
  94550. private static FACE_LEFT;
  94551. private static FACE_DOWN;
  94552. private static FACE_UP;
  94553. /**
  94554. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  94555. *
  94556. * @param float32Array The source data.
  94557. * @param inputWidth The width of the input panorama.
  94558. * @param inputHeight The height of the input panorama.
  94559. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  94560. * @return The cubemap data
  94561. */
  94562. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  94563. private static CreateCubemapTexture;
  94564. private static CalcProjectionSpherical;
  94565. }
  94566. }
  94567. declare module BABYLON {
  94568. /**
  94569. * Helper class dealing with the extraction of spherical polynomial dataArray
  94570. * from a cube map.
  94571. */
  94572. export class CubeMapToSphericalPolynomialTools {
  94573. private static FileFaces;
  94574. /**
  94575. * Converts a texture to the according Spherical Polynomial data.
  94576. * This extracts the first 3 orders only as they are the only one used in the lighting.
  94577. *
  94578. * @param texture The texture to extract the information from.
  94579. * @return The Spherical Polynomial data.
  94580. */
  94581. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  94582. /**
  94583. * Converts a cubemap to the according Spherical Polynomial data.
  94584. * This extracts the first 3 orders only as they are the only one used in the lighting.
  94585. *
  94586. * @param cubeInfo The Cube map to extract the information from.
  94587. * @return The Spherical Polynomial data.
  94588. */
  94589. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  94590. }
  94591. }
  94592. declare module BABYLON {
  94593. /**
  94594. * Class used to manipulate GUIDs
  94595. */
  94596. export class GUID {
  94597. /**
  94598. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  94599. * Be aware Math.random() could cause collisions, but:
  94600. * "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"
  94601. * @returns a pseudo random id
  94602. */
  94603. static RandomId(): string;
  94604. }
  94605. }
  94606. declare module BABYLON {
  94607. /**
  94608. * Base class of all the textures in babylon.
  94609. * It groups all the common properties the materials, post process, lights... might need
  94610. * in order to make a correct use of the texture.
  94611. */
  94612. export class BaseTexture implements IAnimatable {
  94613. /**
  94614. * Default anisotropic filtering level for the application.
  94615. * It is set to 4 as a good tradeoff between perf and quality.
  94616. */
  94617. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  94618. /**
  94619. * Gets or sets the unique id of the texture
  94620. */
  94621. uniqueId: number;
  94622. /**
  94623. * Define the name of the texture.
  94624. */
  94625. name: string;
  94626. /**
  94627. * Gets or sets an object used to store user defined information.
  94628. */
  94629. metadata: any;
  94630. /**
  94631. * For internal use only. Please do not use.
  94632. */
  94633. reservedDataStore: any;
  94634. private _hasAlpha;
  94635. /**
  94636. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  94637. */
  94638. hasAlpha: boolean;
  94639. /**
  94640. * Defines if the alpha value should be determined via the rgb values.
  94641. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  94642. */
  94643. getAlphaFromRGB: boolean;
  94644. /**
  94645. * Intensity or strength of the texture.
  94646. * It is commonly used by materials to fine tune the intensity of the texture
  94647. */
  94648. level: number;
  94649. /**
  94650. * Define the UV chanel to use starting from 0 and defaulting to 0.
  94651. * This is part of the texture as textures usually maps to one uv set.
  94652. */
  94653. coordinatesIndex: number;
  94654. private _coordinatesMode;
  94655. /**
  94656. * How a texture is mapped.
  94657. *
  94658. * | Value | Type | Description |
  94659. * | ----- | ----------------------------------- | ----------- |
  94660. * | 0 | EXPLICIT_MODE | |
  94661. * | 1 | SPHERICAL_MODE | |
  94662. * | 2 | PLANAR_MODE | |
  94663. * | 3 | CUBIC_MODE | |
  94664. * | 4 | PROJECTION_MODE | |
  94665. * | 5 | SKYBOX_MODE | |
  94666. * | 6 | INVCUBIC_MODE | |
  94667. * | 7 | EQUIRECTANGULAR_MODE | |
  94668. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  94669. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  94670. */
  94671. coordinatesMode: number;
  94672. /**
  94673. * | Value | Type | Description |
  94674. * | ----- | ------------------ | ----------- |
  94675. * | 0 | CLAMP_ADDRESSMODE | |
  94676. * | 1 | WRAP_ADDRESSMODE | |
  94677. * | 2 | MIRROR_ADDRESSMODE | |
  94678. */
  94679. wrapU: number;
  94680. /**
  94681. * | Value | Type | Description |
  94682. * | ----- | ------------------ | ----------- |
  94683. * | 0 | CLAMP_ADDRESSMODE | |
  94684. * | 1 | WRAP_ADDRESSMODE | |
  94685. * | 2 | MIRROR_ADDRESSMODE | |
  94686. */
  94687. wrapV: number;
  94688. /**
  94689. * | Value | Type | Description |
  94690. * | ----- | ------------------ | ----------- |
  94691. * | 0 | CLAMP_ADDRESSMODE | |
  94692. * | 1 | WRAP_ADDRESSMODE | |
  94693. * | 2 | MIRROR_ADDRESSMODE | |
  94694. */
  94695. wrapR: number;
  94696. /**
  94697. * With compliant hardware and browser (supporting anisotropic filtering)
  94698. * this defines the level of anisotropic filtering in the texture.
  94699. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  94700. */
  94701. anisotropicFilteringLevel: number;
  94702. /**
  94703. * Define if the texture is a cube texture or if false a 2d texture.
  94704. */
  94705. isCube: boolean;
  94706. /**
  94707. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  94708. */
  94709. is3D: boolean;
  94710. /**
  94711. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  94712. * HDR texture are usually stored in linear space.
  94713. * This only impacts the PBR and Background materials
  94714. */
  94715. gammaSpace: boolean;
  94716. /**
  94717. * Gets or sets whether or not the texture contains RGBD data.
  94718. */
  94719. isRGBD: boolean;
  94720. /**
  94721. * Is Z inverted in the texture (useful in a cube texture).
  94722. */
  94723. invertZ: boolean;
  94724. /**
  94725. * Are mip maps generated for this texture or not.
  94726. */
  94727. readonly noMipmap: boolean;
  94728. /**
  94729. * @hidden
  94730. */
  94731. lodLevelInAlpha: boolean;
  94732. /**
  94733. * With prefiltered texture, defined the offset used during the prefiltering steps.
  94734. */
  94735. lodGenerationOffset: number;
  94736. /**
  94737. * With prefiltered texture, defined the scale used during the prefiltering steps.
  94738. */
  94739. lodGenerationScale: number;
  94740. /**
  94741. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  94742. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  94743. * average roughness values.
  94744. */
  94745. linearSpecularLOD: boolean;
  94746. /**
  94747. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  94748. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  94749. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  94750. */
  94751. irradianceTexture: Nullable<BaseTexture>;
  94752. /**
  94753. * Define if the texture is a render target.
  94754. */
  94755. isRenderTarget: boolean;
  94756. /**
  94757. * Define the unique id of the texture in the scene.
  94758. */
  94759. readonly uid: string;
  94760. /**
  94761. * Return a string representation of the texture.
  94762. * @returns the texture as a string
  94763. */
  94764. toString(): string;
  94765. /**
  94766. * Get the class name of the texture.
  94767. * @returns "BaseTexture"
  94768. */
  94769. getClassName(): string;
  94770. /**
  94771. * Define the list of animation attached to the texture.
  94772. */
  94773. animations: Animation[];
  94774. /**
  94775. * An event triggered when the texture is disposed.
  94776. */
  94777. onDisposeObservable: Observable<BaseTexture>;
  94778. private _onDisposeObserver;
  94779. /**
  94780. * Callback triggered when the texture has been disposed.
  94781. * Kept for back compatibility, you can use the onDisposeObservable instead.
  94782. */
  94783. onDispose: () => void;
  94784. /**
  94785. * Define the current state of the loading sequence when in delayed load mode.
  94786. */
  94787. delayLoadState: number;
  94788. private _scene;
  94789. /** @hidden */
  94790. _texture: Nullable<InternalTexture>;
  94791. private _uid;
  94792. /**
  94793. * Define if the texture is preventinga material to render or not.
  94794. * If not and the texture is not ready, the engine will use a default black texture instead.
  94795. */
  94796. readonly isBlocking: boolean;
  94797. /**
  94798. * Instantiates a new BaseTexture.
  94799. * Base class of all the textures in babylon.
  94800. * It groups all the common properties the materials, post process, lights... might need
  94801. * in order to make a correct use of the texture.
  94802. * @param scene Define the scene the texture blongs to
  94803. */
  94804. constructor(scene: Nullable<Scene>);
  94805. /**
  94806. * Get the scene the texture belongs to.
  94807. * @returns the scene or null if undefined
  94808. */
  94809. getScene(): Nullable<Scene>;
  94810. /**
  94811. * Get the texture transform matrix used to offset tile the texture for istance.
  94812. * @returns the transformation matrix
  94813. */
  94814. getTextureMatrix(): Matrix;
  94815. /**
  94816. * Get the texture reflection matrix used to rotate/transform the reflection.
  94817. * @returns the reflection matrix
  94818. */
  94819. getReflectionTextureMatrix(): Matrix;
  94820. /**
  94821. * Get the underlying lower level texture from Babylon.
  94822. * @returns the insternal texture
  94823. */
  94824. getInternalTexture(): Nullable<InternalTexture>;
  94825. /**
  94826. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  94827. * @returns true if ready or not blocking
  94828. */
  94829. isReadyOrNotBlocking(): boolean;
  94830. /**
  94831. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  94832. * @returns true if fully ready
  94833. */
  94834. isReady(): boolean;
  94835. private _cachedSize;
  94836. /**
  94837. * Get the size of the texture.
  94838. * @returns the texture size.
  94839. */
  94840. getSize(): ISize;
  94841. /**
  94842. * Get the base size of the texture.
  94843. * It can be different from the size if the texture has been resized for POT for instance
  94844. * @returns the base size
  94845. */
  94846. getBaseSize(): ISize;
  94847. /**
  94848. * Update the sampling mode of the texture.
  94849. * Default is Trilinear mode.
  94850. *
  94851. * | Value | Type | Description |
  94852. * | ----- | ------------------ | ----------- |
  94853. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  94854. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  94855. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  94856. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  94857. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  94858. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  94859. * | 7 | NEAREST_LINEAR | |
  94860. * | 8 | NEAREST_NEAREST | |
  94861. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  94862. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  94863. * | 11 | LINEAR_LINEAR | |
  94864. * | 12 | LINEAR_NEAREST | |
  94865. *
  94866. * > _mag_: magnification filter (close to the viewer)
  94867. * > _min_: minification filter (far from the viewer)
  94868. * > _mip_: filter used between mip map levels
  94869. *@param samplingMode Define the new sampling mode of the texture
  94870. */
  94871. updateSamplingMode(samplingMode: number): void;
  94872. /**
  94873. * Scales the texture if is `canRescale()`
  94874. * @param ratio the resize factor we want to use to rescale
  94875. */
  94876. scale(ratio: number): void;
  94877. /**
  94878. * Get if the texture can rescale.
  94879. */
  94880. readonly canRescale: boolean;
  94881. /** @hidden */
  94882. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  94883. /** @hidden */
  94884. _rebuild(): void;
  94885. /**
  94886. * Triggers the load sequence in delayed load mode.
  94887. */
  94888. delayLoad(): void;
  94889. /**
  94890. * Clones the texture.
  94891. * @returns the cloned texture
  94892. */
  94893. clone(): Nullable<BaseTexture>;
  94894. /**
  94895. * Get the texture underlying type (INT, FLOAT...)
  94896. */
  94897. readonly textureType: number;
  94898. /**
  94899. * Get the texture underlying format (RGB, RGBA...)
  94900. */
  94901. readonly textureFormat: number;
  94902. /**
  94903. * Indicates that textures need to be re-calculated for all materials
  94904. */
  94905. protected _markAllSubMeshesAsTexturesDirty(): void;
  94906. /**
  94907. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  94908. * This will returns an RGBA array buffer containing either in values (0-255) or
  94909. * float values (0-1) depending of the underlying buffer type.
  94910. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  94911. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  94912. * @param buffer defines a user defined buffer to fill with data (can be null)
  94913. * @returns The Array buffer containing the pixels data.
  94914. */
  94915. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  94916. /**
  94917. * Release and destroy the underlying lower level texture aka internalTexture.
  94918. */
  94919. releaseInternalTexture(): void;
  94920. /**
  94921. * Get the polynomial representation of the texture data.
  94922. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  94923. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  94924. */
  94925. sphericalPolynomial: Nullable<SphericalPolynomial>;
  94926. /** @hidden */
  94927. readonly _lodTextureHigh: Nullable<BaseTexture>;
  94928. /** @hidden */
  94929. readonly _lodTextureMid: Nullable<BaseTexture>;
  94930. /** @hidden */
  94931. readonly _lodTextureLow: Nullable<BaseTexture>;
  94932. /**
  94933. * Dispose the texture and release its associated resources.
  94934. */
  94935. dispose(): void;
  94936. /**
  94937. * Serialize the texture into a JSON representation that can be parsed later on.
  94938. * @returns the JSON representation of the texture
  94939. */
  94940. serialize(): any;
  94941. /**
  94942. * Helper function to be called back once a list of texture contains only ready textures.
  94943. * @param textures Define the list of textures to wait for
  94944. * @param callback Define the callback triggered once the entire list will be ready
  94945. */
  94946. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  94947. }
  94948. }
  94949. declare module BABYLON {
  94950. /**
  94951. * Options to be used when creating an effect.
  94952. */
  94953. export class EffectCreationOptions {
  94954. /**
  94955. * Atrributes that will be used in the shader.
  94956. */
  94957. attributes: string[];
  94958. /**
  94959. * Uniform varible names that will be set in the shader.
  94960. */
  94961. uniformsNames: string[];
  94962. /**
  94963. * Uniform buffer varible names that will be set in the shader.
  94964. */
  94965. uniformBuffersNames: string[];
  94966. /**
  94967. * Sampler texture variable names that will be set in the shader.
  94968. */
  94969. samplers: string[];
  94970. /**
  94971. * Define statements that will be set in the shader.
  94972. */
  94973. defines: any;
  94974. /**
  94975. * Possible fallbacks for this effect to improve performance when needed.
  94976. */
  94977. fallbacks: Nullable<IEffectFallbacks>;
  94978. /**
  94979. * Callback that will be called when the shader is compiled.
  94980. */
  94981. onCompiled: Nullable<(effect: Effect) => void>;
  94982. /**
  94983. * Callback that will be called if an error occurs during shader compilation.
  94984. */
  94985. onError: Nullable<(effect: Effect, errors: string) => void>;
  94986. /**
  94987. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  94988. */
  94989. indexParameters?: any;
  94990. /**
  94991. * Max number of lights that can be used in the shader.
  94992. */
  94993. maxSimultaneousLights?: number;
  94994. /**
  94995. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  94996. */
  94997. transformFeedbackVaryings?: Nullable<string[]>;
  94998. }
  94999. /**
  95000. * Effect containing vertex and fragment shader that can be executed on an object.
  95001. */
  95002. export class Effect implements IDisposable {
  95003. /**
  95004. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  95005. */
  95006. static ShadersRepository: string;
  95007. /**
  95008. * Name of the effect.
  95009. */
  95010. name: any;
  95011. /**
  95012. * String container all the define statements that should be set on the shader.
  95013. */
  95014. defines: string;
  95015. /**
  95016. * Callback that will be called when the shader is compiled.
  95017. */
  95018. onCompiled: Nullable<(effect: Effect) => void>;
  95019. /**
  95020. * Callback that will be called if an error occurs during shader compilation.
  95021. */
  95022. onError: Nullable<(effect: Effect, errors: string) => void>;
  95023. /**
  95024. * Callback that will be called when effect is bound.
  95025. */
  95026. onBind: Nullable<(effect: Effect) => void>;
  95027. /**
  95028. * Unique ID of the effect.
  95029. */
  95030. uniqueId: number;
  95031. /**
  95032. * Observable that will be called when the shader is compiled.
  95033. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  95034. */
  95035. onCompileObservable: Observable<Effect>;
  95036. /**
  95037. * Observable that will be called if an error occurs during shader compilation.
  95038. */
  95039. onErrorObservable: Observable<Effect>;
  95040. /** @hidden */
  95041. _onBindObservable: Nullable<Observable<Effect>>;
  95042. /**
  95043. * Observable that will be called when effect is bound.
  95044. */
  95045. readonly onBindObservable: Observable<Effect>;
  95046. /** @hidden */
  95047. _bonesComputationForcedToCPU: boolean;
  95048. private static _uniqueIdSeed;
  95049. private _engine;
  95050. private _uniformBuffersNames;
  95051. private _uniformsNames;
  95052. private _samplerList;
  95053. private _samplers;
  95054. private _isReady;
  95055. private _compilationError;
  95056. private _attributesNames;
  95057. private _attributes;
  95058. private _uniforms;
  95059. /**
  95060. * Key for the effect.
  95061. * @hidden
  95062. */
  95063. _key: string;
  95064. private _indexParameters;
  95065. private _fallbacks;
  95066. private _vertexSourceCode;
  95067. private _fragmentSourceCode;
  95068. private _vertexSourceCodeOverride;
  95069. private _fragmentSourceCodeOverride;
  95070. private _transformFeedbackVaryings;
  95071. /**
  95072. * Compiled shader to webGL program.
  95073. * @hidden
  95074. */
  95075. _pipelineContext: Nullable<IPipelineContext>;
  95076. private _valueCache;
  95077. private static _baseCache;
  95078. /**
  95079. * Instantiates an effect.
  95080. * An effect can be used to create/manage/execute vertex and fragment shaders.
  95081. * @param baseName Name of the effect.
  95082. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  95083. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  95084. * @param samplers List of sampler variables that will be passed to the shader.
  95085. * @param engine Engine to be used to render the effect
  95086. * @param defines Define statements to be added to the shader.
  95087. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  95088. * @param onCompiled Callback that will be called when the shader is compiled.
  95089. * @param onError Callback that will be called if an error occurs during shader compilation.
  95090. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  95091. */
  95092. 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);
  95093. private _useFinalCode;
  95094. /**
  95095. * Unique key for this effect
  95096. */
  95097. readonly key: string;
  95098. /**
  95099. * If the effect has been compiled and prepared.
  95100. * @returns if the effect is compiled and prepared.
  95101. */
  95102. isReady(): boolean;
  95103. private _isReadyInternal;
  95104. /**
  95105. * The engine the effect was initialized with.
  95106. * @returns the engine.
  95107. */
  95108. getEngine(): Engine;
  95109. /**
  95110. * The pipeline context for this effect
  95111. * @returns the associated pipeline context
  95112. */
  95113. getPipelineContext(): Nullable<IPipelineContext>;
  95114. /**
  95115. * The set of names of attribute variables for the shader.
  95116. * @returns An array of attribute names.
  95117. */
  95118. getAttributesNames(): string[];
  95119. /**
  95120. * Returns the attribute at the given index.
  95121. * @param index The index of the attribute.
  95122. * @returns The location of the attribute.
  95123. */
  95124. getAttributeLocation(index: number): number;
  95125. /**
  95126. * Returns the attribute based on the name of the variable.
  95127. * @param name of the attribute to look up.
  95128. * @returns the attribute location.
  95129. */
  95130. getAttributeLocationByName(name: string): number;
  95131. /**
  95132. * The number of attributes.
  95133. * @returns the numnber of attributes.
  95134. */
  95135. getAttributesCount(): number;
  95136. /**
  95137. * Gets the index of a uniform variable.
  95138. * @param uniformName of the uniform to look up.
  95139. * @returns the index.
  95140. */
  95141. getUniformIndex(uniformName: string): number;
  95142. /**
  95143. * Returns the attribute based on the name of the variable.
  95144. * @param uniformName of the uniform to look up.
  95145. * @returns the location of the uniform.
  95146. */
  95147. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  95148. /**
  95149. * Returns an array of sampler variable names
  95150. * @returns The array of sampler variable neames.
  95151. */
  95152. getSamplers(): string[];
  95153. /**
  95154. * The error from the last compilation.
  95155. * @returns the error string.
  95156. */
  95157. getCompilationError(): string;
  95158. /**
  95159. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  95160. * @param func The callback to be used.
  95161. */
  95162. executeWhenCompiled(func: (effect: Effect) => void): void;
  95163. private _checkIsReady;
  95164. /** @hidden */
  95165. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  95166. /** @hidden */
  95167. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  95168. /** @hidden */
  95169. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  95170. /**
  95171. * Recompiles the webGL program
  95172. * @param vertexSourceCode The source code for the vertex shader.
  95173. * @param fragmentSourceCode The source code for the fragment shader.
  95174. * @param onCompiled Callback called when completed.
  95175. * @param onError Callback called on error.
  95176. * @hidden
  95177. */
  95178. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  95179. /**
  95180. * Prepares the effect
  95181. * @hidden
  95182. */
  95183. _prepareEffect(): void;
  95184. private _processCompilationErrors;
  95185. /**
  95186. * Checks if the effect is supported. (Must be called after compilation)
  95187. */
  95188. readonly isSupported: boolean;
  95189. /**
  95190. * Binds a texture to the engine to be used as output of the shader.
  95191. * @param channel Name of the output variable.
  95192. * @param texture Texture to bind.
  95193. * @hidden
  95194. */
  95195. _bindTexture(channel: string, texture: InternalTexture): void;
  95196. /**
  95197. * Sets a texture on the engine to be used in the shader.
  95198. * @param channel Name of the sampler variable.
  95199. * @param texture Texture to set.
  95200. */
  95201. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  95202. /**
  95203. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  95204. * @param channel Name of the sampler variable.
  95205. * @param texture Texture to set.
  95206. */
  95207. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  95208. /**
  95209. * Sets an array of textures on the engine to be used in the shader.
  95210. * @param channel Name of the variable.
  95211. * @param textures Textures to set.
  95212. */
  95213. setTextureArray(channel: string, textures: BaseTexture[]): void;
  95214. /**
  95215. * 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)
  95216. * @param channel Name of the sampler variable.
  95217. * @param postProcess Post process to get the input texture from.
  95218. */
  95219. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  95220. /**
  95221. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  95222. * 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)
  95223. * @param channel Name of the sampler variable.
  95224. * @param postProcess Post process to get the output texture from.
  95225. */
  95226. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  95227. /** @hidden */
  95228. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  95229. /** @hidden */
  95230. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  95231. /** @hidden */
  95232. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  95233. /** @hidden */
  95234. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  95235. /**
  95236. * Binds a buffer to a uniform.
  95237. * @param buffer Buffer to bind.
  95238. * @param name Name of the uniform variable to bind to.
  95239. */
  95240. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  95241. /**
  95242. * Binds block to a uniform.
  95243. * @param blockName Name of the block to bind.
  95244. * @param index Index to bind.
  95245. */
  95246. bindUniformBlock(blockName: string, index: number): void;
  95247. /**
  95248. * Sets an interger value on a uniform variable.
  95249. * @param uniformName Name of the variable.
  95250. * @param value Value to be set.
  95251. * @returns this effect.
  95252. */
  95253. setInt(uniformName: string, value: number): Effect;
  95254. /**
  95255. * Sets an int array on a uniform variable.
  95256. * @param uniformName Name of the variable.
  95257. * @param array array to be set.
  95258. * @returns this effect.
  95259. */
  95260. setIntArray(uniformName: string, array: Int32Array): Effect;
  95261. /**
  95262. * 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)
  95263. * @param uniformName Name of the variable.
  95264. * @param array array to be set.
  95265. * @returns this effect.
  95266. */
  95267. setIntArray2(uniformName: string, array: Int32Array): Effect;
  95268. /**
  95269. * 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)
  95270. * @param uniformName Name of the variable.
  95271. * @param array array to be set.
  95272. * @returns this effect.
  95273. */
  95274. setIntArray3(uniformName: string, array: Int32Array): Effect;
  95275. /**
  95276. * 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)
  95277. * @param uniformName Name of the variable.
  95278. * @param array array to be set.
  95279. * @returns this effect.
  95280. */
  95281. setIntArray4(uniformName: string, array: Int32Array): Effect;
  95282. /**
  95283. * Sets an float array on a uniform variable.
  95284. * @param uniformName Name of the variable.
  95285. * @param array array to be set.
  95286. * @returns this effect.
  95287. */
  95288. setFloatArray(uniformName: string, array: Float32Array): Effect;
  95289. /**
  95290. * 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)
  95291. * @param uniformName Name of the variable.
  95292. * @param array array to be set.
  95293. * @returns this effect.
  95294. */
  95295. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  95296. /**
  95297. * 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)
  95298. * @param uniformName Name of the variable.
  95299. * @param array array to be set.
  95300. * @returns this effect.
  95301. */
  95302. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  95303. /**
  95304. * 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)
  95305. * @param uniformName Name of the variable.
  95306. * @param array array to be set.
  95307. * @returns this effect.
  95308. */
  95309. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  95310. /**
  95311. * Sets an array on a uniform variable.
  95312. * @param uniformName Name of the variable.
  95313. * @param array array to be set.
  95314. * @returns this effect.
  95315. */
  95316. setArray(uniformName: string, array: number[]): Effect;
  95317. /**
  95318. * 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)
  95319. * @param uniformName Name of the variable.
  95320. * @param array array to be set.
  95321. * @returns this effect.
  95322. */
  95323. setArray2(uniformName: string, array: number[]): Effect;
  95324. /**
  95325. * 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)
  95326. * @param uniformName Name of the variable.
  95327. * @param array array to be set.
  95328. * @returns this effect.
  95329. */
  95330. setArray3(uniformName: string, array: number[]): Effect;
  95331. /**
  95332. * 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)
  95333. * @param uniformName Name of the variable.
  95334. * @param array array to be set.
  95335. * @returns this effect.
  95336. */
  95337. setArray4(uniformName: string, array: number[]): Effect;
  95338. /**
  95339. * Sets matrices on a uniform variable.
  95340. * @param uniformName Name of the variable.
  95341. * @param matrices matrices to be set.
  95342. * @returns this effect.
  95343. */
  95344. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  95345. /**
  95346. * Sets matrix on a uniform variable.
  95347. * @param uniformName Name of the variable.
  95348. * @param matrix matrix to be set.
  95349. * @returns this effect.
  95350. */
  95351. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  95352. /**
  95353. * 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)
  95354. * @param uniformName Name of the variable.
  95355. * @param matrix matrix to be set.
  95356. * @returns this effect.
  95357. */
  95358. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  95359. /**
  95360. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  95361. * @param uniformName Name of the variable.
  95362. * @param matrix matrix to be set.
  95363. * @returns this effect.
  95364. */
  95365. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  95366. /**
  95367. * Sets a float on a uniform variable.
  95368. * @param uniformName Name of the variable.
  95369. * @param value value to be set.
  95370. * @returns this effect.
  95371. */
  95372. setFloat(uniformName: string, value: number): Effect;
  95373. /**
  95374. * Sets a boolean on a uniform variable.
  95375. * @param uniformName Name of the variable.
  95376. * @param bool value to be set.
  95377. * @returns this effect.
  95378. */
  95379. setBool(uniformName: string, bool: boolean): Effect;
  95380. /**
  95381. * Sets a Vector2 on a uniform variable.
  95382. * @param uniformName Name of the variable.
  95383. * @param vector2 vector2 to be set.
  95384. * @returns this effect.
  95385. */
  95386. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  95387. /**
  95388. * Sets a float2 on a uniform variable.
  95389. * @param uniformName Name of the variable.
  95390. * @param x First float in float2.
  95391. * @param y Second float in float2.
  95392. * @returns this effect.
  95393. */
  95394. setFloat2(uniformName: string, x: number, y: number): Effect;
  95395. /**
  95396. * Sets a Vector3 on a uniform variable.
  95397. * @param uniformName Name of the variable.
  95398. * @param vector3 Value to be set.
  95399. * @returns this effect.
  95400. */
  95401. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  95402. /**
  95403. * Sets a float3 on a uniform variable.
  95404. * @param uniformName Name of the variable.
  95405. * @param x First float in float3.
  95406. * @param y Second float in float3.
  95407. * @param z Third float in float3.
  95408. * @returns this effect.
  95409. */
  95410. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  95411. /**
  95412. * Sets a Vector4 on a uniform variable.
  95413. * @param uniformName Name of the variable.
  95414. * @param vector4 Value to be set.
  95415. * @returns this effect.
  95416. */
  95417. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  95418. /**
  95419. * Sets a float4 on a uniform variable.
  95420. * @param uniformName Name of the variable.
  95421. * @param x First float in float4.
  95422. * @param y Second float in float4.
  95423. * @param z Third float in float4.
  95424. * @param w Fourth float in float4.
  95425. * @returns this effect.
  95426. */
  95427. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  95428. /**
  95429. * Sets a Color3 on a uniform variable.
  95430. * @param uniformName Name of the variable.
  95431. * @param color3 Value to be set.
  95432. * @returns this effect.
  95433. */
  95434. setColor3(uniformName: string, color3: IColor3Like): Effect;
  95435. /**
  95436. * Sets a Color4 on a uniform variable.
  95437. * @param uniformName Name of the variable.
  95438. * @param color3 Value to be set.
  95439. * @param alpha Alpha value to be set.
  95440. * @returns this effect.
  95441. */
  95442. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  95443. /**
  95444. * Sets a Color4 on a uniform variable
  95445. * @param uniformName defines the name of the variable
  95446. * @param color4 defines the value to be set
  95447. * @returns this effect.
  95448. */
  95449. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  95450. /** Release all associated resources */
  95451. dispose(): void;
  95452. /**
  95453. * This function will add a new shader to the shader store
  95454. * @param name the name of the shader
  95455. * @param pixelShader optional pixel shader content
  95456. * @param vertexShader optional vertex shader content
  95457. */
  95458. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  95459. /**
  95460. * Store of each shader (The can be looked up using effect.key)
  95461. */
  95462. static ShadersStore: {
  95463. [key: string]: string;
  95464. };
  95465. /**
  95466. * Store of each included file for a shader (The can be looked up using effect.key)
  95467. */
  95468. static IncludesShadersStore: {
  95469. [key: string]: string;
  95470. };
  95471. /**
  95472. * Resets the cache of effects.
  95473. */
  95474. static ResetCache(): void;
  95475. }
  95476. }
  95477. declare module BABYLON {
  95478. /**
  95479. * Class used to describe the capabilities of the engine relatively to the current browser
  95480. */
  95481. export class EngineCapabilities {
  95482. /** Maximum textures units per fragment shader */
  95483. maxTexturesImageUnits: number;
  95484. /** Maximum texture units per vertex shader */
  95485. maxVertexTextureImageUnits: number;
  95486. /** Maximum textures units in the entire pipeline */
  95487. maxCombinedTexturesImageUnits: number;
  95488. /** Maximum texture size */
  95489. maxTextureSize: number;
  95490. /** Maximum cube texture size */
  95491. maxCubemapTextureSize: number;
  95492. /** Maximum render texture size */
  95493. maxRenderTextureSize: number;
  95494. /** Maximum number of vertex attributes */
  95495. maxVertexAttribs: number;
  95496. /** Maximum number of varyings */
  95497. maxVaryingVectors: number;
  95498. /** Maximum number of uniforms per vertex shader */
  95499. maxVertexUniformVectors: number;
  95500. /** Maximum number of uniforms per fragment shader */
  95501. maxFragmentUniformVectors: number;
  95502. /** Defines if standard derivates (dx/dy) are supported */
  95503. standardDerivatives: boolean;
  95504. /** Defines if s3tc texture compression is supported */
  95505. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  95506. /** Defines if pvrtc texture compression is supported */
  95507. pvrtc: any;
  95508. /** Defines if etc1 texture compression is supported */
  95509. etc1: any;
  95510. /** Defines if etc2 texture compression is supported */
  95511. etc2: any;
  95512. /** Defines if astc texture compression is supported */
  95513. astc: any;
  95514. /** Defines if float textures are supported */
  95515. textureFloat: boolean;
  95516. /** Defines if vertex array objects are supported */
  95517. vertexArrayObject: boolean;
  95518. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  95519. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  95520. /** Gets the maximum level of anisotropy supported */
  95521. maxAnisotropy: number;
  95522. /** Defines if instancing is supported */
  95523. instancedArrays: boolean;
  95524. /** Defines if 32 bits indices are supported */
  95525. uintIndices: boolean;
  95526. /** Defines if high precision shaders are supported */
  95527. highPrecisionShaderSupported: boolean;
  95528. /** Defines if depth reading in the fragment shader is supported */
  95529. fragmentDepthSupported: boolean;
  95530. /** Defines if float texture linear filtering is supported*/
  95531. textureFloatLinearFiltering: boolean;
  95532. /** Defines if rendering to float textures is supported */
  95533. textureFloatRender: boolean;
  95534. /** Defines if half float textures are supported*/
  95535. textureHalfFloat: boolean;
  95536. /** Defines if half float texture linear filtering is supported*/
  95537. textureHalfFloatLinearFiltering: boolean;
  95538. /** Defines if rendering to half float textures is supported */
  95539. textureHalfFloatRender: boolean;
  95540. /** Defines if textureLOD shader command is supported */
  95541. textureLOD: boolean;
  95542. /** Defines if draw buffers extension is supported */
  95543. drawBuffersExtension: boolean;
  95544. /** Defines if depth textures are supported */
  95545. depthTextureExtension: boolean;
  95546. /** Defines if float color buffer are supported */
  95547. colorBufferFloat: boolean;
  95548. /** Gets disjoint timer query extension (null if not supported) */
  95549. timerQuery: EXT_disjoint_timer_query;
  95550. /** Defines if timestamp can be used with timer query */
  95551. canUseTimestampForTimerQuery: boolean;
  95552. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  95553. multiview: any;
  95554. /** Function used to let the system compiles shaders in background */
  95555. parallelShaderCompile: {
  95556. COMPLETION_STATUS_KHR: number;
  95557. };
  95558. /** Max number of texture samples for MSAA */
  95559. maxMSAASamples: number;
  95560. /** Defines if the blend min max extension is supported */
  95561. blendMinMax: boolean;
  95562. }
  95563. }
  95564. declare module BABYLON {
  95565. /**
  95566. * This class is used to track a performance counter which is number based.
  95567. * The user has access to many properties which give statistics of different nature.
  95568. *
  95569. * The implementer can track two kinds of Performance Counter: time and count.
  95570. * 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.
  95571. * 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.
  95572. */
  95573. export class PerfCounter {
  95574. /**
  95575. * Gets or sets a global boolean to turn on and off all the counters
  95576. */
  95577. static Enabled: boolean;
  95578. /**
  95579. * Returns the smallest value ever
  95580. */
  95581. readonly min: number;
  95582. /**
  95583. * Returns the biggest value ever
  95584. */
  95585. readonly max: number;
  95586. /**
  95587. * Returns the average value since the performance counter is running
  95588. */
  95589. readonly average: number;
  95590. /**
  95591. * Returns the average value of the last second the counter was monitored
  95592. */
  95593. readonly lastSecAverage: number;
  95594. /**
  95595. * Returns the current value
  95596. */
  95597. readonly current: number;
  95598. /**
  95599. * Gets the accumulated total
  95600. */
  95601. readonly total: number;
  95602. /**
  95603. * Gets the total value count
  95604. */
  95605. readonly count: number;
  95606. /**
  95607. * Creates a new counter
  95608. */
  95609. constructor();
  95610. /**
  95611. * Call this method to start monitoring a new frame.
  95612. * 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.
  95613. */
  95614. fetchNewFrame(): void;
  95615. /**
  95616. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  95617. * @param newCount the count value to add to the monitored count
  95618. * @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.
  95619. */
  95620. addCount(newCount: number, fetchResult: boolean): void;
  95621. /**
  95622. * Start monitoring this performance counter
  95623. */
  95624. beginMonitoring(): void;
  95625. /**
  95626. * Compute the time lapsed since the previous beginMonitoring() call.
  95627. * @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
  95628. */
  95629. endMonitoring(newFrame?: boolean): void;
  95630. private _fetchResult;
  95631. private _startMonitoringTime;
  95632. private _min;
  95633. private _max;
  95634. private _average;
  95635. private _current;
  95636. private _totalValueCount;
  95637. private _totalAccumulated;
  95638. private _lastSecAverage;
  95639. private _lastSecAccumulated;
  95640. private _lastSecTime;
  95641. private _lastSecValueCount;
  95642. }
  95643. }
  95644. declare module BABYLON {
  95645. /**
  95646. * @hidden
  95647. **/
  95648. export class DepthCullingState {
  95649. private _isDepthTestDirty;
  95650. private _isDepthMaskDirty;
  95651. private _isDepthFuncDirty;
  95652. private _isCullFaceDirty;
  95653. private _isCullDirty;
  95654. private _isZOffsetDirty;
  95655. private _isFrontFaceDirty;
  95656. private _depthTest;
  95657. private _depthMask;
  95658. private _depthFunc;
  95659. private _cull;
  95660. private _cullFace;
  95661. private _zOffset;
  95662. private _frontFace;
  95663. /**
  95664. * Initializes the state.
  95665. */
  95666. constructor();
  95667. readonly isDirty: boolean;
  95668. zOffset: number;
  95669. cullFace: Nullable<number>;
  95670. cull: Nullable<boolean>;
  95671. depthFunc: Nullable<number>;
  95672. depthMask: boolean;
  95673. depthTest: boolean;
  95674. frontFace: Nullable<number>;
  95675. reset(): void;
  95676. apply(gl: WebGLRenderingContext): void;
  95677. }
  95678. }
  95679. declare module BABYLON {
  95680. /**
  95681. * @hidden
  95682. **/
  95683. export class StencilState {
  95684. /** 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 */
  95685. static readonly ALWAYS: number;
  95686. /** Passed to stencilOperation to specify that stencil value must be kept */
  95687. static readonly KEEP: number;
  95688. /** Passed to stencilOperation to specify that stencil value must be replaced */
  95689. static readonly REPLACE: number;
  95690. private _isStencilTestDirty;
  95691. private _isStencilMaskDirty;
  95692. private _isStencilFuncDirty;
  95693. private _isStencilOpDirty;
  95694. private _stencilTest;
  95695. private _stencilMask;
  95696. private _stencilFunc;
  95697. private _stencilFuncRef;
  95698. private _stencilFuncMask;
  95699. private _stencilOpStencilFail;
  95700. private _stencilOpDepthFail;
  95701. private _stencilOpStencilDepthPass;
  95702. readonly isDirty: boolean;
  95703. stencilFunc: number;
  95704. stencilFuncRef: number;
  95705. stencilFuncMask: number;
  95706. stencilOpStencilFail: number;
  95707. stencilOpDepthFail: number;
  95708. stencilOpStencilDepthPass: number;
  95709. stencilMask: number;
  95710. stencilTest: boolean;
  95711. constructor();
  95712. reset(): void;
  95713. apply(gl: WebGLRenderingContext): void;
  95714. }
  95715. }
  95716. declare module BABYLON {
  95717. /**
  95718. * @hidden
  95719. **/
  95720. export class AlphaState {
  95721. private _isAlphaBlendDirty;
  95722. private _isBlendFunctionParametersDirty;
  95723. private _isBlendEquationParametersDirty;
  95724. private _isBlendConstantsDirty;
  95725. private _alphaBlend;
  95726. private _blendFunctionParameters;
  95727. private _blendEquationParameters;
  95728. private _blendConstants;
  95729. /**
  95730. * Initializes the state.
  95731. */
  95732. constructor();
  95733. readonly isDirty: boolean;
  95734. alphaBlend: boolean;
  95735. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  95736. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  95737. setAlphaEquationParameters(rgb: number, alpha: number): void;
  95738. reset(): void;
  95739. apply(gl: WebGLRenderingContext): void;
  95740. }
  95741. }
  95742. declare module BABYLON {
  95743. /** @hidden */
  95744. export class WebGL2ShaderProcessor implements IShaderProcessor {
  95745. attributeProcessor(attribute: string): string;
  95746. varyingProcessor(varying: string, isFragment: boolean): string;
  95747. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  95748. }
  95749. }
  95750. declare module BABYLON {
  95751. /**
  95752. * Interface for attribute information associated with buffer instanciation
  95753. */
  95754. export class InstancingAttributeInfo {
  95755. /**
  95756. * Index/offset of the attribute in the vertex shader
  95757. */
  95758. index: number;
  95759. /**
  95760. * size of the attribute, 1, 2, 3 or 4
  95761. */
  95762. attributeSize: number;
  95763. /**
  95764. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  95765. * default is FLOAT
  95766. */
  95767. attribyteType: number;
  95768. /**
  95769. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  95770. */
  95771. normalized: boolean;
  95772. /**
  95773. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  95774. */
  95775. offset: number;
  95776. /**
  95777. * Name of the GLSL attribute, for debugging purpose only
  95778. */
  95779. attributeName: string;
  95780. }
  95781. }
  95782. declare module BABYLON {
  95783. interface ThinEngine {
  95784. /**
  95785. * Update a video texture
  95786. * @param texture defines the texture to update
  95787. * @param video defines the video element to use
  95788. * @param invertY defines if data must be stored with Y axis inverted
  95789. */
  95790. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  95791. }
  95792. }
  95793. declare module BABYLON {
  95794. /**
  95795. * Settings for finer control over video usage
  95796. */
  95797. export interface VideoTextureSettings {
  95798. /**
  95799. * Applies `autoplay` to video, if specified
  95800. */
  95801. autoPlay?: boolean;
  95802. /**
  95803. * Applies `loop` to video, if specified
  95804. */
  95805. loop?: boolean;
  95806. /**
  95807. * Automatically updates internal texture from video at every frame in the render loop
  95808. */
  95809. autoUpdateTexture: boolean;
  95810. /**
  95811. * Image src displayed during the video loading or until the user interacts with the video.
  95812. */
  95813. poster?: string;
  95814. }
  95815. /**
  95816. * If you want to display a video in your scene, this is the special texture for that.
  95817. * This special texture works similar to other textures, with the exception of a few parameters.
  95818. * @see https://doc.babylonjs.com/how_to/video_texture
  95819. */
  95820. export class VideoTexture extends Texture {
  95821. /**
  95822. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  95823. */
  95824. readonly autoUpdateTexture: boolean;
  95825. /**
  95826. * The video instance used by the texture internally
  95827. */
  95828. readonly video: HTMLVideoElement;
  95829. private _onUserActionRequestedObservable;
  95830. /**
  95831. * Event triggerd when a dom action is required by the user to play the video.
  95832. * This happens due to recent changes in browser policies preventing video to auto start.
  95833. */
  95834. readonly onUserActionRequestedObservable: Observable<Texture>;
  95835. private _generateMipMaps;
  95836. private _engine;
  95837. private _stillImageCaptured;
  95838. private _displayingPosterTexture;
  95839. private _settings;
  95840. private _createInternalTextureOnEvent;
  95841. private _frameId;
  95842. /**
  95843. * Creates a video texture.
  95844. * If you want to display a video in your scene, this is the special texture for that.
  95845. * This special texture works similar to other textures, with the exception of a few parameters.
  95846. * @see https://doc.babylonjs.com/how_to/video_texture
  95847. * @param name optional name, will detect from video source, if not defined
  95848. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  95849. * @param scene is obviously the current scene.
  95850. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  95851. * @param invertY is false by default but can be used to invert video on Y axis
  95852. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  95853. * @param settings allows finer control over video usage
  95854. */
  95855. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  95856. private _getName;
  95857. private _getVideo;
  95858. private _createInternalTexture;
  95859. private reset;
  95860. /**
  95861. * @hidden Internal method to initiate `update`.
  95862. */
  95863. _rebuild(): void;
  95864. /**
  95865. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  95866. */
  95867. update(): void;
  95868. /**
  95869. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  95870. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  95871. */
  95872. updateTexture(isVisible: boolean): void;
  95873. protected _updateInternalTexture: () => void;
  95874. /**
  95875. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  95876. * @param url New url.
  95877. */
  95878. updateURL(url: string): void;
  95879. /**
  95880. * Dispose the texture and release its associated resources.
  95881. */
  95882. dispose(): void;
  95883. /**
  95884. * Creates a video texture straight from a stream.
  95885. * @param scene Define the scene the texture should be created in
  95886. * @param stream Define the stream the texture should be created from
  95887. * @returns The created video texture as a promise
  95888. */
  95889. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  95890. /**
  95891. * Creates a video texture straight from your WebCam video feed.
  95892. * @param scene Define the scene the texture should be created in
  95893. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  95894. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  95895. * @returns The created video texture as a promise
  95896. */
  95897. static CreateFromWebCamAsync(scene: Scene, constraints: {
  95898. minWidth: number;
  95899. maxWidth: number;
  95900. minHeight: number;
  95901. maxHeight: number;
  95902. deviceId: string;
  95903. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  95904. /**
  95905. * Creates a video texture straight from your WebCam video feed.
  95906. * @param scene Define the scene the texture should be created in
  95907. * @param onReady Define a callback to triggered once the texture will be ready
  95908. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  95909. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  95910. */
  95911. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  95912. minWidth: number;
  95913. maxWidth: number;
  95914. minHeight: number;
  95915. maxHeight: number;
  95916. deviceId: string;
  95917. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  95918. }
  95919. }
  95920. declare module BABYLON {
  95921. /**
  95922. * Defines the interface used by objects working like Scene
  95923. * @hidden
  95924. */
  95925. interface ISceneLike {
  95926. _addPendingData(data: any): void;
  95927. _removePendingData(data: any): void;
  95928. offlineProvider: IOfflineProvider;
  95929. }
  95930. /** Interface defining initialization parameters for Engine class */
  95931. export interface EngineOptions extends WebGLContextAttributes {
  95932. /**
  95933. * Defines if the engine should no exceed a specified device ratio
  95934. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  95935. */
  95936. limitDeviceRatio?: number;
  95937. /**
  95938. * Defines if webvr should be enabled automatically
  95939. * @see http://doc.babylonjs.com/how_to/webvr_camera
  95940. */
  95941. autoEnableWebVR?: boolean;
  95942. /**
  95943. * Defines if webgl2 should be turned off even if supported
  95944. * @see http://doc.babylonjs.com/features/webgl2
  95945. */
  95946. disableWebGL2Support?: boolean;
  95947. /**
  95948. * Defines if webaudio should be initialized as well
  95949. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  95950. */
  95951. audioEngine?: boolean;
  95952. /**
  95953. * Defines if animations should run using a deterministic lock step
  95954. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95955. */
  95956. deterministicLockstep?: boolean;
  95957. /** Defines the maximum steps to use with deterministic lock step mode */
  95958. lockstepMaxSteps?: number;
  95959. /**
  95960. * Defines that engine should ignore context lost events
  95961. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  95962. */
  95963. doNotHandleContextLost?: boolean;
  95964. /**
  95965. * Defines that engine should ignore modifying touch action attribute and style
  95966. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  95967. */
  95968. doNotHandleTouchAction?: boolean;
  95969. /**
  95970. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  95971. */
  95972. useHighPrecisionFloats?: boolean;
  95973. }
  95974. /**
  95975. * The base engine class (root of all engines)
  95976. */
  95977. export class ThinEngine {
  95978. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  95979. static ExceptionList: ({
  95980. key: string;
  95981. capture: string;
  95982. captureConstraint: number;
  95983. targets: string[];
  95984. } | {
  95985. key: string;
  95986. capture: null;
  95987. captureConstraint: null;
  95988. targets: string[];
  95989. })[];
  95990. /** @hidden */
  95991. static _TextureLoaders: IInternalTextureLoader[];
  95992. /**
  95993. * Returns the current npm package of the sdk
  95994. */
  95995. static readonly NpmPackage: string;
  95996. /**
  95997. * Returns the current version of the framework
  95998. */
  95999. static readonly Version: string;
  96000. /**
  96001. * Returns a string describing the current engine
  96002. */
  96003. readonly description: string;
  96004. /**
  96005. * Gets or sets the epsilon value used by collision engine
  96006. */
  96007. static CollisionsEpsilon: number;
  96008. /**
  96009. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  96010. */
  96011. static ShadersRepository: string;
  96012. /** @hidden */
  96013. _shaderProcessor: IShaderProcessor;
  96014. /**
  96015. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  96016. */
  96017. forcePOTTextures: boolean;
  96018. /**
  96019. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  96020. */
  96021. isFullscreen: boolean;
  96022. /**
  96023. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  96024. */
  96025. cullBackFaces: boolean;
  96026. /**
  96027. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  96028. */
  96029. renderEvenInBackground: boolean;
  96030. /**
  96031. * Gets or sets a boolean indicating that cache can be kept between frames
  96032. */
  96033. preventCacheWipeBetweenFrames: boolean;
  96034. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  96035. validateShaderPrograms: boolean;
  96036. /**
  96037. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  96038. */
  96039. disableUniformBuffers: boolean;
  96040. /** @hidden */
  96041. _uniformBuffers: UniformBuffer[];
  96042. /**
  96043. * Gets a boolean indicating that the engine supports uniform buffers
  96044. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  96045. */
  96046. readonly supportsUniformBuffers: boolean;
  96047. /** @hidden */
  96048. _gl: WebGLRenderingContext;
  96049. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  96050. protected _windowIsBackground: boolean;
  96051. protected _webGLVersion: number;
  96052. protected _highPrecisionShadersAllowed: boolean;
  96053. /** @hidden */
  96054. readonly _shouldUseHighPrecisionShader: boolean;
  96055. /**
  96056. * Gets a boolean indicating that only power of 2 textures are supported
  96057. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  96058. */
  96059. readonly needPOTTextures: boolean;
  96060. /** @hidden */
  96061. _badOS: boolean;
  96062. /** @hidden */
  96063. _badDesktopOS: boolean;
  96064. private _hardwareScalingLevel;
  96065. /** @hidden */
  96066. _caps: EngineCapabilities;
  96067. private _isStencilEnable;
  96068. protected _colorWrite: boolean;
  96069. /** @hidden */
  96070. _drawCalls: PerfCounter;
  96071. private _glVersion;
  96072. private _glRenderer;
  96073. private _glVendor;
  96074. /** @hidden */
  96075. _videoTextureSupported: boolean;
  96076. protected _renderingQueueLaunched: boolean;
  96077. protected _activeRenderLoops: (() => void)[];
  96078. /**
  96079. * Observable signaled when a context lost event is raised
  96080. */
  96081. onContextLostObservable: Observable<ThinEngine>;
  96082. /**
  96083. * Observable signaled when a context restored event is raised
  96084. */
  96085. onContextRestoredObservable: Observable<ThinEngine>;
  96086. private _onContextLost;
  96087. private _onContextRestored;
  96088. protected _contextWasLost: boolean;
  96089. /** @hidden */
  96090. _doNotHandleContextLost: boolean;
  96091. /**
  96092. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  96093. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  96094. */
  96095. doNotHandleContextLost: boolean;
  96096. /**
  96097. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  96098. */
  96099. disableVertexArrayObjects: boolean;
  96100. /** @hidden */
  96101. protected _depthCullingState: DepthCullingState;
  96102. /** @hidden */
  96103. protected _stencilState: StencilState;
  96104. /** @hidden */
  96105. protected _alphaState: AlphaState;
  96106. /** @hidden */
  96107. _internalTexturesCache: InternalTexture[];
  96108. /** @hidden */
  96109. protected _activeChannel: number;
  96110. private _currentTextureChannel;
  96111. /** @hidden */
  96112. protected _boundTexturesCache: {
  96113. [key: string]: Nullable<InternalTexture>;
  96114. };
  96115. /** @hidden */
  96116. protected _currentEffect: Nullable<Effect>;
  96117. /** @hidden */
  96118. protected _currentProgram: Nullable<WebGLProgram>;
  96119. private _compiledEffects;
  96120. private _vertexAttribArraysEnabled;
  96121. /** @hidden */
  96122. protected _cachedViewport: Nullable<IViewportLike>;
  96123. private _cachedVertexArrayObject;
  96124. /** @hidden */
  96125. protected _cachedVertexBuffers: any;
  96126. /** @hidden */
  96127. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  96128. /** @hidden */
  96129. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  96130. /** @hidden */
  96131. _currentRenderTarget: Nullable<InternalTexture>;
  96132. private _uintIndicesCurrentlySet;
  96133. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  96134. /** @hidden */
  96135. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  96136. private _currentBufferPointers;
  96137. private _currentInstanceLocations;
  96138. private _currentInstanceBuffers;
  96139. private _textureUnits;
  96140. /** @hidden */
  96141. _workingCanvas: Nullable<HTMLCanvasElement>;
  96142. /** @hidden */
  96143. _workingContext: Nullable<CanvasRenderingContext2D>;
  96144. /** @hidden */
  96145. _bindedRenderFunction: any;
  96146. private _vaoRecordInProgress;
  96147. private _mustWipeVertexAttributes;
  96148. private _emptyTexture;
  96149. private _emptyCubeTexture;
  96150. private _emptyTexture3D;
  96151. /** @hidden */
  96152. _frameHandler: number;
  96153. private _nextFreeTextureSlots;
  96154. private _maxSimultaneousTextures;
  96155. private _activeRequests;
  96156. protected _texturesSupported: string[];
  96157. /** @hidden */
  96158. _textureFormatInUse: Nullable<string>;
  96159. protected readonly _supportsHardwareTextureRescaling: boolean;
  96160. /**
  96161. * Gets the list of texture formats supported
  96162. */
  96163. readonly texturesSupported: Array<string>;
  96164. /**
  96165. * Gets the list of texture formats in use
  96166. */
  96167. readonly textureFormatInUse: Nullable<string>;
  96168. /**
  96169. * Gets the current viewport
  96170. */
  96171. readonly currentViewport: Nullable<IViewportLike>;
  96172. /**
  96173. * Gets the default empty texture
  96174. */
  96175. readonly emptyTexture: InternalTexture;
  96176. /**
  96177. * Gets the default empty 3D texture
  96178. */
  96179. readonly emptyTexture3D: InternalTexture;
  96180. /**
  96181. * Gets the default empty cube texture
  96182. */
  96183. readonly emptyCubeTexture: InternalTexture;
  96184. /**
  96185. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  96186. */
  96187. readonly premultipliedAlpha: boolean;
  96188. /**
  96189. * Creates a new engine
  96190. * @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
  96191. * @param antialias defines enable antialiasing (default: false)
  96192. * @param options defines further options to be sent to the getContext() function
  96193. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  96194. */
  96195. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  96196. private _rebuildInternalTextures;
  96197. private _rebuildEffects;
  96198. /**
  96199. * Gets a boolean indicating if all created effects are ready
  96200. * @returns true if all effects are ready
  96201. */
  96202. areAllEffectsReady(): boolean;
  96203. protected _rebuildBuffers(): void;
  96204. private _initGLContext;
  96205. /**
  96206. * Gets version of the current webGL context
  96207. */
  96208. readonly webGLVersion: number;
  96209. /**
  96210. * Gets a string idenfifying the name of the class
  96211. * @returns "Engine" string
  96212. */
  96213. getClassName(): string;
  96214. /**
  96215. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  96216. */
  96217. readonly isStencilEnable: boolean;
  96218. /** @hidden */
  96219. _prepareWorkingCanvas(): void;
  96220. /**
  96221. * Reset the texture cache to empty state
  96222. */
  96223. resetTextureCache(): void;
  96224. /**
  96225. * Gets an object containing information about the current webGL context
  96226. * @returns an object containing the vender, the renderer and the version of the current webGL context
  96227. */
  96228. getGlInfo(): {
  96229. vendor: string;
  96230. renderer: string;
  96231. version: string;
  96232. };
  96233. /**
  96234. * Defines the hardware scaling level.
  96235. * By default the hardware scaling level is computed from the window device ratio.
  96236. * 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.
  96237. * @param level defines the level to use
  96238. */
  96239. setHardwareScalingLevel(level: number): void;
  96240. /**
  96241. * Gets the current hardware scaling level.
  96242. * By default the hardware scaling level is computed from the window device ratio.
  96243. * 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.
  96244. * @returns a number indicating the current hardware scaling level
  96245. */
  96246. getHardwareScalingLevel(): number;
  96247. /**
  96248. * Gets the list of loaded textures
  96249. * @returns an array containing all loaded textures
  96250. */
  96251. getLoadedTexturesCache(): InternalTexture[];
  96252. /**
  96253. * Gets the object containing all engine capabilities
  96254. * @returns the EngineCapabilities object
  96255. */
  96256. getCaps(): EngineCapabilities;
  96257. /**
  96258. * stop executing a render loop function and remove it from the execution array
  96259. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  96260. */
  96261. stopRenderLoop(renderFunction?: () => void): void;
  96262. /** @hidden */
  96263. _renderLoop(): void;
  96264. /**
  96265. * Gets the HTML canvas attached with the current webGL context
  96266. * @returns a HTML canvas
  96267. */
  96268. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  96269. /**
  96270. * Gets host window
  96271. * @returns the host window object
  96272. */
  96273. getHostWindow(): Window;
  96274. /**
  96275. * Gets the current render width
  96276. * @param useScreen defines if screen size must be used (or the current render target if any)
  96277. * @returns a number defining the current render width
  96278. */
  96279. getRenderWidth(useScreen?: boolean): number;
  96280. /**
  96281. * Gets the current render height
  96282. * @param useScreen defines if screen size must be used (or the current render target if any)
  96283. * @returns a number defining the current render height
  96284. */
  96285. getRenderHeight(useScreen?: boolean): number;
  96286. /**
  96287. * Can be used to override the current requestAnimationFrame requester.
  96288. * @hidden
  96289. */
  96290. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  96291. /**
  96292. * Register and execute a render loop. The engine can have more than one render function
  96293. * @param renderFunction defines the function to continuously execute
  96294. */
  96295. runRenderLoop(renderFunction: () => void): void;
  96296. /**
  96297. * Clear the current render buffer or the current render target (if any is set up)
  96298. * @param color defines the color to use
  96299. * @param backBuffer defines if the back buffer must be cleared
  96300. * @param depth defines if the depth buffer must be cleared
  96301. * @param stencil defines if the stencil buffer must be cleared
  96302. */
  96303. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  96304. private _viewportCached;
  96305. /** @hidden */
  96306. _viewport(x: number, y: number, width: number, height: number): void;
  96307. /**
  96308. * Set the WebGL's viewport
  96309. * @param viewport defines the viewport element to be used
  96310. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  96311. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  96312. */
  96313. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  96314. /**
  96315. * Begin a new frame
  96316. */
  96317. beginFrame(): void;
  96318. /**
  96319. * Enf the current frame
  96320. */
  96321. endFrame(): void;
  96322. /**
  96323. * Resize the view according to the canvas' size
  96324. */
  96325. resize(): void;
  96326. /**
  96327. * Force a specific size of the canvas
  96328. * @param width defines the new canvas' width
  96329. * @param height defines the new canvas' height
  96330. */
  96331. setSize(width: number, height: number): void;
  96332. /**
  96333. * Binds the frame buffer to the specified texture.
  96334. * @param texture The texture to render to or null for the default canvas
  96335. * @param faceIndex The face of the texture to render to in case of cube texture
  96336. * @param requiredWidth The width of the target to render to
  96337. * @param requiredHeight The height of the target to render to
  96338. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  96339. * @param depthStencilTexture The depth stencil texture to use to render
  96340. * @param lodLevel defines le lod level to bind to the frame buffer
  96341. */
  96342. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  96343. /** @hidden */
  96344. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  96345. /**
  96346. * Unbind the current render target texture from the webGL context
  96347. * @param texture defines the render target texture to unbind
  96348. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  96349. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  96350. */
  96351. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  96352. /**
  96353. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  96354. */
  96355. flushFramebuffer(): void;
  96356. /**
  96357. * Unbind the current render target and bind the default framebuffer
  96358. */
  96359. restoreDefaultFramebuffer(): void;
  96360. private _resetVertexBufferBinding;
  96361. /**
  96362. * Creates a vertex buffer
  96363. * @param data the data for the vertex buffer
  96364. * @returns the new WebGL static buffer
  96365. */
  96366. createVertexBuffer(data: DataArray): DataBuffer;
  96367. private _createVertexBuffer;
  96368. /**
  96369. * Creates a dynamic vertex buffer
  96370. * @param data the data for the dynamic vertex buffer
  96371. * @returns the new WebGL dynamic buffer
  96372. */
  96373. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  96374. /**
  96375. * Updates a dynamic vertex buffer.
  96376. * @param vertexBuffer the vertex buffer to update
  96377. * @param data the data used to update the vertex buffer
  96378. * @param byteOffset the byte offset of the data
  96379. * @param byteLength the byte length of the data
  96380. */
  96381. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  96382. protected _resetIndexBufferBinding(): void;
  96383. /**
  96384. * Creates a new index buffer
  96385. * @param indices defines the content of the index buffer
  96386. * @param updatable defines if the index buffer must be updatable
  96387. * @returns a new webGL buffer
  96388. */
  96389. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  96390. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  96391. /**
  96392. * Bind a webGL buffer to the webGL context
  96393. * @param buffer defines the buffer to bind
  96394. */
  96395. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  96396. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  96397. private bindBuffer;
  96398. /**
  96399. * update the bound buffer with the given data
  96400. * @param data defines the data to update
  96401. */
  96402. updateArrayBuffer(data: Float32Array): void;
  96403. private _vertexAttribPointer;
  96404. private _bindIndexBufferWithCache;
  96405. private _bindVertexBuffersAttributes;
  96406. /**
  96407. * Records a vertex array object
  96408. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  96409. * @param vertexBuffers defines the list of vertex buffers to store
  96410. * @param indexBuffer defines the index buffer to store
  96411. * @param effect defines the effect to store
  96412. * @returns the new vertex array object
  96413. */
  96414. recordVertexArrayObject(vertexBuffers: {
  96415. [key: string]: VertexBuffer;
  96416. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  96417. /**
  96418. * Bind a specific vertex array object
  96419. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  96420. * @param vertexArrayObject defines the vertex array object to bind
  96421. * @param indexBuffer defines the index buffer to bind
  96422. */
  96423. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  96424. /**
  96425. * Bind webGl buffers directly to the webGL context
  96426. * @param vertexBuffer defines the vertex buffer to bind
  96427. * @param indexBuffer defines the index buffer to bind
  96428. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  96429. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  96430. * @param effect defines the effect associated with the vertex buffer
  96431. */
  96432. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  96433. private _unbindVertexArrayObject;
  96434. /**
  96435. * Bind a list of vertex buffers to the webGL context
  96436. * @param vertexBuffers defines the list of vertex buffers to bind
  96437. * @param indexBuffer defines the index buffer to bind
  96438. * @param effect defines the effect associated with the vertex buffers
  96439. */
  96440. bindBuffers(vertexBuffers: {
  96441. [key: string]: Nullable<VertexBuffer>;
  96442. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  96443. /**
  96444. * Unbind all instance attributes
  96445. */
  96446. unbindInstanceAttributes(): void;
  96447. /**
  96448. * Release and free the memory of a vertex array object
  96449. * @param vao defines the vertex array object to delete
  96450. */
  96451. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  96452. /** @hidden */
  96453. _releaseBuffer(buffer: DataBuffer): boolean;
  96454. protected _deleteBuffer(buffer: DataBuffer): void;
  96455. /**
  96456. * Creates a webGL buffer to use with instanciation
  96457. * @param capacity defines the size of the buffer
  96458. * @returns the webGL buffer
  96459. */
  96460. createInstancesBuffer(capacity: number): DataBuffer;
  96461. /**
  96462. * Delete a webGL buffer used with instanciation
  96463. * @param buffer defines the webGL buffer to delete
  96464. */
  96465. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  96466. /**
  96467. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  96468. * @param instancesBuffer defines the webGL buffer to update and bind
  96469. * @param data defines the data to store in the buffer
  96470. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  96471. */
  96472. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  96473. /**
  96474. * Apply all cached states (depth, culling, stencil and alpha)
  96475. */
  96476. applyStates(): void;
  96477. /**
  96478. * Send a draw order
  96479. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  96480. * @param indexStart defines the starting index
  96481. * @param indexCount defines the number of index to draw
  96482. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96483. */
  96484. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  96485. /**
  96486. * Draw a list of points
  96487. * @param verticesStart defines the index of first vertex to draw
  96488. * @param verticesCount defines the count of vertices to draw
  96489. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96490. */
  96491. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96492. /**
  96493. * Draw a list of unindexed primitives
  96494. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  96495. * @param verticesStart defines the index of first vertex to draw
  96496. * @param verticesCount defines the count of vertices to draw
  96497. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96498. */
  96499. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96500. /**
  96501. * Draw a list of indexed primitives
  96502. * @param fillMode defines the primitive to use
  96503. * @param indexStart defines the starting index
  96504. * @param indexCount defines the number of index to draw
  96505. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96506. */
  96507. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  96508. /**
  96509. * Draw a list of unindexed primitives
  96510. * @param fillMode defines the primitive to use
  96511. * @param verticesStart defines the index of first vertex to draw
  96512. * @param verticesCount defines the count of vertices to draw
  96513. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96514. */
  96515. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96516. private _drawMode;
  96517. /** @hidden */
  96518. _releaseEffect(effect: Effect): void;
  96519. /** @hidden */
  96520. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  96521. /**
  96522. * Create a new effect (used to store vertex/fragment shaders)
  96523. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  96524. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  96525. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  96526. * @param samplers defines an array of string used to represent textures
  96527. * @param defines defines the string containing the defines to use to compile the shaders
  96528. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  96529. * @param onCompiled defines a function to call when the effect creation is successful
  96530. * @param onError defines a function to call when the effect creation has failed
  96531. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  96532. * @returns the new Effect
  96533. */
  96534. 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;
  96535. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  96536. private _compileShader;
  96537. private _compileRawShader;
  96538. /**
  96539. * Directly creates a webGL program
  96540. * @param pipelineContext defines the pipeline context to attach to
  96541. * @param vertexCode defines the vertex shader code to use
  96542. * @param fragmentCode defines the fragment shader code to use
  96543. * @param context defines the webGL context to use (if not set, the current one will be used)
  96544. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  96545. * @returns the new webGL program
  96546. */
  96547. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  96548. /**
  96549. * Creates a webGL program
  96550. * @param pipelineContext defines the pipeline context to attach to
  96551. * @param vertexCode defines the vertex shader code to use
  96552. * @param fragmentCode defines the fragment shader code to use
  96553. * @param defines defines the string containing the defines to use to compile the shaders
  96554. * @param context defines the webGL context to use (if not set, the current one will be used)
  96555. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  96556. * @returns the new webGL program
  96557. */
  96558. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  96559. /**
  96560. * Creates a new pipeline context
  96561. * @returns the new pipeline
  96562. */
  96563. createPipelineContext(): IPipelineContext;
  96564. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  96565. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  96566. /** @hidden */
  96567. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  96568. /** @hidden */
  96569. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  96570. /** @hidden */
  96571. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  96572. /**
  96573. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  96574. * @param pipelineContext defines the pipeline context to use
  96575. * @param uniformsNames defines the list of uniform names
  96576. * @returns an array of webGL uniform locations
  96577. */
  96578. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  96579. /**
  96580. * Gets the lsit of active attributes for a given webGL program
  96581. * @param pipelineContext defines the pipeline context to use
  96582. * @param attributesNames defines the list of attribute names to get
  96583. * @returns an array of indices indicating the offset of each attribute
  96584. */
  96585. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  96586. /**
  96587. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  96588. * @param effect defines the effect to activate
  96589. */
  96590. enableEffect(effect: Nullable<Effect>): void;
  96591. /**
  96592. * Set the value of an uniform to an array of int32
  96593. * @param uniform defines the webGL uniform location where to store the value
  96594. * @param array defines the array of int32 to store
  96595. */
  96596. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96597. /**
  96598. * Set the value of an uniform to an array of int32 (stored as vec2)
  96599. * @param uniform defines the webGL uniform location where to store the value
  96600. * @param array defines the array of int32 to store
  96601. */
  96602. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96603. /**
  96604. * Set the value of an uniform to an array of int32 (stored as vec3)
  96605. * @param uniform defines the webGL uniform location where to store the value
  96606. * @param array defines the array of int32 to store
  96607. */
  96608. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96609. /**
  96610. * Set the value of an uniform to an array of int32 (stored as vec4)
  96611. * @param uniform defines the webGL uniform location where to store the value
  96612. * @param array defines the array of int32 to store
  96613. */
  96614. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96615. /**
  96616. * Set the value of an uniform to an array of float32
  96617. * @param uniform defines the webGL uniform location where to store the value
  96618. * @param array defines the array of float32 to store
  96619. */
  96620. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96621. /**
  96622. * Set the value of an uniform to an array of float32 (stored as vec2)
  96623. * @param uniform defines the webGL uniform location where to store the value
  96624. * @param array defines the array of float32 to store
  96625. */
  96626. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96627. /**
  96628. * Set the value of an uniform to an array of float32 (stored as vec3)
  96629. * @param uniform defines the webGL uniform location where to store the value
  96630. * @param array defines the array of float32 to store
  96631. */
  96632. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96633. /**
  96634. * Set the value of an uniform to an array of float32 (stored as vec4)
  96635. * @param uniform defines the webGL uniform location where to store the value
  96636. * @param array defines the array of float32 to store
  96637. */
  96638. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96639. /**
  96640. * Set the value of an uniform to an array of number
  96641. * @param uniform defines the webGL uniform location where to store the value
  96642. * @param array defines the array of number to store
  96643. */
  96644. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96645. /**
  96646. * Set the value of an uniform to an array of number (stored as vec2)
  96647. * @param uniform defines the webGL uniform location where to store the value
  96648. * @param array defines the array of number to store
  96649. */
  96650. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96651. /**
  96652. * Set the value of an uniform to an array of number (stored as vec3)
  96653. * @param uniform defines the webGL uniform location where to store the value
  96654. * @param array defines the array of number to store
  96655. */
  96656. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96657. /**
  96658. * Set the value of an uniform to an array of number (stored as vec4)
  96659. * @param uniform defines the webGL uniform location where to store the value
  96660. * @param array defines the array of number to store
  96661. */
  96662. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96663. /**
  96664. * Set the value of an uniform to an array of float32 (stored as matrices)
  96665. * @param uniform defines the webGL uniform location where to store the value
  96666. * @param matrices defines the array of float32 to store
  96667. */
  96668. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  96669. /**
  96670. * Set the value of an uniform to a matrix (3x3)
  96671. * @param uniform defines the webGL uniform location where to store the value
  96672. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  96673. */
  96674. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  96675. /**
  96676. * Set the value of an uniform to a matrix (2x2)
  96677. * @param uniform defines the webGL uniform location where to store the value
  96678. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  96679. */
  96680. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  96681. /**
  96682. * Set the value of an uniform to a number (int)
  96683. * @param uniform defines the webGL uniform location where to store the value
  96684. * @param value defines the int number to store
  96685. */
  96686. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  96687. /**
  96688. * Set the value of an uniform to a number (float)
  96689. * @param uniform defines the webGL uniform location where to store the value
  96690. * @param value defines the float number to store
  96691. */
  96692. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  96693. /**
  96694. * Set the value of an uniform to a vec2
  96695. * @param uniform defines the webGL uniform location where to store the value
  96696. * @param x defines the 1st component of the value
  96697. * @param y defines the 2nd component of the value
  96698. */
  96699. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  96700. /**
  96701. * Set the value of an uniform to a vec3
  96702. * @param uniform defines the webGL uniform location where to store the value
  96703. * @param x defines the 1st component of the value
  96704. * @param y defines the 2nd component of the value
  96705. * @param z defines the 3rd component of the value
  96706. */
  96707. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  96708. /**
  96709. * Set the value of an uniform to a boolean
  96710. * @param uniform defines the webGL uniform location where to store the value
  96711. * @param bool defines the boolean to store
  96712. */
  96713. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  96714. /**
  96715. * Set the value of an uniform to a vec4
  96716. * @param uniform defines the webGL uniform location where to store the value
  96717. * @param x defines the 1st component of the value
  96718. * @param y defines the 2nd component of the value
  96719. * @param z defines the 3rd component of the value
  96720. * @param w defines the 4th component of the value
  96721. */
  96722. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  96723. /**
  96724. * Sets a Color4 on a uniform variable
  96725. * @param uniform defines the uniform location
  96726. * @param color4 defines the value to be set
  96727. */
  96728. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  96729. /**
  96730. * Gets the depth culling state manager
  96731. */
  96732. readonly depthCullingState: DepthCullingState;
  96733. /**
  96734. * Gets the alpha state manager
  96735. */
  96736. readonly alphaState: AlphaState;
  96737. /**
  96738. * Gets the stencil state manager
  96739. */
  96740. readonly stencilState: StencilState;
  96741. /**
  96742. * Clears the list of texture accessible through engine.
  96743. * This can help preventing texture load conflict due to name collision.
  96744. */
  96745. clearInternalTexturesCache(): void;
  96746. /**
  96747. * Force the entire cache to be cleared
  96748. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  96749. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  96750. */
  96751. wipeCaches(bruteForce?: boolean): void;
  96752. /** @hidden */
  96753. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  96754. min: number;
  96755. mag: number;
  96756. };
  96757. /** @hidden */
  96758. _createTexture(): WebGLTexture;
  96759. /**
  96760. * Usually called from Texture.ts.
  96761. * Passed information to create a WebGLTexture
  96762. * @param urlArg defines a value which contains one of the following:
  96763. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  96764. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  96765. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  96766. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  96767. * @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)
  96768. * @param scene needed for loading to the correct scene
  96769. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  96770. * @param onLoad optional callback to be called upon successful completion
  96771. * @param onError optional callback to be called upon failure
  96772. * @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
  96773. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  96774. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  96775. * @param forcedExtension defines the extension to use to pick the right loader
  96776. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  96777. * @returns a InternalTexture for assignment back into BABYLON.Texture
  96778. */
  96779. 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;
  96780. /**
  96781. * @hidden
  96782. */
  96783. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  96784. /**
  96785. * Creates a raw texture
  96786. * @param data defines the data to store in the texture
  96787. * @param width defines the width of the texture
  96788. * @param height defines the height of the texture
  96789. * @param format defines the format of the data
  96790. * @param generateMipMaps defines if the engine should generate the mip levels
  96791. * @param invertY defines if data must be stored with Y axis inverted
  96792. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  96793. * @param compression defines the compression used (null by default)
  96794. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  96795. * @returns the raw texture inside an InternalTexture
  96796. */
  96797. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  96798. /**
  96799. * Creates a new raw cube texture
  96800. * @param data defines the array of data to use to create each face
  96801. * @param size defines the size of the textures
  96802. * @param format defines the format of the data
  96803. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  96804. * @param generateMipMaps defines if the engine should generate the mip levels
  96805. * @param invertY defines if data must be stored with Y axis inverted
  96806. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  96807. * @param compression defines the compression used (null by default)
  96808. * @returns the cube texture as an InternalTexture
  96809. */
  96810. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  96811. /**
  96812. * Creates a new raw 3D texture
  96813. * @param data defines the data used to create the texture
  96814. * @param width defines the width of the texture
  96815. * @param height defines the height of the texture
  96816. * @param depth defines the depth of the texture
  96817. * @param format defines the format of the texture
  96818. * @param generateMipMaps defines if the engine must generate mip levels
  96819. * @param invertY defines if data must be stored with Y axis inverted
  96820. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  96821. * @param compression defines the compressed used (can be null)
  96822. * @param textureType defines the compressed used (can be null)
  96823. * @returns a new raw 3D texture (stored in an InternalTexture)
  96824. */
  96825. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  96826. private _unpackFlipYCached;
  96827. /**
  96828. * In case you are sharing the context with other applications, it might
  96829. * be interested to not cache the unpack flip y state to ensure a consistent
  96830. * value would be set.
  96831. */
  96832. enableUnpackFlipYCached: boolean;
  96833. /** @hidden */
  96834. _unpackFlipY(value: boolean): void;
  96835. /** @hidden */
  96836. _getUnpackAlignement(): number;
  96837. /**
  96838. * Update the sampling mode of a given texture
  96839. * @param samplingMode defines the required sampling mode
  96840. * @param texture defines the texture to update
  96841. */
  96842. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  96843. /**
  96844. * Updates a depth texture Comparison Mode and Function.
  96845. * If the comparison Function is equal to 0, the mode will be set to none.
  96846. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  96847. * @param texture The texture to set the comparison function for
  96848. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  96849. */
  96850. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  96851. /** @hidden */
  96852. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  96853. width: number;
  96854. height: number;
  96855. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  96856. /**
  96857. * Creates a depth stencil texture.
  96858. * This is only available in WebGL 2 or with the depth texture extension available.
  96859. * @param size The size of face edge in the texture.
  96860. * @param options The options defining the texture.
  96861. * @returns The texture
  96862. */
  96863. createDepthStencilTexture(size: number | {
  96864. width: number;
  96865. height: number;
  96866. }, options: DepthTextureCreationOptions): InternalTexture;
  96867. /**
  96868. * Creates a depth stencil texture.
  96869. * This is only available in WebGL 2 or with the depth texture extension available.
  96870. * @param size The size of face edge in the texture.
  96871. * @param options The options defining the texture.
  96872. * @returns The texture
  96873. */
  96874. private _createDepthStencilTexture;
  96875. /** @hidden */
  96876. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  96877. /** @hidden */
  96878. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  96879. /** @hidden */
  96880. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  96881. /** @hidden */
  96882. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  96883. /**
  96884. * @hidden
  96885. */
  96886. _setCubeMapTextureParams(loadMipmap: boolean): void;
  96887. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  96888. private _prepareWebGLTexture;
  96889. /** @hidden */
  96890. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  96891. /** @hidden */
  96892. _releaseFramebufferObjects(texture: InternalTexture): void;
  96893. /** @hidden */
  96894. _releaseTexture(texture: InternalTexture): void;
  96895. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  96896. protected _setProgram(program: WebGLProgram): void;
  96897. protected _boundUniforms: {
  96898. [key: number]: WebGLUniformLocation;
  96899. };
  96900. /**
  96901. * Binds an effect to the webGL context
  96902. * @param effect defines the effect to bind
  96903. */
  96904. bindSamplers(effect: Effect): void;
  96905. private _activateCurrentTexture;
  96906. /** @hidden */
  96907. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  96908. /** @hidden */
  96909. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  96910. /**
  96911. * Unbind all textures from the webGL context
  96912. */
  96913. unbindAllTextures(): void;
  96914. /**
  96915. * Sets a texture to the according uniform.
  96916. * @param channel The texture channel
  96917. * @param uniform The uniform to set
  96918. * @param texture The texture to apply
  96919. */
  96920. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  96921. private _bindSamplerUniformToChannel;
  96922. private _getTextureWrapMode;
  96923. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  96924. /**
  96925. * Sets an array of texture to the webGL context
  96926. * @param channel defines the channel where the texture array must be set
  96927. * @param uniform defines the associated uniform location
  96928. * @param textures defines the array of textures to bind
  96929. */
  96930. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  96931. /** @hidden */
  96932. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  96933. private _setTextureParameterFloat;
  96934. private _setTextureParameterInteger;
  96935. /**
  96936. * Unbind all vertex attributes from the webGL context
  96937. */
  96938. unbindAllAttributes(): void;
  96939. /**
  96940. * 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
  96941. */
  96942. releaseEffects(): void;
  96943. /**
  96944. * Dispose and release all associated resources
  96945. */
  96946. dispose(): void;
  96947. /**
  96948. * Attach a new callback raised when context lost event is fired
  96949. * @param callback defines the callback to call
  96950. */
  96951. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  96952. /**
  96953. * Attach a new callback raised when context restored event is fired
  96954. * @param callback defines the callback to call
  96955. */
  96956. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  96957. /**
  96958. * Get the current error code of the webGL context
  96959. * @returns the error code
  96960. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  96961. */
  96962. getError(): number;
  96963. private _canRenderToFloatFramebuffer;
  96964. private _canRenderToHalfFloatFramebuffer;
  96965. private _canRenderToFramebuffer;
  96966. /** @hidden */
  96967. _getWebGLTextureType(type: number): number;
  96968. /** @hidden */
  96969. _getInternalFormat(format: number): number;
  96970. /** @hidden */
  96971. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  96972. /** @hidden */
  96973. _getRGBAMultiSampleBufferFormat(type: number): number;
  96974. /** @hidden */
  96975. _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;
  96976. /**
  96977. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  96978. * @returns true if the engine can be created
  96979. * @ignorenaming
  96980. */
  96981. static isSupported(): boolean;
  96982. /**
  96983. * Find the next highest power of two.
  96984. * @param x Number to start search from.
  96985. * @return Next highest power of two.
  96986. */
  96987. static CeilingPOT(x: number): number;
  96988. /**
  96989. * Find the next lowest power of two.
  96990. * @param x Number to start search from.
  96991. * @return Next lowest power of two.
  96992. */
  96993. static FloorPOT(x: number): number;
  96994. /**
  96995. * Find the nearest power of two.
  96996. * @param x Number to start search from.
  96997. * @return Next nearest power of two.
  96998. */
  96999. static NearestPOT(x: number): number;
  97000. /**
  97001. * Get the closest exponent of two
  97002. * @param value defines the value to approximate
  97003. * @param max defines the maximum value to return
  97004. * @param mode defines how to define the closest value
  97005. * @returns closest exponent of two of the given value
  97006. */
  97007. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  97008. /**
  97009. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  97010. * @param func - the function to be called
  97011. * @param requester - the object that will request the next frame. Falls back to window.
  97012. * @returns frame number
  97013. */
  97014. static QueueNewFrame(func: () => void, requester?: any): number;
  97015. }
  97016. }
  97017. declare module BABYLON {
  97018. /**
  97019. * Defines the source of the internal texture
  97020. */
  97021. export enum InternalTextureSource {
  97022. /**
  97023. * The source of the texture data is unknown
  97024. */
  97025. Unknown = 0,
  97026. /**
  97027. * Texture data comes from an URL
  97028. */
  97029. Url = 1,
  97030. /**
  97031. * Texture data is only used for temporary storage
  97032. */
  97033. Temp = 2,
  97034. /**
  97035. * Texture data comes from raw data (ArrayBuffer)
  97036. */
  97037. Raw = 3,
  97038. /**
  97039. * Texture content is dynamic (video or dynamic texture)
  97040. */
  97041. Dynamic = 4,
  97042. /**
  97043. * Texture content is generated by rendering to it
  97044. */
  97045. RenderTarget = 5,
  97046. /**
  97047. * Texture content is part of a multi render target process
  97048. */
  97049. MultiRenderTarget = 6,
  97050. /**
  97051. * Texture data comes from a cube data file
  97052. */
  97053. Cube = 7,
  97054. /**
  97055. * Texture data comes from a raw cube data
  97056. */
  97057. CubeRaw = 8,
  97058. /**
  97059. * Texture data come from a prefiltered cube data file
  97060. */
  97061. CubePrefiltered = 9,
  97062. /**
  97063. * Texture content is raw 3D data
  97064. */
  97065. Raw3D = 10,
  97066. /**
  97067. * Texture content is a depth texture
  97068. */
  97069. Depth = 11,
  97070. /**
  97071. * Texture data comes from a raw cube data encoded with RGBD
  97072. */
  97073. CubeRawRGBD = 12
  97074. }
  97075. /**
  97076. * Class used to store data associated with WebGL texture data for the engine
  97077. * This class should not be used directly
  97078. */
  97079. export class InternalTexture {
  97080. /** @hidden */
  97081. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  97082. /**
  97083. * Defines if the texture is ready
  97084. */
  97085. isReady: boolean;
  97086. /**
  97087. * Defines if the texture is a cube texture
  97088. */
  97089. isCube: boolean;
  97090. /**
  97091. * Defines if the texture contains 3D data
  97092. */
  97093. is3D: boolean;
  97094. /**
  97095. * Defines if the texture contains multiview data
  97096. */
  97097. isMultiview: boolean;
  97098. /**
  97099. * Gets the URL used to load this texture
  97100. */
  97101. url: string;
  97102. /**
  97103. * Gets the sampling mode of the texture
  97104. */
  97105. samplingMode: number;
  97106. /**
  97107. * Gets a boolean indicating if the texture needs mipmaps generation
  97108. */
  97109. generateMipMaps: boolean;
  97110. /**
  97111. * Gets the number of samples used by the texture (WebGL2+ only)
  97112. */
  97113. samples: number;
  97114. /**
  97115. * Gets the type of the texture (int, float...)
  97116. */
  97117. type: number;
  97118. /**
  97119. * Gets the format of the texture (RGB, RGBA...)
  97120. */
  97121. format: number;
  97122. /**
  97123. * Observable called when the texture is loaded
  97124. */
  97125. onLoadedObservable: Observable<InternalTexture>;
  97126. /**
  97127. * Gets the width of the texture
  97128. */
  97129. width: number;
  97130. /**
  97131. * Gets the height of the texture
  97132. */
  97133. height: number;
  97134. /**
  97135. * Gets the depth of the texture
  97136. */
  97137. depth: number;
  97138. /**
  97139. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  97140. */
  97141. baseWidth: number;
  97142. /**
  97143. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  97144. */
  97145. baseHeight: number;
  97146. /**
  97147. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  97148. */
  97149. baseDepth: number;
  97150. /**
  97151. * Gets a boolean indicating if the texture is inverted on Y axis
  97152. */
  97153. invertY: boolean;
  97154. /** @hidden */
  97155. _invertVScale: boolean;
  97156. /** @hidden */
  97157. _associatedChannel: number;
  97158. /** @hidden */
  97159. _source: InternalTextureSource;
  97160. /** @hidden */
  97161. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  97162. /** @hidden */
  97163. _bufferView: Nullable<ArrayBufferView>;
  97164. /** @hidden */
  97165. _bufferViewArray: Nullable<ArrayBufferView[]>;
  97166. /** @hidden */
  97167. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  97168. /** @hidden */
  97169. _size: number;
  97170. /** @hidden */
  97171. _extension: string;
  97172. /** @hidden */
  97173. _files: Nullable<string[]>;
  97174. /** @hidden */
  97175. _workingCanvas: Nullable<HTMLCanvasElement>;
  97176. /** @hidden */
  97177. _workingContext: Nullable<CanvasRenderingContext2D>;
  97178. /** @hidden */
  97179. _framebuffer: Nullable<WebGLFramebuffer>;
  97180. /** @hidden */
  97181. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  97182. /** @hidden */
  97183. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  97184. /** @hidden */
  97185. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  97186. /** @hidden */
  97187. _attachments: Nullable<number[]>;
  97188. /** @hidden */
  97189. _cachedCoordinatesMode: Nullable<number>;
  97190. /** @hidden */
  97191. _cachedWrapU: Nullable<number>;
  97192. /** @hidden */
  97193. _cachedWrapV: Nullable<number>;
  97194. /** @hidden */
  97195. _cachedWrapR: Nullable<number>;
  97196. /** @hidden */
  97197. _cachedAnisotropicFilteringLevel: Nullable<number>;
  97198. /** @hidden */
  97199. _isDisabled: boolean;
  97200. /** @hidden */
  97201. _compression: Nullable<string>;
  97202. /** @hidden */
  97203. _generateStencilBuffer: boolean;
  97204. /** @hidden */
  97205. _generateDepthBuffer: boolean;
  97206. /** @hidden */
  97207. _comparisonFunction: number;
  97208. /** @hidden */
  97209. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  97210. /** @hidden */
  97211. _lodGenerationScale: number;
  97212. /** @hidden */
  97213. _lodGenerationOffset: number;
  97214. /** @hidden */
  97215. _colorTextureArray: Nullable<WebGLTexture>;
  97216. /** @hidden */
  97217. _depthStencilTextureArray: Nullable<WebGLTexture>;
  97218. /** @hidden */
  97219. _lodTextureHigh: Nullable<BaseTexture>;
  97220. /** @hidden */
  97221. _lodTextureMid: Nullable<BaseTexture>;
  97222. /** @hidden */
  97223. _lodTextureLow: Nullable<BaseTexture>;
  97224. /** @hidden */
  97225. _isRGBD: boolean;
  97226. /** @hidden */
  97227. _linearSpecularLOD: boolean;
  97228. /** @hidden */
  97229. _irradianceTexture: Nullable<BaseTexture>;
  97230. /** @hidden */
  97231. _webGLTexture: Nullable<WebGLTexture>;
  97232. /** @hidden */
  97233. _references: number;
  97234. private _engine;
  97235. /**
  97236. * Gets the Engine the texture belongs to.
  97237. * @returns The babylon engine
  97238. */
  97239. getEngine(): ThinEngine;
  97240. /**
  97241. * Gets the data source type of the texture
  97242. */
  97243. readonly source: InternalTextureSource;
  97244. /**
  97245. * Creates a new InternalTexture
  97246. * @param engine defines the engine to use
  97247. * @param source defines the type of data that will be used
  97248. * @param delayAllocation if the texture allocation should be delayed (default: false)
  97249. */
  97250. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  97251. /**
  97252. * Increments the number of references (ie. the number of Texture that point to it)
  97253. */
  97254. incrementReferences(): void;
  97255. /**
  97256. * Change the size of the texture (not the size of the content)
  97257. * @param width defines the new width
  97258. * @param height defines the new height
  97259. * @param depth defines the new depth (1 by default)
  97260. */
  97261. updateSize(width: int, height: int, depth?: int): void;
  97262. /** @hidden */
  97263. _rebuild(): void;
  97264. /** @hidden */
  97265. _swapAndDie(target: InternalTexture): void;
  97266. /**
  97267. * Dispose the current allocated resources
  97268. */
  97269. dispose(): void;
  97270. }
  97271. }
  97272. declare module BABYLON {
  97273. /**
  97274. * Class used to work with sound analyzer using fast fourier transform (FFT)
  97275. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97276. */
  97277. export class Analyser {
  97278. /**
  97279. * Gets or sets the smoothing
  97280. * @ignorenaming
  97281. */
  97282. SMOOTHING: number;
  97283. /**
  97284. * Gets or sets the FFT table size
  97285. * @ignorenaming
  97286. */
  97287. FFT_SIZE: number;
  97288. /**
  97289. * Gets or sets the bar graph amplitude
  97290. * @ignorenaming
  97291. */
  97292. BARGRAPHAMPLITUDE: number;
  97293. /**
  97294. * Gets or sets the position of the debug canvas
  97295. * @ignorenaming
  97296. */
  97297. DEBUGCANVASPOS: {
  97298. x: number;
  97299. y: number;
  97300. };
  97301. /**
  97302. * Gets or sets the debug canvas size
  97303. * @ignorenaming
  97304. */
  97305. DEBUGCANVASSIZE: {
  97306. width: number;
  97307. height: number;
  97308. };
  97309. private _byteFreqs;
  97310. private _byteTime;
  97311. private _floatFreqs;
  97312. private _webAudioAnalyser;
  97313. private _debugCanvas;
  97314. private _debugCanvasContext;
  97315. private _scene;
  97316. private _registerFunc;
  97317. private _audioEngine;
  97318. /**
  97319. * Creates a new analyser
  97320. * @param scene defines hosting scene
  97321. */
  97322. constructor(scene: Scene);
  97323. /**
  97324. * Get the number of data values you will have to play with for the visualization
  97325. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  97326. * @returns a number
  97327. */
  97328. getFrequencyBinCount(): number;
  97329. /**
  97330. * Gets the current frequency data as a byte array
  97331. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  97332. * @returns a Uint8Array
  97333. */
  97334. getByteFrequencyData(): Uint8Array;
  97335. /**
  97336. * Gets the current waveform as a byte array
  97337. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  97338. * @returns a Uint8Array
  97339. */
  97340. getByteTimeDomainData(): Uint8Array;
  97341. /**
  97342. * Gets the current frequency data as a float array
  97343. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  97344. * @returns a Float32Array
  97345. */
  97346. getFloatFrequencyData(): Float32Array;
  97347. /**
  97348. * Renders the debug canvas
  97349. */
  97350. drawDebugCanvas(): void;
  97351. /**
  97352. * Stops rendering the debug canvas and removes it
  97353. */
  97354. stopDebugCanvas(): void;
  97355. /**
  97356. * Connects two audio nodes
  97357. * @param inputAudioNode defines first node to connect
  97358. * @param outputAudioNode defines second node to connect
  97359. */
  97360. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  97361. /**
  97362. * Releases all associated resources
  97363. */
  97364. dispose(): void;
  97365. }
  97366. }
  97367. declare module BABYLON {
  97368. /**
  97369. * This represents an audio engine and it is responsible
  97370. * to play, synchronize and analyse sounds throughout the application.
  97371. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97372. */
  97373. export interface IAudioEngine extends IDisposable {
  97374. /**
  97375. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  97376. */
  97377. readonly canUseWebAudio: boolean;
  97378. /**
  97379. * Gets the current AudioContext if available.
  97380. */
  97381. readonly audioContext: Nullable<AudioContext>;
  97382. /**
  97383. * The master gain node defines the global audio volume of your audio engine.
  97384. */
  97385. readonly masterGain: GainNode;
  97386. /**
  97387. * Gets whether or not mp3 are supported by your browser.
  97388. */
  97389. readonly isMP3supported: boolean;
  97390. /**
  97391. * Gets whether or not ogg are supported by your browser.
  97392. */
  97393. readonly isOGGsupported: boolean;
  97394. /**
  97395. * Defines if Babylon should emit a warning if WebAudio is not supported.
  97396. * @ignoreNaming
  97397. */
  97398. WarnedWebAudioUnsupported: boolean;
  97399. /**
  97400. * Defines if the audio engine relies on a custom unlocked button.
  97401. * In this case, the embedded button will not be displayed.
  97402. */
  97403. useCustomUnlockedButton: boolean;
  97404. /**
  97405. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  97406. */
  97407. readonly unlocked: boolean;
  97408. /**
  97409. * Event raised when audio has been unlocked on the browser.
  97410. */
  97411. onAudioUnlockedObservable: Observable<AudioEngine>;
  97412. /**
  97413. * Event raised when audio has been locked on the browser.
  97414. */
  97415. onAudioLockedObservable: Observable<AudioEngine>;
  97416. /**
  97417. * Flags the audio engine in Locked state.
  97418. * This happens due to new browser policies preventing audio to autoplay.
  97419. */
  97420. lock(): void;
  97421. /**
  97422. * Unlocks the audio engine once a user action has been done on the dom.
  97423. * This is helpful to resume play once browser policies have been satisfied.
  97424. */
  97425. unlock(): void;
  97426. }
  97427. /**
  97428. * This represents the default audio engine used in babylon.
  97429. * It is responsible to play, synchronize and analyse sounds throughout the application.
  97430. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97431. */
  97432. export class AudioEngine implements IAudioEngine {
  97433. private _audioContext;
  97434. private _audioContextInitialized;
  97435. private _muteButton;
  97436. private _hostElement;
  97437. /**
  97438. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  97439. */
  97440. canUseWebAudio: boolean;
  97441. /**
  97442. * The master gain node defines the global audio volume of your audio engine.
  97443. */
  97444. masterGain: GainNode;
  97445. /**
  97446. * Defines if Babylon should emit a warning if WebAudio is not supported.
  97447. * @ignoreNaming
  97448. */
  97449. WarnedWebAudioUnsupported: boolean;
  97450. /**
  97451. * Gets whether or not mp3 are supported by your browser.
  97452. */
  97453. isMP3supported: boolean;
  97454. /**
  97455. * Gets whether or not ogg are supported by your browser.
  97456. */
  97457. isOGGsupported: boolean;
  97458. /**
  97459. * Gets whether audio has been unlocked on the device.
  97460. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  97461. * a user interaction has happened.
  97462. */
  97463. unlocked: boolean;
  97464. /**
  97465. * Defines if the audio engine relies on a custom unlocked button.
  97466. * In this case, the embedded button will not be displayed.
  97467. */
  97468. useCustomUnlockedButton: boolean;
  97469. /**
  97470. * Event raised when audio has been unlocked on the browser.
  97471. */
  97472. onAudioUnlockedObservable: Observable<AudioEngine>;
  97473. /**
  97474. * Event raised when audio has been locked on the browser.
  97475. */
  97476. onAudioLockedObservable: Observable<AudioEngine>;
  97477. /**
  97478. * Gets the current AudioContext if available.
  97479. */
  97480. readonly audioContext: Nullable<AudioContext>;
  97481. private _connectedAnalyser;
  97482. /**
  97483. * Instantiates a new audio engine.
  97484. *
  97485. * There should be only one per page as some browsers restrict the number
  97486. * of audio contexts you can create.
  97487. * @param hostElement defines the host element where to display the mute icon if necessary
  97488. */
  97489. constructor(hostElement?: Nullable<HTMLElement>);
  97490. /**
  97491. * Flags the audio engine in Locked state.
  97492. * This happens due to new browser policies preventing audio to autoplay.
  97493. */
  97494. lock(): void;
  97495. /**
  97496. * Unlocks the audio engine once a user action has been done on the dom.
  97497. * This is helpful to resume play once browser policies have been satisfied.
  97498. */
  97499. unlock(): void;
  97500. private _resumeAudioContext;
  97501. private _initializeAudioContext;
  97502. private _tryToRun;
  97503. private _triggerRunningState;
  97504. private _triggerSuspendedState;
  97505. private _displayMuteButton;
  97506. private _moveButtonToTopLeft;
  97507. private _onResize;
  97508. private _hideMuteButton;
  97509. /**
  97510. * Destroy and release the resources associated with the audio ccontext.
  97511. */
  97512. dispose(): void;
  97513. /**
  97514. * Gets the global volume sets on the master gain.
  97515. * @returns the global volume if set or -1 otherwise
  97516. */
  97517. getGlobalVolume(): number;
  97518. /**
  97519. * Sets the global volume of your experience (sets on the master gain).
  97520. * @param newVolume Defines the new global volume of the application
  97521. */
  97522. setGlobalVolume(newVolume: number): void;
  97523. /**
  97524. * Connect the audio engine to an audio analyser allowing some amazing
  97525. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  97526. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  97527. * @param analyser The analyser to connect to the engine
  97528. */
  97529. connectToAnalyser(analyser: Analyser): void;
  97530. }
  97531. }
  97532. declare module BABYLON {
  97533. /**
  97534. * Interface used to present a loading screen while loading a scene
  97535. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97536. */
  97537. export interface ILoadingScreen {
  97538. /**
  97539. * Function called to display the loading screen
  97540. */
  97541. displayLoadingUI: () => void;
  97542. /**
  97543. * Function called to hide the loading screen
  97544. */
  97545. hideLoadingUI: () => void;
  97546. /**
  97547. * Gets or sets the color to use for the background
  97548. */
  97549. loadingUIBackgroundColor: string;
  97550. /**
  97551. * Gets or sets the text to display while loading
  97552. */
  97553. loadingUIText: string;
  97554. }
  97555. /**
  97556. * Class used for the default loading screen
  97557. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97558. */
  97559. export class DefaultLoadingScreen implements ILoadingScreen {
  97560. private _renderingCanvas;
  97561. private _loadingText;
  97562. private _loadingDivBackgroundColor;
  97563. private _loadingDiv;
  97564. private _loadingTextDiv;
  97565. /** Gets or sets the logo url to use for the default loading screen */
  97566. static DefaultLogoUrl: string;
  97567. /** Gets or sets the spinner url to use for the default loading screen */
  97568. static DefaultSpinnerUrl: string;
  97569. /**
  97570. * Creates a new default loading screen
  97571. * @param _renderingCanvas defines the canvas used to render the scene
  97572. * @param _loadingText defines the default text to display
  97573. * @param _loadingDivBackgroundColor defines the default background color
  97574. */
  97575. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  97576. /**
  97577. * Function called to display the loading screen
  97578. */
  97579. displayLoadingUI(): void;
  97580. /**
  97581. * Function called to hide the loading screen
  97582. */
  97583. hideLoadingUI(): void;
  97584. /**
  97585. * Gets or sets the text to display while loading
  97586. */
  97587. loadingUIText: string;
  97588. /**
  97589. * Gets or sets the color to use for the background
  97590. */
  97591. loadingUIBackgroundColor: string;
  97592. private _resizeLoadingUI;
  97593. }
  97594. }
  97595. declare module BABYLON {
  97596. /**
  97597. * Interface for any object that can request an animation frame
  97598. */
  97599. export interface ICustomAnimationFrameRequester {
  97600. /**
  97601. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  97602. */
  97603. renderFunction?: Function;
  97604. /**
  97605. * Called to request the next frame to render to
  97606. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  97607. */
  97608. requestAnimationFrame: Function;
  97609. /**
  97610. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  97611. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  97612. */
  97613. requestID?: number;
  97614. }
  97615. }
  97616. declare module BABYLON {
  97617. /**
  97618. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  97619. */
  97620. export class PerformanceMonitor {
  97621. private _enabled;
  97622. private _rollingFrameTime;
  97623. private _lastFrameTimeMs;
  97624. /**
  97625. * constructor
  97626. * @param frameSampleSize The number of samples required to saturate the sliding window
  97627. */
  97628. constructor(frameSampleSize?: number);
  97629. /**
  97630. * Samples current frame
  97631. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  97632. */
  97633. sampleFrame(timeMs?: number): void;
  97634. /**
  97635. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  97636. */
  97637. readonly averageFrameTime: number;
  97638. /**
  97639. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  97640. */
  97641. readonly averageFrameTimeVariance: number;
  97642. /**
  97643. * Returns the frame time of the most recent frame
  97644. */
  97645. readonly instantaneousFrameTime: number;
  97646. /**
  97647. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  97648. */
  97649. readonly averageFPS: number;
  97650. /**
  97651. * Returns the average framerate in frames per second using the most recent frame time
  97652. */
  97653. readonly instantaneousFPS: number;
  97654. /**
  97655. * Returns true if enough samples have been taken to completely fill the sliding window
  97656. */
  97657. readonly isSaturated: boolean;
  97658. /**
  97659. * Enables contributions to the sliding window sample set
  97660. */
  97661. enable(): void;
  97662. /**
  97663. * Disables contributions to the sliding window sample set
  97664. * Samples will not be interpolated over the disabled period
  97665. */
  97666. disable(): void;
  97667. /**
  97668. * Returns true if sampling is enabled
  97669. */
  97670. readonly isEnabled: boolean;
  97671. /**
  97672. * Resets performance monitor
  97673. */
  97674. reset(): void;
  97675. }
  97676. /**
  97677. * RollingAverage
  97678. *
  97679. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  97680. */
  97681. export class RollingAverage {
  97682. /**
  97683. * Current average
  97684. */
  97685. average: number;
  97686. /**
  97687. * Current variance
  97688. */
  97689. variance: number;
  97690. protected _samples: Array<number>;
  97691. protected _sampleCount: number;
  97692. protected _pos: number;
  97693. protected _m2: number;
  97694. /**
  97695. * constructor
  97696. * @param length The number of samples required to saturate the sliding window
  97697. */
  97698. constructor(length: number);
  97699. /**
  97700. * Adds a sample to the sample set
  97701. * @param v The sample value
  97702. */
  97703. add(v: number): void;
  97704. /**
  97705. * Returns previously added values or null if outside of history or outside the sliding window domain
  97706. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  97707. * @return Value previously recorded with add() or null if outside of range
  97708. */
  97709. history(i: number): number;
  97710. /**
  97711. * Returns true if enough samples have been taken to completely fill the sliding window
  97712. * @return true if sample-set saturated
  97713. */
  97714. isSaturated(): boolean;
  97715. /**
  97716. * Resets the rolling average (equivalent to 0 samples taken so far)
  97717. */
  97718. reset(): void;
  97719. /**
  97720. * Wraps a value around the sample range boundaries
  97721. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  97722. * @return Wrapped position in sample range
  97723. */
  97724. protected _wrapPosition(i: number): number;
  97725. }
  97726. }
  97727. declare module BABYLON {
  97728. /**
  97729. * Defines the interface used by display changed events
  97730. */
  97731. export interface IDisplayChangedEventArgs {
  97732. /** Gets the vrDisplay object (if any) */
  97733. vrDisplay: Nullable<any>;
  97734. /** Gets a boolean indicating if webVR is supported */
  97735. vrSupported: boolean;
  97736. }
  97737. /**
  97738. * Defines the interface used by objects containing a viewport (like a camera)
  97739. */
  97740. interface IViewportOwnerLike {
  97741. /**
  97742. * Gets or sets the viewport
  97743. */
  97744. viewport: IViewportLike;
  97745. }
  97746. /**
  97747. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  97748. */
  97749. export class Engine extends ThinEngine {
  97750. /** Defines that alpha blending is disabled */
  97751. static readonly ALPHA_DISABLE: number;
  97752. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  97753. static readonly ALPHA_ADD: number;
  97754. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  97755. static readonly ALPHA_COMBINE: number;
  97756. /** Defines that alpha blending to DEST - SRC * DEST */
  97757. static readonly ALPHA_SUBTRACT: number;
  97758. /** Defines that alpha blending to SRC * DEST */
  97759. static readonly ALPHA_MULTIPLY: number;
  97760. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  97761. static readonly ALPHA_MAXIMIZED: number;
  97762. /** Defines that alpha blending to SRC + DEST */
  97763. static readonly ALPHA_ONEONE: number;
  97764. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  97765. static readonly ALPHA_PREMULTIPLIED: number;
  97766. /**
  97767. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  97768. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  97769. */
  97770. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  97771. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  97772. static readonly ALPHA_INTERPOLATE: number;
  97773. /**
  97774. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  97775. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  97776. */
  97777. static readonly ALPHA_SCREENMODE: number;
  97778. /** Defines that the ressource is not delayed*/
  97779. static readonly DELAYLOADSTATE_NONE: number;
  97780. /** Defines that the ressource was successfully delay loaded */
  97781. static readonly DELAYLOADSTATE_LOADED: number;
  97782. /** Defines that the ressource is currently delay loading */
  97783. static readonly DELAYLOADSTATE_LOADING: number;
  97784. /** Defines that the ressource is delayed and has not started loading */
  97785. static readonly DELAYLOADSTATE_NOTLOADED: number;
  97786. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  97787. static readonly NEVER: number;
  97788. /** 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 */
  97789. static readonly ALWAYS: number;
  97790. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  97791. static readonly LESS: number;
  97792. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  97793. static readonly EQUAL: number;
  97794. /** 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 */
  97795. static readonly LEQUAL: number;
  97796. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  97797. static readonly GREATER: number;
  97798. /** 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 */
  97799. static readonly GEQUAL: number;
  97800. /** 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 */
  97801. static readonly NOTEQUAL: number;
  97802. /** Passed to stencilOperation to specify that stencil value must be kept */
  97803. static readonly KEEP: number;
  97804. /** Passed to stencilOperation to specify that stencil value must be replaced */
  97805. static readonly REPLACE: number;
  97806. /** Passed to stencilOperation to specify that stencil value must be incremented */
  97807. static readonly INCR: number;
  97808. /** Passed to stencilOperation to specify that stencil value must be decremented */
  97809. static readonly DECR: number;
  97810. /** Passed to stencilOperation to specify that stencil value must be inverted */
  97811. static readonly INVERT: number;
  97812. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  97813. static readonly INCR_WRAP: number;
  97814. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  97815. static readonly DECR_WRAP: number;
  97816. /** Texture is not repeating outside of 0..1 UVs */
  97817. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  97818. /** Texture is repeating outside of 0..1 UVs */
  97819. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  97820. /** Texture is repeating and mirrored */
  97821. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  97822. /** ALPHA */
  97823. static readonly TEXTUREFORMAT_ALPHA: number;
  97824. /** LUMINANCE */
  97825. static readonly TEXTUREFORMAT_LUMINANCE: number;
  97826. /** LUMINANCE_ALPHA */
  97827. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  97828. /** RGB */
  97829. static readonly TEXTUREFORMAT_RGB: number;
  97830. /** RGBA */
  97831. static readonly TEXTUREFORMAT_RGBA: number;
  97832. /** RED */
  97833. static readonly TEXTUREFORMAT_RED: number;
  97834. /** RED (2nd reference) */
  97835. static readonly TEXTUREFORMAT_R: number;
  97836. /** RG */
  97837. static readonly TEXTUREFORMAT_RG: number;
  97838. /** RED_INTEGER */
  97839. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  97840. /** RED_INTEGER (2nd reference) */
  97841. static readonly TEXTUREFORMAT_R_INTEGER: number;
  97842. /** RG_INTEGER */
  97843. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  97844. /** RGB_INTEGER */
  97845. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  97846. /** RGBA_INTEGER */
  97847. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  97848. /** UNSIGNED_BYTE */
  97849. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  97850. /** UNSIGNED_BYTE (2nd reference) */
  97851. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  97852. /** FLOAT */
  97853. static readonly TEXTURETYPE_FLOAT: number;
  97854. /** HALF_FLOAT */
  97855. static readonly TEXTURETYPE_HALF_FLOAT: number;
  97856. /** BYTE */
  97857. static readonly TEXTURETYPE_BYTE: number;
  97858. /** SHORT */
  97859. static readonly TEXTURETYPE_SHORT: number;
  97860. /** UNSIGNED_SHORT */
  97861. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  97862. /** INT */
  97863. static readonly TEXTURETYPE_INT: number;
  97864. /** UNSIGNED_INT */
  97865. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  97866. /** UNSIGNED_SHORT_4_4_4_4 */
  97867. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  97868. /** UNSIGNED_SHORT_5_5_5_1 */
  97869. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  97870. /** UNSIGNED_SHORT_5_6_5 */
  97871. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  97872. /** UNSIGNED_INT_2_10_10_10_REV */
  97873. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  97874. /** UNSIGNED_INT_24_8 */
  97875. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  97876. /** UNSIGNED_INT_10F_11F_11F_REV */
  97877. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  97878. /** UNSIGNED_INT_5_9_9_9_REV */
  97879. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  97880. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  97881. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  97882. /** nearest is mag = nearest and min = nearest and mip = linear */
  97883. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  97884. /** Bilinear is mag = linear and min = linear and mip = nearest */
  97885. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  97886. /** Trilinear is mag = linear and min = linear and mip = linear */
  97887. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  97888. /** nearest is mag = nearest and min = nearest and mip = linear */
  97889. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  97890. /** Bilinear is mag = linear and min = linear and mip = nearest */
  97891. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  97892. /** Trilinear is mag = linear and min = linear and mip = linear */
  97893. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  97894. /** mag = nearest and min = nearest and mip = nearest */
  97895. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  97896. /** mag = nearest and min = linear and mip = nearest */
  97897. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  97898. /** mag = nearest and min = linear and mip = linear */
  97899. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  97900. /** mag = nearest and min = linear and mip = none */
  97901. static readonly TEXTURE_NEAREST_LINEAR: number;
  97902. /** mag = nearest and min = nearest and mip = none */
  97903. static readonly TEXTURE_NEAREST_NEAREST: number;
  97904. /** mag = linear and min = nearest and mip = nearest */
  97905. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  97906. /** mag = linear and min = nearest and mip = linear */
  97907. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  97908. /** mag = linear and min = linear and mip = none */
  97909. static readonly TEXTURE_LINEAR_LINEAR: number;
  97910. /** mag = linear and min = nearest and mip = none */
  97911. static readonly TEXTURE_LINEAR_NEAREST: number;
  97912. /** Explicit coordinates mode */
  97913. static readonly TEXTURE_EXPLICIT_MODE: number;
  97914. /** Spherical coordinates mode */
  97915. static readonly TEXTURE_SPHERICAL_MODE: number;
  97916. /** Planar coordinates mode */
  97917. static readonly TEXTURE_PLANAR_MODE: number;
  97918. /** Cubic coordinates mode */
  97919. static readonly TEXTURE_CUBIC_MODE: number;
  97920. /** Projection coordinates mode */
  97921. static readonly TEXTURE_PROJECTION_MODE: number;
  97922. /** Skybox coordinates mode */
  97923. static readonly TEXTURE_SKYBOX_MODE: number;
  97924. /** Inverse Cubic coordinates mode */
  97925. static readonly TEXTURE_INVCUBIC_MODE: number;
  97926. /** Equirectangular coordinates mode */
  97927. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  97928. /** Equirectangular Fixed coordinates mode */
  97929. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  97930. /** Equirectangular Fixed Mirrored coordinates mode */
  97931. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  97932. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  97933. static readonly SCALEMODE_FLOOR: number;
  97934. /** Defines that texture rescaling will look for the nearest power of 2 size */
  97935. static readonly SCALEMODE_NEAREST: number;
  97936. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  97937. static readonly SCALEMODE_CEILING: number;
  97938. /**
  97939. * Returns the current npm package of the sdk
  97940. */
  97941. static readonly NpmPackage: string;
  97942. /**
  97943. * Returns the current version of the framework
  97944. */
  97945. static readonly Version: string;
  97946. /** Gets the list of created engines */
  97947. static readonly Instances: Engine[];
  97948. /**
  97949. * Gets the latest created engine
  97950. */
  97951. static readonly LastCreatedEngine: Nullable<Engine>;
  97952. /**
  97953. * Gets the latest created scene
  97954. */
  97955. static readonly LastCreatedScene: Nullable<Scene>;
  97956. /**
  97957. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  97958. * @param flag defines which part of the materials must be marked as dirty
  97959. * @param predicate defines a predicate used to filter which materials should be affected
  97960. */
  97961. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  97962. /**
  97963. * Method called to create the default loading screen.
  97964. * This can be overriden in your own app.
  97965. * @param canvas The rendering canvas element
  97966. * @returns The loading screen
  97967. */
  97968. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  97969. /**
  97970. * Method called to create the default rescale post process on each engine.
  97971. */
  97972. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  97973. /**
  97974. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  97975. **/
  97976. enableOfflineSupport: boolean;
  97977. /**
  97978. * 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)
  97979. **/
  97980. disableManifestCheck: boolean;
  97981. /**
  97982. * Gets the list of created scenes
  97983. */
  97984. scenes: Scene[];
  97985. /**
  97986. * Event raised when a new scene is created
  97987. */
  97988. onNewSceneAddedObservable: Observable<Scene>;
  97989. /**
  97990. * Gets the list of created postprocesses
  97991. */
  97992. postProcesses: PostProcess[];
  97993. /**
  97994. * Gets a boolean indicating if the pointer is currently locked
  97995. */
  97996. isPointerLock: boolean;
  97997. /**
  97998. * Observable event triggered each time the rendering canvas is resized
  97999. */
  98000. onResizeObservable: Observable<Engine>;
  98001. /**
  98002. * Observable event triggered each time the canvas loses focus
  98003. */
  98004. onCanvasBlurObservable: Observable<Engine>;
  98005. /**
  98006. * Observable event triggered each time the canvas gains focus
  98007. */
  98008. onCanvasFocusObservable: Observable<Engine>;
  98009. /**
  98010. * Observable event triggered each time the canvas receives pointerout event
  98011. */
  98012. onCanvasPointerOutObservable: Observable<PointerEvent>;
  98013. /**
  98014. * Observable event triggered before each texture is initialized
  98015. */
  98016. onBeforeTextureInitObservable: Observable<Texture>;
  98017. /**
  98018. * Observable raised when the engine begins a new frame
  98019. */
  98020. onBeginFrameObservable: Observable<Engine>;
  98021. /**
  98022. * If set, will be used to request the next animation frame for the render loop
  98023. */
  98024. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  98025. /**
  98026. * Observable raised when the engine ends the current frame
  98027. */
  98028. onEndFrameObservable: Observable<Engine>;
  98029. /**
  98030. * Observable raised when the engine is about to compile a shader
  98031. */
  98032. onBeforeShaderCompilationObservable: Observable<Engine>;
  98033. /**
  98034. * Observable raised when the engine has jsut compiled a shader
  98035. */
  98036. onAfterShaderCompilationObservable: Observable<Engine>;
  98037. /**
  98038. * Gets the audio engine
  98039. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  98040. * @ignorenaming
  98041. */
  98042. static audioEngine: IAudioEngine;
  98043. /**
  98044. * Default AudioEngine factory responsible of creating the Audio Engine.
  98045. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  98046. */
  98047. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  98048. /**
  98049. * Default offline support factory responsible of creating a tool used to store data locally.
  98050. * By default, this will create a Database object if the workload has been embedded.
  98051. */
  98052. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  98053. private _loadingScreen;
  98054. private _pointerLockRequested;
  98055. private _dummyFramebuffer;
  98056. private _rescalePostProcess;
  98057. /** @hidden */
  98058. protected _alphaMode: number;
  98059. /** @hidden */
  98060. protected _alphaEquation: number;
  98061. private _deterministicLockstep;
  98062. private _lockstepMaxSteps;
  98063. protected readonly _supportsHardwareTextureRescaling: boolean;
  98064. private _fps;
  98065. private _deltaTime;
  98066. /**
  98067. * Turn this value on if you want to pause FPS computation when in background
  98068. */
  98069. disablePerformanceMonitorInBackground: boolean;
  98070. private _performanceMonitor;
  98071. /**
  98072. * Gets the performance monitor attached to this engine
  98073. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  98074. */
  98075. readonly performanceMonitor: PerformanceMonitor;
  98076. private _onFocus;
  98077. private _onBlur;
  98078. private _onCanvasPointerOut;
  98079. private _onCanvasBlur;
  98080. private _onCanvasFocus;
  98081. private _onFullscreenChange;
  98082. private _onPointerLockChange;
  98083. /**
  98084. * Creates a new engine
  98085. * @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
  98086. * @param antialias defines enable antialiasing (default: false)
  98087. * @param options defines further options to be sent to the getContext() function
  98088. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  98089. */
  98090. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  98091. /**
  98092. * Gets current aspect ratio
  98093. * @param viewportOwner defines the camera to use to get the aspect ratio
  98094. * @param useScreen defines if screen size must be used (or the current render target if any)
  98095. * @returns a number defining the aspect ratio
  98096. */
  98097. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  98098. /**
  98099. * Gets current screen aspect ratio
  98100. * @returns a number defining the aspect ratio
  98101. */
  98102. getScreenAspectRatio(): number;
  98103. /**
  98104. * Gets host document
  98105. * @returns the host document object
  98106. */
  98107. getHostDocument(): Document;
  98108. /**
  98109. * Gets the client rect of the HTML canvas attached with the current webGL context
  98110. * @returns a client rectanglee
  98111. */
  98112. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  98113. /**
  98114. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  98115. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98116. * @returns true if engine is in deterministic lock step mode
  98117. */
  98118. isDeterministicLockStep(): boolean;
  98119. /**
  98120. * Gets the max steps when engine is running in deterministic lock step
  98121. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98122. * @returns the max steps
  98123. */
  98124. getLockstepMaxSteps(): number;
  98125. /**
  98126. * Force the mipmap generation for the given render target texture
  98127. * @param texture defines the render target texture to use
  98128. */
  98129. generateMipMapsForCubemap(texture: InternalTexture): void;
  98130. /** States */
  98131. /**
  98132. * Set various states to the webGL context
  98133. * @param culling defines backface culling state
  98134. * @param zOffset defines the value to apply to zOffset (0 by default)
  98135. * @param force defines if states must be applied even if cache is up to date
  98136. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  98137. */
  98138. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  98139. /**
  98140. * Set the z offset to apply to current rendering
  98141. * @param value defines the offset to apply
  98142. */
  98143. setZOffset(value: number): void;
  98144. /**
  98145. * Gets the current value of the zOffset
  98146. * @returns the current zOffset state
  98147. */
  98148. getZOffset(): number;
  98149. /**
  98150. * Enable or disable depth buffering
  98151. * @param enable defines the state to set
  98152. */
  98153. setDepthBuffer(enable: boolean): void;
  98154. /**
  98155. * Gets a boolean indicating if depth writing is enabled
  98156. * @returns the current depth writing state
  98157. */
  98158. getDepthWrite(): boolean;
  98159. /**
  98160. * Enable or disable depth writing
  98161. * @param enable defines the state to set
  98162. */
  98163. setDepthWrite(enable: boolean): void;
  98164. /**
  98165. * Enable or disable color writing
  98166. * @param enable defines the state to set
  98167. */
  98168. setColorWrite(enable: boolean): void;
  98169. /**
  98170. * Gets a boolean indicating if color writing is enabled
  98171. * @returns the current color writing state
  98172. */
  98173. getColorWrite(): boolean;
  98174. /**
  98175. * Sets alpha constants used by some alpha blending modes
  98176. * @param r defines the red component
  98177. * @param g defines the green component
  98178. * @param b defines the blue component
  98179. * @param a defines the alpha component
  98180. */
  98181. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  98182. /**
  98183. * Sets the current alpha mode
  98184. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  98185. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  98186. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  98187. */
  98188. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  98189. /**
  98190. * Gets the current alpha mode
  98191. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  98192. * @returns the current alpha mode
  98193. */
  98194. getAlphaMode(): number;
  98195. /**
  98196. * Sets the current alpha equation
  98197. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  98198. */
  98199. setAlphaEquation(equation: number): void;
  98200. /**
  98201. * Gets the current alpha equation.
  98202. * @returns the current alpha equation
  98203. */
  98204. getAlphaEquation(): number;
  98205. /**
  98206. * Gets a boolean indicating if stencil buffer is enabled
  98207. * @returns the current stencil buffer state
  98208. */
  98209. getStencilBuffer(): boolean;
  98210. /**
  98211. * Enable or disable the stencil buffer
  98212. * @param enable defines if the stencil buffer must be enabled or disabled
  98213. */
  98214. setStencilBuffer(enable: boolean): void;
  98215. /**
  98216. * Gets the current stencil mask
  98217. * @returns a number defining the new stencil mask to use
  98218. */
  98219. getStencilMask(): number;
  98220. /**
  98221. * Sets the current stencil mask
  98222. * @param mask defines the new stencil mask to use
  98223. */
  98224. setStencilMask(mask: number): void;
  98225. /**
  98226. * Gets the current stencil function
  98227. * @returns a number defining the stencil function to use
  98228. */
  98229. getStencilFunction(): number;
  98230. /**
  98231. * Gets the current stencil reference value
  98232. * @returns a number defining the stencil reference value to use
  98233. */
  98234. getStencilFunctionReference(): number;
  98235. /**
  98236. * Gets the current stencil mask
  98237. * @returns a number defining the stencil mask to use
  98238. */
  98239. getStencilFunctionMask(): number;
  98240. /**
  98241. * Sets the current stencil function
  98242. * @param stencilFunc defines the new stencil function to use
  98243. */
  98244. setStencilFunction(stencilFunc: number): void;
  98245. /**
  98246. * Sets the current stencil reference
  98247. * @param reference defines the new stencil reference to use
  98248. */
  98249. setStencilFunctionReference(reference: number): void;
  98250. /**
  98251. * Sets the current stencil mask
  98252. * @param mask defines the new stencil mask to use
  98253. */
  98254. setStencilFunctionMask(mask: number): void;
  98255. /**
  98256. * Gets the current stencil operation when stencil fails
  98257. * @returns a number defining stencil operation to use when stencil fails
  98258. */
  98259. getStencilOperationFail(): number;
  98260. /**
  98261. * Gets the current stencil operation when depth fails
  98262. * @returns a number defining stencil operation to use when depth fails
  98263. */
  98264. getStencilOperationDepthFail(): number;
  98265. /**
  98266. * Gets the current stencil operation when stencil passes
  98267. * @returns a number defining stencil operation to use when stencil passes
  98268. */
  98269. getStencilOperationPass(): number;
  98270. /**
  98271. * Sets the stencil operation to use when stencil fails
  98272. * @param operation defines the stencil operation to use when stencil fails
  98273. */
  98274. setStencilOperationFail(operation: number): void;
  98275. /**
  98276. * Sets the stencil operation to use when depth fails
  98277. * @param operation defines the stencil operation to use when depth fails
  98278. */
  98279. setStencilOperationDepthFail(operation: number): void;
  98280. /**
  98281. * Sets the stencil operation to use when stencil passes
  98282. * @param operation defines the stencil operation to use when stencil passes
  98283. */
  98284. setStencilOperationPass(operation: number): void;
  98285. /**
  98286. * Sets a boolean indicating if the dithering state is enabled or disabled
  98287. * @param value defines the dithering state
  98288. */
  98289. setDitheringState(value: boolean): void;
  98290. /**
  98291. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  98292. * @param value defines the rasterizer state
  98293. */
  98294. setRasterizerState(value: boolean): void;
  98295. /**
  98296. * Gets the current depth function
  98297. * @returns a number defining the depth function
  98298. */
  98299. getDepthFunction(): Nullable<number>;
  98300. /**
  98301. * Sets the current depth function
  98302. * @param depthFunc defines the function to use
  98303. */
  98304. setDepthFunction(depthFunc: number): void;
  98305. /**
  98306. * Sets the current depth function to GREATER
  98307. */
  98308. setDepthFunctionToGreater(): void;
  98309. /**
  98310. * Sets the current depth function to GEQUAL
  98311. */
  98312. setDepthFunctionToGreaterOrEqual(): void;
  98313. /**
  98314. * Sets the current depth function to LESS
  98315. */
  98316. setDepthFunctionToLess(): void;
  98317. /**
  98318. * Sets the current depth function to LEQUAL
  98319. */
  98320. setDepthFunctionToLessOrEqual(): void;
  98321. private _cachedStencilBuffer;
  98322. private _cachedStencilFunction;
  98323. private _cachedStencilMask;
  98324. private _cachedStencilOperationPass;
  98325. private _cachedStencilOperationFail;
  98326. private _cachedStencilOperationDepthFail;
  98327. private _cachedStencilReference;
  98328. /**
  98329. * Caches the the state of the stencil buffer
  98330. */
  98331. cacheStencilState(): void;
  98332. /**
  98333. * Restores the state of the stencil buffer
  98334. */
  98335. restoreStencilState(): void;
  98336. /**
  98337. * Directly set the WebGL Viewport
  98338. * @param x defines the x coordinate of the viewport (in screen space)
  98339. * @param y defines the y coordinate of the viewport (in screen space)
  98340. * @param width defines the width of the viewport (in screen space)
  98341. * @param height defines the height of the viewport (in screen space)
  98342. * @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
  98343. */
  98344. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  98345. /**
  98346. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  98347. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  98348. * @param y defines the y-coordinate of the corner of the clear rectangle
  98349. * @param width defines the width of the clear rectangle
  98350. * @param height defines the height of the clear rectangle
  98351. * @param clearColor defines the clear color
  98352. */
  98353. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  98354. /**
  98355. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  98356. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  98357. * @param y defines the y-coordinate of the corner of the clear rectangle
  98358. * @param width defines the width of the clear rectangle
  98359. * @param height defines the height of the clear rectangle
  98360. */
  98361. enableScissor(x: number, y: number, width: number, height: number): void;
  98362. /**
  98363. * Disable previously set scissor test rectangle
  98364. */
  98365. disableScissor(): void;
  98366. /**
  98367. * Initializes a webVR display and starts listening to display change events
  98368. * The onVRDisplayChangedObservable will be notified upon these changes
  98369. * @returns The onVRDisplayChangedObservable
  98370. */
  98371. initWebVR(): Observable<IDisplayChangedEventArgs>;
  98372. /** @hidden */
  98373. _prepareVRComponent(): void;
  98374. /** @hidden */
  98375. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  98376. /** @hidden */
  98377. _submitVRFrame(): void;
  98378. /**
  98379. * Call this function to leave webVR mode
  98380. * Will do nothing if webVR is not supported or if there is no webVR device
  98381. * @see http://doc.babylonjs.com/how_to/webvr_camera
  98382. */
  98383. disableVR(): void;
  98384. /**
  98385. * Gets a boolean indicating that the system is in VR mode and is presenting
  98386. * @returns true if VR mode is engaged
  98387. */
  98388. isVRPresenting(): boolean;
  98389. /** @hidden */
  98390. _requestVRFrame(): void;
  98391. /** @hidden */
  98392. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  98393. /**
  98394. * Gets the source code of the vertex shader associated with a specific webGL program
  98395. * @param program defines the program to use
  98396. * @returns a string containing the source code of the vertex shader associated with the program
  98397. */
  98398. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  98399. /**
  98400. * Gets the source code of the fragment shader associated with a specific webGL program
  98401. * @param program defines the program to use
  98402. * @returns a string containing the source code of the fragment shader associated with the program
  98403. */
  98404. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  98405. /**
  98406. * Reads pixels from the current frame buffer. Please note that this function can be slow
  98407. * @param x defines the x coordinate of the rectangle where pixels must be read
  98408. * @param y defines the y coordinate of the rectangle where pixels must be read
  98409. * @param width defines the width of the rectangle where pixels must be read
  98410. * @param height defines the height of the rectangle where pixels must be read
  98411. * @returns a Uint8Array containing RGBA colors
  98412. */
  98413. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  98414. /**
  98415. * Sets a depth stencil texture from a render target to the according uniform.
  98416. * @param channel The texture channel
  98417. * @param uniform The uniform to set
  98418. * @param texture The render target texture containing the depth stencil texture to apply
  98419. */
  98420. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  98421. /**
  98422. * Sets a texture to the webGL context from a postprocess
  98423. * @param channel defines the channel to use
  98424. * @param postProcess defines the source postprocess
  98425. */
  98426. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  98427. /**
  98428. * Binds the output of the passed in post process to the texture channel specified
  98429. * @param channel The channel the texture should be bound to
  98430. * @param postProcess The post process which's output should be bound
  98431. */
  98432. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  98433. /** @hidden */
  98434. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  98435. protected _rebuildBuffers(): void;
  98436. _renderLoop(): void;
  98437. /**
  98438. * Toggle full screen mode
  98439. * @param requestPointerLock defines if a pointer lock should be requested from the user
  98440. */
  98441. switchFullscreen(requestPointerLock: boolean): void;
  98442. /**
  98443. * Enters full screen mode
  98444. * @param requestPointerLock defines if a pointer lock should be requested from the user
  98445. */
  98446. enterFullscreen(requestPointerLock: boolean): void;
  98447. /**
  98448. * Exits full screen mode
  98449. */
  98450. exitFullscreen(): void;
  98451. /**
  98452. * Enters Pointerlock mode
  98453. */
  98454. enterPointerlock(): void;
  98455. /**
  98456. * Exits Pointerlock mode
  98457. */
  98458. exitPointerlock(): void;
  98459. /**
  98460. * Begin a new frame
  98461. */
  98462. beginFrame(): void;
  98463. /**
  98464. * Enf the current frame
  98465. */
  98466. endFrame(): void;
  98467. resize(): void;
  98468. /**
  98469. * Set the compressed texture format to use, based on the formats you have, and the formats
  98470. * supported by the hardware / browser.
  98471. *
  98472. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  98473. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  98474. * to API arguments needed to compressed textures. This puts the burden on the container
  98475. * generator to house the arcane code for determining these for current & future formats.
  98476. *
  98477. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  98478. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  98479. *
  98480. * Note: The result of this call is not taken into account when a texture is base64.
  98481. *
  98482. * @param formatsAvailable defines the list of those format families you have created
  98483. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  98484. *
  98485. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  98486. * @returns The extension selected.
  98487. */
  98488. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  98489. /**
  98490. * Force a specific size of the canvas
  98491. * @param width defines the new canvas' width
  98492. * @param height defines the new canvas' height
  98493. */
  98494. setSize(width: number, height: number): void;
  98495. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  98496. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  98497. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  98498. _releaseTexture(texture: InternalTexture): void;
  98499. /**
  98500. * @hidden
  98501. * Rescales a texture
  98502. * @param source input texutre
  98503. * @param destination destination texture
  98504. * @param scene scene to use to render the resize
  98505. * @param internalFormat format to use when resizing
  98506. * @param onComplete callback to be called when resize has completed
  98507. */
  98508. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  98509. /**
  98510. * Gets the current framerate
  98511. * @returns a number representing the framerate
  98512. */
  98513. getFps(): number;
  98514. /**
  98515. * Gets the time spent between current and previous frame
  98516. * @returns a number representing the delta time in ms
  98517. */
  98518. getDeltaTime(): number;
  98519. private _measureFps;
  98520. /**
  98521. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  98522. * @param renderTarget The render target to set the frame buffer for
  98523. */
  98524. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  98525. /**
  98526. * Update a dynamic index buffer
  98527. * @param indexBuffer defines the target index buffer
  98528. * @param indices defines the data to update
  98529. * @param offset defines the offset in the target index buffer where update should start
  98530. */
  98531. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  98532. /**
  98533. * Creates a new render target texture
  98534. * @param size defines the size of the texture
  98535. * @param options defines the options used to create the texture
  98536. * @returns a new render target texture stored in an InternalTexture
  98537. */
  98538. createRenderTargetTexture(size: number | {
  98539. width: number;
  98540. height: number;
  98541. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  98542. /**
  98543. * Updates the sample count of a render target texture
  98544. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  98545. * @param texture defines the texture to update
  98546. * @param samples defines the sample count to set
  98547. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  98548. */
  98549. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  98550. /** @hidden */
  98551. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  98552. dispose(): void;
  98553. private _disableTouchAction;
  98554. /**
  98555. * Display the loading screen
  98556. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98557. */
  98558. displayLoadingUI(): void;
  98559. /**
  98560. * Hide the loading screen
  98561. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98562. */
  98563. hideLoadingUI(): void;
  98564. /**
  98565. * Gets the current loading screen object
  98566. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98567. */
  98568. /**
  98569. * Sets the current loading screen object
  98570. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98571. */
  98572. loadingScreen: ILoadingScreen;
  98573. /**
  98574. * Sets the current loading screen text
  98575. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98576. */
  98577. loadingUIText: string;
  98578. /**
  98579. * Sets the current loading screen background color
  98580. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98581. */
  98582. loadingUIBackgroundColor: string;
  98583. /** Pointerlock and fullscreen */
  98584. /**
  98585. * Ask the browser to promote the current element to pointerlock mode
  98586. * @param element defines the DOM element to promote
  98587. */
  98588. static _RequestPointerlock(element: HTMLElement): void;
  98589. /**
  98590. * Asks the browser to exit pointerlock mode
  98591. */
  98592. static _ExitPointerlock(): void;
  98593. /**
  98594. * Ask the browser to promote the current element to fullscreen rendering mode
  98595. * @param element defines the DOM element to promote
  98596. */
  98597. static _RequestFullscreen(element: HTMLElement): void;
  98598. /**
  98599. * Asks the browser to exit fullscreen mode
  98600. */
  98601. static _ExitFullscreen(): void;
  98602. }
  98603. }
  98604. declare module BABYLON {
  98605. /**
  98606. * The engine store class is responsible to hold all the instances of Engine and Scene created
  98607. * during the life time of the application.
  98608. */
  98609. export class EngineStore {
  98610. /** Gets the list of created engines */
  98611. static Instances: Engine[];
  98612. /** @hidden */
  98613. static _LastCreatedScene: Nullable<Scene>;
  98614. /**
  98615. * Gets the latest created engine
  98616. */
  98617. static readonly LastCreatedEngine: Nullable<Engine>;
  98618. /**
  98619. * Gets the latest created scene
  98620. */
  98621. static readonly LastCreatedScene: Nullable<Scene>;
  98622. /**
  98623. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  98624. * @ignorenaming
  98625. */
  98626. static UseFallbackTexture: boolean;
  98627. /**
  98628. * Texture content used if a texture cannot loaded
  98629. * @ignorenaming
  98630. */
  98631. static FallbackTexture: string;
  98632. }
  98633. }
  98634. declare module BABYLON {
  98635. /**
  98636. * Helper class that provides a small promise polyfill
  98637. */
  98638. export class PromisePolyfill {
  98639. /**
  98640. * Static function used to check if the polyfill is required
  98641. * If this is the case then the function will inject the polyfill to window.Promise
  98642. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  98643. */
  98644. static Apply(force?: boolean): void;
  98645. }
  98646. }
  98647. declare module BABYLON {
  98648. /**
  98649. * Interface for screenshot methods with describe argument called `size` as object with options
  98650. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  98651. */
  98652. export interface IScreenshotSize {
  98653. /**
  98654. * number in pixels for canvas height
  98655. */
  98656. height?: number;
  98657. /**
  98658. * multiplier allowing render at a higher or lower resolution
  98659. * If value is defined then height and width will be ignored and taken from camera
  98660. */
  98661. precision?: number;
  98662. /**
  98663. * number in pixels for canvas width
  98664. */
  98665. width?: number;
  98666. }
  98667. }
  98668. declare module BABYLON {
  98669. interface IColor4Like {
  98670. r: float;
  98671. g: float;
  98672. b: float;
  98673. a: float;
  98674. }
  98675. /**
  98676. * Class containing a set of static utilities functions
  98677. */
  98678. export class Tools {
  98679. /**
  98680. * Gets or sets the base URL to use to load assets
  98681. */
  98682. static BaseUrl: string;
  98683. /**
  98684. * Enable/Disable Custom HTTP Request Headers globally.
  98685. * default = false
  98686. * @see CustomRequestHeaders
  98687. */
  98688. static UseCustomRequestHeaders: boolean;
  98689. /**
  98690. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  98691. * i.e. when loading files, where the server/service expects an Authorization header
  98692. */
  98693. static CustomRequestHeaders: {
  98694. [key: string]: string;
  98695. };
  98696. /**
  98697. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  98698. */
  98699. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  98700. /**
  98701. * Default behaviour for cors in the application.
  98702. * It can be a string if the expected behavior is identical in the entire app.
  98703. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  98704. */
  98705. static CorsBehavior: string | ((url: string | string[]) => string);
  98706. /**
  98707. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  98708. * @ignorenaming
  98709. */
  98710. static UseFallbackTexture: boolean;
  98711. /**
  98712. * Use this object to register external classes like custom textures or material
  98713. * to allow the laoders to instantiate them
  98714. */
  98715. static RegisteredExternalClasses: {
  98716. [key: string]: Object;
  98717. };
  98718. /**
  98719. * Texture content used if a texture cannot loaded
  98720. * @ignorenaming
  98721. */
  98722. static fallbackTexture: string;
  98723. /**
  98724. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  98725. * @param u defines the coordinate on X axis
  98726. * @param v defines the coordinate on Y axis
  98727. * @param width defines the width of the source data
  98728. * @param height defines the height of the source data
  98729. * @param pixels defines the source byte array
  98730. * @param color defines the output color
  98731. */
  98732. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  98733. /**
  98734. * Interpolates between a and b via alpha
  98735. * @param a The lower value (returned when alpha = 0)
  98736. * @param b The upper value (returned when alpha = 1)
  98737. * @param alpha The interpolation-factor
  98738. * @return The mixed value
  98739. */
  98740. static Mix(a: number, b: number, alpha: number): number;
  98741. /**
  98742. * Tries to instantiate a new object from a given class name
  98743. * @param className defines the class name to instantiate
  98744. * @returns the new object or null if the system was not able to do the instantiation
  98745. */
  98746. static Instantiate(className: string): any;
  98747. /**
  98748. * Provides a slice function that will work even on IE
  98749. * @param data defines the array to slice
  98750. * @param start defines the start of the data (optional)
  98751. * @param end defines the end of the data (optional)
  98752. * @returns the new sliced array
  98753. */
  98754. static Slice<T>(data: T, start?: number, end?: number): T;
  98755. /**
  98756. * Polyfill for setImmediate
  98757. * @param action defines the action to execute after the current execution block
  98758. */
  98759. static SetImmediate(action: () => void): void;
  98760. /**
  98761. * Function indicating if a number is an exponent of 2
  98762. * @param value defines the value to test
  98763. * @returns true if the value is an exponent of 2
  98764. */
  98765. static IsExponentOfTwo(value: number): boolean;
  98766. private static _tmpFloatArray;
  98767. /**
  98768. * Returns the nearest 32-bit single precision float representation of a Number
  98769. * @param value A Number. If the parameter is of a different type, it will get converted
  98770. * to a number or to NaN if it cannot be converted
  98771. * @returns number
  98772. */
  98773. static FloatRound(value: number): number;
  98774. /**
  98775. * Extracts the filename from a path
  98776. * @param path defines the path to use
  98777. * @returns the filename
  98778. */
  98779. static GetFilename(path: string): string;
  98780. /**
  98781. * Extracts the "folder" part of a path (everything before the filename).
  98782. * @param uri The URI to extract the info from
  98783. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  98784. * @returns The "folder" part of the path
  98785. */
  98786. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  98787. /**
  98788. * Extracts text content from a DOM element hierarchy
  98789. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  98790. */
  98791. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  98792. /**
  98793. * Convert an angle in radians to degrees
  98794. * @param angle defines the angle to convert
  98795. * @returns the angle in degrees
  98796. */
  98797. static ToDegrees(angle: number): number;
  98798. /**
  98799. * Convert an angle in degrees to radians
  98800. * @param angle defines the angle to convert
  98801. * @returns the angle in radians
  98802. */
  98803. static ToRadians(angle: number): number;
  98804. /**
  98805. * Encode a buffer to a base64 string
  98806. * @param buffer defines the buffer to encode
  98807. * @returns the encoded string
  98808. */
  98809. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  98810. /**
  98811. * Returns an array if obj is not an array
  98812. * @param obj defines the object to evaluate as an array
  98813. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  98814. * @returns either obj directly if obj is an array or a new array containing obj
  98815. */
  98816. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  98817. /**
  98818. * Gets the pointer prefix to use
  98819. * @returns "pointer" if touch is enabled. Else returns "mouse"
  98820. */
  98821. static GetPointerPrefix(): string;
  98822. /**
  98823. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  98824. * @param url define the url we are trying
  98825. * @param element define the dom element where to configure the cors policy
  98826. */
  98827. static SetCorsBehavior(url: string | string[], element: {
  98828. crossOrigin: string | null;
  98829. }): void;
  98830. /**
  98831. * Removes unwanted characters from an url
  98832. * @param url defines the url to clean
  98833. * @returns the cleaned url
  98834. */
  98835. static CleanUrl(url: string): string;
  98836. /**
  98837. * Gets or sets a function used to pre-process url before using them to load assets
  98838. */
  98839. static PreprocessUrl: (url: string) => string;
  98840. /**
  98841. * Loads an image as an HTMLImageElement.
  98842. * @param input url string, ArrayBuffer, or Blob to load
  98843. * @param onLoad callback called when the image successfully loads
  98844. * @param onError callback called when the image fails to load
  98845. * @param offlineProvider offline provider for caching
  98846. * @returns the HTMLImageElement of the loaded image
  98847. */
  98848. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  98849. /**
  98850. * Loads a file
  98851. * @param url url string, ArrayBuffer, or Blob to load
  98852. * @param onSuccess callback called when the file successfully loads
  98853. * @param onProgress callback called while file is loading (if the server supports this mode)
  98854. * @param offlineProvider defines the offline provider for caching
  98855. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  98856. * @param onError callback called when the file fails to load
  98857. * @returns a file request object
  98858. */
  98859. 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;
  98860. /**
  98861. * Loads a file from a url
  98862. * @param url the file url to load
  98863. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  98864. */
  98865. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  98866. /**
  98867. * Load a script (identified by an url). When the url returns, the
  98868. * content of this file is added into a new script element, attached to the DOM (body element)
  98869. * @param scriptUrl defines the url of the script to laod
  98870. * @param onSuccess defines the callback called when the script is loaded
  98871. * @param onError defines the callback to call if an error occurs
  98872. * @param scriptId defines the id of the script element
  98873. */
  98874. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  98875. /**
  98876. * Load an asynchronous script (identified by an url). When the url returns, the
  98877. * content of this file is added into a new script element, attached to the DOM (body element)
  98878. * @param scriptUrl defines the url of the script to laod
  98879. * @param scriptId defines the id of the script element
  98880. * @returns a promise request object
  98881. */
  98882. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  98883. /**
  98884. * Loads a file from a blob
  98885. * @param fileToLoad defines the blob to use
  98886. * @param callback defines the callback to call when data is loaded
  98887. * @param progressCallback defines the callback to call during loading process
  98888. * @returns a file request object
  98889. */
  98890. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  98891. /**
  98892. * Loads a file
  98893. * @param fileToLoad defines the file to load
  98894. * @param callback defines the callback to call when data is loaded
  98895. * @param progressCallBack defines the callback to call during loading process
  98896. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  98897. * @returns a file request object
  98898. */
  98899. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  98900. /**
  98901. * Creates a data url from a given string content
  98902. * @param content defines the content to convert
  98903. * @returns the new data url link
  98904. */
  98905. static FileAsURL(content: string): string;
  98906. /**
  98907. * Format the given number to a specific decimal format
  98908. * @param value defines the number to format
  98909. * @param decimals defines the number of decimals to use
  98910. * @returns the formatted string
  98911. */
  98912. static Format(value: number, decimals?: number): string;
  98913. /**
  98914. * Tries to copy an object by duplicating every property
  98915. * @param source defines the source object
  98916. * @param destination defines the target object
  98917. * @param doNotCopyList defines a list of properties to avoid
  98918. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  98919. */
  98920. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  98921. /**
  98922. * Gets a boolean indicating if the given object has no own property
  98923. * @param obj defines the object to test
  98924. * @returns true if object has no own property
  98925. */
  98926. static IsEmpty(obj: any): boolean;
  98927. /**
  98928. * Function used to register events at window level
  98929. * @param windowElement defines the Window object to use
  98930. * @param events defines the events to register
  98931. */
  98932. static RegisterTopRootEvents(windowElement: Window, events: {
  98933. name: string;
  98934. handler: Nullable<(e: FocusEvent) => any>;
  98935. }[]): void;
  98936. /**
  98937. * Function used to unregister events from window level
  98938. * @param windowElement defines the Window object to use
  98939. * @param events defines the events to unregister
  98940. */
  98941. static UnregisterTopRootEvents(windowElement: Window, events: {
  98942. name: string;
  98943. handler: Nullable<(e: FocusEvent) => any>;
  98944. }[]): void;
  98945. /**
  98946. * @ignore
  98947. */
  98948. static _ScreenshotCanvas: HTMLCanvasElement;
  98949. /**
  98950. * Dumps the current bound framebuffer
  98951. * @param width defines the rendering width
  98952. * @param height defines the rendering height
  98953. * @param engine defines the hosting engine
  98954. * @param successCallback defines the callback triggered once the data are available
  98955. * @param mimeType defines the mime type of the result
  98956. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  98957. */
  98958. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  98959. /**
  98960. * Converts the canvas data to blob.
  98961. * This acts as a polyfill for browsers not supporting the to blob function.
  98962. * @param canvas Defines the canvas to extract the data from
  98963. * @param successCallback Defines the callback triggered once the data are available
  98964. * @param mimeType Defines the mime type of the result
  98965. */
  98966. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  98967. /**
  98968. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  98969. * @param successCallback defines the callback triggered once the data are available
  98970. * @param mimeType defines the mime type of the result
  98971. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  98972. */
  98973. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  98974. /**
  98975. * Downloads a blob in the browser
  98976. * @param blob defines the blob to download
  98977. * @param fileName defines the name of the downloaded file
  98978. */
  98979. static Download(blob: Blob, fileName: string): void;
  98980. /**
  98981. * Captures a screenshot of the current rendering
  98982. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  98983. * @param engine defines the rendering engine
  98984. * @param camera defines the source camera
  98985. * @param size This parameter can be set to a single number or to an object with the
  98986. * following (optional) properties: precision, width, height. If a single number is passed,
  98987. * it will be used for both width and height. If an object is passed, the screenshot size
  98988. * will be derived from the parameters. The precision property is a multiplier allowing
  98989. * rendering at a higher or lower resolution
  98990. * @param successCallback defines the callback receives a single parameter which contains the
  98991. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  98992. * src parameter of an <img> to display it
  98993. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  98994. * Check your browser for supported MIME types
  98995. */
  98996. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  98997. /**
  98998. * Captures a screenshot of the current rendering
  98999. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  99000. * @param engine defines the rendering engine
  99001. * @param camera defines the source camera
  99002. * @param size This parameter can be set to a single number or to an object with the
  99003. * following (optional) properties: precision, width, height. If a single number is passed,
  99004. * it will be used for both width and height. If an object is passed, the screenshot size
  99005. * will be derived from the parameters. The precision property is a multiplier allowing
  99006. * rendering at a higher or lower resolution
  99007. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  99008. * Check your browser for supported MIME types
  99009. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  99010. * to the src parameter of an <img> to display it
  99011. */
  99012. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  99013. /**
  99014. * Generates an image screenshot from the specified camera.
  99015. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  99016. * @param engine The engine to use for rendering
  99017. * @param camera The camera to use for rendering
  99018. * @param size This parameter can be set to a single number or to an object with the
  99019. * following (optional) properties: precision, width, height. If a single number is passed,
  99020. * it will be used for both width and height. If an object is passed, the screenshot size
  99021. * will be derived from the parameters. The precision property is a multiplier allowing
  99022. * rendering at a higher or lower resolution
  99023. * @param successCallback The callback receives a single parameter which contains the
  99024. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  99025. * src parameter of an <img> to display it
  99026. * @param mimeType The MIME type of the screenshot image (default: image/png).
  99027. * Check your browser for supported MIME types
  99028. * @param samples Texture samples (default: 1)
  99029. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  99030. * @param fileName A name for for the downloaded file.
  99031. */
  99032. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  99033. /**
  99034. * Generates an image screenshot from the specified camera.
  99035. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  99036. * @param engine The engine to use for rendering
  99037. * @param camera The camera to use for rendering
  99038. * @param size This parameter can be set to a single number or to an object with the
  99039. * following (optional) properties: precision, width, height. If a single number is passed,
  99040. * it will be used for both width and height. If an object is passed, the screenshot size
  99041. * will be derived from the parameters. The precision property is a multiplier allowing
  99042. * rendering at a higher or lower resolution
  99043. * @param mimeType The MIME type of the screenshot image (default: image/png).
  99044. * Check your browser for supported MIME types
  99045. * @param samples Texture samples (default: 1)
  99046. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  99047. * @param fileName A name for for the downloaded file.
  99048. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  99049. * to the src parameter of an <img> to display it
  99050. */
  99051. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  99052. /**
  99053. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  99054. * Be aware Math.random() could cause collisions, but:
  99055. * "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"
  99056. * @returns a pseudo random id
  99057. */
  99058. static RandomId(): string;
  99059. /**
  99060. * Test if the given uri is a base64 string
  99061. * @param uri The uri to test
  99062. * @return True if the uri is a base64 string or false otherwise
  99063. */
  99064. static IsBase64(uri: string): boolean;
  99065. /**
  99066. * Decode the given base64 uri.
  99067. * @param uri The uri to decode
  99068. * @return The decoded base64 data.
  99069. */
  99070. static DecodeBase64(uri: string): ArrayBuffer;
  99071. /**
  99072. * Gets the absolute url.
  99073. * @param url the input url
  99074. * @return the absolute url
  99075. */
  99076. static GetAbsoluteUrl(url: string): string;
  99077. /**
  99078. * No log
  99079. */
  99080. static readonly NoneLogLevel: number;
  99081. /**
  99082. * Only message logs
  99083. */
  99084. static readonly MessageLogLevel: number;
  99085. /**
  99086. * Only warning logs
  99087. */
  99088. static readonly WarningLogLevel: number;
  99089. /**
  99090. * Only error logs
  99091. */
  99092. static readonly ErrorLogLevel: number;
  99093. /**
  99094. * All logs
  99095. */
  99096. static readonly AllLogLevel: number;
  99097. /**
  99098. * Gets a value indicating the number of loading errors
  99099. * @ignorenaming
  99100. */
  99101. static readonly errorsCount: number;
  99102. /**
  99103. * Callback called when a new log is added
  99104. */
  99105. static OnNewCacheEntry: (entry: string) => void;
  99106. /**
  99107. * Log a message to the console
  99108. * @param message defines the message to log
  99109. */
  99110. static Log(message: string): void;
  99111. /**
  99112. * Write a warning message to the console
  99113. * @param message defines the message to log
  99114. */
  99115. static Warn(message: string): void;
  99116. /**
  99117. * Write an error message to the console
  99118. * @param message defines the message to log
  99119. */
  99120. static Error(message: string): void;
  99121. /**
  99122. * Gets current log cache (list of logs)
  99123. */
  99124. static readonly LogCache: string;
  99125. /**
  99126. * Clears the log cache
  99127. */
  99128. static ClearLogCache(): void;
  99129. /**
  99130. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  99131. */
  99132. static LogLevels: number;
  99133. /**
  99134. * Checks if the window object exists
  99135. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  99136. */
  99137. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  99138. /**
  99139. * No performance log
  99140. */
  99141. static readonly PerformanceNoneLogLevel: number;
  99142. /**
  99143. * Use user marks to log performance
  99144. */
  99145. static readonly PerformanceUserMarkLogLevel: number;
  99146. /**
  99147. * Log performance to the console
  99148. */
  99149. static readonly PerformanceConsoleLogLevel: number;
  99150. private static _performance;
  99151. /**
  99152. * Sets the current performance log level
  99153. */
  99154. static PerformanceLogLevel: number;
  99155. private static _StartPerformanceCounterDisabled;
  99156. private static _EndPerformanceCounterDisabled;
  99157. private static _StartUserMark;
  99158. private static _EndUserMark;
  99159. private static _StartPerformanceConsole;
  99160. private static _EndPerformanceConsole;
  99161. /**
  99162. * Starts a performance counter
  99163. */
  99164. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  99165. /**
  99166. * Ends a specific performance coutner
  99167. */
  99168. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  99169. /**
  99170. * Gets either window.performance.now() if supported or Date.now() else
  99171. */
  99172. static readonly Now: number;
  99173. /**
  99174. * This method will return the name of the class used to create the instance of the given object.
  99175. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  99176. * @param object the object to get the class name from
  99177. * @param isType defines if the object is actually a type
  99178. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  99179. */
  99180. static GetClassName(object: any, isType?: boolean): string;
  99181. /**
  99182. * Gets the first element of an array satisfying a given predicate
  99183. * @param array defines the array to browse
  99184. * @param predicate defines the predicate to use
  99185. * @returns null if not found or the element
  99186. */
  99187. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  99188. /**
  99189. * This method will return the name of the full name of the class, including its owning module (if any).
  99190. * 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).
  99191. * @param object the object to get the class name from
  99192. * @param isType defines if the object is actually a type
  99193. * @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.
  99194. * @ignorenaming
  99195. */
  99196. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  99197. /**
  99198. * Returns a promise that resolves after the given amount of time.
  99199. * @param delay Number of milliseconds to delay
  99200. * @returns Promise that resolves after the given amount of time
  99201. */
  99202. static DelayAsync(delay: number): Promise<void>;
  99203. }
  99204. /**
  99205. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  99206. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  99207. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  99208. * @param name The name of the class, case should be preserved
  99209. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  99210. */
  99211. export function className(name: string, module?: string): (target: Object) => void;
  99212. /**
  99213. * An implementation of a loop for asynchronous functions.
  99214. */
  99215. export class AsyncLoop {
  99216. /**
  99217. * Defines the number of iterations for the loop
  99218. */
  99219. iterations: number;
  99220. /**
  99221. * Defines the current index of the loop.
  99222. */
  99223. index: number;
  99224. private _done;
  99225. private _fn;
  99226. private _successCallback;
  99227. /**
  99228. * Constructor.
  99229. * @param iterations the number of iterations.
  99230. * @param func the function to run each iteration
  99231. * @param successCallback the callback that will be called upon succesful execution
  99232. * @param offset starting offset.
  99233. */
  99234. constructor(
  99235. /**
  99236. * Defines the number of iterations for the loop
  99237. */
  99238. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  99239. /**
  99240. * Execute the next iteration. Must be called after the last iteration was finished.
  99241. */
  99242. executeNext(): void;
  99243. /**
  99244. * Break the loop and run the success callback.
  99245. */
  99246. breakLoop(): void;
  99247. /**
  99248. * Create and run an async loop.
  99249. * @param iterations the number of iterations.
  99250. * @param fn the function to run each iteration
  99251. * @param successCallback the callback that will be called upon succesful execution
  99252. * @param offset starting offset.
  99253. * @returns the created async loop object
  99254. */
  99255. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  99256. /**
  99257. * A for-loop that will run a given number of iterations synchronous and the rest async.
  99258. * @param iterations total number of iterations
  99259. * @param syncedIterations number of synchronous iterations in each async iteration.
  99260. * @param fn the function to call each iteration.
  99261. * @param callback a success call back that will be called when iterating stops.
  99262. * @param breakFunction a break condition (optional)
  99263. * @param timeout timeout settings for the setTimeout function. default - 0.
  99264. * @returns the created async loop object
  99265. */
  99266. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  99267. }
  99268. }
  99269. declare module BABYLON {
  99270. /**
  99271. * This class implement a typical dictionary using a string as key and the generic type T as value.
  99272. * The underlying implementation relies on an associative array to ensure the best performances.
  99273. * The value can be anything including 'null' but except 'undefined'
  99274. */
  99275. export class StringDictionary<T> {
  99276. /**
  99277. * This will clear this dictionary and copy the content from the 'source' one.
  99278. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  99279. * @param source the dictionary to take the content from and copy to this dictionary
  99280. */
  99281. copyFrom(source: StringDictionary<T>): void;
  99282. /**
  99283. * Get a value based from its key
  99284. * @param key the given key to get the matching value from
  99285. * @return the value if found, otherwise undefined is returned
  99286. */
  99287. get(key: string): T | undefined;
  99288. /**
  99289. * Get a value from its key or add it if it doesn't exist.
  99290. * This method will ensure you that a given key/data will be present in the dictionary.
  99291. * @param key the given key to get the matching value from
  99292. * @param factory the factory that will create the value if the key is not present in the dictionary.
  99293. * The factory will only be invoked if there's no data for the given key.
  99294. * @return the value corresponding to the key.
  99295. */
  99296. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  99297. /**
  99298. * Get a value from its key if present in the dictionary otherwise add it
  99299. * @param key the key to get the value from
  99300. * @param val if there's no such key/value pair in the dictionary add it with this value
  99301. * @return the value corresponding to the key
  99302. */
  99303. getOrAdd(key: string, val: T): T;
  99304. /**
  99305. * Check if there's a given key in the dictionary
  99306. * @param key the key to check for
  99307. * @return true if the key is present, false otherwise
  99308. */
  99309. contains(key: string): boolean;
  99310. /**
  99311. * Add a new key and its corresponding value
  99312. * @param key the key to add
  99313. * @param value the value corresponding to the key
  99314. * @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
  99315. */
  99316. add(key: string, value: T): boolean;
  99317. /**
  99318. * Update a specific value associated to a key
  99319. * @param key defines the key to use
  99320. * @param value defines the value to store
  99321. * @returns true if the value was updated (or false if the key was not found)
  99322. */
  99323. set(key: string, value: T): boolean;
  99324. /**
  99325. * Get the element of the given key and remove it from the dictionary
  99326. * @param key defines the key to search
  99327. * @returns the value associated with the key or null if not found
  99328. */
  99329. getAndRemove(key: string): Nullable<T>;
  99330. /**
  99331. * Remove a key/value from the dictionary.
  99332. * @param key the key to remove
  99333. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  99334. */
  99335. remove(key: string): boolean;
  99336. /**
  99337. * Clear the whole content of the dictionary
  99338. */
  99339. clear(): void;
  99340. /**
  99341. * Gets the current count
  99342. */
  99343. readonly count: number;
  99344. /**
  99345. * Execute a callback on each key/val of the dictionary.
  99346. * Note that you can remove any element in this dictionary in the callback implementation
  99347. * @param callback the callback to execute on a given key/value pair
  99348. */
  99349. forEach(callback: (key: string, val: T) => void): void;
  99350. /**
  99351. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  99352. * If the callback returns null or undefined the method will iterate to the next key/value pair
  99353. * Note that you can remove any element in this dictionary in the callback implementation
  99354. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  99355. * @returns the first item
  99356. */
  99357. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  99358. private _count;
  99359. private _data;
  99360. }
  99361. }
  99362. declare module BABYLON {
  99363. /** @hidden */
  99364. export interface ICollisionCoordinator {
  99365. createCollider(): Collider;
  99366. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  99367. init(scene: Scene): void;
  99368. }
  99369. /** @hidden */
  99370. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  99371. private _scene;
  99372. private _scaledPosition;
  99373. private _scaledVelocity;
  99374. private _finalPosition;
  99375. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  99376. createCollider(): Collider;
  99377. init(scene: Scene): void;
  99378. private _collideWithWorld;
  99379. }
  99380. }
  99381. declare module BABYLON {
  99382. /**
  99383. * Class used to manage all inputs for the scene.
  99384. */
  99385. export class InputManager {
  99386. /** The distance in pixel that you have to move to prevent some events */
  99387. static DragMovementThreshold: number;
  99388. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  99389. static LongPressDelay: number;
  99390. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  99391. static DoubleClickDelay: number;
  99392. /** If you need to check double click without raising a single click at first click, enable this flag */
  99393. static ExclusiveDoubleClickMode: boolean;
  99394. private _wheelEventName;
  99395. private _onPointerMove;
  99396. private _onPointerDown;
  99397. private _onPointerUp;
  99398. private _initClickEvent;
  99399. private _initActionManager;
  99400. private _delayedSimpleClick;
  99401. private _delayedSimpleClickTimeout;
  99402. private _previousDelayedSimpleClickTimeout;
  99403. private _meshPickProceed;
  99404. private _previousButtonPressed;
  99405. private _currentPickResult;
  99406. private _previousPickResult;
  99407. private _totalPointersPressed;
  99408. private _doubleClickOccured;
  99409. private _pointerOverMesh;
  99410. private _pickedDownMesh;
  99411. private _pickedUpMesh;
  99412. private _pointerX;
  99413. private _pointerY;
  99414. private _unTranslatedPointerX;
  99415. private _unTranslatedPointerY;
  99416. private _startingPointerPosition;
  99417. private _previousStartingPointerPosition;
  99418. private _startingPointerTime;
  99419. private _previousStartingPointerTime;
  99420. private _pointerCaptures;
  99421. private _onKeyDown;
  99422. private _onKeyUp;
  99423. private _onCanvasFocusObserver;
  99424. private _onCanvasBlurObserver;
  99425. private _scene;
  99426. /**
  99427. * Creates a new InputManager
  99428. * @param scene defines the hosting scene
  99429. */
  99430. constructor(scene: Scene);
  99431. /**
  99432. * Gets the mesh that is currently under the pointer
  99433. */
  99434. readonly meshUnderPointer: Nullable<AbstractMesh>;
  99435. /**
  99436. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  99437. */
  99438. readonly unTranslatedPointer: Vector2;
  99439. /**
  99440. * Gets or sets the current on-screen X position of the pointer
  99441. */
  99442. pointerX: number;
  99443. /**
  99444. * Gets or sets the current on-screen Y position of the pointer
  99445. */
  99446. pointerY: number;
  99447. private _updatePointerPosition;
  99448. private _processPointerMove;
  99449. private _setRayOnPointerInfo;
  99450. private _checkPrePointerObservable;
  99451. /**
  99452. * Use this method to simulate a pointer move on a mesh
  99453. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99454. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99455. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99456. */
  99457. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  99458. /**
  99459. * Use this method to simulate a pointer down on a mesh
  99460. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99461. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99462. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99463. */
  99464. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  99465. private _processPointerDown;
  99466. /** @hidden */
  99467. _isPointerSwiping(): boolean;
  99468. /**
  99469. * Use this method to simulate a pointer up on a mesh
  99470. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99471. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99472. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99473. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  99474. */
  99475. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  99476. private _processPointerUp;
  99477. /**
  99478. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  99479. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  99480. * @returns true if the pointer was captured
  99481. */
  99482. isPointerCaptured(pointerId?: number): boolean;
  99483. /**
  99484. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  99485. * @param attachUp defines if you want to attach events to pointerup
  99486. * @param attachDown defines if you want to attach events to pointerdown
  99487. * @param attachMove defines if you want to attach events to pointermove
  99488. */
  99489. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  99490. /**
  99491. * Detaches all event handlers
  99492. */
  99493. detachControl(): void;
  99494. /**
  99495. * Force the value of meshUnderPointer
  99496. * @param mesh defines the mesh to use
  99497. */
  99498. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  99499. /**
  99500. * Gets the mesh under the pointer
  99501. * @returns a Mesh or null if no mesh is under the pointer
  99502. */
  99503. getPointerOverMesh(): Nullable<AbstractMesh>;
  99504. }
  99505. }
  99506. declare module BABYLON {
  99507. /**
  99508. * Helper class used to generate session unique ID
  99509. */
  99510. export class UniqueIdGenerator {
  99511. private static _UniqueIdCounter;
  99512. /**
  99513. * Gets an unique (relatively to the current scene) Id
  99514. */
  99515. static readonly UniqueId: number;
  99516. }
  99517. }
  99518. declare module BABYLON {
  99519. /**
  99520. * This class defines the direct association between an animation and a target
  99521. */
  99522. export class TargetedAnimation {
  99523. /**
  99524. * Animation to perform
  99525. */
  99526. animation: Animation;
  99527. /**
  99528. * Target to animate
  99529. */
  99530. target: any;
  99531. /**
  99532. * Serialize the object
  99533. * @returns the JSON object representing the current entity
  99534. */
  99535. serialize(): any;
  99536. }
  99537. /**
  99538. * Use this class to create coordinated animations on multiple targets
  99539. */
  99540. export class AnimationGroup implements IDisposable {
  99541. /** The name of the animation group */
  99542. name: string;
  99543. private _scene;
  99544. private _targetedAnimations;
  99545. private _animatables;
  99546. private _from;
  99547. private _to;
  99548. private _isStarted;
  99549. private _isPaused;
  99550. private _speedRatio;
  99551. private _loopAnimation;
  99552. /**
  99553. * Gets or sets the unique id of the node
  99554. */
  99555. uniqueId: number;
  99556. /**
  99557. * This observable will notify when one animation have ended
  99558. */
  99559. onAnimationEndObservable: Observable<TargetedAnimation>;
  99560. /**
  99561. * Observer raised when one animation loops
  99562. */
  99563. onAnimationLoopObservable: Observable<TargetedAnimation>;
  99564. /**
  99565. * This observable will notify when all animations have ended.
  99566. */
  99567. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  99568. /**
  99569. * This observable will notify when all animations have paused.
  99570. */
  99571. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  99572. /**
  99573. * This observable will notify when all animations are playing.
  99574. */
  99575. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  99576. /**
  99577. * Gets the first frame
  99578. */
  99579. readonly from: number;
  99580. /**
  99581. * Gets the last frame
  99582. */
  99583. readonly to: number;
  99584. /**
  99585. * Define if the animations are started
  99586. */
  99587. readonly isStarted: boolean;
  99588. /**
  99589. * Gets a value indicating that the current group is playing
  99590. */
  99591. readonly isPlaying: boolean;
  99592. /**
  99593. * Gets or sets the speed ratio to use for all animations
  99594. */
  99595. /**
  99596. * Gets or sets the speed ratio to use for all animations
  99597. */
  99598. speedRatio: number;
  99599. /**
  99600. * Gets or sets if all animations should loop or not
  99601. */
  99602. loopAnimation: boolean;
  99603. /**
  99604. * Gets the targeted animations for this animation group
  99605. */
  99606. readonly targetedAnimations: Array<TargetedAnimation>;
  99607. /**
  99608. * returning the list of animatables controlled by this animation group.
  99609. */
  99610. readonly animatables: Array<Animatable>;
  99611. /**
  99612. * Instantiates a new Animation Group.
  99613. * This helps managing several animations at once.
  99614. * @see http://doc.babylonjs.com/how_to/group
  99615. * @param name Defines the name of the group
  99616. * @param scene Defines the scene the group belongs to
  99617. */
  99618. constructor(
  99619. /** The name of the animation group */
  99620. name: string, scene?: Nullable<Scene>);
  99621. /**
  99622. * Add an animation (with its target) in the group
  99623. * @param animation defines the animation we want to add
  99624. * @param target defines the target of the animation
  99625. * @returns the TargetedAnimation object
  99626. */
  99627. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  99628. /**
  99629. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  99630. * It can add constant keys at begin or end
  99631. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  99632. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  99633. * @returns the animation group
  99634. */
  99635. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  99636. /**
  99637. * Start all animations on given targets
  99638. * @param loop defines if animations must loop
  99639. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  99640. * @param from defines the from key (optional)
  99641. * @param to defines the to key (optional)
  99642. * @returns the current animation group
  99643. */
  99644. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  99645. /**
  99646. * Pause all animations
  99647. * @returns the animation group
  99648. */
  99649. pause(): AnimationGroup;
  99650. /**
  99651. * Play all animations to initial state
  99652. * This function will start() the animations if they were not started or will restart() them if they were paused
  99653. * @param loop defines if animations must loop
  99654. * @returns the animation group
  99655. */
  99656. play(loop?: boolean): AnimationGroup;
  99657. /**
  99658. * Reset all animations to initial state
  99659. * @returns the animation group
  99660. */
  99661. reset(): AnimationGroup;
  99662. /**
  99663. * Restart animations from key 0
  99664. * @returns the animation group
  99665. */
  99666. restart(): AnimationGroup;
  99667. /**
  99668. * Stop all animations
  99669. * @returns the animation group
  99670. */
  99671. stop(): AnimationGroup;
  99672. /**
  99673. * Set animation weight for all animatables
  99674. * @param weight defines the weight to use
  99675. * @return the animationGroup
  99676. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  99677. */
  99678. setWeightForAllAnimatables(weight: number): AnimationGroup;
  99679. /**
  99680. * Synchronize and normalize all animatables with a source animatable
  99681. * @param root defines the root animatable to synchronize with
  99682. * @return the animationGroup
  99683. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  99684. */
  99685. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  99686. /**
  99687. * Goes to a specific frame in this animation group
  99688. * @param frame the frame number to go to
  99689. * @return the animationGroup
  99690. */
  99691. goToFrame(frame: number): AnimationGroup;
  99692. /**
  99693. * Dispose all associated resources
  99694. */
  99695. dispose(): void;
  99696. private _checkAnimationGroupEnded;
  99697. /**
  99698. * Clone the current animation group and returns a copy
  99699. * @param newName defines the name of the new group
  99700. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  99701. * @returns the new aniamtion group
  99702. */
  99703. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  99704. /**
  99705. * Serializes the animationGroup to an object
  99706. * @returns Serialized object
  99707. */
  99708. serialize(): any;
  99709. /**
  99710. * Returns a new AnimationGroup object parsed from the source provided.
  99711. * @param parsedAnimationGroup defines the source
  99712. * @param scene defines the scene that will receive the animationGroup
  99713. * @returns a new AnimationGroup
  99714. */
  99715. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  99716. /**
  99717. * Returns the string "AnimationGroup"
  99718. * @returns "AnimationGroup"
  99719. */
  99720. getClassName(): string;
  99721. /**
  99722. * Creates a detailled string about the object
  99723. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  99724. * @returns a string representing the object
  99725. */
  99726. toString(fullDetails?: boolean): string;
  99727. }
  99728. }
  99729. declare module BABYLON {
  99730. /**
  99731. * Define an interface for all classes that will hold resources
  99732. */
  99733. export interface IDisposable {
  99734. /**
  99735. * Releases all held resources
  99736. */
  99737. dispose(): void;
  99738. }
  99739. /** Interface defining initialization parameters for Scene class */
  99740. export interface SceneOptions {
  99741. /**
  99742. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  99743. * It will improve performance when the number of geometries becomes important.
  99744. */
  99745. useGeometryUniqueIdsMap?: boolean;
  99746. /**
  99747. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  99748. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  99749. */
  99750. useMaterialMeshMap?: boolean;
  99751. /**
  99752. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  99753. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  99754. */
  99755. useClonedMeshhMap?: boolean;
  99756. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  99757. virtual?: boolean;
  99758. }
  99759. /**
  99760. * Represents a scene to be rendered by the engine.
  99761. * @see http://doc.babylonjs.com/features/scene
  99762. */
  99763. export class Scene extends AbstractScene implements IAnimatable {
  99764. /** The fog is deactivated */
  99765. static readonly FOGMODE_NONE: number;
  99766. /** The fog density is following an exponential function */
  99767. static readonly FOGMODE_EXP: number;
  99768. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  99769. static readonly FOGMODE_EXP2: number;
  99770. /** The fog density is following a linear function. */
  99771. static readonly FOGMODE_LINEAR: number;
  99772. /**
  99773. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  99774. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99775. */
  99776. static MinDeltaTime: number;
  99777. /**
  99778. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  99779. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99780. */
  99781. static MaxDeltaTime: number;
  99782. /**
  99783. * Factory used to create the default material.
  99784. * @param name The name of the material to create
  99785. * @param scene The scene to create the material for
  99786. * @returns The default material
  99787. */
  99788. static DefaultMaterialFactory(scene: Scene): Material;
  99789. /**
  99790. * Factory used to create the a collision coordinator.
  99791. * @returns The collision coordinator
  99792. */
  99793. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  99794. /** @hidden */
  99795. _inputManager: InputManager;
  99796. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  99797. cameraToUseForPointers: Nullable<Camera>;
  99798. /** @hidden */
  99799. readonly _isScene: boolean;
  99800. /**
  99801. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  99802. */
  99803. autoClear: boolean;
  99804. /**
  99805. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  99806. */
  99807. autoClearDepthAndStencil: boolean;
  99808. /**
  99809. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  99810. */
  99811. clearColor: Color4;
  99812. /**
  99813. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  99814. */
  99815. ambientColor: Color3;
  99816. /**
  99817. * This is use to store the default BRDF lookup for PBR materials in your scene.
  99818. * It should only be one of the following (if not the default embedded one):
  99819. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  99820. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  99821. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  99822. * The material properties need to be setup according to the type of texture in use.
  99823. */
  99824. environmentBRDFTexture: BaseTexture;
  99825. /** @hidden */
  99826. protected _environmentTexture: Nullable<BaseTexture>;
  99827. /**
  99828. * Texture used in all pbr material as the reflection texture.
  99829. * As in the majority of the scene they are the same (exception for multi room and so on),
  99830. * this is easier to reference from here than from all the materials.
  99831. */
  99832. /**
  99833. * Texture used in all pbr material as the reflection texture.
  99834. * As in the majority of the scene they are the same (exception for multi room and so on),
  99835. * this is easier to set here than in all the materials.
  99836. */
  99837. environmentTexture: Nullable<BaseTexture>;
  99838. /** @hidden */
  99839. protected _environmentIntensity: number;
  99840. /**
  99841. * Intensity of the environment in all pbr material.
  99842. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  99843. * As in the majority of the scene they are the same (exception for multi room and so on),
  99844. * this is easier to reference from here than from all the materials.
  99845. */
  99846. /**
  99847. * Intensity of the environment in all pbr material.
  99848. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  99849. * As in the majority of the scene they are the same (exception for multi room and so on),
  99850. * this is easier to set here than in all the materials.
  99851. */
  99852. environmentIntensity: number;
  99853. /** @hidden */
  99854. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  99855. /**
  99856. * Default image processing configuration used either in the rendering
  99857. * Forward main pass or through the imageProcessingPostProcess if present.
  99858. * As in the majority of the scene they are the same (exception for multi camera),
  99859. * this is easier to reference from here than from all the materials and post process.
  99860. *
  99861. * No setter as we it is a shared configuration, you can set the values instead.
  99862. */
  99863. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  99864. private _forceWireframe;
  99865. /**
  99866. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  99867. */
  99868. forceWireframe: boolean;
  99869. private _forcePointsCloud;
  99870. /**
  99871. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  99872. */
  99873. forcePointsCloud: boolean;
  99874. /**
  99875. * Gets or sets the active clipplane 1
  99876. */
  99877. clipPlane: Nullable<Plane>;
  99878. /**
  99879. * Gets or sets the active clipplane 2
  99880. */
  99881. clipPlane2: Nullable<Plane>;
  99882. /**
  99883. * Gets or sets the active clipplane 3
  99884. */
  99885. clipPlane3: Nullable<Plane>;
  99886. /**
  99887. * Gets or sets the active clipplane 4
  99888. */
  99889. clipPlane4: Nullable<Plane>;
  99890. /**
  99891. * Gets or sets a boolean indicating if animations are enabled
  99892. */
  99893. animationsEnabled: boolean;
  99894. private _animationPropertiesOverride;
  99895. /**
  99896. * Gets or sets the animation properties override
  99897. */
  99898. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  99899. /**
  99900. * Gets or sets a boolean indicating if a constant deltatime has to be used
  99901. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  99902. */
  99903. useConstantAnimationDeltaTime: boolean;
  99904. /**
  99905. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  99906. * Please note that it requires to run a ray cast through the scene on every frame
  99907. */
  99908. constantlyUpdateMeshUnderPointer: boolean;
  99909. /**
  99910. * Defines the HTML cursor to use when hovering over interactive elements
  99911. */
  99912. hoverCursor: string;
  99913. /**
  99914. * Defines the HTML default cursor to use (empty by default)
  99915. */
  99916. defaultCursor: string;
  99917. /**
  99918. * This is used to call preventDefault() on pointer down
  99919. * in order to block unwanted artifacts like system double clicks
  99920. */
  99921. preventDefaultOnPointerDown: boolean;
  99922. /**
  99923. * This is used to call preventDefault() on pointer up
  99924. * in order to block unwanted artifacts like system double clicks
  99925. */
  99926. preventDefaultOnPointerUp: boolean;
  99927. /**
  99928. * Gets or sets user defined metadata
  99929. */
  99930. metadata: any;
  99931. /**
  99932. * For internal use only. Please do not use.
  99933. */
  99934. reservedDataStore: any;
  99935. /**
  99936. * Gets the name of the plugin used to load this scene (null by default)
  99937. */
  99938. loadingPluginName: string;
  99939. /**
  99940. * Use this array to add regular expressions used to disable offline support for specific urls
  99941. */
  99942. disableOfflineSupportExceptionRules: RegExp[];
  99943. /**
  99944. * An event triggered when the scene is disposed.
  99945. */
  99946. onDisposeObservable: Observable<Scene>;
  99947. private _onDisposeObserver;
  99948. /** Sets a function to be executed when this scene is disposed. */
  99949. onDispose: () => void;
  99950. /**
  99951. * An event triggered before rendering the scene (right after animations and physics)
  99952. */
  99953. onBeforeRenderObservable: Observable<Scene>;
  99954. private _onBeforeRenderObserver;
  99955. /** Sets a function to be executed before rendering this scene */
  99956. beforeRender: Nullable<() => void>;
  99957. /**
  99958. * An event triggered after rendering the scene
  99959. */
  99960. onAfterRenderObservable: Observable<Scene>;
  99961. /**
  99962. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  99963. */
  99964. onAfterRenderCameraObservable: Observable<Camera>;
  99965. private _onAfterRenderObserver;
  99966. /** Sets a function to be executed after rendering this scene */
  99967. afterRender: Nullable<() => void>;
  99968. /**
  99969. * An event triggered before animating the scene
  99970. */
  99971. onBeforeAnimationsObservable: Observable<Scene>;
  99972. /**
  99973. * An event triggered after animations processing
  99974. */
  99975. onAfterAnimationsObservable: Observable<Scene>;
  99976. /**
  99977. * An event triggered before draw calls are ready to be sent
  99978. */
  99979. onBeforeDrawPhaseObservable: Observable<Scene>;
  99980. /**
  99981. * An event triggered after draw calls have been sent
  99982. */
  99983. onAfterDrawPhaseObservable: Observable<Scene>;
  99984. /**
  99985. * An event triggered when the scene is ready
  99986. */
  99987. onReadyObservable: Observable<Scene>;
  99988. /**
  99989. * An event triggered before rendering a camera
  99990. */
  99991. onBeforeCameraRenderObservable: Observable<Camera>;
  99992. private _onBeforeCameraRenderObserver;
  99993. /** Sets a function to be executed before rendering a camera*/
  99994. beforeCameraRender: () => void;
  99995. /**
  99996. * An event triggered after rendering a camera
  99997. */
  99998. onAfterCameraRenderObservable: Observable<Camera>;
  99999. private _onAfterCameraRenderObserver;
  100000. /** Sets a function to be executed after rendering a camera*/
  100001. afterCameraRender: () => void;
  100002. /**
  100003. * An event triggered when active meshes evaluation is about to start
  100004. */
  100005. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  100006. /**
  100007. * An event triggered when active meshes evaluation is done
  100008. */
  100009. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  100010. /**
  100011. * An event triggered when particles rendering is about to start
  100012. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  100013. */
  100014. onBeforeParticlesRenderingObservable: Observable<Scene>;
  100015. /**
  100016. * An event triggered when particles rendering is done
  100017. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  100018. */
  100019. onAfterParticlesRenderingObservable: Observable<Scene>;
  100020. /**
  100021. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  100022. */
  100023. onDataLoadedObservable: Observable<Scene>;
  100024. /**
  100025. * An event triggered when a camera is created
  100026. */
  100027. onNewCameraAddedObservable: Observable<Camera>;
  100028. /**
  100029. * An event triggered when a camera is removed
  100030. */
  100031. onCameraRemovedObservable: Observable<Camera>;
  100032. /**
  100033. * An event triggered when a light is created
  100034. */
  100035. onNewLightAddedObservable: Observable<Light>;
  100036. /**
  100037. * An event triggered when a light is removed
  100038. */
  100039. onLightRemovedObservable: Observable<Light>;
  100040. /**
  100041. * An event triggered when a geometry is created
  100042. */
  100043. onNewGeometryAddedObservable: Observable<Geometry>;
  100044. /**
  100045. * An event triggered when a geometry is removed
  100046. */
  100047. onGeometryRemovedObservable: Observable<Geometry>;
  100048. /**
  100049. * An event triggered when a transform node is created
  100050. */
  100051. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  100052. /**
  100053. * An event triggered when a transform node is removed
  100054. */
  100055. onTransformNodeRemovedObservable: Observable<TransformNode>;
  100056. /**
  100057. * An event triggered when a mesh is created
  100058. */
  100059. onNewMeshAddedObservable: Observable<AbstractMesh>;
  100060. /**
  100061. * An event triggered when a mesh is removed
  100062. */
  100063. onMeshRemovedObservable: Observable<AbstractMesh>;
  100064. /**
  100065. * An event triggered when a skeleton is created
  100066. */
  100067. onNewSkeletonAddedObservable: Observable<Skeleton>;
  100068. /**
  100069. * An event triggered when a skeleton is removed
  100070. */
  100071. onSkeletonRemovedObservable: Observable<Skeleton>;
  100072. /**
  100073. * An event triggered when a material is created
  100074. */
  100075. onNewMaterialAddedObservable: Observable<Material>;
  100076. /**
  100077. * An event triggered when a material is removed
  100078. */
  100079. onMaterialRemovedObservable: Observable<Material>;
  100080. /**
  100081. * An event triggered when a texture is created
  100082. */
  100083. onNewTextureAddedObservable: Observable<BaseTexture>;
  100084. /**
  100085. * An event triggered when a texture is removed
  100086. */
  100087. onTextureRemovedObservable: Observable<BaseTexture>;
  100088. /**
  100089. * An event triggered when render targets are about to be rendered
  100090. * Can happen multiple times per frame.
  100091. */
  100092. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  100093. /**
  100094. * An event triggered when render targets were rendered.
  100095. * Can happen multiple times per frame.
  100096. */
  100097. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  100098. /**
  100099. * An event triggered before calculating deterministic simulation step
  100100. */
  100101. onBeforeStepObservable: Observable<Scene>;
  100102. /**
  100103. * An event triggered after calculating deterministic simulation step
  100104. */
  100105. onAfterStepObservable: Observable<Scene>;
  100106. /**
  100107. * An event triggered when the activeCamera property is updated
  100108. */
  100109. onActiveCameraChanged: Observable<Scene>;
  100110. /**
  100111. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  100112. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  100113. * 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)
  100114. */
  100115. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  100116. /**
  100117. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  100118. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  100119. * 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)
  100120. */
  100121. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  100122. /**
  100123. * This Observable will when a mesh has been imported into the scene.
  100124. */
  100125. onMeshImportedObservable: Observable<AbstractMesh>;
  100126. /**
  100127. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  100128. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  100129. */
  100130. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  100131. /** @hidden */
  100132. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  100133. /**
  100134. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  100135. */
  100136. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  100137. /**
  100138. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  100139. */
  100140. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  100141. /**
  100142. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  100143. */
  100144. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  100145. /** Callback called when a pointer move is detected */
  100146. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  100147. /** Callback called when a pointer down is detected */
  100148. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  100149. /** Callback called when a pointer up is detected */
  100150. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  100151. /** Callback called when a pointer pick is detected */
  100152. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  100153. /**
  100154. * 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).
  100155. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  100156. */
  100157. onPrePointerObservable: Observable<PointerInfoPre>;
  100158. /**
  100159. * Observable event triggered each time an input event is received from the rendering canvas
  100160. */
  100161. onPointerObservable: Observable<PointerInfo>;
  100162. /**
  100163. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  100164. */
  100165. readonly unTranslatedPointer: Vector2;
  100166. /**
  100167. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  100168. */
  100169. static DragMovementThreshold: number;
  100170. /**
  100171. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  100172. */
  100173. static LongPressDelay: number;
  100174. /**
  100175. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  100176. */
  100177. static DoubleClickDelay: number;
  100178. /** If you need to check double click without raising a single click at first click, enable this flag */
  100179. static ExclusiveDoubleClickMode: boolean;
  100180. /** @hidden */
  100181. _mirroredCameraPosition: Nullable<Vector3>;
  100182. /**
  100183. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  100184. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  100185. */
  100186. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  100187. /**
  100188. * Observable event triggered each time an keyboard event is received from the hosting window
  100189. */
  100190. onKeyboardObservable: Observable<KeyboardInfo>;
  100191. private _useRightHandedSystem;
  100192. /**
  100193. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  100194. */
  100195. useRightHandedSystem: boolean;
  100196. private _timeAccumulator;
  100197. private _currentStepId;
  100198. private _currentInternalStep;
  100199. /**
  100200. * Sets the step Id used by deterministic lock step
  100201. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100202. * @param newStepId defines the step Id
  100203. */
  100204. setStepId(newStepId: number): void;
  100205. /**
  100206. * Gets the step Id used by deterministic lock step
  100207. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100208. * @returns the step Id
  100209. */
  100210. getStepId(): number;
  100211. /**
  100212. * Gets the internal step used by deterministic lock step
  100213. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100214. * @returns the internal step
  100215. */
  100216. getInternalStep(): number;
  100217. private _fogEnabled;
  100218. /**
  100219. * Gets or sets a boolean indicating if fog is enabled on this scene
  100220. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100221. * (Default is true)
  100222. */
  100223. fogEnabled: boolean;
  100224. private _fogMode;
  100225. /**
  100226. * Gets or sets the fog mode to use
  100227. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100228. * | mode | value |
  100229. * | --- | --- |
  100230. * | FOGMODE_NONE | 0 |
  100231. * | FOGMODE_EXP | 1 |
  100232. * | FOGMODE_EXP2 | 2 |
  100233. * | FOGMODE_LINEAR | 3 |
  100234. */
  100235. fogMode: number;
  100236. /**
  100237. * Gets or sets the fog color to use
  100238. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100239. * (Default is Color3(0.2, 0.2, 0.3))
  100240. */
  100241. fogColor: Color3;
  100242. /**
  100243. * Gets or sets the fog density to use
  100244. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100245. * (Default is 0.1)
  100246. */
  100247. fogDensity: number;
  100248. /**
  100249. * Gets or sets the fog start distance to use
  100250. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100251. * (Default is 0)
  100252. */
  100253. fogStart: number;
  100254. /**
  100255. * Gets or sets the fog end distance to use
  100256. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100257. * (Default is 1000)
  100258. */
  100259. fogEnd: number;
  100260. private _shadowsEnabled;
  100261. /**
  100262. * Gets or sets a boolean indicating if shadows are enabled on this scene
  100263. */
  100264. shadowsEnabled: boolean;
  100265. private _lightsEnabled;
  100266. /**
  100267. * Gets or sets a boolean indicating if lights are enabled on this scene
  100268. */
  100269. lightsEnabled: boolean;
  100270. /** All of the active cameras added to this scene. */
  100271. activeCameras: Camera[];
  100272. /** @hidden */
  100273. _activeCamera: Nullable<Camera>;
  100274. /** Gets or sets the current active camera */
  100275. activeCamera: Nullable<Camera>;
  100276. private _defaultMaterial;
  100277. /** The default material used on meshes when no material is affected */
  100278. /** The default material used on meshes when no material is affected */
  100279. defaultMaterial: Material;
  100280. private _texturesEnabled;
  100281. /**
  100282. * Gets or sets a boolean indicating if textures are enabled on this scene
  100283. */
  100284. texturesEnabled: boolean;
  100285. /**
  100286. * Gets or sets a boolean indicating if particles are enabled on this scene
  100287. */
  100288. particlesEnabled: boolean;
  100289. /**
  100290. * Gets or sets a boolean indicating if sprites are enabled on this scene
  100291. */
  100292. spritesEnabled: boolean;
  100293. private _skeletonsEnabled;
  100294. /**
  100295. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  100296. */
  100297. skeletonsEnabled: boolean;
  100298. /**
  100299. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  100300. */
  100301. lensFlaresEnabled: boolean;
  100302. /**
  100303. * Gets or sets a boolean indicating if collisions are enabled on this scene
  100304. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  100305. */
  100306. collisionsEnabled: boolean;
  100307. private _collisionCoordinator;
  100308. /** @hidden */
  100309. readonly collisionCoordinator: ICollisionCoordinator;
  100310. /**
  100311. * Defines the gravity applied to this scene (used only for collisions)
  100312. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  100313. */
  100314. gravity: Vector3;
  100315. /**
  100316. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  100317. */
  100318. postProcessesEnabled: boolean;
  100319. /**
  100320. * The list of postprocesses added to the scene
  100321. */
  100322. postProcesses: PostProcess[];
  100323. /**
  100324. * Gets the current postprocess manager
  100325. */
  100326. postProcessManager: PostProcessManager;
  100327. /**
  100328. * Gets or sets a boolean indicating if render targets are enabled on this scene
  100329. */
  100330. renderTargetsEnabled: boolean;
  100331. /**
  100332. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  100333. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  100334. */
  100335. dumpNextRenderTargets: boolean;
  100336. /**
  100337. * The list of user defined render targets added to the scene
  100338. */
  100339. customRenderTargets: RenderTargetTexture[];
  100340. /**
  100341. * Defines if texture loading must be delayed
  100342. * If true, textures will only be loaded when they need to be rendered
  100343. */
  100344. useDelayedTextureLoading: boolean;
  100345. /**
  100346. * Gets the list of meshes imported to the scene through SceneLoader
  100347. */
  100348. importedMeshesFiles: String[];
  100349. /**
  100350. * Gets or sets a boolean indicating if probes are enabled on this scene
  100351. */
  100352. probesEnabled: boolean;
  100353. /**
  100354. * Gets or sets the current offline provider to use to store scene data
  100355. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  100356. */
  100357. offlineProvider: IOfflineProvider;
  100358. /**
  100359. * Gets or sets the action manager associated with the scene
  100360. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  100361. */
  100362. actionManager: AbstractActionManager;
  100363. private _meshesForIntersections;
  100364. /**
  100365. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  100366. */
  100367. proceduralTexturesEnabled: boolean;
  100368. private _engine;
  100369. private _totalVertices;
  100370. /** @hidden */
  100371. _activeIndices: PerfCounter;
  100372. /** @hidden */
  100373. _activeParticles: PerfCounter;
  100374. /** @hidden */
  100375. _activeBones: PerfCounter;
  100376. private _animationRatio;
  100377. /** @hidden */
  100378. _animationTimeLast: number;
  100379. /** @hidden */
  100380. _animationTime: number;
  100381. /**
  100382. * Gets or sets a general scale for animation speed
  100383. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  100384. */
  100385. animationTimeScale: number;
  100386. /** @hidden */
  100387. _cachedMaterial: Nullable<Material>;
  100388. /** @hidden */
  100389. _cachedEffect: Nullable<Effect>;
  100390. /** @hidden */
  100391. _cachedVisibility: Nullable<number>;
  100392. private _renderId;
  100393. private _frameId;
  100394. private _executeWhenReadyTimeoutId;
  100395. private _intermediateRendering;
  100396. private _viewUpdateFlag;
  100397. private _projectionUpdateFlag;
  100398. /** @hidden */
  100399. _toBeDisposed: Nullable<IDisposable>[];
  100400. private _activeRequests;
  100401. /** @hidden */
  100402. _pendingData: any[];
  100403. private _isDisposed;
  100404. /**
  100405. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  100406. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  100407. */
  100408. dispatchAllSubMeshesOfActiveMeshes: boolean;
  100409. private _activeMeshes;
  100410. private _processedMaterials;
  100411. private _renderTargets;
  100412. /** @hidden */
  100413. _activeParticleSystems: SmartArray<IParticleSystem>;
  100414. private _activeSkeletons;
  100415. private _softwareSkinnedMeshes;
  100416. private _renderingManager;
  100417. /** @hidden */
  100418. _activeAnimatables: Animatable[];
  100419. private _transformMatrix;
  100420. private _sceneUbo;
  100421. /** @hidden */
  100422. _viewMatrix: Matrix;
  100423. private _projectionMatrix;
  100424. /** @hidden */
  100425. _forcedViewPosition: Nullable<Vector3>;
  100426. /** @hidden */
  100427. _frustumPlanes: Plane[];
  100428. /**
  100429. * Gets the list of frustum planes (built from the active camera)
  100430. */
  100431. readonly frustumPlanes: Plane[];
  100432. /**
  100433. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  100434. * This is useful if there are more lights that the maximum simulteanous authorized
  100435. */
  100436. requireLightSorting: boolean;
  100437. /** @hidden */
  100438. readonly useMaterialMeshMap: boolean;
  100439. /** @hidden */
  100440. readonly useClonedMeshhMap: boolean;
  100441. private _externalData;
  100442. private _uid;
  100443. /**
  100444. * @hidden
  100445. * Backing store of defined scene components.
  100446. */
  100447. _components: ISceneComponent[];
  100448. /**
  100449. * @hidden
  100450. * Backing store of defined scene components.
  100451. */
  100452. _serializableComponents: ISceneSerializableComponent[];
  100453. /**
  100454. * List of components to register on the next registration step.
  100455. */
  100456. private _transientComponents;
  100457. /**
  100458. * Registers the transient components if needed.
  100459. */
  100460. private _registerTransientComponents;
  100461. /**
  100462. * @hidden
  100463. * Add a component to the scene.
  100464. * Note that the ccomponent could be registered on th next frame if this is called after
  100465. * the register component stage.
  100466. * @param component Defines the component to add to the scene
  100467. */
  100468. _addComponent(component: ISceneComponent): void;
  100469. /**
  100470. * @hidden
  100471. * Gets a component from the scene.
  100472. * @param name defines the name of the component to retrieve
  100473. * @returns the component or null if not present
  100474. */
  100475. _getComponent(name: string): Nullable<ISceneComponent>;
  100476. /**
  100477. * @hidden
  100478. * Defines the actions happening before camera updates.
  100479. */
  100480. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  100481. /**
  100482. * @hidden
  100483. * Defines the actions happening before clear the canvas.
  100484. */
  100485. _beforeClearStage: Stage<SimpleStageAction>;
  100486. /**
  100487. * @hidden
  100488. * Defines the actions when collecting render targets for the frame.
  100489. */
  100490. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  100491. /**
  100492. * @hidden
  100493. * Defines the actions happening for one camera in the frame.
  100494. */
  100495. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  100496. /**
  100497. * @hidden
  100498. * Defines the actions happening during the per mesh ready checks.
  100499. */
  100500. _isReadyForMeshStage: Stage<MeshStageAction>;
  100501. /**
  100502. * @hidden
  100503. * Defines the actions happening before evaluate active mesh checks.
  100504. */
  100505. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  100506. /**
  100507. * @hidden
  100508. * Defines the actions happening during the evaluate sub mesh checks.
  100509. */
  100510. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  100511. /**
  100512. * @hidden
  100513. * Defines the actions happening during the active mesh stage.
  100514. */
  100515. _activeMeshStage: Stage<ActiveMeshStageAction>;
  100516. /**
  100517. * @hidden
  100518. * Defines the actions happening during the per camera render target step.
  100519. */
  100520. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  100521. /**
  100522. * @hidden
  100523. * Defines the actions happening just before the active camera is drawing.
  100524. */
  100525. _beforeCameraDrawStage: Stage<CameraStageAction>;
  100526. /**
  100527. * @hidden
  100528. * Defines the actions happening just before a render target is drawing.
  100529. */
  100530. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  100531. /**
  100532. * @hidden
  100533. * Defines the actions happening just before a rendering group is drawing.
  100534. */
  100535. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  100536. /**
  100537. * @hidden
  100538. * Defines the actions happening just before a mesh is drawing.
  100539. */
  100540. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  100541. /**
  100542. * @hidden
  100543. * Defines the actions happening just after a mesh has been drawn.
  100544. */
  100545. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  100546. /**
  100547. * @hidden
  100548. * Defines the actions happening just after a rendering group has been drawn.
  100549. */
  100550. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  100551. /**
  100552. * @hidden
  100553. * Defines the actions happening just after the active camera has been drawn.
  100554. */
  100555. _afterCameraDrawStage: Stage<CameraStageAction>;
  100556. /**
  100557. * @hidden
  100558. * Defines the actions happening just after a render target has been drawn.
  100559. */
  100560. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  100561. /**
  100562. * @hidden
  100563. * Defines the actions happening just after rendering all cameras and computing intersections.
  100564. */
  100565. _afterRenderStage: Stage<SimpleStageAction>;
  100566. /**
  100567. * @hidden
  100568. * Defines the actions happening when a pointer move event happens.
  100569. */
  100570. _pointerMoveStage: Stage<PointerMoveStageAction>;
  100571. /**
  100572. * @hidden
  100573. * Defines the actions happening when a pointer down event happens.
  100574. */
  100575. _pointerDownStage: Stage<PointerUpDownStageAction>;
  100576. /**
  100577. * @hidden
  100578. * Defines the actions happening when a pointer up event happens.
  100579. */
  100580. _pointerUpStage: Stage<PointerUpDownStageAction>;
  100581. /**
  100582. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  100583. */
  100584. private geometriesByUniqueId;
  100585. /**
  100586. * Creates a new Scene
  100587. * @param engine defines the engine to use to render this scene
  100588. * @param options defines the scene options
  100589. */
  100590. constructor(engine: Engine, options?: SceneOptions);
  100591. /**
  100592. * Gets a string idenfifying the name of the class
  100593. * @returns "Scene" string
  100594. */
  100595. getClassName(): string;
  100596. private _defaultMeshCandidates;
  100597. /**
  100598. * @hidden
  100599. */
  100600. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  100601. private _defaultSubMeshCandidates;
  100602. /**
  100603. * @hidden
  100604. */
  100605. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  100606. /**
  100607. * Sets the default candidate providers for the scene.
  100608. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  100609. * and getCollidingSubMeshCandidates to their default function
  100610. */
  100611. setDefaultCandidateProviders(): void;
  100612. /**
  100613. * Gets the mesh that is currently under the pointer
  100614. */
  100615. readonly meshUnderPointer: Nullable<AbstractMesh>;
  100616. /**
  100617. * Gets or sets the current on-screen X position of the pointer
  100618. */
  100619. pointerX: number;
  100620. /**
  100621. * Gets or sets the current on-screen Y position of the pointer
  100622. */
  100623. pointerY: number;
  100624. /**
  100625. * Gets the cached material (ie. the latest rendered one)
  100626. * @returns the cached material
  100627. */
  100628. getCachedMaterial(): Nullable<Material>;
  100629. /**
  100630. * Gets the cached effect (ie. the latest rendered one)
  100631. * @returns the cached effect
  100632. */
  100633. getCachedEffect(): Nullable<Effect>;
  100634. /**
  100635. * Gets the cached visibility state (ie. the latest rendered one)
  100636. * @returns the cached visibility state
  100637. */
  100638. getCachedVisibility(): Nullable<number>;
  100639. /**
  100640. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  100641. * @param material defines the current material
  100642. * @param effect defines the current effect
  100643. * @param visibility defines the current visibility state
  100644. * @returns true if one parameter is not cached
  100645. */
  100646. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  100647. /**
  100648. * Gets the engine associated with the scene
  100649. * @returns an Engine
  100650. */
  100651. getEngine(): Engine;
  100652. /**
  100653. * Gets the total number of vertices rendered per frame
  100654. * @returns the total number of vertices rendered per frame
  100655. */
  100656. getTotalVertices(): number;
  100657. /**
  100658. * Gets the performance counter for total vertices
  100659. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  100660. */
  100661. readonly totalVerticesPerfCounter: PerfCounter;
  100662. /**
  100663. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  100664. * @returns the total number of active indices rendered per frame
  100665. */
  100666. getActiveIndices(): number;
  100667. /**
  100668. * Gets the performance counter for active indices
  100669. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  100670. */
  100671. readonly totalActiveIndicesPerfCounter: PerfCounter;
  100672. /**
  100673. * Gets the total number of active particles rendered per frame
  100674. * @returns the total number of active particles rendered per frame
  100675. */
  100676. getActiveParticles(): number;
  100677. /**
  100678. * Gets the performance counter for active particles
  100679. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  100680. */
  100681. readonly activeParticlesPerfCounter: PerfCounter;
  100682. /**
  100683. * Gets the total number of active bones rendered per frame
  100684. * @returns the total number of active bones rendered per frame
  100685. */
  100686. getActiveBones(): number;
  100687. /**
  100688. * Gets the performance counter for active bones
  100689. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  100690. */
  100691. readonly activeBonesPerfCounter: PerfCounter;
  100692. /**
  100693. * Gets the array of active meshes
  100694. * @returns an array of AbstractMesh
  100695. */
  100696. getActiveMeshes(): SmartArray<AbstractMesh>;
  100697. /**
  100698. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  100699. * @returns a number
  100700. */
  100701. getAnimationRatio(): number;
  100702. /**
  100703. * Gets an unique Id for the current render phase
  100704. * @returns a number
  100705. */
  100706. getRenderId(): number;
  100707. /**
  100708. * Gets an unique Id for the current frame
  100709. * @returns a number
  100710. */
  100711. getFrameId(): number;
  100712. /** Call this function if you want to manually increment the render Id*/
  100713. incrementRenderId(): void;
  100714. private _createUbo;
  100715. /**
  100716. * Use this method to simulate a pointer move on a mesh
  100717. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  100718. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  100719. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  100720. * @returns the current scene
  100721. */
  100722. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  100723. /**
  100724. * Use this method to simulate a pointer down on a mesh
  100725. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  100726. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  100727. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  100728. * @returns the current scene
  100729. */
  100730. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  100731. /**
  100732. * Use this method to simulate a pointer up on a mesh
  100733. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  100734. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  100735. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  100736. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  100737. * @returns the current scene
  100738. */
  100739. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  100740. /**
  100741. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  100742. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  100743. * @returns true if the pointer was captured
  100744. */
  100745. isPointerCaptured(pointerId?: number): boolean;
  100746. /**
  100747. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  100748. * @param attachUp defines if you want to attach events to pointerup
  100749. * @param attachDown defines if you want to attach events to pointerdown
  100750. * @param attachMove defines if you want to attach events to pointermove
  100751. */
  100752. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  100753. /** Detaches all event handlers*/
  100754. detachControl(): void;
  100755. /**
  100756. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  100757. * Delay loaded resources are not taking in account
  100758. * @return true if all required resources are ready
  100759. */
  100760. isReady(): boolean;
  100761. /** Resets all cached information relative to material (including effect and visibility) */
  100762. resetCachedMaterial(): void;
  100763. /**
  100764. * Registers a function to be called before every frame render
  100765. * @param func defines the function to register
  100766. */
  100767. registerBeforeRender(func: () => void): void;
  100768. /**
  100769. * Unregisters a function called before every frame render
  100770. * @param func defines the function to unregister
  100771. */
  100772. unregisterBeforeRender(func: () => void): void;
  100773. /**
  100774. * Registers a function to be called after every frame render
  100775. * @param func defines the function to register
  100776. */
  100777. registerAfterRender(func: () => void): void;
  100778. /**
  100779. * Unregisters a function called after every frame render
  100780. * @param func defines the function to unregister
  100781. */
  100782. unregisterAfterRender(func: () => void): void;
  100783. private _executeOnceBeforeRender;
  100784. /**
  100785. * The provided function will run before render once and will be disposed afterwards.
  100786. * A timeout delay can be provided so that the function will be executed in N ms.
  100787. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  100788. * @param func The function to be executed.
  100789. * @param timeout optional delay in ms
  100790. */
  100791. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  100792. /** @hidden */
  100793. _addPendingData(data: any): void;
  100794. /** @hidden */
  100795. _removePendingData(data: any): void;
  100796. /**
  100797. * Returns the number of items waiting to be loaded
  100798. * @returns the number of items waiting to be loaded
  100799. */
  100800. getWaitingItemsCount(): number;
  100801. /**
  100802. * Returns a boolean indicating if the scene is still loading data
  100803. */
  100804. readonly isLoading: boolean;
  100805. /**
  100806. * Registers a function to be executed when the scene is ready
  100807. * @param {Function} func - the function to be executed
  100808. */
  100809. executeWhenReady(func: () => void): void;
  100810. /**
  100811. * Returns a promise that resolves when the scene is ready
  100812. * @returns A promise that resolves when the scene is ready
  100813. */
  100814. whenReadyAsync(): Promise<void>;
  100815. /** @hidden */
  100816. _checkIsReady(): void;
  100817. /**
  100818. * Gets all animatable attached to the scene
  100819. */
  100820. readonly animatables: Animatable[];
  100821. /**
  100822. * Resets the last animation time frame.
  100823. * Useful to override when animations start running when loading a scene for the first time.
  100824. */
  100825. resetLastAnimationTimeFrame(): void;
  100826. /**
  100827. * Gets the current view matrix
  100828. * @returns a Matrix
  100829. */
  100830. getViewMatrix(): Matrix;
  100831. /**
  100832. * Gets the current projection matrix
  100833. * @returns a Matrix
  100834. */
  100835. getProjectionMatrix(): Matrix;
  100836. /**
  100837. * Gets the current transform matrix
  100838. * @returns a Matrix made of View * Projection
  100839. */
  100840. getTransformMatrix(): Matrix;
  100841. /**
  100842. * Sets the current transform matrix
  100843. * @param viewL defines the View matrix to use
  100844. * @param projectionL defines the Projection matrix to use
  100845. * @param viewR defines the right View matrix to use (if provided)
  100846. * @param projectionR defines the right Projection matrix to use (if provided)
  100847. */
  100848. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  100849. /**
  100850. * Gets the uniform buffer used to store scene data
  100851. * @returns a UniformBuffer
  100852. */
  100853. getSceneUniformBuffer(): UniformBuffer;
  100854. /**
  100855. * Gets an unique (relatively to the current scene) Id
  100856. * @returns an unique number for the scene
  100857. */
  100858. getUniqueId(): number;
  100859. /**
  100860. * Add a mesh to the list of scene's meshes
  100861. * @param newMesh defines the mesh to add
  100862. * @param recursive if all child meshes should also be added to the scene
  100863. */
  100864. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  100865. /**
  100866. * Remove a mesh for the list of scene's meshes
  100867. * @param toRemove defines the mesh to remove
  100868. * @param recursive if all child meshes should also be removed from the scene
  100869. * @returns the index where the mesh was in the mesh list
  100870. */
  100871. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  100872. /**
  100873. * Add a transform node to the list of scene's transform nodes
  100874. * @param newTransformNode defines the transform node to add
  100875. */
  100876. addTransformNode(newTransformNode: TransformNode): void;
  100877. /**
  100878. * Remove a transform node for the list of scene's transform nodes
  100879. * @param toRemove defines the transform node to remove
  100880. * @returns the index where the transform node was in the transform node list
  100881. */
  100882. removeTransformNode(toRemove: TransformNode): number;
  100883. /**
  100884. * Remove a skeleton for the list of scene's skeletons
  100885. * @param toRemove defines the skeleton to remove
  100886. * @returns the index where the skeleton was in the skeleton list
  100887. */
  100888. removeSkeleton(toRemove: Skeleton): number;
  100889. /**
  100890. * Remove a morph target for the list of scene's morph targets
  100891. * @param toRemove defines the morph target to remove
  100892. * @returns the index where the morph target was in the morph target list
  100893. */
  100894. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  100895. /**
  100896. * Remove a light for the list of scene's lights
  100897. * @param toRemove defines the light to remove
  100898. * @returns the index where the light was in the light list
  100899. */
  100900. removeLight(toRemove: Light): number;
  100901. /**
  100902. * Remove a camera for the list of scene's cameras
  100903. * @param toRemove defines the camera to remove
  100904. * @returns the index where the camera was in the camera list
  100905. */
  100906. removeCamera(toRemove: Camera): number;
  100907. /**
  100908. * Remove a particle system for the list of scene's particle systems
  100909. * @param toRemove defines the particle system to remove
  100910. * @returns the index where the particle system was in the particle system list
  100911. */
  100912. removeParticleSystem(toRemove: IParticleSystem): number;
  100913. /**
  100914. * Remove a animation for the list of scene's animations
  100915. * @param toRemove defines the animation to remove
  100916. * @returns the index where the animation was in the animation list
  100917. */
  100918. removeAnimation(toRemove: Animation): number;
  100919. /**
  100920. * Will stop the animation of the given target
  100921. * @param target - the target
  100922. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  100923. * @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)
  100924. */
  100925. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  100926. /**
  100927. * Removes the given animation group from this scene.
  100928. * @param toRemove The animation group to remove
  100929. * @returns The index of the removed animation group
  100930. */
  100931. removeAnimationGroup(toRemove: AnimationGroup): number;
  100932. /**
  100933. * Removes the given multi-material from this scene.
  100934. * @param toRemove The multi-material to remove
  100935. * @returns The index of the removed multi-material
  100936. */
  100937. removeMultiMaterial(toRemove: MultiMaterial): number;
  100938. /**
  100939. * Removes the given material from this scene.
  100940. * @param toRemove The material to remove
  100941. * @returns The index of the removed material
  100942. */
  100943. removeMaterial(toRemove: Material): number;
  100944. /**
  100945. * Removes the given action manager from this scene.
  100946. * @param toRemove The action manager to remove
  100947. * @returns The index of the removed action manager
  100948. */
  100949. removeActionManager(toRemove: AbstractActionManager): number;
  100950. /**
  100951. * Removes the given texture from this scene.
  100952. * @param toRemove The texture to remove
  100953. * @returns The index of the removed texture
  100954. */
  100955. removeTexture(toRemove: BaseTexture): number;
  100956. /**
  100957. * Adds the given light to this scene
  100958. * @param newLight The light to add
  100959. */
  100960. addLight(newLight: Light): void;
  100961. /**
  100962. * Sorts the list list based on light priorities
  100963. */
  100964. sortLightsByPriority(): void;
  100965. /**
  100966. * Adds the given camera to this scene
  100967. * @param newCamera The camera to add
  100968. */
  100969. addCamera(newCamera: Camera): void;
  100970. /**
  100971. * Adds the given skeleton to this scene
  100972. * @param newSkeleton The skeleton to add
  100973. */
  100974. addSkeleton(newSkeleton: Skeleton): void;
  100975. /**
  100976. * Adds the given particle system to this scene
  100977. * @param newParticleSystem The particle system to add
  100978. */
  100979. addParticleSystem(newParticleSystem: IParticleSystem): void;
  100980. /**
  100981. * Adds the given animation to this scene
  100982. * @param newAnimation The animation to add
  100983. */
  100984. addAnimation(newAnimation: Animation): void;
  100985. /**
  100986. * Adds the given animation group to this scene.
  100987. * @param newAnimationGroup The animation group to add
  100988. */
  100989. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  100990. /**
  100991. * Adds the given multi-material to this scene
  100992. * @param newMultiMaterial The multi-material to add
  100993. */
  100994. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  100995. /**
  100996. * Adds the given material to this scene
  100997. * @param newMaterial The material to add
  100998. */
  100999. addMaterial(newMaterial: Material): void;
  101000. /**
  101001. * Adds the given morph target to this scene
  101002. * @param newMorphTargetManager The morph target to add
  101003. */
  101004. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  101005. /**
  101006. * Adds the given geometry to this scene
  101007. * @param newGeometry The geometry to add
  101008. */
  101009. addGeometry(newGeometry: Geometry): void;
  101010. /**
  101011. * Adds the given action manager to this scene
  101012. * @param newActionManager The action manager to add
  101013. */
  101014. addActionManager(newActionManager: AbstractActionManager): void;
  101015. /**
  101016. * Adds the given texture to this scene.
  101017. * @param newTexture The texture to add
  101018. */
  101019. addTexture(newTexture: BaseTexture): void;
  101020. /**
  101021. * Switch active camera
  101022. * @param newCamera defines the new active camera
  101023. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  101024. */
  101025. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  101026. /**
  101027. * sets the active camera of the scene using its ID
  101028. * @param id defines the camera's ID
  101029. * @return the new active camera or null if none found.
  101030. */
  101031. setActiveCameraByID(id: string): Nullable<Camera>;
  101032. /**
  101033. * sets the active camera of the scene using its name
  101034. * @param name defines the camera's name
  101035. * @returns the new active camera or null if none found.
  101036. */
  101037. setActiveCameraByName(name: string): Nullable<Camera>;
  101038. /**
  101039. * get an animation group using its name
  101040. * @param name defines the material's name
  101041. * @return the animation group or null if none found.
  101042. */
  101043. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  101044. /**
  101045. * Get a material using its unique id
  101046. * @param uniqueId defines the material's unique id
  101047. * @return the material or null if none found.
  101048. */
  101049. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  101050. /**
  101051. * get a material using its id
  101052. * @param id defines the material's ID
  101053. * @return the material or null if none found.
  101054. */
  101055. getMaterialByID(id: string): Nullable<Material>;
  101056. /**
  101057. * Gets a the last added material using a given id
  101058. * @param id defines the material's ID
  101059. * @return the last material with the given id or null if none found.
  101060. */
  101061. getLastMaterialByID(id: string): Nullable<Material>;
  101062. /**
  101063. * Gets a material using its name
  101064. * @param name defines the material's name
  101065. * @return the material or null if none found.
  101066. */
  101067. getMaterialByName(name: string): Nullable<Material>;
  101068. /**
  101069. * Get a texture using its unique id
  101070. * @param uniqueId defines the texture's unique id
  101071. * @return the texture or null if none found.
  101072. */
  101073. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  101074. /**
  101075. * Gets a camera using its id
  101076. * @param id defines the id to look for
  101077. * @returns the camera or null if not found
  101078. */
  101079. getCameraByID(id: string): Nullable<Camera>;
  101080. /**
  101081. * Gets a camera using its unique id
  101082. * @param uniqueId defines the unique id to look for
  101083. * @returns the camera or null if not found
  101084. */
  101085. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  101086. /**
  101087. * Gets a camera using its name
  101088. * @param name defines the camera's name
  101089. * @return the camera or null if none found.
  101090. */
  101091. getCameraByName(name: string): Nullable<Camera>;
  101092. /**
  101093. * Gets a bone using its id
  101094. * @param id defines the bone's id
  101095. * @return the bone or null if not found
  101096. */
  101097. getBoneByID(id: string): Nullable<Bone>;
  101098. /**
  101099. * Gets a bone using its id
  101100. * @param name defines the bone's name
  101101. * @return the bone or null if not found
  101102. */
  101103. getBoneByName(name: string): Nullable<Bone>;
  101104. /**
  101105. * Gets a light node using its name
  101106. * @param name defines the the light's name
  101107. * @return the light or null if none found.
  101108. */
  101109. getLightByName(name: string): Nullable<Light>;
  101110. /**
  101111. * Gets a light node using its id
  101112. * @param id defines the light's id
  101113. * @return the light or null if none found.
  101114. */
  101115. getLightByID(id: string): Nullable<Light>;
  101116. /**
  101117. * Gets a light node using its scene-generated unique ID
  101118. * @param uniqueId defines the light's unique id
  101119. * @return the light or null if none found.
  101120. */
  101121. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  101122. /**
  101123. * Gets a particle system by id
  101124. * @param id defines the particle system id
  101125. * @return the corresponding system or null if none found
  101126. */
  101127. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  101128. /**
  101129. * Gets a geometry using its ID
  101130. * @param id defines the geometry's id
  101131. * @return the geometry or null if none found.
  101132. */
  101133. getGeometryByID(id: string): Nullable<Geometry>;
  101134. private _getGeometryByUniqueID;
  101135. /**
  101136. * Add a new geometry to this scene
  101137. * @param geometry defines the geometry to be added to the scene.
  101138. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  101139. * @return a boolean defining if the geometry was added or not
  101140. */
  101141. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  101142. /**
  101143. * Removes an existing geometry
  101144. * @param geometry defines the geometry to be removed from the scene
  101145. * @return a boolean defining if the geometry was removed or not
  101146. */
  101147. removeGeometry(geometry: Geometry): boolean;
  101148. /**
  101149. * Gets the list of geometries attached to the scene
  101150. * @returns an array of Geometry
  101151. */
  101152. getGeometries(): Geometry[];
  101153. /**
  101154. * Gets the first added mesh found of a given ID
  101155. * @param id defines the id to search for
  101156. * @return the mesh found or null if not found at all
  101157. */
  101158. getMeshByID(id: string): Nullable<AbstractMesh>;
  101159. /**
  101160. * Gets a list of meshes using their id
  101161. * @param id defines the id to search for
  101162. * @returns a list of meshes
  101163. */
  101164. getMeshesByID(id: string): Array<AbstractMesh>;
  101165. /**
  101166. * Gets the first added transform node found of a given ID
  101167. * @param id defines the id to search for
  101168. * @return the found transform node or null if not found at all.
  101169. */
  101170. getTransformNodeByID(id: string): Nullable<TransformNode>;
  101171. /**
  101172. * Gets a transform node with its auto-generated unique id
  101173. * @param uniqueId efines the unique id to search for
  101174. * @return the found transform node or null if not found at all.
  101175. */
  101176. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  101177. /**
  101178. * Gets a list of transform nodes using their id
  101179. * @param id defines the id to search for
  101180. * @returns a list of transform nodes
  101181. */
  101182. getTransformNodesByID(id: string): Array<TransformNode>;
  101183. /**
  101184. * Gets a mesh with its auto-generated unique id
  101185. * @param uniqueId defines the unique id to search for
  101186. * @return the found mesh or null if not found at all.
  101187. */
  101188. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  101189. /**
  101190. * Gets a the last added mesh using a given id
  101191. * @param id defines the id to search for
  101192. * @return the found mesh or null if not found at all.
  101193. */
  101194. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  101195. /**
  101196. * Gets a the last added node (Mesh, Camera, Light) using a given id
  101197. * @param id defines the id to search for
  101198. * @return the found node or null if not found at all
  101199. */
  101200. getLastEntryByID(id: string): Nullable<Node>;
  101201. /**
  101202. * Gets a node (Mesh, Camera, Light) using a given id
  101203. * @param id defines the id to search for
  101204. * @return the found node or null if not found at all
  101205. */
  101206. getNodeByID(id: string): Nullable<Node>;
  101207. /**
  101208. * Gets a node (Mesh, Camera, Light) using a given name
  101209. * @param name defines the name to search for
  101210. * @return the found node or null if not found at all.
  101211. */
  101212. getNodeByName(name: string): Nullable<Node>;
  101213. /**
  101214. * Gets a mesh using a given name
  101215. * @param name defines the name to search for
  101216. * @return the found mesh or null if not found at all.
  101217. */
  101218. getMeshByName(name: string): Nullable<AbstractMesh>;
  101219. /**
  101220. * Gets a transform node using a given name
  101221. * @param name defines the name to search for
  101222. * @return the found transform node or null if not found at all.
  101223. */
  101224. getTransformNodeByName(name: string): Nullable<TransformNode>;
  101225. /**
  101226. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  101227. * @param id defines the id to search for
  101228. * @return the found skeleton or null if not found at all.
  101229. */
  101230. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  101231. /**
  101232. * Gets a skeleton using a given auto generated unique id
  101233. * @param uniqueId defines the unique id to search for
  101234. * @return the found skeleton or null if not found at all.
  101235. */
  101236. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  101237. /**
  101238. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  101239. * @param id defines the id to search for
  101240. * @return the found skeleton or null if not found at all.
  101241. */
  101242. getSkeletonById(id: string): Nullable<Skeleton>;
  101243. /**
  101244. * Gets a skeleton using a given name
  101245. * @param name defines the name to search for
  101246. * @return the found skeleton or null if not found at all.
  101247. */
  101248. getSkeletonByName(name: string): Nullable<Skeleton>;
  101249. /**
  101250. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  101251. * @param id defines the id to search for
  101252. * @return the found morph target manager or null if not found at all.
  101253. */
  101254. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  101255. /**
  101256. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  101257. * @param id defines the id to search for
  101258. * @return the found morph target or null if not found at all.
  101259. */
  101260. getMorphTargetById(id: string): Nullable<MorphTarget>;
  101261. /**
  101262. * Gets a boolean indicating if the given mesh is active
  101263. * @param mesh defines the mesh to look for
  101264. * @returns true if the mesh is in the active list
  101265. */
  101266. isActiveMesh(mesh: AbstractMesh): boolean;
  101267. /**
  101268. * Return a unique id as a string which can serve as an identifier for the scene
  101269. */
  101270. readonly uid: string;
  101271. /**
  101272. * Add an externaly attached data from its key.
  101273. * This method call will fail and return false, if such key already exists.
  101274. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  101275. * @param key the unique key that identifies the data
  101276. * @param data the data object to associate to the key for this Engine instance
  101277. * @return true if no such key were already present and the data was added successfully, false otherwise
  101278. */
  101279. addExternalData<T>(key: string, data: T): boolean;
  101280. /**
  101281. * Get an externaly attached data from its key
  101282. * @param key the unique key that identifies the data
  101283. * @return the associated data, if present (can be null), or undefined if not present
  101284. */
  101285. getExternalData<T>(key: string): Nullable<T>;
  101286. /**
  101287. * Get an externaly attached data from its key, create it using a factory if it's not already present
  101288. * @param key the unique key that identifies the data
  101289. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  101290. * @return the associated data, can be null if the factory returned null.
  101291. */
  101292. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  101293. /**
  101294. * Remove an externaly attached data from the Engine instance
  101295. * @param key the unique key that identifies the data
  101296. * @return true if the data was successfully removed, false if it doesn't exist
  101297. */
  101298. removeExternalData(key: string): boolean;
  101299. private _evaluateSubMesh;
  101300. /**
  101301. * Clear the processed materials smart array preventing retention point in material dispose.
  101302. */
  101303. freeProcessedMaterials(): void;
  101304. private _preventFreeActiveMeshesAndRenderingGroups;
  101305. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  101306. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  101307. * when disposing several meshes in a row or a hierarchy of meshes.
  101308. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  101309. */
  101310. blockfreeActiveMeshesAndRenderingGroups: boolean;
  101311. /**
  101312. * Clear the active meshes smart array preventing retention point in mesh dispose.
  101313. */
  101314. freeActiveMeshes(): void;
  101315. /**
  101316. * Clear the info related to rendering groups preventing retention points during dispose.
  101317. */
  101318. freeRenderingGroups(): void;
  101319. /** @hidden */
  101320. _isInIntermediateRendering(): boolean;
  101321. /**
  101322. * Lambda returning the list of potentially active meshes.
  101323. */
  101324. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  101325. /**
  101326. * Lambda returning the list of potentially active sub meshes.
  101327. */
  101328. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  101329. /**
  101330. * Lambda returning the list of potentially intersecting sub meshes.
  101331. */
  101332. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  101333. /**
  101334. * Lambda returning the list of potentially colliding sub meshes.
  101335. */
  101336. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  101337. private _activeMeshesFrozen;
  101338. /**
  101339. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  101340. * @returns the current scene
  101341. */
  101342. freezeActiveMeshes(): Scene;
  101343. /**
  101344. * Use this function to restart evaluating active meshes on every frame
  101345. * @returns the current scene
  101346. */
  101347. unfreezeActiveMeshes(): Scene;
  101348. private _evaluateActiveMeshes;
  101349. private _activeMesh;
  101350. /**
  101351. * Update the transform matrix to update from the current active camera
  101352. * @param force defines a boolean used to force the update even if cache is up to date
  101353. */
  101354. updateTransformMatrix(force?: boolean): void;
  101355. private _bindFrameBuffer;
  101356. /** @hidden */
  101357. _allowPostProcessClearColor: boolean;
  101358. /** @hidden */
  101359. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  101360. private _processSubCameras;
  101361. private _checkIntersections;
  101362. /** @hidden */
  101363. _advancePhysicsEngineStep(step: number): void;
  101364. /**
  101365. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  101366. */
  101367. getDeterministicFrameTime: () => number;
  101368. /** @hidden */
  101369. _animate(): void;
  101370. /** Execute all animations (for a frame) */
  101371. animate(): void;
  101372. /**
  101373. * Render the scene
  101374. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  101375. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  101376. */
  101377. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  101378. /**
  101379. * Freeze all materials
  101380. * A frozen material will not be updatable but should be faster to render
  101381. */
  101382. freezeMaterials(): void;
  101383. /**
  101384. * Unfreeze all materials
  101385. * A frozen material will not be updatable but should be faster to render
  101386. */
  101387. unfreezeMaterials(): void;
  101388. /**
  101389. * Releases all held ressources
  101390. */
  101391. dispose(): void;
  101392. /**
  101393. * Gets if the scene is already disposed
  101394. */
  101395. readonly isDisposed: boolean;
  101396. /**
  101397. * Call this function to reduce memory footprint of the scene.
  101398. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  101399. */
  101400. clearCachedVertexData(): void;
  101401. /**
  101402. * This function will remove the local cached buffer data from texture.
  101403. * It will save memory but will prevent the texture from being rebuilt
  101404. */
  101405. cleanCachedTextureBuffer(): void;
  101406. /**
  101407. * Get the world extend vectors with an optional filter
  101408. *
  101409. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  101410. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  101411. */
  101412. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  101413. min: Vector3;
  101414. max: Vector3;
  101415. };
  101416. /**
  101417. * Creates a ray that can be used to pick in the scene
  101418. * @param x defines the x coordinate of the origin (on-screen)
  101419. * @param y defines the y coordinate of the origin (on-screen)
  101420. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  101421. * @param camera defines the camera to use for the picking
  101422. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  101423. * @returns a Ray
  101424. */
  101425. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  101426. /**
  101427. * Creates a ray that can be used to pick in the scene
  101428. * @param x defines the x coordinate of the origin (on-screen)
  101429. * @param y defines the y coordinate of the origin (on-screen)
  101430. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  101431. * @param result defines the ray where to store the picking ray
  101432. * @param camera defines the camera to use for the picking
  101433. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  101434. * @returns the current scene
  101435. */
  101436. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  101437. /**
  101438. * Creates a ray that can be used to pick in the scene
  101439. * @param x defines the x coordinate of the origin (on-screen)
  101440. * @param y defines the y coordinate of the origin (on-screen)
  101441. * @param camera defines the camera to use for the picking
  101442. * @returns a Ray
  101443. */
  101444. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  101445. /**
  101446. * Creates a ray that can be used to pick in the scene
  101447. * @param x defines the x coordinate of the origin (on-screen)
  101448. * @param y defines the y coordinate of the origin (on-screen)
  101449. * @param result defines the ray where to store the picking ray
  101450. * @param camera defines the camera to use for the picking
  101451. * @returns the current scene
  101452. */
  101453. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  101454. /** Launch a ray to try to pick a mesh in the scene
  101455. * @param x position on screen
  101456. * @param y position on screen
  101457. * @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
  101458. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  101459. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  101460. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101461. * @returns a PickingInfo
  101462. */
  101463. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  101464. /** Use the given ray to pick a mesh in the scene
  101465. * @param ray The ray to use to pick meshes
  101466. * @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
  101467. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  101468. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101469. * @returns a PickingInfo
  101470. */
  101471. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  101472. /**
  101473. * Launch a ray to try to pick a mesh in the scene
  101474. * @param x X position on screen
  101475. * @param y Y position on screen
  101476. * @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
  101477. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  101478. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101479. * @returns an array of PickingInfo
  101480. */
  101481. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  101482. /**
  101483. * Launch a ray to try to pick a mesh in the scene
  101484. * @param ray Ray to use
  101485. * @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
  101486. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101487. * @returns an array of PickingInfo
  101488. */
  101489. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  101490. /**
  101491. * Force the value of meshUnderPointer
  101492. * @param mesh defines the mesh to use
  101493. */
  101494. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  101495. /**
  101496. * Gets the mesh under the pointer
  101497. * @returns a Mesh or null if no mesh is under the pointer
  101498. */
  101499. getPointerOverMesh(): Nullable<AbstractMesh>;
  101500. /** @hidden */
  101501. _rebuildGeometries(): void;
  101502. /** @hidden */
  101503. _rebuildTextures(): void;
  101504. private _getByTags;
  101505. /**
  101506. * Get a list of meshes by tags
  101507. * @param tagsQuery defines the tags query to use
  101508. * @param forEach defines a predicate used to filter results
  101509. * @returns an array of Mesh
  101510. */
  101511. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  101512. /**
  101513. * Get a list of cameras by tags
  101514. * @param tagsQuery defines the tags query to use
  101515. * @param forEach defines a predicate used to filter results
  101516. * @returns an array of Camera
  101517. */
  101518. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  101519. /**
  101520. * Get a list of lights by tags
  101521. * @param tagsQuery defines the tags query to use
  101522. * @param forEach defines a predicate used to filter results
  101523. * @returns an array of Light
  101524. */
  101525. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  101526. /**
  101527. * Get a list of materials by tags
  101528. * @param tagsQuery defines the tags query to use
  101529. * @param forEach defines a predicate used to filter results
  101530. * @returns an array of Material
  101531. */
  101532. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  101533. /**
  101534. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  101535. * This allowed control for front to back rendering or reversly depending of the special needs.
  101536. *
  101537. * @param renderingGroupId The rendering group id corresponding to its index
  101538. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  101539. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  101540. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  101541. */
  101542. 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;
  101543. /**
  101544. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  101545. *
  101546. * @param renderingGroupId The rendering group id corresponding to its index
  101547. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  101548. * @param depth Automatically clears depth between groups if true and autoClear is true.
  101549. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  101550. */
  101551. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  101552. /**
  101553. * Gets the current auto clear configuration for one rendering group of the rendering
  101554. * manager.
  101555. * @param index the rendering group index to get the information for
  101556. * @returns The auto clear setup for the requested rendering group
  101557. */
  101558. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  101559. private _blockMaterialDirtyMechanism;
  101560. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  101561. blockMaterialDirtyMechanism: boolean;
  101562. /**
  101563. * Will flag all materials as dirty to trigger new shader compilation
  101564. * @param flag defines the flag used to specify which material part must be marked as dirty
  101565. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  101566. */
  101567. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  101568. /** @hidden */
  101569. _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;
  101570. /** @hidden */
  101571. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  101572. }
  101573. }
  101574. declare module BABYLON {
  101575. /**
  101576. * Set of assets to keep when moving a scene into an asset container.
  101577. */
  101578. export class KeepAssets extends AbstractScene {
  101579. }
  101580. /**
  101581. * Container with a set of assets that can be added or removed from a scene.
  101582. */
  101583. export class AssetContainer extends AbstractScene {
  101584. /**
  101585. * The scene the AssetContainer belongs to.
  101586. */
  101587. scene: Scene;
  101588. /**
  101589. * Instantiates an AssetContainer.
  101590. * @param scene The scene the AssetContainer belongs to.
  101591. */
  101592. constructor(scene: Scene);
  101593. /**
  101594. * Adds all the assets from the container to the scene.
  101595. */
  101596. addAllToScene(): void;
  101597. /**
  101598. * Removes all the assets in the container from the scene
  101599. */
  101600. removeAllFromScene(): void;
  101601. /**
  101602. * Disposes all the assets in the container
  101603. */
  101604. dispose(): void;
  101605. private _moveAssets;
  101606. /**
  101607. * Removes all the assets contained in the scene and adds them to the container.
  101608. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  101609. */
  101610. moveAllFromScene(keepAssets?: KeepAssets): void;
  101611. /**
  101612. * 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.
  101613. * @returns the root mesh
  101614. */
  101615. createRootMesh(): Mesh;
  101616. }
  101617. }
  101618. declare module BABYLON {
  101619. /**
  101620. * Defines how the parser contract is defined.
  101621. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  101622. */
  101623. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  101624. /**
  101625. * Defines how the individual parser contract is defined.
  101626. * These parser can parse an individual asset
  101627. */
  101628. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  101629. /**
  101630. * Base class of the scene acting as a container for the different elements composing a scene.
  101631. * This class is dynamically extended by the different components of the scene increasing
  101632. * flexibility and reducing coupling
  101633. */
  101634. export abstract class AbstractScene {
  101635. /**
  101636. * Stores the list of available parsers in the application.
  101637. */
  101638. private static _BabylonFileParsers;
  101639. /**
  101640. * Stores the list of available individual parsers in the application.
  101641. */
  101642. private static _IndividualBabylonFileParsers;
  101643. /**
  101644. * Adds a parser in the list of available ones
  101645. * @param name Defines the name of the parser
  101646. * @param parser Defines the parser to add
  101647. */
  101648. static AddParser(name: string, parser: BabylonFileParser): void;
  101649. /**
  101650. * Gets a general parser from the list of avaialble ones
  101651. * @param name Defines the name of the parser
  101652. * @returns the requested parser or null
  101653. */
  101654. static GetParser(name: string): Nullable<BabylonFileParser>;
  101655. /**
  101656. * Adds n individual parser in the list of available ones
  101657. * @param name Defines the name of the parser
  101658. * @param parser Defines the parser to add
  101659. */
  101660. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  101661. /**
  101662. * Gets an individual parser from the list of avaialble ones
  101663. * @param name Defines the name of the parser
  101664. * @returns the requested parser or null
  101665. */
  101666. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  101667. /**
  101668. * Parser json data and populate both a scene and its associated container object
  101669. * @param jsonData Defines the data to parse
  101670. * @param scene Defines the scene to parse the data for
  101671. * @param container Defines the container attached to the parsing sequence
  101672. * @param rootUrl Defines the root url of the data
  101673. */
  101674. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  101675. /**
  101676. * Gets the list of root nodes (ie. nodes with no parent)
  101677. */
  101678. rootNodes: Node[];
  101679. /** All of the cameras added to this scene
  101680. * @see http://doc.babylonjs.com/babylon101/cameras
  101681. */
  101682. cameras: Camera[];
  101683. /**
  101684. * All of the lights added to this scene
  101685. * @see http://doc.babylonjs.com/babylon101/lights
  101686. */
  101687. lights: Light[];
  101688. /**
  101689. * All of the (abstract) meshes added to this scene
  101690. */
  101691. meshes: AbstractMesh[];
  101692. /**
  101693. * The list of skeletons added to the scene
  101694. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  101695. */
  101696. skeletons: Skeleton[];
  101697. /**
  101698. * All of the particle systems added to this scene
  101699. * @see http://doc.babylonjs.com/babylon101/particles
  101700. */
  101701. particleSystems: IParticleSystem[];
  101702. /**
  101703. * Gets a list of Animations associated with the scene
  101704. */
  101705. animations: Animation[];
  101706. /**
  101707. * All of the animation groups added to this scene
  101708. * @see http://doc.babylonjs.com/how_to/group
  101709. */
  101710. animationGroups: AnimationGroup[];
  101711. /**
  101712. * All of the multi-materials added to this scene
  101713. * @see http://doc.babylonjs.com/how_to/multi_materials
  101714. */
  101715. multiMaterials: MultiMaterial[];
  101716. /**
  101717. * All of the materials added to this scene
  101718. * In the context of a Scene, it is not supposed to be modified manually.
  101719. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  101720. * Note also that the order of the Material wihin the array is not significant and might change.
  101721. * @see http://doc.babylonjs.com/babylon101/materials
  101722. */
  101723. materials: Material[];
  101724. /**
  101725. * The list of morph target managers added to the scene
  101726. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  101727. */
  101728. morphTargetManagers: MorphTargetManager[];
  101729. /**
  101730. * The list of geometries used in the scene.
  101731. */
  101732. geometries: Geometry[];
  101733. /**
  101734. * All of the tranform nodes added to this scene
  101735. * In the context of a Scene, it is not supposed to be modified manually.
  101736. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  101737. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  101738. * @see http://doc.babylonjs.com/how_to/transformnode
  101739. */
  101740. transformNodes: TransformNode[];
  101741. /**
  101742. * ActionManagers available on the scene.
  101743. */
  101744. actionManagers: AbstractActionManager[];
  101745. /**
  101746. * Textures to keep.
  101747. */
  101748. textures: BaseTexture[];
  101749. /**
  101750. * Environment texture for the scene
  101751. */
  101752. environmentTexture: Nullable<BaseTexture>;
  101753. }
  101754. }
  101755. declare module BABYLON {
  101756. /**
  101757. * Interface used to define options for Sound class
  101758. */
  101759. export interface ISoundOptions {
  101760. /**
  101761. * Does the sound autoplay once loaded.
  101762. */
  101763. autoplay?: boolean;
  101764. /**
  101765. * Does the sound loop after it finishes playing once.
  101766. */
  101767. loop?: boolean;
  101768. /**
  101769. * Sound's volume
  101770. */
  101771. volume?: number;
  101772. /**
  101773. * Is it a spatial sound?
  101774. */
  101775. spatialSound?: boolean;
  101776. /**
  101777. * Maximum distance to hear that sound
  101778. */
  101779. maxDistance?: number;
  101780. /**
  101781. * Uses user defined attenuation function
  101782. */
  101783. useCustomAttenuation?: boolean;
  101784. /**
  101785. * Define the roll off factor of spatial sounds.
  101786. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101787. */
  101788. rolloffFactor?: number;
  101789. /**
  101790. * Define the reference distance the sound should be heard perfectly.
  101791. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101792. */
  101793. refDistance?: number;
  101794. /**
  101795. * Define the distance attenuation model the sound will follow.
  101796. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101797. */
  101798. distanceModel?: string;
  101799. /**
  101800. * Defines the playback speed (1 by default)
  101801. */
  101802. playbackRate?: number;
  101803. /**
  101804. * Defines if the sound is from a streaming source
  101805. */
  101806. streaming?: boolean;
  101807. /**
  101808. * Defines an optional length (in seconds) inside the sound file
  101809. */
  101810. length?: number;
  101811. /**
  101812. * Defines an optional offset (in seconds) inside the sound file
  101813. */
  101814. offset?: number;
  101815. /**
  101816. * If true, URLs will not be required to state the audio file codec to use.
  101817. */
  101818. skipCodecCheck?: boolean;
  101819. }
  101820. /**
  101821. * Defines a sound that can be played in the application.
  101822. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  101823. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101824. */
  101825. export class Sound {
  101826. /**
  101827. * The name of the sound in the scene.
  101828. */
  101829. name: string;
  101830. /**
  101831. * Does the sound autoplay once loaded.
  101832. */
  101833. autoplay: boolean;
  101834. /**
  101835. * Does the sound loop after it finishes playing once.
  101836. */
  101837. loop: boolean;
  101838. /**
  101839. * Does the sound use a custom attenuation curve to simulate the falloff
  101840. * happening when the source gets further away from the camera.
  101841. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  101842. */
  101843. useCustomAttenuation: boolean;
  101844. /**
  101845. * The sound track id this sound belongs to.
  101846. */
  101847. soundTrackId: number;
  101848. /**
  101849. * Is this sound currently played.
  101850. */
  101851. isPlaying: boolean;
  101852. /**
  101853. * Is this sound currently paused.
  101854. */
  101855. isPaused: boolean;
  101856. /**
  101857. * Does this sound enables spatial sound.
  101858. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101859. */
  101860. spatialSound: boolean;
  101861. /**
  101862. * Define the reference distance the sound should be heard perfectly.
  101863. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101864. */
  101865. refDistance: number;
  101866. /**
  101867. * Define the roll off factor of spatial sounds.
  101868. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101869. */
  101870. rolloffFactor: number;
  101871. /**
  101872. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  101873. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101874. */
  101875. maxDistance: number;
  101876. /**
  101877. * Define the distance attenuation model the sound will follow.
  101878. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101879. */
  101880. distanceModel: string;
  101881. /**
  101882. * @hidden
  101883. * Back Compat
  101884. **/
  101885. onended: () => any;
  101886. /**
  101887. * Observable event when the current playing sound finishes.
  101888. */
  101889. onEndedObservable: Observable<Sound>;
  101890. private _panningModel;
  101891. private _playbackRate;
  101892. private _streaming;
  101893. private _startTime;
  101894. private _startOffset;
  101895. private _position;
  101896. /** @hidden */
  101897. _positionInEmitterSpace: boolean;
  101898. private _localDirection;
  101899. private _volume;
  101900. private _isReadyToPlay;
  101901. private _isDirectional;
  101902. private _readyToPlayCallback;
  101903. private _audioBuffer;
  101904. private _soundSource;
  101905. private _streamingSource;
  101906. private _soundPanner;
  101907. private _soundGain;
  101908. private _inputAudioNode;
  101909. private _outputAudioNode;
  101910. private _coneInnerAngle;
  101911. private _coneOuterAngle;
  101912. private _coneOuterGain;
  101913. private _scene;
  101914. private _connectedTransformNode;
  101915. private _customAttenuationFunction;
  101916. private _registerFunc;
  101917. private _isOutputConnected;
  101918. private _htmlAudioElement;
  101919. private _urlType;
  101920. private _length?;
  101921. private _offset?;
  101922. /** @hidden */
  101923. static _SceneComponentInitialization: (scene: Scene) => void;
  101924. /**
  101925. * Create a sound and attach it to a scene
  101926. * @param name Name of your sound
  101927. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  101928. * @param scene defines the scene the sound belongs to
  101929. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  101930. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  101931. */
  101932. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  101933. /**
  101934. * Release the sound and its associated resources
  101935. */
  101936. dispose(): void;
  101937. /**
  101938. * Gets if the sounds is ready to be played or not.
  101939. * @returns true if ready, otherwise false
  101940. */
  101941. isReady(): boolean;
  101942. private _soundLoaded;
  101943. /**
  101944. * Sets the data of the sound from an audiobuffer
  101945. * @param audioBuffer The audioBuffer containing the data
  101946. */
  101947. setAudioBuffer(audioBuffer: AudioBuffer): void;
  101948. /**
  101949. * Updates the current sounds options such as maxdistance, loop...
  101950. * @param options A JSON object containing values named as the object properties
  101951. */
  101952. updateOptions(options: ISoundOptions): void;
  101953. private _createSpatialParameters;
  101954. private _updateSpatialParameters;
  101955. /**
  101956. * Switch the panning model to HRTF:
  101957. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  101958. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101959. */
  101960. switchPanningModelToHRTF(): void;
  101961. /**
  101962. * Switch the panning model to Equal Power:
  101963. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  101964. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101965. */
  101966. switchPanningModelToEqualPower(): void;
  101967. private _switchPanningModel;
  101968. /**
  101969. * Connect this sound to a sound track audio node like gain...
  101970. * @param soundTrackAudioNode the sound track audio node to connect to
  101971. */
  101972. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  101973. /**
  101974. * Transform this sound into a directional source
  101975. * @param coneInnerAngle Size of the inner cone in degree
  101976. * @param coneOuterAngle Size of the outer cone in degree
  101977. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  101978. */
  101979. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  101980. /**
  101981. * Gets or sets the inner angle for the directional cone.
  101982. */
  101983. /**
  101984. * Gets or sets the inner angle for the directional cone.
  101985. */
  101986. directionalConeInnerAngle: number;
  101987. /**
  101988. * Gets or sets the outer angle for the directional cone.
  101989. */
  101990. /**
  101991. * Gets or sets the outer angle for the directional cone.
  101992. */
  101993. directionalConeOuterAngle: number;
  101994. /**
  101995. * Sets the position of the emitter if spatial sound is enabled
  101996. * @param newPosition Defines the new posisiton
  101997. */
  101998. setPosition(newPosition: Vector3): void;
  101999. /**
  102000. * Sets the local direction of the emitter if spatial sound is enabled
  102001. * @param newLocalDirection Defines the new local direction
  102002. */
  102003. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  102004. private _updateDirection;
  102005. /** @hidden */
  102006. updateDistanceFromListener(): void;
  102007. /**
  102008. * Sets a new custom attenuation function for the sound.
  102009. * @param callback Defines the function used for the attenuation
  102010. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  102011. */
  102012. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  102013. /**
  102014. * Play the sound
  102015. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  102016. * @param offset (optional) Start the sound at a specific time in seconds
  102017. * @param length (optional) Sound duration (in seconds)
  102018. */
  102019. play(time?: number, offset?: number, length?: number): void;
  102020. private _onended;
  102021. /**
  102022. * Stop the sound
  102023. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  102024. */
  102025. stop(time?: number): void;
  102026. /**
  102027. * Put the sound in pause
  102028. */
  102029. pause(): void;
  102030. /**
  102031. * Sets a dedicated volume for this sounds
  102032. * @param newVolume Define the new volume of the sound
  102033. * @param time Define time for gradual change to new volume
  102034. */
  102035. setVolume(newVolume: number, time?: number): void;
  102036. /**
  102037. * Set the sound play back rate
  102038. * @param newPlaybackRate Define the playback rate the sound should be played at
  102039. */
  102040. setPlaybackRate(newPlaybackRate: number): void;
  102041. /**
  102042. * Gets the volume of the sound.
  102043. * @returns the volume of the sound
  102044. */
  102045. getVolume(): number;
  102046. /**
  102047. * Attach the sound to a dedicated mesh
  102048. * @param transformNode The transform node to connect the sound with
  102049. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  102050. */
  102051. attachToMesh(transformNode: TransformNode): void;
  102052. /**
  102053. * Detach the sound from the previously attached mesh
  102054. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  102055. */
  102056. detachFromMesh(): void;
  102057. private _onRegisterAfterWorldMatrixUpdate;
  102058. /**
  102059. * Clone the current sound in the scene.
  102060. * @returns the new sound clone
  102061. */
  102062. clone(): Nullable<Sound>;
  102063. /**
  102064. * Gets the current underlying audio buffer containing the data
  102065. * @returns the audio buffer
  102066. */
  102067. getAudioBuffer(): Nullable<AudioBuffer>;
  102068. /**
  102069. * Serializes the Sound in a JSON representation
  102070. * @returns the JSON representation of the sound
  102071. */
  102072. serialize(): any;
  102073. /**
  102074. * Parse a JSON representation of a sound to innstantiate in a given scene
  102075. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  102076. * @param scene Define the scene the new parsed sound should be created in
  102077. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  102078. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  102079. * @returns the newly parsed sound
  102080. */
  102081. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  102082. }
  102083. }
  102084. declare module BABYLON {
  102085. /**
  102086. * This defines an action helpful to play a defined sound on a triggered action.
  102087. */
  102088. export class PlaySoundAction extends Action {
  102089. private _sound;
  102090. /**
  102091. * Instantiate the action
  102092. * @param triggerOptions defines the trigger options
  102093. * @param sound defines the sound to play
  102094. * @param condition defines the trigger related conditions
  102095. */
  102096. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  102097. /** @hidden */
  102098. _prepare(): void;
  102099. /**
  102100. * Execute the action and play the sound.
  102101. */
  102102. execute(): void;
  102103. /**
  102104. * Serializes the actions and its related information.
  102105. * @param parent defines the object to serialize in
  102106. * @returns the serialized object
  102107. */
  102108. serialize(parent: any): any;
  102109. }
  102110. /**
  102111. * This defines an action helpful to stop a defined sound on a triggered action.
  102112. */
  102113. export class StopSoundAction extends Action {
  102114. private _sound;
  102115. /**
  102116. * Instantiate the action
  102117. * @param triggerOptions defines the trigger options
  102118. * @param sound defines the sound to stop
  102119. * @param condition defines the trigger related conditions
  102120. */
  102121. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  102122. /** @hidden */
  102123. _prepare(): void;
  102124. /**
  102125. * Execute the action and stop the sound.
  102126. */
  102127. execute(): void;
  102128. /**
  102129. * Serializes the actions and its related information.
  102130. * @param parent defines the object to serialize in
  102131. * @returns the serialized object
  102132. */
  102133. serialize(parent: any): any;
  102134. }
  102135. }
  102136. declare module BABYLON {
  102137. /**
  102138. * This defines an action responsible to change the value of a property
  102139. * by interpolating between its current value and the newly set one once triggered.
  102140. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  102141. */
  102142. export class InterpolateValueAction extends Action {
  102143. /**
  102144. * Defines the path of the property where the value should be interpolated
  102145. */
  102146. propertyPath: string;
  102147. /**
  102148. * Defines the target value at the end of the interpolation.
  102149. */
  102150. value: any;
  102151. /**
  102152. * Defines the time it will take for the property to interpolate to the value.
  102153. */
  102154. duration: number;
  102155. /**
  102156. * Defines if the other scene animations should be stopped when the action has been triggered
  102157. */
  102158. stopOtherAnimations?: boolean;
  102159. /**
  102160. * Defines a callback raised once the interpolation animation has been done.
  102161. */
  102162. onInterpolationDone?: () => void;
  102163. /**
  102164. * Observable triggered once the interpolation animation has been done.
  102165. */
  102166. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  102167. private _target;
  102168. private _effectiveTarget;
  102169. private _property;
  102170. /**
  102171. * Instantiate the action
  102172. * @param triggerOptions defines the trigger options
  102173. * @param target defines the object containing the value to interpolate
  102174. * @param propertyPath defines the path to the property in the target object
  102175. * @param value defines the target value at the end of the interpolation
  102176. * @param duration deines the time it will take for the property to interpolate to the value.
  102177. * @param condition defines the trigger related conditions
  102178. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  102179. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  102180. */
  102181. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  102182. /** @hidden */
  102183. _prepare(): void;
  102184. /**
  102185. * Execute the action starts the value interpolation.
  102186. */
  102187. execute(): void;
  102188. /**
  102189. * Serializes the actions and its related information.
  102190. * @param parent defines the object to serialize in
  102191. * @returns the serialized object
  102192. */
  102193. serialize(parent: any): any;
  102194. }
  102195. }
  102196. declare module BABYLON {
  102197. /**
  102198. * Options allowed during the creation of a sound track.
  102199. */
  102200. export interface ISoundTrackOptions {
  102201. /**
  102202. * The volume the sound track should take during creation
  102203. */
  102204. volume?: number;
  102205. /**
  102206. * Define if the sound track is the main sound track of the scene
  102207. */
  102208. mainTrack?: boolean;
  102209. }
  102210. /**
  102211. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  102212. * It will be also used in a future release to apply effects on a specific track.
  102213. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  102214. */
  102215. export class SoundTrack {
  102216. /**
  102217. * The unique identifier of the sound track in the scene.
  102218. */
  102219. id: number;
  102220. /**
  102221. * The list of sounds included in the sound track.
  102222. */
  102223. soundCollection: Array<Sound>;
  102224. private _outputAudioNode;
  102225. private _scene;
  102226. private _isMainTrack;
  102227. private _connectedAnalyser;
  102228. private _options;
  102229. private _isInitialized;
  102230. /**
  102231. * Creates a new sound track.
  102232. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  102233. * @param scene Define the scene the sound track belongs to
  102234. * @param options
  102235. */
  102236. constructor(scene: Scene, options?: ISoundTrackOptions);
  102237. private _initializeSoundTrackAudioGraph;
  102238. /**
  102239. * Release the sound track and its associated resources
  102240. */
  102241. dispose(): void;
  102242. /**
  102243. * Adds a sound to this sound track
  102244. * @param sound define the cound to add
  102245. * @ignoreNaming
  102246. */
  102247. AddSound(sound: Sound): void;
  102248. /**
  102249. * Removes a sound to this sound track
  102250. * @param sound define the cound to remove
  102251. * @ignoreNaming
  102252. */
  102253. RemoveSound(sound: Sound): void;
  102254. /**
  102255. * Set a global volume for the full sound track.
  102256. * @param newVolume Define the new volume of the sound track
  102257. */
  102258. setVolume(newVolume: number): void;
  102259. /**
  102260. * Switch the panning model to HRTF:
  102261. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  102262. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102263. */
  102264. switchPanningModelToHRTF(): void;
  102265. /**
  102266. * Switch the panning model to Equal Power:
  102267. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  102268. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102269. */
  102270. switchPanningModelToEqualPower(): void;
  102271. /**
  102272. * Connect the sound track to an audio analyser allowing some amazing
  102273. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  102274. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  102275. * @param analyser The analyser to connect to the engine
  102276. */
  102277. connectToAnalyser(analyser: Analyser): void;
  102278. }
  102279. }
  102280. declare module BABYLON {
  102281. interface AbstractScene {
  102282. /**
  102283. * The list of sounds used in the scene.
  102284. */
  102285. sounds: Nullable<Array<Sound>>;
  102286. }
  102287. interface Scene {
  102288. /**
  102289. * @hidden
  102290. * Backing field
  102291. */
  102292. _mainSoundTrack: SoundTrack;
  102293. /**
  102294. * The main sound track played by the scene.
  102295. * It cotains your primary collection of sounds.
  102296. */
  102297. mainSoundTrack: SoundTrack;
  102298. /**
  102299. * The list of sound tracks added to the scene
  102300. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102301. */
  102302. soundTracks: Nullable<Array<SoundTrack>>;
  102303. /**
  102304. * Gets a sound using a given name
  102305. * @param name defines the name to search for
  102306. * @return the found sound or null if not found at all.
  102307. */
  102308. getSoundByName(name: string): Nullable<Sound>;
  102309. /**
  102310. * Gets or sets if audio support is enabled
  102311. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102312. */
  102313. audioEnabled: boolean;
  102314. /**
  102315. * Gets or sets if audio will be output to headphones
  102316. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102317. */
  102318. headphone: boolean;
  102319. /**
  102320. * Gets or sets custom audio listener position provider
  102321. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102322. */
  102323. audioListenerPositionProvider: Nullable<() => Vector3>;
  102324. }
  102325. /**
  102326. * Defines the sound scene component responsible to manage any sounds
  102327. * in a given scene.
  102328. */
  102329. export class AudioSceneComponent implements ISceneSerializableComponent {
  102330. /**
  102331. * The component name helpfull to identify the component in the list of scene components.
  102332. */
  102333. readonly name: string;
  102334. /**
  102335. * The scene the component belongs to.
  102336. */
  102337. scene: Scene;
  102338. private _audioEnabled;
  102339. /**
  102340. * Gets whether audio is enabled or not.
  102341. * Please use related enable/disable method to switch state.
  102342. */
  102343. readonly audioEnabled: boolean;
  102344. private _headphone;
  102345. /**
  102346. * Gets whether audio is outputing to headphone or not.
  102347. * Please use the according Switch methods to change output.
  102348. */
  102349. readonly headphone: boolean;
  102350. private _audioListenerPositionProvider;
  102351. /**
  102352. * Gets the current audio listener position provider
  102353. */
  102354. /**
  102355. * Sets a custom listener position for all sounds in the scene
  102356. * By default, this is the position of the first active camera
  102357. */
  102358. audioListenerPositionProvider: Nullable<() => Vector3>;
  102359. /**
  102360. * Creates a new instance of the component for the given scene
  102361. * @param scene Defines the scene to register the component in
  102362. */
  102363. constructor(scene: Scene);
  102364. /**
  102365. * Registers the component in a given scene
  102366. */
  102367. register(): void;
  102368. /**
  102369. * Rebuilds the elements related to this component in case of
  102370. * context lost for instance.
  102371. */
  102372. rebuild(): void;
  102373. /**
  102374. * Serializes the component data to the specified json object
  102375. * @param serializationObject The object to serialize to
  102376. */
  102377. serialize(serializationObject: any): void;
  102378. /**
  102379. * Adds all the elements from the container to the scene
  102380. * @param container the container holding the elements
  102381. */
  102382. addFromContainer(container: AbstractScene): void;
  102383. /**
  102384. * Removes all the elements in the container from the scene
  102385. * @param container contains the elements to remove
  102386. * @param dispose if the removed element should be disposed (default: false)
  102387. */
  102388. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  102389. /**
  102390. * Disposes the component and the associated ressources.
  102391. */
  102392. dispose(): void;
  102393. /**
  102394. * Disables audio in the associated scene.
  102395. */
  102396. disableAudio(): void;
  102397. /**
  102398. * Enables audio in the associated scene.
  102399. */
  102400. enableAudio(): void;
  102401. /**
  102402. * Switch audio to headphone output.
  102403. */
  102404. switchAudioModeForHeadphones(): void;
  102405. /**
  102406. * Switch audio to normal speakers.
  102407. */
  102408. switchAudioModeForNormalSpeakers(): void;
  102409. private _afterRender;
  102410. }
  102411. }
  102412. declare module BABYLON {
  102413. /**
  102414. * Wraps one or more Sound objects and selects one with random weight for playback.
  102415. */
  102416. export class WeightedSound {
  102417. /** When true a Sound will be selected and played when the current playing Sound completes. */
  102418. loop: boolean;
  102419. private _coneInnerAngle;
  102420. private _coneOuterAngle;
  102421. private _volume;
  102422. /** A Sound is currently playing. */
  102423. isPlaying: boolean;
  102424. /** A Sound is currently paused. */
  102425. isPaused: boolean;
  102426. private _sounds;
  102427. private _weights;
  102428. private _currentIndex?;
  102429. /**
  102430. * Creates a new WeightedSound from the list of sounds given.
  102431. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  102432. * @param sounds Array of Sounds that will be selected from.
  102433. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  102434. */
  102435. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  102436. /**
  102437. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  102438. */
  102439. /**
  102440. * The size of cone in degress for a directional sound in which there will be no attenuation.
  102441. */
  102442. directionalConeInnerAngle: number;
  102443. /**
  102444. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  102445. * Listener angles between innerAngle and outerAngle will falloff linearly.
  102446. */
  102447. /**
  102448. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  102449. * Listener angles between innerAngle and outerAngle will falloff linearly.
  102450. */
  102451. directionalConeOuterAngle: number;
  102452. /**
  102453. * Playback volume.
  102454. */
  102455. /**
  102456. * Playback volume.
  102457. */
  102458. volume: number;
  102459. private _onended;
  102460. /**
  102461. * Suspend playback
  102462. */
  102463. pause(): void;
  102464. /**
  102465. * Stop playback
  102466. */
  102467. stop(): void;
  102468. /**
  102469. * Start playback.
  102470. * @param startOffset Position the clip head at a specific time in seconds.
  102471. */
  102472. play(startOffset?: number): void;
  102473. }
  102474. }
  102475. declare module BABYLON {
  102476. /**
  102477. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  102478. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  102479. */
  102480. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  102481. /**
  102482. * Gets the name of the behavior.
  102483. */
  102484. readonly name: string;
  102485. /**
  102486. * The easing function used by animations
  102487. */
  102488. static EasingFunction: BackEase;
  102489. /**
  102490. * The easing mode used by animations
  102491. */
  102492. static EasingMode: number;
  102493. /**
  102494. * The duration of the animation, in milliseconds
  102495. */
  102496. transitionDuration: number;
  102497. /**
  102498. * Length of the distance animated by the transition when lower radius is reached
  102499. */
  102500. lowerRadiusTransitionRange: number;
  102501. /**
  102502. * Length of the distance animated by the transition when upper radius is reached
  102503. */
  102504. upperRadiusTransitionRange: number;
  102505. private _autoTransitionRange;
  102506. /**
  102507. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  102508. */
  102509. /**
  102510. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  102511. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  102512. */
  102513. autoTransitionRange: boolean;
  102514. private _attachedCamera;
  102515. private _onAfterCheckInputsObserver;
  102516. private _onMeshTargetChangedObserver;
  102517. /**
  102518. * Initializes the behavior.
  102519. */
  102520. init(): void;
  102521. /**
  102522. * Attaches the behavior to its arc rotate camera.
  102523. * @param camera Defines the camera to attach the behavior to
  102524. */
  102525. attach(camera: ArcRotateCamera): void;
  102526. /**
  102527. * Detaches the behavior from its current arc rotate camera.
  102528. */
  102529. detach(): void;
  102530. private _radiusIsAnimating;
  102531. private _radiusBounceTransition;
  102532. private _animatables;
  102533. private _cachedWheelPrecision;
  102534. /**
  102535. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  102536. * @param radiusLimit The limit to check against.
  102537. * @return Bool to indicate if at limit.
  102538. */
  102539. private _isRadiusAtLimit;
  102540. /**
  102541. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  102542. * @param radiusDelta The delta by which to animate to. Can be negative.
  102543. */
  102544. private _applyBoundRadiusAnimation;
  102545. /**
  102546. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  102547. */
  102548. protected _clearAnimationLocks(): void;
  102549. /**
  102550. * Stops and removes all animations that have been applied to the camera
  102551. */
  102552. stopAllAnimations(): void;
  102553. }
  102554. }
  102555. declare module BABYLON {
  102556. /**
  102557. * 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.
  102558. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  102559. */
  102560. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  102561. /**
  102562. * Gets the name of the behavior.
  102563. */
  102564. readonly name: string;
  102565. private _mode;
  102566. private _radiusScale;
  102567. private _positionScale;
  102568. private _defaultElevation;
  102569. private _elevationReturnTime;
  102570. private _elevationReturnWaitTime;
  102571. private _zoomStopsAnimation;
  102572. private _framingTime;
  102573. /**
  102574. * The easing function used by animations
  102575. */
  102576. static EasingFunction: ExponentialEase;
  102577. /**
  102578. * The easing mode used by animations
  102579. */
  102580. static EasingMode: number;
  102581. /**
  102582. * Sets the current mode used by the behavior
  102583. */
  102584. /**
  102585. * Gets current mode used by the behavior.
  102586. */
  102587. mode: number;
  102588. /**
  102589. * Sets the scale applied to the radius (1 by default)
  102590. */
  102591. /**
  102592. * Gets the scale applied to the radius
  102593. */
  102594. radiusScale: number;
  102595. /**
  102596. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  102597. */
  102598. /**
  102599. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  102600. */
  102601. positionScale: number;
  102602. /**
  102603. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  102604. * behaviour is triggered, in radians.
  102605. */
  102606. /**
  102607. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  102608. * behaviour is triggered, in radians.
  102609. */
  102610. defaultElevation: number;
  102611. /**
  102612. * Sets the time (in milliseconds) taken to return to the default beta position.
  102613. * Negative value indicates camera should not return to default.
  102614. */
  102615. /**
  102616. * Gets the time (in milliseconds) taken to return to the default beta position.
  102617. * Negative value indicates camera should not return to default.
  102618. */
  102619. elevationReturnTime: number;
  102620. /**
  102621. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  102622. */
  102623. /**
  102624. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  102625. */
  102626. elevationReturnWaitTime: number;
  102627. /**
  102628. * Sets the flag that indicates if user zooming should stop animation.
  102629. */
  102630. /**
  102631. * Gets the flag that indicates if user zooming should stop animation.
  102632. */
  102633. zoomStopsAnimation: boolean;
  102634. /**
  102635. * Sets the transition time when framing the mesh, in milliseconds
  102636. */
  102637. /**
  102638. * Gets the transition time when framing the mesh, in milliseconds
  102639. */
  102640. framingTime: number;
  102641. /**
  102642. * Define if the behavior should automatically change the configured
  102643. * camera limits and sensibilities.
  102644. */
  102645. autoCorrectCameraLimitsAndSensibility: boolean;
  102646. private _onPrePointerObservableObserver;
  102647. private _onAfterCheckInputsObserver;
  102648. private _onMeshTargetChangedObserver;
  102649. private _attachedCamera;
  102650. private _isPointerDown;
  102651. private _lastInteractionTime;
  102652. /**
  102653. * Initializes the behavior.
  102654. */
  102655. init(): void;
  102656. /**
  102657. * Attaches the behavior to its arc rotate camera.
  102658. * @param camera Defines the camera to attach the behavior to
  102659. */
  102660. attach(camera: ArcRotateCamera): void;
  102661. /**
  102662. * Detaches the behavior from its current arc rotate camera.
  102663. */
  102664. detach(): void;
  102665. private _animatables;
  102666. private _betaIsAnimating;
  102667. private _betaTransition;
  102668. private _radiusTransition;
  102669. private _vectorTransition;
  102670. /**
  102671. * Targets the given mesh and updates zoom level accordingly.
  102672. * @param mesh The mesh to target.
  102673. * @param radius Optional. If a cached radius position already exists, overrides default.
  102674. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  102675. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  102676. * @param onAnimationEnd Callback triggered at the end of the framing animation
  102677. */
  102678. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  102679. /**
  102680. * Targets the given mesh with its children and updates zoom level accordingly.
  102681. * @param mesh The mesh to target.
  102682. * @param radius Optional. If a cached radius position already exists, overrides default.
  102683. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  102684. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  102685. * @param onAnimationEnd Callback triggered at the end of the framing animation
  102686. */
  102687. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  102688. /**
  102689. * Targets the given meshes with their children and updates zoom level accordingly.
  102690. * @param meshes The mesh to target.
  102691. * @param radius Optional. If a cached radius position already exists, overrides default.
  102692. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  102693. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  102694. * @param onAnimationEnd Callback triggered at the end of the framing animation
  102695. */
  102696. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  102697. /**
  102698. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  102699. * @param minimumWorld Determines the smaller position of the bounding box extend
  102700. * @param maximumWorld Determines the bigger position of the bounding box extend
  102701. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  102702. * @param onAnimationEnd Callback triggered at the end of the framing animation
  102703. */
  102704. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  102705. /**
  102706. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  102707. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  102708. * frustum width.
  102709. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  102710. * to fully enclose the mesh in the viewing frustum.
  102711. */
  102712. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  102713. /**
  102714. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  102715. * is automatically returned to its default position (expected to be above ground plane).
  102716. */
  102717. private _maintainCameraAboveGround;
  102718. /**
  102719. * Returns the frustum slope based on the canvas ratio and camera FOV
  102720. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  102721. */
  102722. private _getFrustumSlope;
  102723. /**
  102724. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  102725. */
  102726. private _clearAnimationLocks;
  102727. /**
  102728. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  102729. */
  102730. private _applyUserInteraction;
  102731. /**
  102732. * Stops and removes all animations that have been applied to the camera
  102733. */
  102734. stopAllAnimations(): void;
  102735. /**
  102736. * Gets a value indicating if the user is moving the camera
  102737. */
  102738. readonly isUserIsMoving: boolean;
  102739. /**
  102740. * The camera can move all the way towards the mesh.
  102741. */
  102742. static IgnoreBoundsSizeMode: number;
  102743. /**
  102744. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  102745. */
  102746. static FitFrustumSidesMode: number;
  102747. }
  102748. }
  102749. declare module BABYLON {
  102750. /**
  102751. * Base class for Camera Pointer Inputs.
  102752. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  102753. * for example usage.
  102754. */
  102755. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  102756. /**
  102757. * Defines the camera the input is attached to.
  102758. */
  102759. abstract camera: Camera;
  102760. /**
  102761. * Whether keyboard modifier keys are pressed at time of last mouse event.
  102762. */
  102763. protected _altKey: boolean;
  102764. protected _ctrlKey: boolean;
  102765. protected _metaKey: boolean;
  102766. protected _shiftKey: boolean;
  102767. /**
  102768. * Which mouse buttons were pressed at time of last mouse event.
  102769. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  102770. */
  102771. protected _buttonsPressed: number;
  102772. /**
  102773. * Defines the buttons associated with the input to handle camera move.
  102774. */
  102775. buttons: number[];
  102776. /**
  102777. * Attach the input controls to a specific dom element to get the input from.
  102778. * @param element Defines the element the controls should be listened from
  102779. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102780. */
  102781. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102782. /**
  102783. * Detach the current controls from the specified dom element.
  102784. * @param element Defines the element to stop listening the inputs from
  102785. */
  102786. detachControl(element: Nullable<HTMLElement>): void;
  102787. /**
  102788. * Gets the class name of the current input.
  102789. * @returns the class name
  102790. */
  102791. getClassName(): string;
  102792. /**
  102793. * Get the friendly name associated with the input class.
  102794. * @returns the input friendly name
  102795. */
  102796. getSimpleName(): string;
  102797. /**
  102798. * Called on pointer POINTERDOUBLETAP event.
  102799. * Override this method to provide functionality on POINTERDOUBLETAP event.
  102800. */
  102801. protected onDoubleTap(type: string): void;
  102802. /**
  102803. * Called on pointer POINTERMOVE event if only a single touch is active.
  102804. * Override this method to provide functionality.
  102805. */
  102806. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  102807. /**
  102808. * Called on pointer POINTERMOVE event if multiple touches are active.
  102809. * Override this method to provide functionality.
  102810. */
  102811. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  102812. /**
  102813. * Called on JS contextmenu event.
  102814. * Override this method to provide functionality.
  102815. */
  102816. protected onContextMenu(evt: PointerEvent): void;
  102817. /**
  102818. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  102819. * press.
  102820. * Override this method to provide functionality.
  102821. */
  102822. protected onButtonDown(evt: PointerEvent): void;
  102823. /**
  102824. * Called each time a new POINTERUP event occurs. Ie, for each button
  102825. * release.
  102826. * Override this method to provide functionality.
  102827. */
  102828. protected onButtonUp(evt: PointerEvent): void;
  102829. /**
  102830. * Called when window becomes inactive.
  102831. * Override this method to provide functionality.
  102832. */
  102833. protected onLostFocus(): void;
  102834. private _pointerInput;
  102835. private _observer;
  102836. private _onLostFocus;
  102837. private pointA;
  102838. private pointB;
  102839. }
  102840. }
  102841. declare module BABYLON {
  102842. /**
  102843. * Manage the pointers inputs to control an arc rotate camera.
  102844. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102845. */
  102846. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  102847. /**
  102848. * Defines the camera the input is attached to.
  102849. */
  102850. camera: ArcRotateCamera;
  102851. /**
  102852. * Gets the class name of the current input.
  102853. * @returns the class name
  102854. */
  102855. getClassName(): string;
  102856. /**
  102857. * Defines the buttons associated with the input to handle camera move.
  102858. */
  102859. buttons: number[];
  102860. /**
  102861. * Defines the pointer angular sensibility along the X axis or how fast is
  102862. * the camera rotating.
  102863. */
  102864. angularSensibilityX: number;
  102865. /**
  102866. * Defines the pointer angular sensibility along the Y axis or how fast is
  102867. * the camera rotating.
  102868. */
  102869. angularSensibilityY: number;
  102870. /**
  102871. * Defines the pointer pinch precision or how fast is the camera zooming.
  102872. */
  102873. pinchPrecision: number;
  102874. /**
  102875. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  102876. * from 0.
  102877. * It defines the percentage of current camera.radius to use as delta when
  102878. * pinch zoom is used.
  102879. */
  102880. pinchDeltaPercentage: number;
  102881. /**
  102882. * Defines the pointer panning sensibility or how fast is the camera moving.
  102883. */
  102884. panningSensibility: number;
  102885. /**
  102886. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  102887. */
  102888. multiTouchPanning: boolean;
  102889. /**
  102890. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  102891. * zoom (pinch) through multitouch.
  102892. */
  102893. multiTouchPanAndZoom: boolean;
  102894. /**
  102895. * Revers pinch action direction.
  102896. */
  102897. pinchInwards: boolean;
  102898. private _isPanClick;
  102899. private _twoFingerActivityCount;
  102900. private _isPinching;
  102901. /**
  102902. * Called on pointer POINTERMOVE event if only a single touch is active.
  102903. */
  102904. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  102905. /**
  102906. * Called on pointer POINTERDOUBLETAP event.
  102907. */
  102908. protected onDoubleTap(type: string): void;
  102909. /**
  102910. * Called on pointer POINTERMOVE event if multiple touches are active.
  102911. */
  102912. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  102913. /**
  102914. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  102915. * press.
  102916. */
  102917. protected onButtonDown(evt: PointerEvent): void;
  102918. /**
  102919. * Called each time a new POINTERUP event occurs. Ie, for each button
  102920. * release.
  102921. */
  102922. protected onButtonUp(evt: PointerEvent): void;
  102923. /**
  102924. * Called when window becomes inactive.
  102925. */
  102926. protected onLostFocus(): void;
  102927. }
  102928. }
  102929. declare module BABYLON {
  102930. /**
  102931. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  102932. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102933. */
  102934. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  102935. /**
  102936. * Defines the camera the input is attached to.
  102937. */
  102938. camera: ArcRotateCamera;
  102939. /**
  102940. * Defines the list of key codes associated with the up action (increase alpha)
  102941. */
  102942. keysUp: number[];
  102943. /**
  102944. * Defines the list of key codes associated with the down action (decrease alpha)
  102945. */
  102946. keysDown: number[];
  102947. /**
  102948. * Defines the list of key codes associated with the left action (increase beta)
  102949. */
  102950. keysLeft: number[];
  102951. /**
  102952. * Defines the list of key codes associated with the right action (decrease beta)
  102953. */
  102954. keysRight: number[];
  102955. /**
  102956. * Defines the list of key codes associated with the reset action.
  102957. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  102958. */
  102959. keysReset: number[];
  102960. /**
  102961. * Defines the panning sensibility of the inputs.
  102962. * (How fast is the camera paning)
  102963. */
  102964. panningSensibility: number;
  102965. /**
  102966. * Defines the zooming sensibility of the inputs.
  102967. * (How fast is the camera zooming)
  102968. */
  102969. zoomingSensibility: number;
  102970. /**
  102971. * Defines wether maintaining the alt key down switch the movement mode from
  102972. * orientation to zoom.
  102973. */
  102974. useAltToZoom: boolean;
  102975. /**
  102976. * Rotation speed of the camera
  102977. */
  102978. angularSpeed: number;
  102979. private _keys;
  102980. private _ctrlPressed;
  102981. private _altPressed;
  102982. private _onCanvasBlurObserver;
  102983. private _onKeyboardObserver;
  102984. private _engine;
  102985. private _scene;
  102986. /**
  102987. * Attach the input controls to a specific dom element to get the input from.
  102988. * @param element Defines the element the controls should be listened from
  102989. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102990. */
  102991. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102992. /**
  102993. * Detach the current controls from the specified dom element.
  102994. * @param element Defines the element to stop listening the inputs from
  102995. */
  102996. detachControl(element: Nullable<HTMLElement>): void;
  102997. /**
  102998. * Update the current camera state depending on the inputs that have been used this frame.
  102999. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103000. */
  103001. checkInputs(): void;
  103002. /**
  103003. * Gets the class name of the current intput.
  103004. * @returns the class name
  103005. */
  103006. getClassName(): string;
  103007. /**
  103008. * Get the friendly name associated with the input class.
  103009. * @returns the input friendly name
  103010. */
  103011. getSimpleName(): string;
  103012. }
  103013. }
  103014. declare module BABYLON {
  103015. /**
  103016. * Manage the mouse wheel inputs to control an arc rotate camera.
  103017. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103018. */
  103019. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  103020. /**
  103021. * Defines the camera the input is attached to.
  103022. */
  103023. camera: ArcRotateCamera;
  103024. /**
  103025. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  103026. */
  103027. wheelPrecision: number;
  103028. /**
  103029. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  103030. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  103031. */
  103032. wheelDeltaPercentage: number;
  103033. private _wheel;
  103034. private _observer;
  103035. private computeDeltaFromMouseWheelLegacyEvent;
  103036. /**
  103037. * Attach the input controls to a specific dom element to get the input from.
  103038. * @param element Defines the element the controls should be listened from
  103039. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103040. */
  103041. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103042. /**
  103043. * Detach the current controls from the specified dom element.
  103044. * @param element Defines the element to stop listening the inputs from
  103045. */
  103046. detachControl(element: Nullable<HTMLElement>): void;
  103047. /**
  103048. * Gets the class name of the current intput.
  103049. * @returns the class name
  103050. */
  103051. getClassName(): string;
  103052. /**
  103053. * Get the friendly name associated with the input class.
  103054. * @returns the input friendly name
  103055. */
  103056. getSimpleName(): string;
  103057. }
  103058. }
  103059. declare module BABYLON {
  103060. /**
  103061. * Default Inputs manager for the ArcRotateCamera.
  103062. * It groups all the default supported inputs for ease of use.
  103063. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103064. */
  103065. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  103066. /**
  103067. * Instantiates a new ArcRotateCameraInputsManager.
  103068. * @param camera Defines the camera the inputs belong to
  103069. */
  103070. constructor(camera: ArcRotateCamera);
  103071. /**
  103072. * Add mouse wheel input support to the input manager.
  103073. * @returns the current input manager
  103074. */
  103075. addMouseWheel(): ArcRotateCameraInputsManager;
  103076. /**
  103077. * Add pointers input support to the input manager.
  103078. * @returns the current input manager
  103079. */
  103080. addPointers(): ArcRotateCameraInputsManager;
  103081. /**
  103082. * Add keyboard input support to the input manager.
  103083. * @returns the current input manager
  103084. */
  103085. addKeyboard(): ArcRotateCameraInputsManager;
  103086. }
  103087. }
  103088. declare module BABYLON {
  103089. /**
  103090. * This represents an orbital type of camera.
  103091. *
  103092. * 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.
  103093. * 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.
  103094. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  103095. */
  103096. export class ArcRotateCamera extends TargetCamera {
  103097. /**
  103098. * Defines the rotation angle of the camera along the longitudinal axis.
  103099. */
  103100. alpha: number;
  103101. /**
  103102. * Defines the rotation angle of the camera along the latitudinal axis.
  103103. */
  103104. beta: number;
  103105. /**
  103106. * Defines the radius of the camera from it s target point.
  103107. */
  103108. radius: number;
  103109. protected _target: Vector3;
  103110. protected _targetHost: Nullable<AbstractMesh>;
  103111. /**
  103112. * Defines the target point of the camera.
  103113. * The camera looks towards it form the radius distance.
  103114. */
  103115. target: Vector3;
  103116. /**
  103117. * Define the current local position of the camera in the scene
  103118. */
  103119. position: Vector3;
  103120. protected _upVector: Vector3;
  103121. protected _upToYMatrix: Matrix;
  103122. protected _YToUpMatrix: Matrix;
  103123. /**
  103124. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  103125. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  103126. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  103127. */
  103128. upVector: Vector3;
  103129. /**
  103130. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  103131. */
  103132. setMatUp(): void;
  103133. /**
  103134. * Current inertia value on the longitudinal axis.
  103135. * The bigger this number the longer it will take for the camera to stop.
  103136. */
  103137. inertialAlphaOffset: number;
  103138. /**
  103139. * Current inertia value on the latitudinal axis.
  103140. * The bigger this number the longer it will take for the camera to stop.
  103141. */
  103142. inertialBetaOffset: number;
  103143. /**
  103144. * Current inertia value on the radius axis.
  103145. * The bigger this number the longer it will take for the camera to stop.
  103146. */
  103147. inertialRadiusOffset: number;
  103148. /**
  103149. * Minimum allowed angle on the longitudinal axis.
  103150. * This can help limiting how the Camera is able to move in the scene.
  103151. */
  103152. lowerAlphaLimit: Nullable<number>;
  103153. /**
  103154. * Maximum allowed angle on the longitudinal axis.
  103155. * This can help limiting how the Camera is able to move in the scene.
  103156. */
  103157. upperAlphaLimit: Nullable<number>;
  103158. /**
  103159. * Minimum allowed angle on the latitudinal axis.
  103160. * This can help limiting how the Camera is able to move in the scene.
  103161. */
  103162. lowerBetaLimit: number;
  103163. /**
  103164. * Maximum allowed angle on the latitudinal axis.
  103165. * This can help limiting how the Camera is able to move in the scene.
  103166. */
  103167. upperBetaLimit: number;
  103168. /**
  103169. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  103170. * This can help limiting how the Camera is able to move in the scene.
  103171. */
  103172. lowerRadiusLimit: Nullable<number>;
  103173. /**
  103174. * Maximum allowed distance of the camera to the target (The camera can not get further).
  103175. * This can help limiting how the Camera is able to move in the scene.
  103176. */
  103177. upperRadiusLimit: Nullable<number>;
  103178. /**
  103179. * Defines the current inertia value used during panning of the camera along the X axis.
  103180. */
  103181. inertialPanningX: number;
  103182. /**
  103183. * Defines the current inertia value used during panning of the camera along the Y axis.
  103184. */
  103185. inertialPanningY: number;
  103186. /**
  103187. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  103188. * Basically if your fingers moves away from more than this distance you will be considered
  103189. * in pinch mode.
  103190. */
  103191. pinchToPanMaxDistance: number;
  103192. /**
  103193. * Defines the maximum distance the camera can pan.
  103194. * This could help keeping the cammera always in your scene.
  103195. */
  103196. panningDistanceLimit: Nullable<number>;
  103197. /**
  103198. * Defines the target of the camera before paning.
  103199. */
  103200. panningOriginTarget: Vector3;
  103201. /**
  103202. * Defines the value of the inertia used during panning.
  103203. * 0 would mean stop inertia and one would mean no decelleration at all.
  103204. */
  103205. panningInertia: number;
  103206. /**
  103207. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  103208. */
  103209. angularSensibilityX: number;
  103210. /**
  103211. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  103212. */
  103213. angularSensibilityY: number;
  103214. /**
  103215. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  103216. */
  103217. pinchPrecision: number;
  103218. /**
  103219. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  103220. * It will be used instead of pinchDeltaPrecision if different from 0.
  103221. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  103222. */
  103223. pinchDeltaPercentage: number;
  103224. /**
  103225. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  103226. */
  103227. panningSensibility: number;
  103228. /**
  103229. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  103230. */
  103231. keysUp: number[];
  103232. /**
  103233. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  103234. */
  103235. keysDown: number[];
  103236. /**
  103237. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  103238. */
  103239. keysLeft: number[];
  103240. /**
  103241. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  103242. */
  103243. keysRight: number[];
  103244. /**
  103245. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  103246. */
  103247. wheelPrecision: number;
  103248. /**
  103249. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  103250. * It will be used instead of pinchDeltaPrecision if different from 0.
  103251. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  103252. */
  103253. wheelDeltaPercentage: number;
  103254. /**
  103255. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  103256. */
  103257. zoomOnFactor: number;
  103258. /**
  103259. * Defines a screen offset for the camera position.
  103260. */
  103261. targetScreenOffset: Vector2;
  103262. /**
  103263. * Allows the camera to be completely reversed.
  103264. * If false the camera can not arrive upside down.
  103265. */
  103266. allowUpsideDown: boolean;
  103267. /**
  103268. * Define if double tap/click is used to restore the previously saved state of the camera.
  103269. */
  103270. useInputToRestoreState: boolean;
  103271. /** @hidden */
  103272. _viewMatrix: Matrix;
  103273. /** @hidden */
  103274. _useCtrlForPanning: boolean;
  103275. /** @hidden */
  103276. _panningMouseButton: number;
  103277. /**
  103278. * Defines the input associated to the camera.
  103279. */
  103280. inputs: ArcRotateCameraInputsManager;
  103281. /** @hidden */
  103282. _reset: () => void;
  103283. /**
  103284. * Defines the allowed panning axis.
  103285. */
  103286. panningAxis: Vector3;
  103287. protected _localDirection: Vector3;
  103288. protected _transformedDirection: Vector3;
  103289. private _bouncingBehavior;
  103290. /**
  103291. * Gets the bouncing behavior of the camera if it has been enabled.
  103292. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  103293. */
  103294. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  103295. /**
  103296. * Defines if the bouncing behavior of the camera is enabled on the camera.
  103297. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  103298. */
  103299. useBouncingBehavior: boolean;
  103300. private _framingBehavior;
  103301. /**
  103302. * Gets the framing behavior of the camera if it has been enabled.
  103303. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  103304. */
  103305. readonly framingBehavior: Nullable<FramingBehavior>;
  103306. /**
  103307. * Defines if the framing behavior of the camera is enabled on the camera.
  103308. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  103309. */
  103310. useFramingBehavior: boolean;
  103311. private _autoRotationBehavior;
  103312. /**
  103313. * Gets the auto rotation behavior of the camera if it has been enabled.
  103314. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  103315. */
  103316. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  103317. /**
  103318. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  103319. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  103320. */
  103321. useAutoRotationBehavior: boolean;
  103322. /**
  103323. * Observable triggered when the mesh target has been changed on the camera.
  103324. */
  103325. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  103326. /**
  103327. * Event raised when the camera is colliding with a mesh.
  103328. */
  103329. onCollide: (collidedMesh: AbstractMesh) => void;
  103330. /**
  103331. * Defines whether the camera should check collision with the objects oh the scene.
  103332. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  103333. */
  103334. checkCollisions: boolean;
  103335. /**
  103336. * Defines the collision radius of the camera.
  103337. * This simulates a sphere around the camera.
  103338. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  103339. */
  103340. collisionRadius: Vector3;
  103341. protected _collider: Collider;
  103342. protected _previousPosition: Vector3;
  103343. protected _collisionVelocity: Vector3;
  103344. protected _newPosition: Vector3;
  103345. protected _previousAlpha: number;
  103346. protected _previousBeta: number;
  103347. protected _previousRadius: number;
  103348. protected _collisionTriggered: boolean;
  103349. protected _targetBoundingCenter: Nullable<Vector3>;
  103350. private _computationVector;
  103351. /**
  103352. * Instantiates a new ArcRotateCamera in a given scene
  103353. * @param name Defines the name of the camera
  103354. * @param alpha Defines the camera rotation along the logitudinal axis
  103355. * @param beta Defines the camera rotation along the latitudinal axis
  103356. * @param radius Defines the camera distance from its target
  103357. * @param target Defines the camera target
  103358. * @param scene Defines the scene the camera belongs to
  103359. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  103360. */
  103361. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  103362. /** @hidden */
  103363. _initCache(): void;
  103364. /** @hidden */
  103365. _updateCache(ignoreParentClass?: boolean): void;
  103366. protected _getTargetPosition(): Vector3;
  103367. private _storedAlpha;
  103368. private _storedBeta;
  103369. private _storedRadius;
  103370. private _storedTarget;
  103371. private _storedTargetScreenOffset;
  103372. /**
  103373. * Stores the current state of the camera (alpha, beta, radius and target)
  103374. * @returns the camera itself
  103375. */
  103376. storeState(): Camera;
  103377. /**
  103378. * @hidden
  103379. * Restored camera state. You must call storeState() first
  103380. */
  103381. _restoreStateValues(): boolean;
  103382. /** @hidden */
  103383. _isSynchronizedViewMatrix(): boolean;
  103384. /**
  103385. * Attached controls to the current camera.
  103386. * @param element Defines the element the controls should be listened from
  103387. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103388. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  103389. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  103390. */
  103391. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  103392. /**
  103393. * Detach the current controls from the camera.
  103394. * The camera will stop reacting to inputs.
  103395. * @param element Defines the element to stop listening the inputs from
  103396. */
  103397. detachControl(element: HTMLElement): void;
  103398. /** @hidden */
  103399. _checkInputs(): void;
  103400. protected _checkLimits(): void;
  103401. /**
  103402. * Rebuilds angles (alpha, beta) and radius from the give position and target
  103403. */
  103404. rebuildAnglesAndRadius(): void;
  103405. /**
  103406. * Use a position to define the current camera related information like alpha, beta and radius
  103407. * @param position Defines the position to set the camera at
  103408. */
  103409. setPosition(position: Vector3): void;
  103410. /**
  103411. * Defines the target the camera should look at.
  103412. * This will automatically adapt alpha beta and radius to fit within the new target.
  103413. * @param target Defines the new target as a Vector or a mesh
  103414. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  103415. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  103416. */
  103417. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  103418. /** @hidden */
  103419. _getViewMatrix(): Matrix;
  103420. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  103421. /**
  103422. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  103423. * @param meshes Defines the mesh to zoom on
  103424. * @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)
  103425. */
  103426. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  103427. /**
  103428. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  103429. * The target will be changed but the radius
  103430. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  103431. * @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)
  103432. */
  103433. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  103434. min: Vector3;
  103435. max: Vector3;
  103436. distance: number;
  103437. }, doNotUpdateMaxZ?: boolean): void;
  103438. /**
  103439. * @override
  103440. * Override Camera.createRigCamera
  103441. */
  103442. createRigCamera(name: string, cameraIndex: number): Camera;
  103443. /**
  103444. * @hidden
  103445. * @override
  103446. * Override Camera._updateRigCameras
  103447. */
  103448. _updateRigCameras(): void;
  103449. /**
  103450. * Destroy the camera and release the current resources hold by it.
  103451. */
  103452. dispose(): void;
  103453. /**
  103454. * Gets the current object class name.
  103455. * @return the class name
  103456. */
  103457. getClassName(): string;
  103458. }
  103459. }
  103460. declare module BABYLON {
  103461. /**
  103462. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  103463. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  103464. */
  103465. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  103466. /**
  103467. * Gets the name of the behavior.
  103468. */
  103469. readonly name: string;
  103470. private _zoomStopsAnimation;
  103471. private _idleRotationSpeed;
  103472. private _idleRotationWaitTime;
  103473. private _idleRotationSpinupTime;
  103474. /**
  103475. * Sets the flag that indicates if user zooming should stop animation.
  103476. */
  103477. /**
  103478. * Gets the flag that indicates if user zooming should stop animation.
  103479. */
  103480. zoomStopsAnimation: boolean;
  103481. /**
  103482. * Sets the default speed at which the camera rotates around the model.
  103483. */
  103484. /**
  103485. * Gets the default speed at which the camera rotates around the model.
  103486. */
  103487. idleRotationSpeed: number;
  103488. /**
  103489. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  103490. */
  103491. /**
  103492. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  103493. */
  103494. idleRotationWaitTime: number;
  103495. /**
  103496. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  103497. */
  103498. /**
  103499. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  103500. */
  103501. idleRotationSpinupTime: number;
  103502. /**
  103503. * Gets a value indicating if the camera is currently rotating because of this behavior
  103504. */
  103505. readonly rotationInProgress: boolean;
  103506. private _onPrePointerObservableObserver;
  103507. private _onAfterCheckInputsObserver;
  103508. private _attachedCamera;
  103509. private _isPointerDown;
  103510. private _lastFrameTime;
  103511. private _lastInteractionTime;
  103512. private _cameraRotationSpeed;
  103513. /**
  103514. * Initializes the behavior.
  103515. */
  103516. init(): void;
  103517. /**
  103518. * Attaches the behavior to its arc rotate camera.
  103519. * @param camera Defines the camera to attach the behavior to
  103520. */
  103521. attach(camera: ArcRotateCamera): void;
  103522. /**
  103523. * Detaches the behavior from its current arc rotate camera.
  103524. */
  103525. detach(): void;
  103526. /**
  103527. * Returns true if user is scrolling.
  103528. * @return true if user is scrolling.
  103529. */
  103530. private _userIsZooming;
  103531. private _lastFrameRadius;
  103532. private _shouldAnimationStopForInteraction;
  103533. /**
  103534. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  103535. */
  103536. private _applyUserInteraction;
  103537. private _userIsMoving;
  103538. }
  103539. }
  103540. declare module BABYLON {
  103541. /**
  103542. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  103543. */
  103544. export class AttachToBoxBehavior implements Behavior<Mesh> {
  103545. private ui;
  103546. /**
  103547. * The name of the behavior
  103548. */
  103549. name: string;
  103550. /**
  103551. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  103552. */
  103553. distanceAwayFromFace: number;
  103554. /**
  103555. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  103556. */
  103557. distanceAwayFromBottomOfFace: number;
  103558. private _faceVectors;
  103559. private _target;
  103560. private _scene;
  103561. private _onRenderObserver;
  103562. private _tmpMatrix;
  103563. private _tmpVector;
  103564. /**
  103565. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  103566. * @param ui The transform node that should be attched to the mesh
  103567. */
  103568. constructor(ui: TransformNode);
  103569. /**
  103570. * Initializes the behavior
  103571. */
  103572. init(): void;
  103573. private _closestFace;
  103574. private _zeroVector;
  103575. private _lookAtTmpMatrix;
  103576. private _lookAtToRef;
  103577. /**
  103578. * Attaches the AttachToBoxBehavior to the passed in mesh
  103579. * @param target The mesh that the specified node will be attached to
  103580. */
  103581. attach(target: Mesh): void;
  103582. /**
  103583. * Detaches the behavior from the mesh
  103584. */
  103585. detach(): void;
  103586. }
  103587. }
  103588. declare module BABYLON {
  103589. /**
  103590. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  103591. */
  103592. export class FadeInOutBehavior implements Behavior<Mesh> {
  103593. /**
  103594. * Time in milliseconds to delay before fading in (Default: 0)
  103595. */
  103596. delay: number;
  103597. /**
  103598. * Time in milliseconds for the mesh to fade in (Default: 300)
  103599. */
  103600. fadeInTime: number;
  103601. private _millisecondsPerFrame;
  103602. private _hovered;
  103603. private _hoverValue;
  103604. private _ownerNode;
  103605. /**
  103606. * Instatiates the FadeInOutBehavior
  103607. */
  103608. constructor();
  103609. /**
  103610. * The name of the behavior
  103611. */
  103612. readonly name: string;
  103613. /**
  103614. * Initializes the behavior
  103615. */
  103616. init(): void;
  103617. /**
  103618. * Attaches the fade behavior on the passed in mesh
  103619. * @param ownerNode The mesh that will be faded in/out once attached
  103620. */
  103621. attach(ownerNode: Mesh): void;
  103622. /**
  103623. * Detaches the behavior from the mesh
  103624. */
  103625. detach(): void;
  103626. /**
  103627. * Triggers the mesh to begin fading in or out
  103628. * @param value if the object should fade in or out (true to fade in)
  103629. */
  103630. fadeIn(value: boolean): void;
  103631. private _update;
  103632. private _setAllVisibility;
  103633. }
  103634. }
  103635. declare module BABYLON {
  103636. /**
  103637. * Class containing a set of static utilities functions for managing Pivots
  103638. * @hidden
  103639. */
  103640. export class PivotTools {
  103641. private static _PivotCached;
  103642. private static _OldPivotPoint;
  103643. private static _PivotTranslation;
  103644. private static _PivotTmpVector;
  103645. /** @hidden */
  103646. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  103647. /** @hidden */
  103648. static _RestorePivotPoint(mesh: AbstractMesh): void;
  103649. }
  103650. }
  103651. declare module BABYLON {
  103652. /**
  103653. * Class containing static functions to help procedurally build meshes
  103654. */
  103655. export class PlaneBuilder {
  103656. /**
  103657. * Creates a plane mesh
  103658. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  103659. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  103660. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  103661. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103662. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103663. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103664. * @param name defines the name of the mesh
  103665. * @param options defines the options used to create the mesh
  103666. * @param scene defines the hosting scene
  103667. * @returns the plane mesh
  103668. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  103669. */
  103670. static CreatePlane(name: string, options: {
  103671. size?: number;
  103672. width?: number;
  103673. height?: number;
  103674. sideOrientation?: number;
  103675. frontUVs?: Vector4;
  103676. backUVs?: Vector4;
  103677. updatable?: boolean;
  103678. sourcePlane?: Plane;
  103679. }, scene?: Nullable<Scene>): Mesh;
  103680. }
  103681. }
  103682. declare module BABYLON {
  103683. /**
  103684. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  103685. */
  103686. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  103687. private static _AnyMouseID;
  103688. /**
  103689. * Abstract mesh the behavior is set on
  103690. */
  103691. attachedNode: AbstractMesh;
  103692. private _dragPlane;
  103693. private _scene;
  103694. private _pointerObserver;
  103695. private _beforeRenderObserver;
  103696. private static _planeScene;
  103697. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  103698. /**
  103699. * 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)
  103700. */
  103701. maxDragAngle: number;
  103702. /**
  103703. * @hidden
  103704. */
  103705. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  103706. /**
  103707. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  103708. */
  103709. currentDraggingPointerID: number;
  103710. /**
  103711. * The last position where the pointer hit the drag plane in world space
  103712. */
  103713. lastDragPosition: Vector3;
  103714. /**
  103715. * If the behavior is currently in a dragging state
  103716. */
  103717. dragging: boolean;
  103718. /**
  103719. * 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)
  103720. */
  103721. dragDeltaRatio: number;
  103722. /**
  103723. * If the drag plane orientation should be updated during the dragging (Default: true)
  103724. */
  103725. updateDragPlane: boolean;
  103726. private _debugMode;
  103727. private _moving;
  103728. /**
  103729. * Fires each time the attached mesh is dragged with the pointer
  103730. * * delta between last drag position and current drag position in world space
  103731. * * dragDistance along the drag axis
  103732. * * dragPlaneNormal normal of the current drag plane used during the drag
  103733. * * dragPlanePoint in world space where the drag intersects the drag plane
  103734. */
  103735. onDragObservable: Observable<{
  103736. delta: Vector3;
  103737. dragPlanePoint: Vector3;
  103738. dragPlaneNormal: Vector3;
  103739. dragDistance: number;
  103740. pointerId: number;
  103741. }>;
  103742. /**
  103743. * Fires each time a drag begins (eg. mouse down on mesh)
  103744. */
  103745. onDragStartObservable: Observable<{
  103746. dragPlanePoint: Vector3;
  103747. pointerId: number;
  103748. }>;
  103749. /**
  103750. * Fires each time a drag ends (eg. mouse release after drag)
  103751. */
  103752. onDragEndObservable: Observable<{
  103753. dragPlanePoint: Vector3;
  103754. pointerId: number;
  103755. }>;
  103756. /**
  103757. * If the attached mesh should be moved when dragged
  103758. */
  103759. moveAttached: boolean;
  103760. /**
  103761. * If the drag behavior will react to drag events (Default: true)
  103762. */
  103763. enabled: boolean;
  103764. /**
  103765. * If pointer events should start and release the drag (Default: true)
  103766. */
  103767. startAndReleaseDragOnPointerEvents: boolean;
  103768. /**
  103769. * If camera controls should be detached during the drag
  103770. */
  103771. detachCameraControls: boolean;
  103772. /**
  103773. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  103774. */
  103775. useObjectOrienationForDragging: boolean;
  103776. private _options;
  103777. /**
  103778. * Creates a pointer drag behavior that can be attached to a mesh
  103779. * @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)
  103780. */
  103781. constructor(options?: {
  103782. dragAxis?: Vector3;
  103783. dragPlaneNormal?: Vector3;
  103784. });
  103785. /**
  103786. * Predicate to determine if it is valid to move the object to a new position when it is moved
  103787. */
  103788. validateDrag: (targetPosition: Vector3) => boolean;
  103789. /**
  103790. * The name of the behavior
  103791. */
  103792. readonly name: string;
  103793. /**
  103794. * Initializes the behavior
  103795. */
  103796. init(): void;
  103797. private _tmpVector;
  103798. private _alternatePickedPoint;
  103799. private _worldDragAxis;
  103800. private _targetPosition;
  103801. private _attachedElement;
  103802. /**
  103803. * Attaches the drag behavior the passed in mesh
  103804. * @param ownerNode The mesh that will be dragged around once attached
  103805. * @param predicate Predicate to use for pick filtering
  103806. */
  103807. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  103808. /**
  103809. * Force relase the drag action by code.
  103810. */
  103811. releaseDrag(): void;
  103812. private _startDragRay;
  103813. private _lastPointerRay;
  103814. /**
  103815. * Simulates the start of a pointer drag event on the behavior
  103816. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  103817. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  103818. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  103819. */
  103820. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  103821. private _startDrag;
  103822. private _dragDelta;
  103823. private _moveDrag;
  103824. private _pickWithRayOnDragPlane;
  103825. private _pointA;
  103826. private _pointB;
  103827. private _pointC;
  103828. private _lineA;
  103829. private _lineB;
  103830. private _localAxis;
  103831. private _lookAt;
  103832. private _updateDragPlanePosition;
  103833. /**
  103834. * Detaches the behavior from the mesh
  103835. */
  103836. detach(): void;
  103837. }
  103838. }
  103839. declare module BABYLON {
  103840. /**
  103841. * A behavior that when attached to a mesh will allow the mesh to be scaled
  103842. */
  103843. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  103844. private _dragBehaviorA;
  103845. private _dragBehaviorB;
  103846. private _startDistance;
  103847. private _initialScale;
  103848. private _targetScale;
  103849. private _ownerNode;
  103850. private _sceneRenderObserver;
  103851. /**
  103852. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  103853. */
  103854. constructor();
  103855. /**
  103856. * The name of the behavior
  103857. */
  103858. readonly name: string;
  103859. /**
  103860. * Initializes the behavior
  103861. */
  103862. init(): void;
  103863. private _getCurrentDistance;
  103864. /**
  103865. * Attaches the scale behavior the passed in mesh
  103866. * @param ownerNode The mesh that will be scaled around once attached
  103867. */
  103868. attach(ownerNode: Mesh): void;
  103869. /**
  103870. * Detaches the behavior from the mesh
  103871. */
  103872. detach(): void;
  103873. }
  103874. }
  103875. declare module BABYLON {
  103876. /**
  103877. * 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
  103878. */
  103879. export class SixDofDragBehavior implements Behavior<Mesh> {
  103880. private static _virtualScene;
  103881. private _ownerNode;
  103882. private _sceneRenderObserver;
  103883. private _scene;
  103884. private _targetPosition;
  103885. private _virtualOriginMesh;
  103886. private _virtualDragMesh;
  103887. private _pointerObserver;
  103888. private _moving;
  103889. private _startingOrientation;
  103890. /**
  103891. * 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)
  103892. */
  103893. private zDragFactor;
  103894. /**
  103895. * If the object should rotate to face the drag origin
  103896. */
  103897. rotateDraggedObject: boolean;
  103898. /**
  103899. * If the behavior is currently in a dragging state
  103900. */
  103901. dragging: boolean;
  103902. /**
  103903. * 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)
  103904. */
  103905. dragDeltaRatio: number;
  103906. /**
  103907. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  103908. */
  103909. currentDraggingPointerID: number;
  103910. /**
  103911. * If camera controls should be detached during the drag
  103912. */
  103913. detachCameraControls: boolean;
  103914. /**
  103915. * Fires each time a drag starts
  103916. */
  103917. onDragStartObservable: Observable<{}>;
  103918. /**
  103919. * Fires each time a drag ends (eg. mouse release after drag)
  103920. */
  103921. onDragEndObservable: Observable<{}>;
  103922. /**
  103923. * 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
  103924. */
  103925. constructor();
  103926. /**
  103927. * The name of the behavior
  103928. */
  103929. readonly name: string;
  103930. /**
  103931. * Initializes the behavior
  103932. */
  103933. init(): void;
  103934. /**
  103935. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  103936. */
  103937. private readonly _pointerCamera;
  103938. /**
  103939. * Attaches the scale behavior the passed in mesh
  103940. * @param ownerNode The mesh that will be scaled around once attached
  103941. */
  103942. attach(ownerNode: Mesh): void;
  103943. /**
  103944. * Detaches the behavior from the mesh
  103945. */
  103946. detach(): void;
  103947. }
  103948. }
  103949. declare module BABYLON {
  103950. /**
  103951. * Class used to apply inverse kinematics to bones
  103952. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  103953. */
  103954. export class BoneIKController {
  103955. private static _tmpVecs;
  103956. private static _tmpQuat;
  103957. private static _tmpMats;
  103958. /**
  103959. * Gets or sets the target mesh
  103960. */
  103961. targetMesh: AbstractMesh;
  103962. /** Gets or sets the mesh used as pole */
  103963. poleTargetMesh: AbstractMesh;
  103964. /**
  103965. * Gets or sets the bone used as pole
  103966. */
  103967. poleTargetBone: Nullable<Bone>;
  103968. /**
  103969. * Gets or sets the target position
  103970. */
  103971. targetPosition: Vector3;
  103972. /**
  103973. * Gets or sets the pole target position
  103974. */
  103975. poleTargetPosition: Vector3;
  103976. /**
  103977. * Gets or sets the pole target local offset
  103978. */
  103979. poleTargetLocalOffset: Vector3;
  103980. /**
  103981. * Gets or sets the pole angle
  103982. */
  103983. poleAngle: number;
  103984. /**
  103985. * Gets or sets the mesh associated with the controller
  103986. */
  103987. mesh: AbstractMesh;
  103988. /**
  103989. * 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)
  103990. */
  103991. slerpAmount: number;
  103992. private _bone1Quat;
  103993. private _bone1Mat;
  103994. private _bone2Ang;
  103995. private _bone1;
  103996. private _bone2;
  103997. private _bone1Length;
  103998. private _bone2Length;
  103999. private _maxAngle;
  104000. private _maxReach;
  104001. private _rightHandedSystem;
  104002. private _bendAxis;
  104003. private _slerping;
  104004. private _adjustRoll;
  104005. /**
  104006. * Gets or sets maximum allowed angle
  104007. */
  104008. maxAngle: number;
  104009. /**
  104010. * Creates a new BoneIKController
  104011. * @param mesh defines the mesh to control
  104012. * @param bone defines the bone to control
  104013. * @param options defines options to set up the controller
  104014. */
  104015. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  104016. targetMesh?: AbstractMesh;
  104017. poleTargetMesh?: AbstractMesh;
  104018. poleTargetBone?: Bone;
  104019. poleTargetLocalOffset?: Vector3;
  104020. poleAngle?: number;
  104021. bendAxis?: Vector3;
  104022. maxAngle?: number;
  104023. slerpAmount?: number;
  104024. });
  104025. private _setMaxAngle;
  104026. /**
  104027. * Force the controller to update the bones
  104028. */
  104029. update(): void;
  104030. }
  104031. }
  104032. declare module BABYLON {
  104033. /**
  104034. * Class used to make a bone look toward a point in space
  104035. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  104036. */
  104037. export class BoneLookController {
  104038. private static _tmpVecs;
  104039. private static _tmpQuat;
  104040. private static _tmpMats;
  104041. /**
  104042. * The target Vector3 that the bone will look at
  104043. */
  104044. target: Vector3;
  104045. /**
  104046. * The mesh that the bone is attached to
  104047. */
  104048. mesh: AbstractMesh;
  104049. /**
  104050. * The bone that will be looking to the target
  104051. */
  104052. bone: Bone;
  104053. /**
  104054. * The up axis of the coordinate system that is used when the bone is rotated
  104055. */
  104056. upAxis: Vector3;
  104057. /**
  104058. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  104059. */
  104060. upAxisSpace: Space;
  104061. /**
  104062. * Used to make an adjustment to the yaw of the bone
  104063. */
  104064. adjustYaw: number;
  104065. /**
  104066. * Used to make an adjustment to the pitch of the bone
  104067. */
  104068. adjustPitch: number;
  104069. /**
  104070. * Used to make an adjustment to the roll of the bone
  104071. */
  104072. adjustRoll: number;
  104073. /**
  104074. * 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)
  104075. */
  104076. slerpAmount: number;
  104077. private _minYaw;
  104078. private _maxYaw;
  104079. private _minPitch;
  104080. private _maxPitch;
  104081. private _minYawSin;
  104082. private _minYawCos;
  104083. private _maxYawSin;
  104084. private _maxYawCos;
  104085. private _midYawConstraint;
  104086. private _minPitchTan;
  104087. private _maxPitchTan;
  104088. private _boneQuat;
  104089. private _slerping;
  104090. private _transformYawPitch;
  104091. private _transformYawPitchInv;
  104092. private _firstFrameSkipped;
  104093. private _yawRange;
  104094. private _fowardAxis;
  104095. /**
  104096. * Gets or sets the minimum yaw angle that the bone can look to
  104097. */
  104098. minYaw: number;
  104099. /**
  104100. * Gets or sets the maximum yaw angle that the bone can look to
  104101. */
  104102. maxYaw: number;
  104103. /**
  104104. * Gets or sets the minimum pitch angle that the bone can look to
  104105. */
  104106. minPitch: number;
  104107. /**
  104108. * Gets or sets the maximum pitch angle that the bone can look to
  104109. */
  104110. maxPitch: number;
  104111. /**
  104112. * Create a BoneLookController
  104113. * @param mesh the mesh that the bone belongs to
  104114. * @param bone the bone that will be looking to the target
  104115. * @param target the target Vector3 to look at
  104116. * @param options optional settings:
  104117. * * maxYaw: the maximum angle the bone will yaw to
  104118. * * minYaw: the minimum angle the bone will yaw to
  104119. * * maxPitch: the maximum angle the bone will pitch to
  104120. * * minPitch: the minimum angle the bone will yaw to
  104121. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  104122. * * upAxis: the up axis of the coordinate system
  104123. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  104124. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  104125. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  104126. * * adjustYaw: used to make an adjustment to the yaw of the bone
  104127. * * adjustPitch: used to make an adjustment to the pitch of the bone
  104128. * * adjustRoll: used to make an adjustment to the roll of the bone
  104129. **/
  104130. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  104131. maxYaw?: number;
  104132. minYaw?: number;
  104133. maxPitch?: number;
  104134. minPitch?: number;
  104135. slerpAmount?: number;
  104136. upAxis?: Vector3;
  104137. upAxisSpace?: Space;
  104138. yawAxis?: Vector3;
  104139. pitchAxis?: Vector3;
  104140. adjustYaw?: number;
  104141. adjustPitch?: number;
  104142. adjustRoll?: number;
  104143. });
  104144. /**
  104145. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  104146. */
  104147. update(): void;
  104148. private _getAngleDiff;
  104149. private _getAngleBetween;
  104150. private _isAngleBetween;
  104151. }
  104152. }
  104153. declare module BABYLON {
  104154. /**
  104155. * Manage the gamepad inputs to control an arc rotate camera.
  104156. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104157. */
  104158. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  104159. /**
  104160. * Defines the camera the input is attached to.
  104161. */
  104162. camera: ArcRotateCamera;
  104163. /**
  104164. * Defines the gamepad the input is gathering event from.
  104165. */
  104166. gamepad: Nullable<Gamepad>;
  104167. /**
  104168. * Defines the gamepad rotation sensiblity.
  104169. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  104170. */
  104171. gamepadRotationSensibility: number;
  104172. /**
  104173. * Defines the gamepad move sensiblity.
  104174. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  104175. */
  104176. gamepadMoveSensibility: number;
  104177. private _onGamepadConnectedObserver;
  104178. private _onGamepadDisconnectedObserver;
  104179. /**
  104180. * Attach the input controls to a specific dom element to get the input from.
  104181. * @param element Defines the element the controls should be listened from
  104182. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104183. */
  104184. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104185. /**
  104186. * Detach the current controls from the specified dom element.
  104187. * @param element Defines the element to stop listening the inputs from
  104188. */
  104189. detachControl(element: Nullable<HTMLElement>): void;
  104190. /**
  104191. * Update the current camera state depending on the inputs that have been used this frame.
  104192. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104193. */
  104194. checkInputs(): void;
  104195. /**
  104196. * Gets the class name of the current intput.
  104197. * @returns the class name
  104198. */
  104199. getClassName(): string;
  104200. /**
  104201. * Get the friendly name associated with the input class.
  104202. * @returns the input friendly name
  104203. */
  104204. getSimpleName(): string;
  104205. }
  104206. }
  104207. declare module BABYLON {
  104208. interface ArcRotateCameraInputsManager {
  104209. /**
  104210. * Add orientation input support to the input manager.
  104211. * @returns the current input manager
  104212. */
  104213. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  104214. }
  104215. /**
  104216. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  104217. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104218. */
  104219. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  104220. /**
  104221. * Defines the camera the input is attached to.
  104222. */
  104223. camera: ArcRotateCamera;
  104224. /**
  104225. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  104226. */
  104227. alphaCorrection: number;
  104228. /**
  104229. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  104230. */
  104231. gammaCorrection: number;
  104232. private _alpha;
  104233. private _gamma;
  104234. private _dirty;
  104235. private _deviceOrientationHandler;
  104236. /**
  104237. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  104238. */
  104239. constructor();
  104240. /**
  104241. * Attach the input controls to a specific dom element to get the input from.
  104242. * @param element Defines the element the controls should be listened from
  104243. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104244. */
  104245. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104246. /** @hidden */
  104247. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  104248. /**
  104249. * Update the current camera state depending on the inputs that have been used this frame.
  104250. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104251. */
  104252. checkInputs(): void;
  104253. /**
  104254. * Detach the current controls from the specified dom element.
  104255. * @param element Defines the element to stop listening the inputs from
  104256. */
  104257. detachControl(element: Nullable<HTMLElement>): void;
  104258. /**
  104259. * Gets the class name of the current intput.
  104260. * @returns the class name
  104261. */
  104262. getClassName(): string;
  104263. /**
  104264. * Get the friendly name associated with the input class.
  104265. * @returns the input friendly name
  104266. */
  104267. getSimpleName(): string;
  104268. }
  104269. }
  104270. declare module BABYLON {
  104271. /**
  104272. * Listen to mouse events to control the camera.
  104273. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104274. */
  104275. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  104276. /**
  104277. * Defines the camera the input is attached to.
  104278. */
  104279. camera: FlyCamera;
  104280. /**
  104281. * Defines if touch is enabled. (Default is true.)
  104282. */
  104283. touchEnabled: boolean;
  104284. /**
  104285. * Defines the buttons associated with the input to handle camera rotation.
  104286. */
  104287. buttons: number[];
  104288. /**
  104289. * Assign buttons for Yaw control.
  104290. */
  104291. buttonsYaw: number[];
  104292. /**
  104293. * Assign buttons for Pitch control.
  104294. */
  104295. buttonsPitch: number[];
  104296. /**
  104297. * Assign buttons for Roll control.
  104298. */
  104299. buttonsRoll: number[];
  104300. /**
  104301. * Detect if any button is being pressed while mouse is moved.
  104302. * -1 = Mouse locked.
  104303. * 0 = Left button.
  104304. * 1 = Middle Button.
  104305. * 2 = Right Button.
  104306. */
  104307. activeButton: number;
  104308. /**
  104309. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  104310. * Higher values reduce its sensitivity.
  104311. */
  104312. angularSensibility: number;
  104313. private _mousemoveCallback;
  104314. private _observer;
  104315. private _rollObserver;
  104316. private previousPosition;
  104317. private noPreventDefault;
  104318. private element;
  104319. /**
  104320. * Listen to mouse events to control the camera.
  104321. * @param touchEnabled Define if touch is enabled. (Default is true.)
  104322. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104323. */
  104324. constructor(touchEnabled?: boolean);
  104325. /**
  104326. * Attach the mouse control to the HTML DOM element.
  104327. * @param element Defines the element that listens to the input events.
  104328. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  104329. */
  104330. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104331. /**
  104332. * Detach the current controls from the specified dom element.
  104333. * @param element Defines the element to stop listening the inputs from
  104334. */
  104335. detachControl(element: Nullable<HTMLElement>): void;
  104336. /**
  104337. * Gets the class name of the current input.
  104338. * @returns the class name.
  104339. */
  104340. getClassName(): string;
  104341. /**
  104342. * Get the friendly name associated with the input class.
  104343. * @returns the input's friendly name.
  104344. */
  104345. getSimpleName(): string;
  104346. private _pointerInput;
  104347. private _onMouseMove;
  104348. /**
  104349. * Rotate camera by mouse offset.
  104350. */
  104351. private rotateCamera;
  104352. }
  104353. }
  104354. declare module BABYLON {
  104355. /**
  104356. * Default Inputs manager for the FlyCamera.
  104357. * It groups all the default supported inputs for ease of use.
  104358. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104359. */
  104360. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  104361. /**
  104362. * Instantiates a new FlyCameraInputsManager.
  104363. * @param camera Defines the camera the inputs belong to.
  104364. */
  104365. constructor(camera: FlyCamera);
  104366. /**
  104367. * Add keyboard input support to the input manager.
  104368. * @returns the new FlyCameraKeyboardMoveInput().
  104369. */
  104370. addKeyboard(): FlyCameraInputsManager;
  104371. /**
  104372. * Add mouse input support to the input manager.
  104373. * @param touchEnabled Enable touch screen support.
  104374. * @returns the new FlyCameraMouseInput().
  104375. */
  104376. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  104377. }
  104378. }
  104379. declare module BABYLON {
  104380. /**
  104381. * This is a flying camera, designed for 3D movement and rotation in all directions,
  104382. * such as in a 3D Space Shooter or a Flight Simulator.
  104383. */
  104384. export class FlyCamera extends TargetCamera {
  104385. /**
  104386. * Define the collision ellipsoid of the camera.
  104387. * This is helpful for simulating a camera body, like a player's body.
  104388. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  104389. */
  104390. ellipsoid: Vector3;
  104391. /**
  104392. * Define an offset for the position of the ellipsoid around the camera.
  104393. * This can be helpful if the camera is attached away from the player's body center,
  104394. * such as at its head.
  104395. */
  104396. ellipsoidOffset: Vector3;
  104397. /**
  104398. * Enable or disable collisions of the camera with the rest of the scene objects.
  104399. */
  104400. checkCollisions: boolean;
  104401. /**
  104402. * Enable or disable gravity on the camera.
  104403. */
  104404. applyGravity: boolean;
  104405. /**
  104406. * Define the current direction the camera is moving to.
  104407. */
  104408. cameraDirection: Vector3;
  104409. /**
  104410. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  104411. * This overrides and empties cameraRotation.
  104412. */
  104413. rotationQuaternion: Quaternion;
  104414. /**
  104415. * Track Roll to maintain the wanted Rolling when looking around.
  104416. */
  104417. _trackRoll: number;
  104418. /**
  104419. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  104420. */
  104421. rollCorrect: number;
  104422. /**
  104423. * Mimic a banked turn, Rolling the camera when Yawing.
  104424. * It's recommended to use rollCorrect = 10 for faster banking correction.
  104425. */
  104426. bankedTurn: boolean;
  104427. /**
  104428. * Limit in radians for how much Roll banking will add. (Default: 90°)
  104429. */
  104430. bankedTurnLimit: number;
  104431. /**
  104432. * Value of 0 disables the banked Roll.
  104433. * Value of 1 is equal to the Yaw angle in radians.
  104434. */
  104435. bankedTurnMultiplier: number;
  104436. /**
  104437. * The inputs manager loads all the input sources, such as keyboard and mouse.
  104438. */
  104439. inputs: FlyCameraInputsManager;
  104440. /**
  104441. * Gets the input sensibility for mouse input.
  104442. * Higher values reduce sensitivity.
  104443. */
  104444. /**
  104445. * Sets the input sensibility for a mouse input.
  104446. * Higher values reduce sensitivity.
  104447. */
  104448. angularSensibility: number;
  104449. /**
  104450. * Get the keys for camera movement forward.
  104451. */
  104452. /**
  104453. * Set the keys for camera movement forward.
  104454. */
  104455. keysForward: number[];
  104456. /**
  104457. * Get the keys for camera movement backward.
  104458. */
  104459. keysBackward: number[];
  104460. /**
  104461. * Get the keys for camera movement up.
  104462. */
  104463. /**
  104464. * Set the keys for camera movement up.
  104465. */
  104466. keysUp: number[];
  104467. /**
  104468. * Get the keys for camera movement down.
  104469. */
  104470. /**
  104471. * Set the keys for camera movement down.
  104472. */
  104473. keysDown: number[];
  104474. /**
  104475. * Get the keys for camera movement left.
  104476. */
  104477. /**
  104478. * Set the keys for camera movement left.
  104479. */
  104480. keysLeft: number[];
  104481. /**
  104482. * Set the keys for camera movement right.
  104483. */
  104484. /**
  104485. * Set the keys for camera movement right.
  104486. */
  104487. keysRight: number[];
  104488. /**
  104489. * Event raised when the camera collides with a mesh in the scene.
  104490. */
  104491. onCollide: (collidedMesh: AbstractMesh) => void;
  104492. private _collider;
  104493. private _needMoveForGravity;
  104494. private _oldPosition;
  104495. private _diffPosition;
  104496. private _newPosition;
  104497. /** @hidden */
  104498. _localDirection: Vector3;
  104499. /** @hidden */
  104500. _transformedDirection: Vector3;
  104501. /**
  104502. * Instantiates a FlyCamera.
  104503. * This is a flying camera, designed for 3D movement and rotation in all directions,
  104504. * such as in a 3D Space Shooter or a Flight Simulator.
  104505. * @param name Define the name of the camera in the scene.
  104506. * @param position Define the starting position of the camera in the scene.
  104507. * @param scene Define the scene the camera belongs to.
  104508. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  104509. */
  104510. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  104511. /**
  104512. * Attach a control to the HTML DOM element.
  104513. * @param element Defines the element that listens to the input events.
  104514. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  104515. */
  104516. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104517. /**
  104518. * Detach a control from the HTML DOM element.
  104519. * The camera will stop reacting to that input.
  104520. * @param element Defines the element that listens to the input events.
  104521. */
  104522. detachControl(element: HTMLElement): void;
  104523. private _collisionMask;
  104524. /**
  104525. * Get the mask that the camera ignores in collision events.
  104526. */
  104527. /**
  104528. * Set the mask that the camera ignores in collision events.
  104529. */
  104530. collisionMask: number;
  104531. /** @hidden */
  104532. _collideWithWorld(displacement: Vector3): void;
  104533. /** @hidden */
  104534. private _onCollisionPositionChange;
  104535. /** @hidden */
  104536. _checkInputs(): void;
  104537. /** @hidden */
  104538. _decideIfNeedsToMove(): boolean;
  104539. /** @hidden */
  104540. _updatePosition(): void;
  104541. /**
  104542. * Restore the Roll to its target value at the rate specified.
  104543. * @param rate - Higher means slower restoring.
  104544. * @hidden
  104545. */
  104546. restoreRoll(rate: number): void;
  104547. /**
  104548. * Destroy the camera and release the current resources held by it.
  104549. */
  104550. dispose(): void;
  104551. /**
  104552. * Get the current object class name.
  104553. * @returns the class name.
  104554. */
  104555. getClassName(): string;
  104556. }
  104557. }
  104558. declare module BABYLON {
  104559. /**
  104560. * Listen to keyboard events to control the camera.
  104561. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104562. */
  104563. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  104564. /**
  104565. * Defines the camera the input is attached to.
  104566. */
  104567. camera: FlyCamera;
  104568. /**
  104569. * The list of keyboard keys used to control the forward move of the camera.
  104570. */
  104571. keysForward: number[];
  104572. /**
  104573. * The list of keyboard keys used to control the backward move of the camera.
  104574. */
  104575. keysBackward: number[];
  104576. /**
  104577. * The list of keyboard keys used to control the forward move of the camera.
  104578. */
  104579. keysUp: number[];
  104580. /**
  104581. * The list of keyboard keys used to control the backward move of the camera.
  104582. */
  104583. keysDown: number[];
  104584. /**
  104585. * The list of keyboard keys used to control the right strafe move of the camera.
  104586. */
  104587. keysRight: number[];
  104588. /**
  104589. * The list of keyboard keys used to control the left strafe move of the camera.
  104590. */
  104591. keysLeft: number[];
  104592. private _keys;
  104593. private _onCanvasBlurObserver;
  104594. private _onKeyboardObserver;
  104595. private _engine;
  104596. private _scene;
  104597. /**
  104598. * Attach the input controls to a specific dom element to get the input from.
  104599. * @param element Defines the element the controls should be listened from
  104600. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104601. */
  104602. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104603. /**
  104604. * Detach the current controls from the specified dom element.
  104605. * @param element Defines the element to stop listening the inputs from
  104606. */
  104607. detachControl(element: Nullable<HTMLElement>): void;
  104608. /**
  104609. * Gets the class name of the current intput.
  104610. * @returns the class name
  104611. */
  104612. getClassName(): string;
  104613. /** @hidden */
  104614. _onLostFocus(e: FocusEvent): void;
  104615. /**
  104616. * Get the friendly name associated with the input class.
  104617. * @returns the input friendly name
  104618. */
  104619. getSimpleName(): string;
  104620. /**
  104621. * Update the current camera state depending on the inputs that have been used this frame.
  104622. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104623. */
  104624. checkInputs(): void;
  104625. }
  104626. }
  104627. declare module BABYLON {
  104628. /**
  104629. * Manage the mouse wheel inputs to control a follow camera.
  104630. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104631. */
  104632. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  104633. /**
  104634. * Defines the camera the input is attached to.
  104635. */
  104636. camera: FollowCamera;
  104637. /**
  104638. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  104639. */
  104640. axisControlRadius: boolean;
  104641. /**
  104642. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  104643. */
  104644. axisControlHeight: boolean;
  104645. /**
  104646. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  104647. */
  104648. axisControlRotation: boolean;
  104649. /**
  104650. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  104651. * relation to mouseWheel events.
  104652. */
  104653. wheelPrecision: number;
  104654. /**
  104655. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  104656. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  104657. */
  104658. wheelDeltaPercentage: number;
  104659. private _wheel;
  104660. private _observer;
  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. /**
  104678. * Get the friendly name associated with the input class.
  104679. * @returns the input friendly name
  104680. */
  104681. getSimpleName(): string;
  104682. }
  104683. }
  104684. declare module BABYLON {
  104685. /**
  104686. * Manage the pointers inputs to control an follow camera.
  104687. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104688. */
  104689. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  104690. /**
  104691. * Defines the camera the input is attached to.
  104692. */
  104693. camera: FollowCamera;
  104694. /**
  104695. * Gets the class name of the current input.
  104696. * @returns the class name
  104697. */
  104698. getClassName(): string;
  104699. /**
  104700. * Defines the pointer angular sensibility along the X axis or how fast is
  104701. * the camera rotating.
  104702. * A negative number will reverse the axis direction.
  104703. */
  104704. angularSensibilityX: number;
  104705. /**
  104706. * Defines the pointer angular sensibility along the Y axis or how fast is
  104707. * the camera rotating.
  104708. * A negative number will reverse the axis direction.
  104709. */
  104710. angularSensibilityY: number;
  104711. /**
  104712. * Defines the pointer pinch precision or how fast is the camera zooming.
  104713. * A negative number will reverse the axis direction.
  104714. */
  104715. pinchPrecision: number;
  104716. /**
  104717. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  104718. * from 0.
  104719. * It defines the percentage of current camera.radius to use as delta when
  104720. * pinch zoom is used.
  104721. */
  104722. pinchDeltaPercentage: number;
  104723. /**
  104724. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  104725. */
  104726. axisXControlRadius: boolean;
  104727. /**
  104728. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  104729. */
  104730. axisXControlHeight: boolean;
  104731. /**
  104732. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  104733. */
  104734. axisXControlRotation: boolean;
  104735. /**
  104736. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  104737. */
  104738. axisYControlRadius: boolean;
  104739. /**
  104740. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  104741. */
  104742. axisYControlHeight: boolean;
  104743. /**
  104744. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  104745. */
  104746. axisYControlRotation: boolean;
  104747. /**
  104748. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  104749. */
  104750. axisPinchControlRadius: boolean;
  104751. /**
  104752. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  104753. */
  104754. axisPinchControlHeight: boolean;
  104755. /**
  104756. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  104757. */
  104758. axisPinchControlRotation: boolean;
  104759. /**
  104760. * Log error messages if basic misconfiguration has occurred.
  104761. */
  104762. warningEnable: boolean;
  104763. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  104764. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  104765. private _warningCounter;
  104766. private _warning;
  104767. }
  104768. }
  104769. declare module BABYLON {
  104770. /**
  104771. * Default Inputs manager for the FollowCamera.
  104772. * It groups all the default supported inputs for ease of use.
  104773. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104774. */
  104775. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  104776. /**
  104777. * Instantiates a new FollowCameraInputsManager.
  104778. * @param camera Defines the camera the inputs belong to
  104779. */
  104780. constructor(camera: FollowCamera);
  104781. /**
  104782. * Add keyboard input support to the input manager.
  104783. * @returns the current input manager
  104784. */
  104785. addKeyboard(): FollowCameraInputsManager;
  104786. /**
  104787. * Add mouse wheel input support to the input manager.
  104788. * @returns the current input manager
  104789. */
  104790. addMouseWheel(): FollowCameraInputsManager;
  104791. /**
  104792. * Add pointers input support to the input manager.
  104793. * @returns the current input manager
  104794. */
  104795. addPointers(): FollowCameraInputsManager;
  104796. /**
  104797. * Add orientation input support to the input manager.
  104798. * @returns the current input manager
  104799. */
  104800. addVRDeviceOrientation(): FollowCameraInputsManager;
  104801. }
  104802. }
  104803. declare module BABYLON {
  104804. /**
  104805. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  104806. * an arc rotate version arcFollowCamera are available.
  104807. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  104808. */
  104809. export class FollowCamera extends TargetCamera {
  104810. /**
  104811. * Distance the follow camera should follow an object at
  104812. */
  104813. radius: number;
  104814. /**
  104815. * Minimum allowed distance of the camera to the axis of rotation
  104816. * (The camera can not get closer).
  104817. * This can help limiting how the Camera is able to move in the scene.
  104818. */
  104819. lowerRadiusLimit: Nullable<number>;
  104820. /**
  104821. * Maximum allowed distance of the camera to the axis of rotation
  104822. * (The camera can not get further).
  104823. * This can help limiting how the Camera is able to move in the scene.
  104824. */
  104825. upperRadiusLimit: Nullable<number>;
  104826. /**
  104827. * Define a rotation offset between the camera and the object it follows
  104828. */
  104829. rotationOffset: number;
  104830. /**
  104831. * Minimum allowed angle to camera position relative to target object.
  104832. * This can help limiting how the Camera is able to move in the scene.
  104833. */
  104834. lowerRotationOffsetLimit: Nullable<number>;
  104835. /**
  104836. * Maximum allowed angle to camera position relative to target object.
  104837. * This can help limiting how the Camera is able to move in the scene.
  104838. */
  104839. upperRotationOffsetLimit: Nullable<number>;
  104840. /**
  104841. * Define a height offset between the camera and the object it follows.
  104842. * It can help following an object from the top (like a car chaing a plane)
  104843. */
  104844. heightOffset: number;
  104845. /**
  104846. * Minimum allowed height of camera position relative to target object.
  104847. * This can help limiting how the Camera is able to move in the scene.
  104848. */
  104849. lowerHeightOffsetLimit: Nullable<number>;
  104850. /**
  104851. * Maximum allowed height of camera position relative to target object.
  104852. * This can help limiting how the Camera is able to move in the scene.
  104853. */
  104854. upperHeightOffsetLimit: Nullable<number>;
  104855. /**
  104856. * Define how fast the camera can accelerate to follow it s target.
  104857. */
  104858. cameraAcceleration: number;
  104859. /**
  104860. * Define the speed limit of the camera following an object.
  104861. */
  104862. maxCameraSpeed: number;
  104863. /**
  104864. * Define the target of the camera.
  104865. */
  104866. lockedTarget: Nullable<AbstractMesh>;
  104867. /**
  104868. * Defines the input associated with the camera.
  104869. */
  104870. inputs: FollowCameraInputsManager;
  104871. /**
  104872. * Instantiates the follow camera.
  104873. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  104874. * @param name Define the name of the camera in the scene
  104875. * @param position Define the position of the camera
  104876. * @param scene Define the scene the camera belong to
  104877. * @param lockedTarget Define the target of the camera
  104878. */
  104879. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  104880. private _follow;
  104881. /**
  104882. * Attached controls to the current camera.
  104883. * @param element Defines the element the controls should be listened from
  104884. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104885. */
  104886. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104887. /**
  104888. * Detach the current controls from the camera.
  104889. * The camera will stop reacting to inputs.
  104890. * @param element Defines the element to stop listening the inputs from
  104891. */
  104892. detachControl(element: HTMLElement): void;
  104893. /** @hidden */
  104894. _checkInputs(): void;
  104895. private _checkLimits;
  104896. /**
  104897. * Gets the camera class name.
  104898. * @returns the class name
  104899. */
  104900. getClassName(): string;
  104901. }
  104902. /**
  104903. * Arc Rotate version of the follow camera.
  104904. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  104905. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  104906. */
  104907. export class ArcFollowCamera extends TargetCamera {
  104908. /** The longitudinal angle of the camera */
  104909. alpha: number;
  104910. /** The latitudinal angle of the camera */
  104911. beta: number;
  104912. /** The radius of the camera from its target */
  104913. radius: number;
  104914. /** Define the camera target (the messh it should follow) */
  104915. target: Nullable<AbstractMesh>;
  104916. private _cartesianCoordinates;
  104917. /**
  104918. * Instantiates a new ArcFollowCamera
  104919. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  104920. * @param name Define the name of the camera
  104921. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  104922. * @param beta Define the rotation angle of the camera around the elevation axis
  104923. * @param radius Define the radius of the camera from its target point
  104924. * @param target Define the target of the camera
  104925. * @param scene Define the scene the camera belongs to
  104926. */
  104927. constructor(name: string,
  104928. /** The longitudinal angle of the camera */
  104929. alpha: number,
  104930. /** The latitudinal angle of the camera */
  104931. beta: number,
  104932. /** The radius of the camera from its target */
  104933. radius: number,
  104934. /** Define the camera target (the messh it should follow) */
  104935. target: Nullable<AbstractMesh>, scene: Scene);
  104936. private _follow;
  104937. /** @hidden */
  104938. _checkInputs(): void;
  104939. /**
  104940. * Returns the class name of the object.
  104941. * It is mostly used internally for serialization purposes.
  104942. */
  104943. getClassName(): string;
  104944. }
  104945. }
  104946. declare module BABYLON {
  104947. /**
  104948. * Manage the keyboard inputs to control the movement of a follow camera.
  104949. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104950. */
  104951. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  104952. /**
  104953. * Defines the camera the input is attached to.
  104954. */
  104955. camera: FollowCamera;
  104956. /**
  104957. * Defines the list of key codes associated with the up action (increase heightOffset)
  104958. */
  104959. keysHeightOffsetIncr: number[];
  104960. /**
  104961. * Defines the list of key codes associated with the down action (decrease heightOffset)
  104962. */
  104963. keysHeightOffsetDecr: number[];
  104964. /**
  104965. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  104966. */
  104967. keysHeightOffsetModifierAlt: boolean;
  104968. /**
  104969. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  104970. */
  104971. keysHeightOffsetModifierCtrl: boolean;
  104972. /**
  104973. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  104974. */
  104975. keysHeightOffsetModifierShift: boolean;
  104976. /**
  104977. * Defines the list of key codes associated with the left action (increase rotationOffset)
  104978. */
  104979. keysRotationOffsetIncr: number[];
  104980. /**
  104981. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  104982. */
  104983. keysRotationOffsetDecr: number[];
  104984. /**
  104985. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  104986. */
  104987. keysRotationOffsetModifierAlt: boolean;
  104988. /**
  104989. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  104990. */
  104991. keysRotationOffsetModifierCtrl: boolean;
  104992. /**
  104993. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  104994. */
  104995. keysRotationOffsetModifierShift: boolean;
  104996. /**
  104997. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  104998. */
  104999. keysRadiusIncr: number[];
  105000. /**
  105001. * Defines the list of key codes associated with the zoom-out action (increase radius)
  105002. */
  105003. keysRadiusDecr: number[];
  105004. /**
  105005. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  105006. */
  105007. keysRadiusModifierAlt: boolean;
  105008. /**
  105009. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  105010. */
  105011. keysRadiusModifierCtrl: boolean;
  105012. /**
  105013. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  105014. */
  105015. keysRadiusModifierShift: boolean;
  105016. /**
  105017. * Defines the rate of change of heightOffset.
  105018. */
  105019. heightSensibility: number;
  105020. /**
  105021. * Defines the rate of change of rotationOffset.
  105022. */
  105023. rotationSensibility: number;
  105024. /**
  105025. * Defines the rate of change of radius.
  105026. */
  105027. radiusSensibility: number;
  105028. private _keys;
  105029. private _ctrlPressed;
  105030. private _altPressed;
  105031. private _shiftPressed;
  105032. private _onCanvasBlurObserver;
  105033. private _onKeyboardObserver;
  105034. private _engine;
  105035. private _scene;
  105036. /**
  105037. * Attach the input controls to a specific dom element to get the input from.
  105038. * @param element Defines the element the controls should be listened from
  105039. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105040. */
  105041. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105042. /**
  105043. * Detach the current controls from the specified dom element.
  105044. * @param element Defines the element to stop listening the inputs from
  105045. */
  105046. detachControl(element: Nullable<HTMLElement>): void;
  105047. /**
  105048. * Update the current camera state depending on the inputs that have been used this frame.
  105049. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105050. */
  105051. checkInputs(): void;
  105052. /**
  105053. * Gets the class name of the current input.
  105054. * @returns the class name
  105055. */
  105056. getClassName(): string;
  105057. /**
  105058. * Get the friendly name associated with the input class.
  105059. * @returns the input friendly name
  105060. */
  105061. getSimpleName(): string;
  105062. /**
  105063. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  105064. * allow modification of the heightOffset value.
  105065. */
  105066. private _modifierHeightOffset;
  105067. /**
  105068. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  105069. * allow modification of the rotationOffset value.
  105070. */
  105071. private _modifierRotationOffset;
  105072. /**
  105073. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  105074. * allow modification of the radius value.
  105075. */
  105076. private _modifierRadius;
  105077. }
  105078. }
  105079. declare module BABYLON {
  105080. interface FreeCameraInputsManager {
  105081. /**
  105082. * @hidden
  105083. */
  105084. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  105085. /**
  105086. * Add orientation input support to the input manager.
  105087. * @returns the current input manager
  105088. */
  105089. addDeviceOrientation(): FreeCameraInputsManager;
  105090. }
  105091. /**
  105092. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  105093. * Screen rotation is taken into account.
  105094. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105095. */
  105096. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  105097. private _camera;
  105098. private _screenOrientationAngle;
  105099. private _constantTranform;
  105100. private _screenQuaternion;
  105101. private _alpha;
  105102. private _beta;
  105103. private _gamma;
  105104. /**
  105105. * Can be used to detect if a device orientation sensor is availible on a device
  105106. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  105107. * @returns a promise that will resolve on orientation change
  105108. */
  105109. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  105110. /**
  105111. * @hidden
  105112. */
  105113. _onDeviceOrientationChangedObservable: Observable<void>;
  105114. /**
  105115. * Instantiates a new input
  105116. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105117. */
  105118. constructor();
  105119. /**
  105120. * Define the camera controlled by the input.
  105121. */
  105122. camera: FreeCamera;
  105123. /**
  105124. * Attach the input controls to a specific dom element to get the input from.
  105125. * @param element Defines the element the controls should be listened from
  105126. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105127. */
  105128. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105129. private _orientationChanged;
  105130. private _deviceOrientation;
  105131. /**
  105132. * Detach the current controls from the specified dom element.
  105133. * @param element Defines the element to stop listening the inputs from
  105134. */
  105135. detachControl(element: Nullable<HTMLElement>): void;
  105136. /**
  105137. * Update the current camera state depending on the inputs that have been used this frame.
  105138. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105139. */
  105140. checkInputs(): void;
  105141. /**
  105142. * Gets the class name of the current intput.
  105143. * @returns the class name
  105144. */
  105145. getClassName(): string;
  105146. /**
  105147. * Get the friendly name associated with the input class.
  105148. * @returns the input friendly name
  105149. */
  105150. getSimpleName(): string;
  105151. }
  105152. }
  105153. declare module BABYLON {
  105154. /**
  105155. * Manage the gamepad inputs to control a free camera.
  105156. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105157. */
  105158. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  105159. /**
  105160. * Define the camera the input is attached to.
  105161. */
  105162. camera: FreeCamera;
  105163. /**
  105164. * Define the Gamepad controlling the input
  105165. */
  105166. gamepad: Nullable<Gamepad>;
  105167. /**
  105168. * Defines the gamepad rotation sensiblity.
  105169. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  105170. */
  105171. gamepadAngularSensibility: number;
  105172. /**
  105173. * Defines the gamepad move sensiblity.
  105174. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  105175. */
  105176. gamepadMoveSensibility: number;
  105177. private _onGamepadConnectedObserver;
  105178. private _onGamepadDisconnectedObserver;
  105179. private _cameraTransform;
  105180. private _deltaTransform;
  105181. private _vector3;
  105182. private _vector2;
  105183. /**
  105184. * Attach the input controls to a specific dom element to get the input from.
  105185. * @param element Defines the element the controls should be listened from
  105186. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105187. */
  105188. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105189. /**
  105190. * Detach the current controls from the specified dom element.
  105191. * @param element Defines the element to stop listening the inputs from
  105192. */
  105193. detachControl(element: Nullable<HTMLElement>): void;
  105194. /**
  105195. * Update the current camera state depending on the inputs that have been used this frame.
  105196. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105197. */
  105198. checkInputs(): void;
  105199. /**
  105200. * Gets the class name of the current intput.
  105201. * @returns the class name
  105202. */
  105203. getClassName(): string;
  105204. /**
  105205. * Get the friendly name associated with the input class.
  105206. * @returns the input friendly name
  105207. */
  105208. getSimpleName(): string;
  105209. }
  105210. }
  105211. declare module BABYLON {
  105212. /**
  105213. * Defines the potential axis of a Joystick
  105214. */
  105215. export enum JoystickAxis {
  105216. /** X axis */
  105217. X = 0,
  105218. /** Y axis */
  105219. Y = 1,
  105220. /** Z axis */
  105221. Z = 2
  105222. }
  105223. /**
  105224. * Class used to define virtual joystick (used in touch mode)
  105225. */
  105226. export class VirtualJoystick {
  105227. /**
  105228. * Gets or sets a boolean indicating that left and right values must be inverted
  105229. */
  105230. reverseLeftRight: boolean;
  105231. /**
  105232. * Gets or sets a boolean indicating that up and down values must be inverted
  105233. */
  105234. reverseUpDown: boolean;
  105235. /**
  105236. * Gets the offset value for the position (ie. the change of the position value)
  105237. */
  105238. deltaPosition: Vector3;
  105239. /**
  105240. * Gets a boolean indicating if the virtual joystick was pressed
  105241. */
  105242. pressed: boolean;
  105243. /**
  105244. * Canvas the virtual joystick will render onto, default z-index of this is 5
  105245. */
  105246. static Canvas: Nullable<HTMLCanvasElement>;
  105247. private static _globalJoystickIndex;
  105248. private static vjCanvasContext;
  105249. private static vjCanvasWidth;
  105250. private static vjCanvasHeight;
  105251. private static halfWidth;
  105252. private _action;
  105253. private _axisTargetedByLeftAndRight;
  105254. private _axisTargetedByUpAndDown;
  105255. private _joystickSensibility;
  105256. private _inversedSensibility;
  105257. private _joystickPointerID;
  105258. private _joystickColor;
  105259. private _joystickPointerPos;
  105260. private _joystickPreviousPointerPos;
  105261. private _joystickPointerStartPos;
  105262. private _deltaJoystickVector;
  105263. private _leftJoystick;
  105264. private _touches;
  105265. private _onPointerDownHandlerRef;
  105266. private _onPointerMoveHandlerRef;
  105267. private _onPointerUpHandlerRef;
  105268. private _onResize;
  105269. /**
  105270. * Creates a new virtual joystick
  105271. * @param leftJoystick defines that the joystick is for left hand (false by default)
  105272. */
  105273. constructor(leftJoystick?: boolean);
  105274. /**
  105275. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  105276. * @param newJoystickSensibility defines the new sensibility
  105277. */
  105278. setJoystickSensibility(newJoystickSensibility: number): void;
  105279. private _onPointerDown;
  105280. private _onPointerMove;
  105281. private _onPointerUp;
  105282. /**
  105283. * Change the color of the virtual joystick
  105284. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  105285. */
  105286. setJoystickColor(newColor: string): void;
  105287. /**
  105288. * Defines a callback to call when the joystick is touched
  105289. * @param action defines the callback
  105290. */
  105291. setActionOnTouch(action: () => any): void;
  105292. /**
  105293. * Defines which axis you'd like to control for left & right
  105294. * @param axis defines the axis to use
  105295. */
  105296. setAxisForLeftRight(axis: JoystickAxis): void;
  105297. /**
  105298. * Defines which axis you'd like to control for up & down
  105299. * @param axis defines the axis to use
  105300. */
  105301. setAxisForUpDown(axis: JoystickAxis): void;
  105302. private _drawVirtualJoystick;
  105303. /**
  105304. * Release internal HTML canvas
  105305. */
  105306. releaseCanvas(): void;
  105307. }
  105308. }
  105309. declare module BABYLON {
  105310. interface FreeCameraInputsManager {
  105311. /**
  105312. * Add virtual joystick input support to the input manager.
  105313. * @returns the current input manager
  105314. */
  105315. addVirtualJoystick(): FreeCameraInputsManager;
  105316. }
  105317. /**
  105318. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  105319. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105320. */
  105321. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  105322. /**
  105323. * Defines the camera the input is attached to.
  105324. */
  105325. camera: FreeCamera;
  105326. private _leftjoystick;
  105327. private _rightjoystick;
  105328. /**
  105329. * Gets the left stick of the virtual joystick.
  105330. * @returns The virtual Joystick
  105331. */
  105332. getLeftJoystick(): VirtualJoystick;
  105333. /**
  105334. * Gets the right stick of the virtual joystick.
  105335. * @returns The virtual Joystick
  105336. */
  105337. getRightJoystick(): VirtualJoystick;
  105338. /**
  105339. * Update the current camera state depending on the inputs that have been used this frame.
  105340. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105341. */
  105342. checkInputs(): void;
  105343. /**
  105344. * Attach the input controls to a specific dom element to get the input from.
  105345. * @param element Defines the element the controls should be listened from
  105346. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105347. */
  105348. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105349. /**
  105350. * Detach the current controls from the specified dom element.
  105351. * @param element Defines the element to stop listening the inputs from
  105352. */
  105353. detachControl(element: Nullable<HTMLElement>): void;
  105354. /**
  105355. * Gets the class name of the current intput.
  105356. * @returns the class name
  105357. */
  105358. getClassName(): string;
  105359. /**
  105360. * Get the friendly name associated with the input class.
  105361. * @returns the input friendly name
  105362. */
  105363. getSimpleName(): string;
  105364. }
  105365. }
  105366. declare module BABYLON {
  105367. /**
  105368. * This represents a FPS type of camera controlled by touch.
  105369. * This is like a universal camera minus the Gamepad controls.
  105370. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  105371. */
  105372. export class TouchCamera extends FreeCamera {
  105373. /**
  105374. * Defines the touch sensibility for rotation.
  105375. * The higher the faster.
  105376. */
  105377. touchAngularSensibility: number;
  105378. /**
  105379. * Defines the touch sensibility for move.
  105380. * The higher the faster.
  105381. */
  105382. touchMoveSensibility: number;
  105383. /**
  105384. * Instantiates a new touch camera.
  105385. * This represents a FPS type of camera controlled by touch.
  105386. * This is like a universal camera minus the Gamepad controls.
  105387. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  105388. * @param name Define the name of the camera in the scene
  105389. * @param position Define the start position of the camera in the scene
  105390. * @param scene Define the scene the camera belongs to
  105391. */
  105392. constructor(name: string, position: Vector3, scene: Scene);
  105393. /**
  105394. * Gets the current object class name.
  105395. * @return the class name
  105396. */
  105397. getClassName(): string;
  105398. /** @hidden */
  105399. _setupInputs(): void;
  105400. }
  105401. }
  105402. declare module BABYLON {
  105403. /**
  105404. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  105405. * being tilted forward or back and left or right.
  105406. */
  105407. export class DeviceOrientationCamera extends FreeCamera {
  105408. private _initialQuaternion;
  105409. private _quaternionCache;
  105410. private _tmpDragQuaternion;
  105411. private _disablePointerInputWhenUsingDeviceOrientation;
  105412. /**
  105413. * Creates a new device orientation camera
  105414. * @param name The name of the camera
  105415. * @param position The start position camera
  105416. * @param scene The scene the camera belongs to
  105417. */
  105418. constructor(name: string, position: Vector3, scene: Scene);
  105419. /**
  105420. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  105421. */
  105422. disablePointerInputWhenUsingDeviceOrientation: boolean;
  105423. private _dragFactor;
  105424. /**
  105425. * Enabled turning on the y axis when the orientation sensor is active
  105426. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  105427. */
  105428. enableHorizontalDragging(dragFactor?: number): void;
  105429. /**
  105430. * Gets the current instance class name ("DeviceOrientationCamera").
  105431. * This helps avoiding instanceof at run time.
  105432. * @returns the class name
  105433. */
  105434. getClassName(): string;
  105435. /**
  105436. * @hidden
  105437. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  105438. */
  105439. _checkInputs(): void;
  105440. /**
  105441. * Reset the camera to its default orientation on the specified axis only.
  105442. * @param axis The axis to reset
  105443. */
  105444. resetToCurrentRotation(axis?: Axis): void;
  105445. }
  105446. }
  105447. declare module BABYLON {
  105448. /**
  105449. * Defines supported buttons for XBox360 compatible gamepads
  105450. */
  105451. export enum Xbox360Button {
  105452. /** A */
  105453. A = 0,
  105454. /** B */
  105455. B = 1,
  105456. /** X */
  105457. X = 2,
  105458. /** Y */
  105459. Y = 3,
  105460. /** Start */
  105461. Start = 4,
  105462. /** Back */
  105463. Back = 5,
  105464. /** Left button */
  105465. LB = 6,
  105466. /** Right button */
  105467. RB = 7,
  105468. /** Left stick */
  105469. LeftStick = 8,
  105470. /** Right stick */
  105471. RightStick = 9
  105472. }
  105473. /** Defines values for XBox360 DPad */
  105474. export enum Xbox360Dpad {
  105475. /** Up */
  105476. Up = 0,
  105477. /** Down */
  105478. Down = 1,
  105479. /** Left */
  105480. Left = 2,
  105481. /** Right */
  105482. Right = 3
  105483. }
  105484. /**
  105485. * Defines a XBox360 gamepad
  105486. */
  105487. export class Xbox360Pad extends Gamepad {
  105488. private _leftTrigger;
  105489. private _rightTrigger;
  105490. private _onlefttriggerchanged;
  105491. private _onrighttriggerchanged;
  105492. private _onbuttondown;
  105493. private _onbuttonup;
  105494. private _ondpaddown;
  105495. private _ondpadup;
  105496. /** Observable raised when a button is pressed */
  105497. onButtonDownObservable: Observable<Xbox360Button>;
  105498. /** Observable raised when a button is released */
  105499. onButtonUpObservable: Observable<Xbox360Button>;
  105500. /** Observable raised when a pad is pressed */
  105501. onPadDownObservable: Observable<Xbox360Dpad>;
  105502. /** Observable raised when a pad is released */
  105503. onPadUpObservable: Observable<Xbox360Dpad>;
  105504. private _buttonA;
  105505. private _buttonB;
  105506. private _buttonX;
  105507. private _buttonY;
  105508. private _buttonBack;
  105509. private _buttonStart;
  105510. private _buttonLB;
  105511. private _buttonRB;
  105512. private _buttonLeftStick;
  105513. private _buttonRightStick;
  105514. private _dPadUp;
  105515. private _dPadDown;
  105516. private _dPadLeft;
  105517. private _dPadRight;
  105518. private _isXboxOnePad;
  105519. /**
  105520. * Creates a new XBox360 gamepad object
  105521. * @param id defines the id of this gamepad
  105522. * @param index defines its index
  105523. * @param gamepad defines the internal HTML gamepad object
  105524. * @param xboxOne defines if it is a XBox One gamepad
  105525. */
  105526. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  105527. /**
  105528. * Defines the callback to call when left trigger is pressed
  105529. * @param callback defines the callback to use
  105530. */
  105531. onlefttriggerchanged(callback: (value: number) => void): void;
  105532. /**
  105533. * Defines the callback to call when right trigger is pressed
  105534. * @param callback defines the callback to use
  105535. */
  105536. onrighttriggerchanged(callback: (value: number) => void): void;
  105537. /**
  105538. * Gets the left trigger value
  105539. */
  105540. /**
  105541. * Sets the left trigger value
  105542. */
  105543. leftTrigger: number;
  105544. /**
  105545. * Gets the right trigger value
  105546. */
  105547. /**
  105548. * Sets the right trigger value
  105549. */
  105550. rightTrigger: number;
  105551. /**
  105552. * Defines the callback to call when a button is pressed
  105553. * @param callback defines the callback to use
  105554. */
  105555. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  105556. /**
  105557. * Defines the callback to call when a button is released
  105558. * @param callback defines the callback to use
  105559. */
  105560. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  105561. /**
  105562. * Defines the callback to call when a pad is pressed
  105563. * @param callback defines the callback to use
  105564. */
  105565. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  105566. /**
  105567. * Defines the callback to call when a pad is released
  105568. * @param callback defines the callback to use
  105569. */
  105570. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  105571. private _setButtonValue;
  105572. private _setDPadValue;
  105573. /**
  105574. * Gets the value of the `A` button
  105575. */
  105576. /**
  105577. * Sets the value of the `A` button
  105578. */
  105579. buttonA: number;
  105580. /**
  105581. * Gets the value of the `B` button
  105582. */
  105583. /**
  105584. * Sets the value of the `B` button
  105585. */
  105586. buttonB: number;
  105587. /**
  105588. * Gets the value of the `X` button
  105589. */
  105590. /**
  105591. * Sets the value of the `X` button
  105592. */
  105593. buttonX: number;
  105594. /**
  105595. * Gets the value of the `Y` button
  105596. */
  105597. /**
  105598. * Sets the value of the `Y` button
  105599. */
  105600. buttonY: number;
  105601. /**
  105602. * Gets the value of the `Start` button
  105603. */
  105604. /**
  105605. * Sets the value of the `Start` button
  105606. */
  105607. buttonStart: number;
  105608. /**
  105609. * Gets the value of the `Back` button
  105610. */
  105611. /**
  105612. * Sets the value of the `Back` button
  105613. */
  105614. buttonBack: number;
  105615. /**
  105616. * Gets the value of the `Left` button
  105617. */
  105618. /**
  105619. * Sets the value of the `Left` button
  105620. */
  105621. buttonLB: number;
  105622. /**
  105623. * Gets the value of the `Right` button
  105624. */
  105625. /**
  105626. * Sets the value of the `Right` button
  105627. */
  105628. buttonRB: number;
  105629. /**
  105630. * Gets the value of the Left joystick
  105631. */
  105632. /**
  105633. * Sets the value of the Left joystick
  105634. */
  105635. buttonLeftStick: number;
  105636. /**
  105637. * Gets the value of the Right joystick
  105638. */
  105639. /**
  105640. * Sets the value of the Right joystick
  105641. */
  105642. buttonRightStick: number;
  105643. /**
  105644. * Gets the value of D-pad up
  105645. */
  105646. /**
  105647. * Sets the value of D-pad up
  105648. */
  105649. dPadUp: number;
  105650. /**
  105651. * Gets the value of D-pad down
  105652. */
  105653. /**
  105654. * Sets the value of D-pad down
  105655. */
  105656. dPadDown: number;
  105657. /**
  105658. * Gets the value of D-pad left
  105659. */
  105660. /**
  105661. * Sets the value of D-pad left
  105662. */
  105663. dPadLeft: number;
  105664. /**
  105665. * Gets the value of D-pad right
  105666. */
  105667. /**
  105668. * Sets the value of D-pad right
  105669. */
  105670. dPadRight: number;
  105671. /**
  105672. * Force the gamepad to synchronize with device values
  105673. */
  105674. update(): void;
  105675. /**
  105676. * Disposes the gamepad
  105677. */
  105678. dispose(): void;
  105679. }
  105680. }
  105681. declare module BABYLON {
  105682. /**
  105683. * Defines supported buttons for DualShock compatible gamepads
  105684. */
  105685. export enum DualShockButton {
  105686. /** Cross */
  105687. Cross = 0,
  105688. /** Circle */
  105689. Circle = 1,
  105690. /** Square */
  105691. Square = 2,
  105692. /** Triangle */
  105693. Triangle = 3,
  105694. /** Options */
  105695. Options = 4,
  105696. /** Share */
  105697. Share = 5,
  105698. /** L1 */
  105699. L1 = 6,
  105700. /** R1 */
  105701. R1 = 7,
  105702. /** Left stick */
  105703. LeftStick = 8,
  105704. /** Right stick */
  105705. RightStick = 9
  105706. }
  105707. /** Defines values for DualShock DPad */
  105708. export enum DualShockDpad {
  105709. /** Up */
  105710. Up = 0,
  105711. /** Down */
  105712. Down = 1,
  105713. /** Left */
  105714. Left = 2,
  105715. /** Right */
  105716. Right = 3
  105717. }
  105718. /**
  105719. * Defines a DualShock gamepad
  105720. */
  105721. export class DualShockPad extends Gamepad {
  105722. private _leftTrigger;
  105723. private _rightTrigger;
  105724. private _onlefttriggerchanged;
  105725. private _onrighttriggerchanged;
  105726. private _onbuttondown;
  105727. private _onbuttonup;
  105728. private _ondpaddown;
  105729. private _ondpadup;
  105730. /** Observable raised when a button is pressed */
  105731. onButtonDownObservable: Observable<DualShockButton>;
  105732. /** Observable raised when a button is released */
  105733. onButtonUpObservable: Observable<DualShockButton>;
  105734. /** Observable raised when a pad is pressed */
  105735. onPadDownObservable: Observable<DualShockDpad>;
  105736. /** Observable raised when a pad is released */
  105737. onPadUpObservable: Observable<DualShockDpad>;
  105738. private _buttonCross;
  105739. private _buttonCircle;
  105740. private _buttonSquare;
  105741. private _buttonTriangle;
  105742. private _buttonShare;
  105743. private _buttonOptions;
  105744. private _buttonL1;
  105745. private _buttonR1;
  105746. private _buttonLeftStick;
  105747. private _buttonRightStick;
  105748. private _dPadUp;
  105749. private _dPadDown;
  105750. private _dPadLeft;
  105751. private _dPadRight;
  105752. /**
  105753. * Creates a new DualShock gamepad object
  105754. * @param id defines the id of this gamepad
  105755. * @param index defines its index
  105756. * @param gamepad defines the internal HTML gamepad object
  105757. */
  105758. constructor(id: string, index: number, gamepad: any);
  105759. /**
  105760. * Defines the callback to call when left trigger is pressed
  105761. * @param callback defines the callback to use
  105762. */
  105763. onlefttriggerchanged(callback: (value: number) => void): void;
  105764. /**
  105765. * Defines the callback to call when right trigger is pressed
  105766. * @param callback defines the callback to use
  105767. */
  105768. onrighttriggerchanged(callback: (value: number) => void): void;
  105769. /**
  105770. * Gets the left trigger value
  105771. */
  105772. /**
  105773. * Sets the left trigger value
  105774. */
  105775. leftTrigger: number;
  105776. /**
  105777. * Gets the right trigger value
  105778. */
  105779. /**
  105780. * Sets the right trigger value
  105781. */
  105782. rightTrigger: number;
  105783. /**
  105784. * Defines the callback to call when a button is pressed
  105785. * @param callback defines the callback to use
  105786. */
  105787. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  105788. /**
  105789. * Defines the callback to call when a button is released
  105790. * @param callback defines the callback to use
  105791. */
  105792. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  105793. /**
  105794. * Defines the callback to call when a pad is pressed
  105795. * @param callback defines the callback to use
  105796. */
  105797. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  105798. /**
  105799. * Defines the callback to call when a pad is released
  105800. * @param callback defines the callback to use
  105801. */
  105802. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  105803. private _setButtonValue;
  105804. private _setDPadValue;
  105805. /**
  105806. * Gets the value of the `Cross` button
  105807. */
  105808. /**
  105809. * Sets the value of the `Cross` button
  105810. */
  105811. buttonCross: number;
  105812. /**
  105813. * Gets the value of the `Circle` button
  105814. */
  105815. /**
  105816. * Sets the value of the `Circle` button
  105817. */
  105818. buttonCircle: number;
  105819. /**
  105820. * Gets the value of the `Square` button
  105821. */
  105822. /**
  105823. * Sets the value of the `Square` button
  105824. */
  105825. buttonSquare: number;
  105826. /**
  105827. * Gets the value of the `Triangle` button
  105828. */
  105829. /**
  105830. * Sets the value of the `Triangle` button
  105831. */
  105832. buttonTriangle: number;
  105833. /**
  105834. * Gets the value of the `Options` button
  105835. */
  105836. /**
  105837. * Sets the value of the `Options` button
  105838. */
  105839. buttonOptions: number;
  105840. /**
  105841. * Gets the value of the `Share` button
  105842. */
  105843. /**
  105844. * Sets the value of the `Share` button
  105845. */
  105846. buttonShare: number;
  105847. /**
  105848. * Gets the value of the `L1` button
  105849. */
  105850. /**
  105851. * Sets the value of the `L1` button
  105852. */
  105853. buttonL1: number;
  105854. /**
  105855. * Gets the value of the `R1` button
  105856. */
  105857. /**
  105858. * Sets the value of the `R1` button
  105859. */
  105860. buttonR1: number;
  105861. /**
  105862. * Gets the value of the Left joystick
  105863. */
  105864. /**
  105865. * Sets the value of the Left joystick
  105866. */
  105867. buttonLeftStick: number;
  105868. /**
  105869. * Gets the value of the Right joystick
  105870. */
  105871. /**
  105872. * Sets the value of the Right joystick
  105873. */
  105874. buttonRightStick: number;
  105875. /**
  105876. * Gets the value of D-pad up
  105877. */
  105878. /**
  105879. * Sets the value of D-pad up
  105880. */
  105881. dPadUp: number;
  105882. /**
  105883. * Gets the value of D-pad down
  105884. */
  105885. /**
  105886. * Sets the value of D-pad down
  105887. */
  105888. dPadDown: number;
  105889. /**
  105890. * Gets the value of D-pad left
  105891. */
  105892. /**
  105893. * Sets the value of D-pad left
  105894. */
  105895. dPadLeft: number;
  105896. /**
  105897. * Gets the value of D-pad right
  105898. */
  105899. /**
  105900. * Sets the value of D-pad right
  105901. */
  105902. dPadRight: number;
  105903. /**
  105904. * Force the gamepad to synchronize with device values
  105905. */
  105906. update(): void;
  105907. /**
  105908. * Disposes the gamepad
  105909. */
  105910. dispose(): void;
  105911. }
  105912. }
  105913. declare module BABYLON {
  105914. /**
  105915. * Manager for handling gamepads
  105916. */
  105917. export class GamepadManager {
  105918. private _scene?;
  105919. private _babylonGamepads;
  105920. private _oneGamepadConnected;
  105921. /** @hidden */
  105922. _isMonitoring: boolean;
  105923. private _gamepadEventSupported;
  105924. private _gamepadSupport;
  105925. /**
  105926. * observable to be triggered when the gamepad controller has been connected
  105927. */
  105928. onGamepadConnectedObservable: Observable<Gamepad>;
  105929. /**
  105930. * observable to be triggered when the gamepad controller has been disconnected
  105931. */
  105932. onGamepadDisconnectedObservable: Observable<Gamepad>;
  105933. private _onGamepadConnectedEvent;
  105934. private _onGamepadDisconnectedEvent;
  105935. /**
  105936. * Initializes the gamepad manager
  105937. * @param _scene BabylonJS scene
  105938. */
  105939. constructor(_scene?: Scene | undefined);
  105940. /**
  105941. * The gamepads in the game pad manager
  105942. */
  105943. readonly gamepads: Gamepad[];
  105944. /**
  105945. * Get the gamepad controllers based on type
  105946. * @param type The type of gamepad controller
  105947. * @returns Nullable gamepad
  105948. */
  105949. getGamepadByType(type?: number): Nullable<Gamepad>;
  105950. /**
  105951. * Disposes the gamepad manager
  105952. */
  105953. dispose(): void;
  105954. private _addNewGamepad;
  105955. private _startMonitoringGamepads;
  105956. private _stopMonitoringGamepads;
  105957. /** @hidden */
  105958. _checkGamepadsStatus(): void;
  105959. private _updateGamepadObjects;
  105960. }
  105961. }
  105962. declare module BABYLON {
  105963. interface Scene {
  105964. /** @hidden */
  105965. _gamepadManager: Nullable<GamepadManager>;
  105966. /**
  105967. * Gets the gamepad manager associated with the scene
  105968. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  105969. */
  105970. gamepadManager: GamepadManager;
  105971. }
  105972. /**
  105973. * Interface representing a free camera inputs manager
  105974. */
  105975. interface FreeCameraInputsManager {
  105976. /**
  105977. * Adds gamepad input support to the FreeCameraInputsManager.
  105978. * @returns the FreeCameraInputsManager
  105979. */
  105980. addGamepad(): FreeCameraInputsManager;
  105981. }
  105982. /**
  105983. * Interface representing an arc rotate camera inputs manager
  105984. */
  105985. interface ArcRotateCameraInputsManager {
  105986. /**
  105987. * Adds gamepad input support to the ArcRotateCamera InputManager.
  105988. * @returns the camera inputs manager
  105989. */
  105990. addGamepad(): ArcRotateCameraInputsManager;
  105991. }
  105992. /**
  105993. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  105994. */
  105995. export class GamepadSystemSceneComponent implements ISceneComponent {
  105996. /**
  105997. * The component name helpfull to identify the component in the list of scene components.
  105998. */
  105999. readonly name: string;
  106000. /**
  106001. * The scene the component belongs to.
  106002. */
  106003. scene: Scene;
  106004. /**
  106005. * Creates a new instance of the component for the given scene
  106006. * @param scene Defines the scene to register the component in
  106007. */
  106008. constructor(scene: Scene);
  106009. /**
  106010. * Registers the component in a given scene
  106011. */
  106012. register(): void;
  106013. /**
  106014. * Rebuilds the elements related to this component in case of
  106015. * context lost for instance.
  106016. */
  106017. rebuild(): void;
  106018. /**
  106019. * Disposes the component and the associated ressources
  106020. */
  106021. dispose(): void;
  106022. private _beforeCameraUpdate;
  106023. }
  106024. }
  106025. declare module BABYLON {
  106026. /**
  106027. * 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,
  106028. * which still works and will still be found in many Playgrounds.
  106029. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106030. */
  106031. export class UniversalCamera extends TouchCamera {
  106032. /**
  106033. * Defines the gamepad rotation sensiblity.
  106034. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  106035. */
  106036. gamepadAngularSensibility: number;
  106037. /**
  106038. * Defines the gamepad move sensiblity.
  106039. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  106040. */
  106041. gamepadMoveSensibility: number;
  106042. /**
  106043. * 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,
  106044. * which still works and will still be found in many Playgrounds.
  106045. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106046. * @param name Define the name of the camera in the scene
  106047. * @param position Define the start position of the camera in the scene
  106048. * @param scene Define the scene the camera belongs to
  106049. */
  106050. constructor(name: string, position: Vector3, scene: Scene);
  106051. /**
  106052. * Gets the current object class name.
  106053. * @return the class name
  106054. */
  106055. getClassName(): string;
  106056. }
  106057. }
  106058. declare module BABYLON {
  106059. /**
  106060. * This represents a FPS type of camera. This is only here for back compat purpose.
  106061. * Please use the UniversalCamera instead as both are identical.
  106062. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106063. */
  106064. export class GamepadCamera extends UniversalCamera {
  106065. /**
  106066. * Instantiates a new Gamepad Camera
  106067. * This represents a FPS type of camera. This is only here for back compat purpose.
  106068. * Please use the UniversalCamera instead as both are identical.
  106069. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106070. * @param name Define the name of the camera in the scene
  106071. * @param position Define the start position of the camera in the scene
  106072. * @param scene Define the scene the camera belongs to
  106073. */
  106074. constructor(name: string, position: Vector3, scene: Scene);
  106075. /**
  106076. * Gets the current object class name.
  106077. * @return the class name
  106078. */
  106079. getClassName(): string;
  106080. }
  106081. }
  106082. declare module BABYLON {
  106083. /** @hidden */
  106084. export var passPixelShader: {
  106085. name: string;
  106086. shader: string;
  106087. };
  106088. }
  106089. declare module BABYLON {
  106090. /** @hidden */
  106091. export var passCubePixelShader: {
  106092. name: string;
  106093. shader: string;
  106094. };
  106095. }
  106096. declare module BABYLON {
  106097. /**
  106098. * PassPostProcess which produces an output the same as it's input
  106099. */
  106100. export class PassPostProcess extends PostProcess {
  106101. /**
  106102. * Creates the PassPostProcess
  106103. * @param name The name of the effect.
  106104. * @param options The required width/height ratio to downsize to before computing the render pass.
  106105. * @param camera The camera to apply the render pass to.
  106106. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106107. * @param engine The engine which the post process will be applied. (default: current engine)
  106108. * @param reusable If the post process can be reused on the same frame. (default: false)
  106109. * @param textureType The type of texture to be used when performing the post processing.
  106110. * @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)
  106111. */
  106112. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  106113. }
  106114. /**
  106115. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  106116. */
  106117. export class PassCubePostProcess extends PostProcess {
  106118. private _face;
  106119. /**
  106120. * Gets or sets the cube face to display.
  106121. * * 0 is +X
  106122. * * 1 is -X
  106123. * * 2 is +Y
  106124. * * 3 is -Y
  106125. * * 4 is +Z
  106126. * * 5 is -Z
  106127. */
  106128. face: number;
  106129. /**
  106130. * Creates the PassCubePostProcess
  106131. * @param name The name of the effect.
  106132. * @param options The required width/height ratio to downsize to before computing the render pass.
  106133. * @param camera The camera to apply the render pass to.
  106134. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106135. * @param engine The engine which the post process will be applied. (default: current engine)
  106136. * @param reusable If the post process can be reused on the same frame. (default: false)
  106137. * @param textureType The type of texture to be used when performing the post processing.
  106138. * @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)
  106139. */
  106140. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  106141. }
  106142. }
  106143. declare module BABYLON {
  106144. /** @hidden */
  106145. export var anaglyphPixelShader: {
  106146. name: string;
  106147. shader: string;
  106148. };
  106149. }
  106150. declare module BABYLON {
  106151. /**
  106152. * Postprocess used to generate anaglyphic rendering
  106153. */
  106154. export class AnaglyphPostProcess extends PostProcess {
  106155. private _passedProcess;
  106156. /**
  106157. * Creates a new AnaglyphPostProcess
  106158. * @param name defines postprocess name
  106159. * @param options defines creation options or target ratio scale
  106160. * @param rigCameras defines cameras using this postprocess
  106161. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  106162. * @param engine defines hosting engine
  106163. * @param reusable defines if the postprocess will be reused multiple times per frame
  106164. */
  106165. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  106166. }
  106167. }
  106168. declare module BABYLON {
  106169. /**
  106170. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  106171. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  106172. */
  106173. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  106174. /**
  106175. * Creates a new AnaglyphArcRotateCamera
  106176. * @param name defines camera name
  106177. * @param alpha defines alpha angle (in radians)
  106178. * @param beta defines beta angle (in radians)
  106179. * @param radius defines radius
  106180. * @param target defines camera target
  106181. * @param interaxialDistance defines distance between each color axis
  106182. * @param scene defines the hosting scene
  106183. */
  106184. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  106185. /**
  106186. * Gets camera class name
  106187. * @returns AnaglyphArcRotateCamera
  106188. */
  106189. getClassName(): string;
  106190. }
  106191. }
  106192. declare module BABYLON {
  106193. /**
  106194. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  106195. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  106196. */
  106197. export class AnaglyphFreeCamera extends FreeCamera {
  106198. /**
  106199. * Creates a new AnaglyphFreeCamera
  106200. * @param name defines camera name
  106201. * @param position defines initial position
  106202. * @param interaxialDistance defines distance between each color axis
  106203. * @param scene defines the hosting scene
  106204. */
  106205. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  106206. /**
  106207. * Gets camera class name
  106208. * @returns AnaglyphFreeCamera
  106209. */
  106210. getClassName(): string;
  106211. }
  106212. }
  106213. declare module BABYLON {
  106214. /**
  106215. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  106216. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  106217. */
  106218. export class AnaglyphGamepadCamera extends GamepadCamera {
  106219. /**
  106220. * Creates a new AnaglyphGamepadCamera
  106221. * @param name defines camera name
  106222. * @param position defines initial position
  106223. * @param interaxialDistance defines distance between each color axis
  106224. * @param scene defines the hosting scene
  106225. */
  106226. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  106227. /**
  106228. * Gets camera class name
  106229. * @returns AnaglyphGamepadCamera
  106230. */
  106231. getClassName(): string;
  106232. }
  106233. }
  106234. declare module BABYLON {
  106235. /**
  106236. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  106237. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  106238. */
  106239. export class AnaglyphUniversalCamera extends UniversalCamera {
  106240. /**
  106241. * Creates a new AnaglyphUniversalCamera
  106242. * @param name defines camera name
  106243. * @param position defines initial position
  106244. * @param interaxialDistance defines distance between each color axis
  106245. * @param scene defines the hosting scene
  106246. */
  106247. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  106248. /**
  106249. * Gets camera class name
  106250. * @returns AnaglyphUniversalCamera
  106251. */
  106252. getClassName(): string;
  106253. }
  106254. }
  106255. declare module BABYLON {
  106256. /** @hidden */
  106257. export var stereoscopicInterlacePixelShader: {
  106258. name: string;
  106259. shader: string;
  106260. };
  106261. }
  106262. declare module BABYLON {
  106263. /**
  106264. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  106265. */
  106266. export class StereoscopicInterlacePostProcess extends PostProcess {
  106267. private _stepSize;
  106268. private _passedProcess;
  106269. /**
  106270. * Initializes a StereoscopicInterlacePostProcess
  106271. * @param name The name of the effect.
  106272. * @param rigCameras The rig cameras to be appled to the post process
  106273. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  106274. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106275. * @param engine The engine which the post process will be applied. (default: current engine)
  106276. * @param reusable If the post process can be reused on the same frame. (default: false)
  106277. */
  106278. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  106279. }
  106280. }
  106281. declare module BABYLON {
  106282. /**
  106283. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  106284. * @see http://doc.babylonjs.com/features/cameras
  106285. */
  106286. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  106287. /**
  106288. * Creates a new StereoscopicArcRotateCamera
  106289. * @param name defines camera name
  106290. * @param alpha defines alpha angle (in radians)
  106291. * @param beta defines beta angle (in radians)
  106292. * @param radius defines radius
  106293. * @param target defines camera target
  106294. * @param interaxialDistance defines distance between each color axis
  106295. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  106296. * @param scene defines the hosting scene
  106297. */
  106298. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  106299. /**
  106300. * Gets camera class name
  106301. * @returns StereoscopicArcRotateCamera
  106302. */
  106303. getClassName(): string;
  106304. }
  106305. }
  106306. declare module BABYLON {
  106307. /**
  106308. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  106309. * @see http://doc.babylonjs.com/features/cameras
  106310. */
  106311. export class StereoscopicFreeCamera extends FreeCamera {
  106312. /**
  106313. * Creates a new StereoscopicFreeCamera
  106314. * @param name defines camera name
  106315. * @param position defines initial position
  106316. * @param interaxialDistance defines distance between each color axis
  106317. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  106318. * @param scene defines the hosting scene
  106319. */
  106320. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  106321. /**
  106322. * Gets camera class name
  106323. * @returns StereoscopicFreeCamera
  106324. */
  106325. getClassName(): string;
  106326. }
  106327. }
  106328. declare module BABYLON {
  106329. /**
  106330. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  106331. * @see http://doc.babylonjs.com/features/cameras
  106332. */
  106333. export class StereoscopicGamepadCamera extends GamepadCamera {
  106334. /**
  106335. * Creates a new StereoscopicGamepadCamera
  106336. * @param name defines camera name
  106337. * @param position defines initial position
  106338. * @param interaxialDistance defines distance between each color axis
  106339. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  106340. * @param scene defines the hosting scene
  106341. */
  106342. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  106343. /**
  106344. * Gets camera class name
  106345. * @returns StereoscopicGamepadCamera
  106346. */
  106347. getClassName(): string;
  106348. }
  106349. }
  106350. declare module BABYLON {
  106351. /**
  106352. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  106353. * @see http://doc.babylonjs.com/features/cameras
  106354. */
  106355. export class StereoscopicUniversalCamera extends UniversalCamera {
  106356. /**
  106357. * Creates a new StereoscopicUniversalCamera
  106358. * @param name defines camera name
  106359. * @param position defines initial position
  106360. * @param interaxialDistance defines distance between each color axis
  106361. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  106362. * @param scene defines the hosting scene
  106363. */
  106364. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  106365. /**
  106366. * Gets camera class name
  106367. * @returns StereoscopicUniversalCamera
  106368. */
  106369. getClassName(): string;
  106370. }
  106371. }
  106372. declare module BABYLON {
  106373. /**
  106374. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  106375. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  106376. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  106377. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  106378. */
  106379. export class VirtualJoysticksCamera extends FreeCamera {
  106380. /**
  106381. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  106382. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  106383. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  106384. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  106385. * @param name Define the name of the camera in the scene
  106386. * @param position Define the start position of the camera in the scene
  106387. * @param scene Define the scene the camera belongs to
  106388. */
  106389. constructor(name: string, position: Vector3, scene: Scene);
  106390. /**
  106391. * Gets the current object class name.
  106392. * @return the class name
  106393. */
  106394. getClassName(): string;
  106395. }
  106396. }
  106397. declare module BABYLON {
  106398. /**
  106399. * This represents all the required metrics to create a VR camera.
  106400. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  106401. */
  106402. export class VRCameraMetrics {
  106403. /**
  106404. * Define the horizontal resolution off the screen.
  106405. */
  106406. hResolution: number;
  106407. /**
  106408. * Define the vertical resolution off the screen.
  106409. */
  106410. vResolution: number;
  106411. /**
  106412. * Define the horizontal screen size.
  106413. */
  106414. hScreenSize: number;
  106415. /**
  106416. * Define the vertical screen size.
  106417. */
  106418. vScreenSize: number;
  106419. /**
  106420. * Define the vertical screen center position.
  106421. */
  106422. vScreenCenter: number;
  106423. /**
  106424. * Define the distance of the eyes to the screen.
  106425. */
  106426. eyeToScreenDistance: number;
  106427. /**
  106428. * Define the distance between both lenses
  106429. */
  106430. lensSeparationDistance: number;
  106431. /**
  106432. * Define the distance between both viewer's eyes.
  106433. */
  106434. interpupillaryDistance: number;
  106435. /**
  106436. * Define the distortion factor of the VR postprocess.
  106437. * Please, touch with care.
  106438. */
  106439. distortionK: number[];
  106440. /**
  106441. * Define the chromatic aberration correction factors for the VR post process.
  106442. */
  106443. chromaAbCorrection: number[];
  106444. /**
  106445. * Define the scale factor of the post process.
  106446. * The smaller the better but the slower.
  106447. */
  106448. postProcessScaleFactor: number;
  106449. /**
  106450. * Define an offset for the lens center.
  106451. */
  106452. lensCenterOffset: number;
  106453. /**
  106454. * Define if the current vr camera should compensate the distortion of the lense or not.
  106455. */
  106456. compensateDistortion: boolean;
  106457. /**
  106458. * Defines if multiview should be enabled when rendering (Default: false)
  106459. */
  106460. multiviewEnabled: boolean;
  106461. /**
  106462. * Gets the rendering aspect ratio based on the provided resolutions.
  106463. */
  106464. readonly aspectRatio: number;
  106465. /**
  106466. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  106467. */
  106468. readonly aspectRatioFov: number;
  106469. /**
  106470. * @hidden
  106471. */
  106472. readonly leftHMatrix: Matrix;
  106473. /**
  106474. * @hidden
  106475. */
  106476. readonly rightHMatrix: Matrix;
  106477. /**
  106478. * @hidden
  106479. */
  106480. readonly leftPreViewMatrix: Matrix;
  106481. /**
  106482. * @hidden
  106483. */
  106484. readonly rightPreViewMatrix: Matrix;
  106485. /**
  106486. * Get the default VRMetrics based on the most generic setup.
  106487. * @returns the default vr metrics
  106488. */
  106489. static GetDefault(): VRCameraMetrics;
  106490. }
  106491. }
  106492. declare module BABYLON {
  106493. /** @hidden */
  106494. export var vrDistortionCorrectionPixelShader: {
  106495. name: string;
  106496. shader: string;
  106497. };
  106498. }
  106499. declare module BABYLON {
  106500. /**
  106501. * VRDistortionCorrectionPostProcess used for mobile VR
  106502. */
  106503. export class VRDistortionCorrectionPostProcess extends PostProcess {
  106504. private _isRightEye;
  106505. private _distortionFactors;
  106506. private _postProcessScaleFactor;
  106507. private _lensCenterOffset;
  106508. private _scaleIn;
  106509. private _scaleFactor;
  106510. private _lensCenter;
  106511. /**
  106512. * Initializes the VRDistortionCorrectionPostProcess
  106513. * @param name The name of the effect.
  106514. * @param camera The camera to apply the render pass to.
  106515. * @param isRightEye If this is for the right eye distortion
  106516. * @param vrMetrics All the required metrics for the VR camera
  106517. */
  106518. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  106519. }
  106520. }
  106521. declare module BABYLON {
  106522. /**
  106523. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  106524. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  106525. */
  106526. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  106527. /**
  106528. * Creates a new VRDeviceOrientationArcRotateCamera
  106529. * @param name defines camera name
  106530. * @param alpha defines the camera rotation along the logitudinal axis
  106531. * @param beta defines the camera rotation along the latitudinal axis
  106532. * @param radius defines the camera distance from its target
  106533. * @param target defines the camera target
  106534. * @param scene defines the scene the camera belongs to
  106535. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  106536. * @param vrCameraMetrics defines the vr metrics associated to the camera
  106537. */
  106538. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  106539. /**
  106540. * Gets camera class name
  106541. * @returns VRDeviceOrientationArcRotateCamera
  106542. */
  106543. getClassName(): string;
  106544. }
  106545. }
  106546. declare module BABYLON {
  106547. /**
  106548. * Camera used to simulate VR rendering (based on FreeCamera)
  106549. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  106550. */
  106551. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  106552. /**
  106553. * Creates a new VRDeviceOrientationFreeCamera
  106554. * @param name defines camera name
  106555. * @param position defines the start position of the camera
  106556. * @param scene defines the scene the camera belongs to
  106557. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  106558. * @param vrCameraMetrics defines the vr metrics associated to the camera
  106559. */
  106560. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  106561. /**
  106562. * Gets camera class name
  106563. * @returns VRDeviceOrientationFreeCamera
  106564. */
  106565. getClassName(): string;
  106566. }
  106567. }
  106568. declare module BABYLON {
  106569. /**
  106570. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  106571. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  106572. */
  106573. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  106574. /**
  106575. * Creates a new VRDeviceOrientationGamepadCamera
  106576. * @param name defines camera name
  106577. * @param position defines the start position of the camera
  106578. * @param scene defines the scene the camera belongs to
  106579. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  106580. * @param vrCameraMetrics defines the vr metrics associated to the camera
  106581. */
  106582. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  106583. /**
  106584. * Gets camera class name
  106585. * @returns VRDeviceOrientationGamepadCamera
  106586. */
  106587. getClassName(): string;
  106588. }
  106589. }
  106590. declare module BABYLON {
  106591. /**
  106592. * Base class of materials working in push mode in babylon JS
  106593. * @hidden
  106594. */
  106595. export class PushMaterial extends Material {
  106596. protected _activeEffect: Effect;
  106597. protected _normalMatrix: Matrix;
  106598. /**
  106599. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  106600. * This means that the material can keep using a previous shader while a new one is being compiled.
  106601. * This is mostly used when shader parallel compilation is supported (true by default)
  106602. */
  106603. allowShaderHotSwapping: boolean;
  106604. constructor(name: string, scene: Scene);
  106605. getEffect(): Effect;
  106606. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  106607. /**
  106608. * Binds the given world matrix to the active effect
  106609. *
  106610. * @param world the matrix to bind
  106611. */
  106612. bindOnlyWorldMatrix(world: Matrix): void;
  106613. /**
  106614. * Binds the given normal matrix to the active effect
  106615. *
  106616. * @param normalMatrix the matrix to bind
  106617. */
  106618. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  106619. bind(world: Matrix, mesh?: Mesh): void;
  106620. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  106621. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  106622. }
  106623. }
  106624. declare module BABYLON {
  106625. /**
  106626. * This groups all the flags used to control the materials channel.
  106627. */
  106628. export class MaterialFlags {
  106629. private static _DiffuseTextureEnabled;
  106630. /**
  106631. * Are diffuse textures enabled in the application.
  106632. */
  106633. static DiffuseTextureEnabled: boolean;
  106634. private static _AmbientTextureEnabled;
  106635. /**
  106636. * Are ambient textures enabled in the application.
  106637. */
  106638. static AmbientTextureEnabled: boolean;
  106639. private static _OpacityTextureEnabled;
  106640. /**
  106641. * Are opacity textures enabled in the application.
  106642. */
  106643. static OpacityTextureEnabled: boolean;
  106644. private static _ReflectionTextureEnabled;
  106645. /**
  106646. * Are reflection textures enabled in the application.
  106647. */
  106648. static ReflectionTextureEnabled: boolean;
  106649. private static _EmissiveTextureEnabled;
  106650. /**
  106651. * Are emissive textures enabled in the application.
  106652. */
  106653. static EmissiveTextureEnabled: boolean;
  106654. private static _SpecularTextureEnabled;
  106655. /**
  106656. * Are specular textures enabled in the application.
  106657. */
  106658. static SpecularTextureEnabled: boolean;
  106659. private static _BumpTextureEnabled;
  106660. /**
  106661. * Are bump textures enabled in the application.
  106662. */
  106663. static BumpTextureEnabled: boolean;
  106664. private static _LightmapTextureEnabled;
  106665. /**
  106666. * Are lightmap textures enabled in the application.
  106667. */
  106668. static LightmapTextureEnabled: boolean;
  106669. private static _RefractionTextureEnabled;
  106670. /**
  106671. * Are refraction textures enabled in the application.
  106672. */
  106673. static RefractionTextureEnabled: boolean;
  106674. private static _ColorGradingTextureEnabled;
  106675. /**
  106676. * Are color grading textures enabled in the application.
  106677. */
  106678. static ColorGradingTextureEnabled: boolean;
  106679. private static _FresnelEnabled;
  106680. /**
  106681. * Are fresnels enabled in the application.
  106682. */
  106683. static FresnelEnabled: boolean;
  106684. private static _ClearCoatTextureEnabled;
  106685. /**
  106686. * Are clear coat textures enabled in the application.
  106687. */
  106688. static ClearCoatTextureEnabled: boolean;
  106689. private static _ClearCoatBumpTextureEnabled;
  106690. /**
  106691. * Are clear coat bump textures enabled in the application.
  106692. */
  106693. static ClearCoatBumpTextureEnabled: boolean;
  106694. private static _ClearCoatTintTextureEnabled;
  106695. /**
  106696. * Are clear coat tint textures enabled in the application.
  106697. */
  106698. static ClearCoatTintTextureEnabled: boolean;
  106699. private static _SheenTextureEnabled;
  106700. /**
  106701. * Are sheen textures enabled in the application.
  106702. */
  106703. static SheenTextureEnabled: boolean;
  106704. private static _AnisotropicTextureEnabled;
  106705. /**
  106706. * Are anisotropic textures enabled in the application.
  106707. */
  106708. static AnisotropicTextureEnabled: boolean;
  106709. private static _ThicknessTextureEnabled;
  106710. /**
  106711. * Are thickness textures enabled in the application.
  106712. */
  106713. static ThicknessTextureEnabled: boolean;
  106714. }
  106715. }
  106716. declare module BABYLON {
  106717. /** @hidden */
  106718. export var defaultFragmentDeclaration: {
  106719. name: string;
  106720. shader: string;
  106721. };
  106722. }
  106723. declare module BABYLON {
  106724. /** @hidden */
  106725. export var defaultUboDeclaration: {
  106726. name: string;
  106727. shader: string;
  106728. };
  106729. }
  106730. declare module BABYLON {
  106731. /** @hidden */
  106732. export var lightFragmentDeclaration: {
  106733. name: string;
  106734. shader: string;
  106735. };
  106736. }
  106737. declare module BABYLON {
  106738. /** @hidden */
  106739. export var lightUboDeclaration: {
  106740. name: string;
  106741. shader: string;
  106742. };
  106743. }
  106744. declare module BABYLON {
  106745. /** @hidden */
  106746. export var lightsFragmentFunctions: {
  106747. name: string;
  106748. shader: string;
  106749. };
  106750. }
  106751. declare module BABYLON {
  106752. /** @hidden */
  106753. export var shadowsFragmentFunctions: {
  106754. name: string;
  106755. shader: string;
  106756. };
  106757. }
  106758. declare module BABYLON {
  106759. /** @hidden */
  106760. export var fresnelFunction: {
  106761. name: string;
  106762. shader: string;
  106763. };
  106764. }
  106765. declare module BABYLON {
  106766. /** @hidden */
  106767. export var reflectionFunction: {
  106768. name: string;
  106769. shader: string;
  106770. };
  106771. }
  106772. declare module BABYLON {
  106773. /** @hidden */
  106774. export var bumpFragmentFunctions: {
  106775. name: string;
  106776. shader: string;
  106777. };
  106778. }
  106779. declare module BABYLON {
  106780. /** @hidden */
  106781. export var logDepthDeclaration: {
  106782. name: string;
  106783. shader: string;
  106784. };
  106785. }
  106786. declare module BABYLON {
  106787. /** @hidden */
  106788. export var bumpFragment: {
  106789. name: string;
  106790. shader: string;
  106791. };
  106792. }
  106793. declare module BABYLON {
  106794. /** @hidden */
  106795. export var depthPrePass: {
  106796. name: string;
  106797. shader: string;
  106798. };
  106799. }
  106800. declare module BABYLON {
  106801. /** @hidden */
  106802. export var lightFragment: {
  106803. name: string;
  106804. shader: string;
  106805. };
  106806. }
  106807. declare module BABYLON {
  106808. /** @hidden */
  106809. export var logDepthFragment: {
  106810. name: string;
  106811. shader: string;
  106812. };
  106813. }
  106814. declare module BABYLON {
  106815. /** @hidden */
  106816. export var defaultPixelShader: {
  106817. name: string;
  106818. shader: string;
  106819. };
  106820. }
  106821. declare module BABYLON {
  106822. /** @hidden */
  106823. export var defaultVertexDeclaration: {
  106824. name: string;
  106825. shader: string;
  106826. };
  106827. }
  106828. declare module BABYLON {
  106829. /** @hidden */
  106830. export var bumpVertexDeclaration: {
  106831. name: string;
  106832. shader: string;
  106833. };
  106834. }
  106835. declare module BABYLON {
  106836. /** @hidden */
  106837. export var bumpVertex: {
  106838. name: string;
  106839. shader: string;
  106840. };
  106841. }
  106842. declare module BABYLON {
  106843. /** @hidden */
  106844. export var fogVertex: {
  106845. name: string;
  106846. shader: string;
  106847. };
  106848. }
  106849. declare module BABYLON {
  106850. /** @hidden */
  106851. export var shadowsVertex: {
  106852. name: string;
  106853. shader: string;
  106854. };
  106855. }
  106856. declare module BABYLON {
  106857. /** @hidden */
  106858. export var pointCloudVertex: {
  106859. name: string;
  106860. shader: string;
  106861. };
  106862. }
  106863. declare module BABYLON {
  106864. /** @hidden */
  106865. export var logDepthVertex: {
  106866. name: string;
  106867. shader: string;
  106868. };
  106869. }
  106870. declare module BABYLON {
  106871. /** @hidden */
  106872. export var defaultVertexShader: {
  106873. name: string;
  106874. shader: string;
  106875. };
  106876. }
  106877. declare module BABYLON {
  106878. /** @hidden */
  106879. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  106880. MAINUV1: boolean;
  106881. MAINUV2: boolean;
  106882. DIFFUSE: boolean;
  106883. DIFFUSEDIRECTUV: number;
  106884. AMBIENT: boolean;
  106885. AMBIENTDIRECTUV: number;
  106886. OPACITY: boolean;
  106887. OPACITYDIRECTUV: number;
  106888. OPACITYRGB: boolean;
  106889. REFLECTION: boolean;
  106890. EMISSIVE: boolean;
  106891. EMISSIVEDIRECTUV: number;
  106892. SPECULAR: boolean;
  106893. SPECULARDIRECTUV: number;
  106894. BUMP: boolean;
  106895. BUMPDIRECTUV: number;
  106896. PARALLAX: boolean;
  106897. PARALLAXOCCLUSION: boolean;
  106898. SPECULAROVERALPHA: boolean;
  106899. CLIPPLANE: boolean;
  106900. CLIPPLANE2: boolean;
  106901. CLIPPLANE3: boolean;
  106902. CLIPPLANE4: boolean;
  106903. ALPHATEST: boolean;
  106904. DEPTHPREPASS: boolean;
  106905. ALPHAFROMDIFFUSE: boolean;
  106906. POINTSIZE: boolean;
  106907. FOG: boolean;
  106908. SPECULARTERM: boolean;
  106909. DIFFUSEFRESNEL: boolean;
  106910. OPACITYFRESNEL: boolean;
  106911. REFLECTIONFRESNEL: boolean;
  106912. REFRACTIONFRESNEL: boolean;
  106913. EMISSIVEFRESNEL: boolean;
  106914. FRESNEL: boolean;
  106915. NORMAL: boolean;
  106916. UV1: boolean;
  106917. UV2: boolean;
  106918. VERTEXCOLOR: boolean;
  106919. VERTEXALPHA: boolean;
  106920. NUM_BONE_INFLUENCERS: number;
  106921. BonesPerMesh: number;
  106922. BONETEXTURE: boolean;
  106923. INSTANCES: boolean;
  106924. GLOSSINESS: boolean;
  106925. ROUGHNESS: boolean;
  106926. EMISSIVEASILLUMINATION: boolean;
  106927. LINKEMISSIVEWITHDIFFUSE: boolean;
  106928. REFLECTIONFRESNELFROMSPECULAR: boolean;
  106929. LIGHTMAP: boolean;
  106930. LIGHTMAPDIRECTUV: number;
  106931. OBJECTSPACE_NORMALMAP: boolean;
  106932. USELIGHTMAPASSHADOWMAP: boolean;
  106933. REFLECTIONMAP_3D: boolean;
  106934. REFLECTIONMAP_SPHERICAL: boolean;
  106935. REFLECTIONMAP_PLANAR: boolean;
  106936. REFLECTIONMAP_CUBIC: boolean;
  106937. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  106938. REFLECTIONMAP_PROJECTION: boolean;
  106939. REFLECTIONMAP_SKYBOX: boolean;
  106940. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  106941. REFLECTIONMAP_EXPLICIT: boolean;
  106942. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  106943. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  106944. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  106945. INVERTCUBICMAP: boolean;
  106946. LOGARITHMICDEPTH: boolean;
  106947. REFRACTION: boolean;
  106948. REFRACTIONMAP_3D: boolean;
  106949. REFLECTIONOVERALPHA: boolean;
  106950. TWOSIDEDLIGHTING: boolean;
  106951. SHADOWFLOAT: boolean;
  106952. MORPHTARGETS: boolean;
  106953. MORPHTARGETS_NORMAL: boolean;
  106954. MORPHTARGETS_TANGENT: boolean;
  106955. MORPHTARGETS_UV: boolean;
  106956. NUM_MORPH_INFLUENCERS: number;
  106957. NONUNIFORMSCALING: boolean;
  106958. PREMULTIPLYALPHA: boolean;
  106959. IMAGEPROCESSING: boolean;
  106960. VIGNETTE: boolean;
  106961. VIGNETTEBLENDMODEMULTIPLY: boolean;
  106962. VIGNETTEBLENDMODEOPAQUE: boolean;
  106963. TONEMAPPING: boolean;
  106964. TONEMAPPING_ACES: boolean;
  106965. CONTRAST: boolean;
  106966. COLORCURVES: boolean;
  106967. COLORGRADING: boolean;
  106968. COLORGRADING3D: boolean;
  106969. SAMPLER3DGREENDEPTH: boolean;
  106970. SAMPLER3DBGRMAP: boolean;
  106971. IMAGEPROCESSINGPOSTPROCESS: boolean;
  106972. MULTIVIEW: boolean;
  106973. /**
  106974. * If the reflection texture on this material is in linear color space
  106975. * @hidden
  106976. */
  106977. IS_REFLECTION_LINEAR: boolean;
  106978. /**
  106979. * If the refraction texture on this material is in linear color space
  106980. * @hidden
  106981. */
  106982. IS_REFRACTION_LINEAR: boolean;
  106983. EXPOSURE: boolean;
  106984. constructor();
  106985. setReflectionMode(modeToEnable: string): void;
  106986. }
  106987. /**
  106988. * This is the default material used in Babylon. It is the best trade off between quality
  106989. * and performances.
  106990. * @see http://doc.babylonjs.com/babylon101/materials
  106991. */
  106992. export class StandardMaterial extends PushMaterial {
  106993. private _diffuseTexture;
  106994. /**
  106995. * The basic texture of the material as viewed under a light.
  106996. */
  106997. diffuseTexture: Nullable<BaseTexture>;
  106998. private _ambientTexture;
  106999. /**
  107000. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  107001. */
  107002. ambientTexture: Nullable<BaseTexture>;
  107003. private _opacityTexture;
  107004. /**
  107005. * Define the transparency of the material from a texture.
  107006. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  107007. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  107008. */
  107009. opacityTexture: Nullable<BaseTexture>;
  107010. private _reflectionTexture;
  107011. /**
  107012. * Define the texture used to display the reflection.
  107013. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107014. */
  107015. reflectionTexture: Nullable<BaseTexture>;
  107016. private _emissiveTexture;
  107017. /**
  107018. * Define texture of the material as if self lit.
  107019. * This will be mixed in the final result even in the absence of light.
  107020. */
  107021. emissiveTexture: Nullable<BaseTexture>;
  107022. private _specularTexture;
  107023. /**
  107024. * Define how the color and intensity of the highlight given by the light in the material.
  107025. */
  107026. specularTexture: Nullable<BaseTexture>;
  107027. private _bumpTexture;
  107028. /**
  107029. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  107030. * 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.
  107031. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  107032. */
  107033. bumpTexture: Nullable<BaseTexture>;
  107034. private _lightmapTexture;
  107035. /**
  107036. * Complex lighting can be computationally expensive to compute at runtime.
  107037. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  107038. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  107039. */
  107040. lightmapTexture: Nullable<BaseTexture>;
  107041. private _refractionTexture;
  107042. /**
  107043. * Define the texture used to display the refraction.
  107044. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107045. */
  107046. refractionTexture: Nullable<BaseTexture>;
  107047. /**
  107048. * The color of the material lit by the environmental background lighting.
  107049. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  107050. */
  107051. ambientColor: Color3;
  107052. /**
  107053. * The basic color of the material as viewed under a light.
  107054. */
  107055. diffuseColor: Color3;
  107056. /**
  107057. * Define how the color and intensity of the highlight given by the light in the material.
  107058. */
  107059. specularColor: Color3;
  107060. /**
  107061. * Define the color of the material as if self lit.
  107062. * This will be mixed in the final result even in the absence of light.
  107063. */
  107064. emissiveColor: Color3;
  107065. /**
  107066. * Defines how sharp are the highlights in the material.
  107067. * The bigger the value the sharper giving a more glossy feeling to the result.
  107068. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  107069. */
  107070. specularPower: number;
  107071. private _useAlphaFromDiffuseTexture;
  107072. /**
  107073. * Does the transparency come from the diffuse texture alpha channel.
  107074. */
  107075. useAlphaFromDiffuseTexture: boolean;
  107076. private _useEmissiveAsIllumination;
  107077. /**
  107078. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  107079. */
  107080. useEmissiveAsIllumination: boolean;
  107081. private _linkEmissiveWithDiffuse;
  107082. /**
  107083. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  107084. * the emissive level when the final color is close to one.
  107085. */
  107086. linkEmissiveWithDiffuse: boolean;
  107087. private _useSpecularOverAlpha;
  107088. /**
  107089. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  107090. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  107091. */
  107092. useSpecularOverAlpha: boolean;
  107093. private _useReflectionOverAlpha;
  107094. /**
  107095. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  107096. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  107097. */
  107098. useReflectionOverAlpha: boolean;
  107099. private _disableLighting;
  107100. /**
  107101. * Does lights from the scene impacts this material.
  107102. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  107103. */
  107104. disableLighting: boolean;
  107105. private _useObjectSpaceNormalMap;
  107106. /**
  107107. * Allows using an object space normal map (instead of tangent space).
  107108. */
  107109. useObjectSpaceNormalMap: boolean;
  107110. private _useParallax;
  107111. /**
  107112. * Is parallax enabled or not.
  107113. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  107114. */
  107115. useParallax: boolean;
  107116. private _useParallaxOcclusion;
  107117. /**
  107118. * Is parallax occlusion enabled or not.
  107119. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  107120. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  107121. */
  107122. useParallaxOcclusion: boolean;
  107123. /**
  107124. * 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.
  107125. */
  107126. parallaxScaleBias: number;
  107127. private _roughness;
  107128. /**
  107129. * Helps to define how blurry the reflections should appears in the material.
  107130. */
  107131. roughness: number;
  107132. /**
  107133. * In case of refraction, define the value of the index of refraction.
  107134. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107135. */
  107136. indexOfRefraction: number;
  107137. /**
  107138. * Invert the refraction texture alongside the y axis.
  107139. * It can be useful with procedural textures or probe for instance.
  107140. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107141. */
  107142. invertRefractionY: boolean;
  107143. /**
  107144. * Defines the alpha limits in alpha test mode.
  107145. */
  107146. alphaCutOff: number;
  107147. private _useLightmapAsShadowmap;
  107148. /**
  107149. * In case of light mapping, define whether the map contains light or shadow informations.
  107150. */
  107151. useLightmapAsShadowmap: boolean;
  107152. private _diffuseFresnelParameters;
  107153. /**
  107154. * Define the diffuse fresnel parameters of the material.
  107155. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107156. */
  107157. diffuseFresnelParameters: FresnelParameters;
  107158. private _opacityFresnelParameters;
  107159. /**
  107160. * Define the opacity fresnel parameters of the material.
  107161. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107162. */
  107163. opacityFresnelParameters: FresnelParameters;
  107164. private _reflectionFresnelParameters;
  107165. /**
  107166. * Define the reflection fresnel parameters of the material.
  107167. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107168. */
  107169. reflectionFresnelParameters: FresnelParameters;
  107170. private _refractionFresnelParameters;
  107171. /**
  107172. * Define the refraction fresnel parameters of the material.
  107173. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107174. */
  107175. refractionFresnelParameters: FresnelParameters;
  107176. private _emissiveFresnelParameters;
  107177. /**
  107178. * Define the emissive fresnel parameters of the material.
  107179. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107180. */
  107181. emissiveFresnelParameters: FresnelParameters;
  107182. private _useReflectionFresnelFromSpecular;
  107183. /**
  107184. * If true automatically deducts the fresnels values from the material specularity.
  107185. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107186. */
  107187. useReflectionFresnelFromSpecular: boolean;
  107188. private _useGlossinessFromSpecularMapAlpha;
  107189. /**
  107190. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  107191. */
  107192. useGlossinessFromSpecularMapAlpha: boolean;
  107193. private _maxSimultaneousLights;
  107194. /**
  107195. * Defines the maximum number of lights that can be used in the material
  107196. */
  107197. maxSimultaneousLights: number;
  107198. private _invertNormalMapX;
  107199. /**
  107200. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  107201. */
  107202. invertNormalMapX: boolean;
  107203. private _invertNormalMapY;
  107204. /**
  107205. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  107206. */
  107207. invertNormalMapY: boolean;
  107208. private _twoSidedLighting;
  107209. /**
  107210. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  107211. */
  107212. twoSidedLighting: boolean;
  107213. /**
  107214. * Default configuration related to image processing available in the standard Material.
  107215. */
  107216. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  107217. /**
  107218. * Gets the image processing configuration used either in this material.
  107219. */
  107220. /**
  107221. * Sets the Default image processing configuration used either in the this material.
  107222. *
  107223. * If sets to null, the scene one is in use.
  107224. */
  107225. imageProcessingConfiguration: ImageProcessingConfiguration;
  107226. /**
  107227. * Keep track of the image processing observer to allow dispose and replace.
  107228. */
  107229. private _imageProcessingObserver;
  107230. /**
  107231. * Attaches a new image processing configuration to the Standard Material.
  107232. * @param configuration
  107233. */
  107234. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  107235. /**
  107236. * Gets wether the color curves effect is enabled.
  107237. */
  107238. /**
  107239. * Sets wether the color curves effect is enabled.
  107240. */
  107241. cameraColorCurvesEnabled: boolean;
  107242. /**
  107243. * Gets wether the color grading effect is enabled.
  107244. */
  107245. /**
  107246. * Gets wether the color grading effect is enabled.
  107247. */
  107248. cameraColorGradingEnabled: boolean;
  107249. /**
  107250. * Gets wether tonemapping is enabled or not.
  107251. */
  107252. /**
  107253. * Sets wether tonemapping is enabled or not
  107254. */
  107255. cameraToneMappingEnabled: boolean;
  107256. /**
  107257. * The camera exposure used on this material.
  107258. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  107259. * This corresponds to a photographic exposure.
  107260. */
  107261. /**
  107262. * The camera exposure used on this material.
  107263. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  107264. * This corresponds to a photographic exposure.
  107265. */
  107266. cameraExposure: number;
  107267. /**
  107268. * Gets The camera contrast used on this material.
  107269. */
  107270. /**
  107271. * Sets The camera contrast used on this material.
  107272. */
  107273. cameraContrast: number;
  107274. /**
  107275. * Gets the Color Grading 2D Lookup Texture.
  107276. */
  107277. /**
  107278. * Sets the Color Grading 2D Lookup Texture.
  107279. */
  107280. cameraColorGradingTexture: Nullable<BaseTexture>;
  107281. /**
  107282. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107283. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107284. * 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;
  107285. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107286. */
  107287. /**
  107288. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107289. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107290. * 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;
  107291. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107292. */
  107293. cameraColorCurves: Nullable<ColorCurves>;
  107294. /**
  107295. * Custom callback helping to override the default shader used in the material.
  107296. */
  107297. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  107298. protected _renderTargets: SmartArray<RenderTargetTexture>;
  107299. protected _worldViewProjectionMatrix: Matrix;
  107300. protected _globalAmbientColor: Color3;
  107301. protected _useLogarithmicDepth: boolean;
  107302. protected _rebuildInParallel: boolean;
  107303. /**
  107304. * Instantiates a new standard material.
  107305. * This is the default material used in Babylon. It is the best trade off between quality
  107306. * and performances.
  107307. * @see http://doc.babylonjs.com/babylon101/materials
  107308. * @param name Define the name of the material in the scene
  107309. * @param scene Define the scene the material belong to
  107310. */
  107311. constructor(name: string, scene: Scene);
  107312. /**
  107313. * Gets a boolean indicating that current material needs to register RTT
  107314. */
  107315. readonly hasRenderTargetTextures: boolean;
  107316. /**
  107317. * Gets the current class name of the material e.g. "StandardMaterial"
  107318. * Mainly use in serialization.
  107319. * @returns the class name
  107320. */
  107321. getClassName(): string;
  107322. /**
  107323. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  107324. * You can try switching to logarithmic depth.
  107325. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  107326. */
  107327. useLogarithmicDepth: boolean;
  107328. /**
  107329. * Specifies if the material will require alpha blending
  107330. * @returns a boolean specifying if alpha blending is needed
  107331. */
  107332. needAlphaBlending(): boolean;
  107333. /**
  107334. * Specifies if this material should be rendered in alpha test mode
  107335. * @returns a boolean specifying if an alpha test is needed.
  107336. */
  107337. needAlphaTesting(): boolean;
  107338. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  107339. /**
  107340. * Get the texture used for alpha test purpose.
  107341. * @returns the diffuse texture in case of the standard material.
  107342. */
  107343. getAlphaTestTexture(): Nullable<BaseTexture>;
  107344. /**
  107345. * Get if the submesh is ready to be used and all its information available.
  107346. * Child classes can use it to update shaders
  107347. * @param mesh defines the mesh to check
  107348. * @param subMesh defines which submesh to check
  107349. * @param useInstances specifies that instances should be used
  107350. * @returns a boolean indicating that the submesh is ready or not
  107351. */
  107352. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  107353. /**
  107354. * Builds the material UBO layouts.
  107355. * Used internally during the effect preparation.
  107356. */
  107357. buildUniformLayout(): void;
  107358. /**
  107359. * Unbinds the material from the mesh
  107360. */
  107361. unbind(): void;
  107362. /**
  107363. * Binds the submesh to this material by preparing the effect and shader to draw
  107364. * @param world defines the world transformation matrix
  107365. * @param mesh defines the mesh containing the submesh
  107366. * @param subMesh defines the submesh to bind the material to
  107367. */
  107368. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  107369. /**
  107370. * Get the list of animatables in the material.
  107371. * @returns the list of animatables object used in the material
  107372. */
  107373. getAnimatables(): IAnimatable[];
  107374. /**
  107375. * Gets the active textures from the material
  107376. * @returns an array of textures
  107377. */
  107378. getActiveTextures(): BaseTexture[];
  107379. /**
  107380. * Specifies if the material uses a texture
  107381. * @param texture defines the texture to check against the material
  107382. * @returns a boolean specifying if the material uses the texture
  107383. */
  107384. hasTexture(texture: BaseTexture): boolean;
  107385. /**
  107386. * Disposes the material
  107387. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  107388. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  107389. */
  107390. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  107391. /**
  107392. * Makes a duplicate of the material, and gives it a new name
  107393. * @param name defines the new name for the duplicated material
  107394. * @returns the cloned material
  107395. */
  107396. clone(name: string): StandardMaterial;
  107397. /**
  107398. * Serializes this material in a JSON representation
  107399. * @returns the serialized material object
  107400. */
  107401. serialize(): any;
  107402. /**
  107403. * Creates a standard material from parsed material data
  107404. * @param source defines the JSON representation of the material
  107405. * @param scene defines the hosting scene
  107406. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  107407. * @returns a new standard material
  107408. */
  107409. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  107410. /**
  107411. * Are diffuse textures enabled in the application.
  107412. */
  107413. static DiffuseTextureEnabled: boolean;
  107414. /**
  107415. * Are ambient textures enabled in the application.
  107416. */
  107417. static AmbientTextureEnabled: boolean;
  107418. /**
  107419. * Are opacity textures enabled in the application.
  107420. */
  107421. static OpacityTextureEnabled: boolean;
  107422. /**
  107423. * Are reflection textures enabled in the application.
  107424. */
  107425. static ReflectionTextureEnabled: boolean;
  107426. /**
  107427. * Are emissive textures enabled in the application.
  107428. */
  107429. static EmissiveTextureEnabled: boolean;
  107430. /**
  107431. * Are specular textures enabled in the application.
  107432. */
  107433. static SpecularTextureEnabled: boolean;
  107434. /**
  107435. * Are bump textures enabled in the application.
  107436. */
  107437. static BumpTextureEnabled: boolean;
  107438. /**
  107439. * Are lightmap textures enabled in the application.
  107440. */
  107441. static LightmapTextureEnabled: boolean;
  107442. /**
  107443. * Are refraction textures enabled in the application.
  107444. */
  107445. static RefractionTextureEnabled: boolean;
  107446. /**
  107447. * Are color grading textures enabled in the application.
  107448. */
  107449. static ColorGradingTextureEnabled: boolean;
  107450. /**
  107451. * Are fresnels enabled in the application.
  107452. */
  107453. static FresnelEnabled: boolean;
  107454. }
  107455. }
  107456. declare module BABYLON {
  107457. /** @hidden */
  107458. export var imageProcessingPixelShader: {
  107459. name: string;
  107460. shader: string;
  107461. };
  107462. }
  107463. declare module BABYLON {
  107464. /**
  107465. * ImageProcessingPostProcess
  107466. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  107467. */
  107468. export class ImageProcessingPostProcess extends PostProcess {
  107469. /**
  107470. * Default configuration related to image processing available in the PBR Material.
  107471. */
  107472. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  107473. /**
  107474. * Gets the image processing configuration used either in this material.
  107475. */
  107476. /**
  107477. * Sets the Default image processing configuration used either in the this material.
  107478. *
  107479. * If sets to null, the scene one is in use.
  107480. */
  107481. imageProcessingConfiguration: ImageProcessingConfiguration;
  107482. /**
  107483. * Keep track of the image processing observer to allow dispose and replace.
  107484. */
  107485. private _imageProcessingObserver;
  107486. /**
  107487. * Attaches a new image processing configuration to the PBR Material.
  107488. * @param configuration
  107489. */
  107490. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  107491. /**
  107492. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  107493. */
  107494. /**
  107495. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  107496. */
  107497. colorCurves: Nullable<ColorCurves>;
  107498. /**
  107499. * Gets wether the color curves effect is enabled.
  107500. */
  107501. /**
  107502. * Sets wether the color curves effect is enabled.
  107503. */
  107504. colorCurvesEnabled: boolean;
  107505. /**
  107506. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  107507. */
  107508. /**
  107509. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  107510. */
  107511. colorGradingTexture: Nullable<BaseTexture>;
  107512. /**
  107513. * Gets wether the color grading effect is enabled.
  107514. */
  107515. /**
  107516. * Gets wether the color grading effect is enabled.
  107517. */
  107518. colorGradingEnabled: boolean;
  107519. /**
  107520. * Gets exposure used in the effect.
  107521. */
  107522. /**
  107523. * Sets exposure used in the effect.
  107524. */
  107525. exposure: number;
  107526. /**
  107527. * Gets wether tonemapping is enabled or not.
  107528. */
  107529. /**
  107530. * Sets wether tonemapping is enabled or not
  107531. */
  107532. toneMappingEnabled: boolean;
  107533. /**
  107534. * Gets the type of tone mapping effect.
  107535. */
  107536. /**
  107537. * Sets the type of tone mapping effect.
  107538. */
  107539. toneMappingType: number;
  107540. /**
  107541. * Gets contrast used in the effect.
  107542. */
  107543. /**
  107544. * Sets contrast used in the effect.
  107545. */
  107546. contrast: number;
  107547. /**
  107548. * Gets Vignette stretch size.
  107549. */
  107550. /**
  107551. * Sets Vignette stretch size.
  107552. */
  107553. vignetteStretch: number;
  107554. /**
  107555. * Gets Vignette centre X Offset.
  107556. */
  107557. /**
  107558. * Sets Vignette centre X Offset.
  107559. */
  107560. vignetteCentreX: number;
  107561. /**
  107562. * Gets Vignette centre Y Offset.
  107563. */
  107564. /**
  107565. * Sets Vignette centre Y Offset.
  107566. */
  107567. vignetteCentreY: number;
  107568. /**
  107569. * Gets Vignette weight or intensity of the vignette effect.
  107570. */
  107571. /**
  107572. * Sets Vignette weight or intensity of the vignette effect.
  107573. */
  107574. vignetteWeight: number;
  107575. /**
  107576. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  107577. * if vignetteEnabled is set to true.
  107578. */
  107579. /**
  107580. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  107581. * if vignetteEnabled is set to true.
  107582. */
  107583. vignetteColor: Color4;
  107584. /**
  107585. * Gets Camera field of view used by the Vignette effect.
  107586. */
  107587. /**
  107588. * Sets Camera field of view used by the Vignette effect.
  107589. */
  107590. vignetteCameraFov: number;
  107591. /**
  107592. * Gets the vignette blend mode allowing different kind of effect.
  107593. */
  107594. /**
  107595. * Sets the vignette blend mode allowing different kind of effect.
  107596. */
  107597. vignetteBlendMode: number;
  107598. /**
  107599. * Gets wether the vignette effect is enabled.
  107600. */
  107601. /**
  107602. * Sets wether the vignette effect is enabled.
  107603. */
  107604. vignetteEnabled: boolean;
  107605. private _fromLinearSpace;
  107606. /**
  107607. * Gets wether the input of the processing is in Gamma or Linear Space.
  107608. */
  107609. /**
  107610. * Sets wether the input of the processing is in Gamma or Linear Space.
  107611. */
  107612. fromLinearSpace: boolean;
  107613. /**
  107614. * Defines cache preventing GC.
  107615. */
  107616. private _defines;
  107617. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  107618. /**
  107619. * "ImageProcessingPostProcess"
  107620. * @returns "ImageProcessingPostProcess"
  107621. */
  107622. getClassName(): string;
  107623. protected _updateParameters(): void;
  107624. dispose(camera?: Camera): void;
  107625. }
  107626. }
  107627. declare module BABYLON {
  107628. /**
  107629. * Class containing static functions to help procedurally build meshes
  107630. */
  107631. export class GroundBuilder {
  107632. /**
  107633. * Creates a ground mesh
  107634. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  107635. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  107636. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107637. * @param name defines the name of the mesh
  107638. * @param options defines the options used to create the mesh
  107639. * @param scene defines the hosting scene
  107640. * @returns the ground mesh
  107641. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  107642. */
  107643. static CreateGround(name: string, options: {
  107644. width?: number;
  107645. height?: number;
  107646. subdivisions?: number;
  107647. subdivisionsX?: number;
  107648. subdivisionsY?: number;
  107649. updatable?: boolean;
  107650. }, scene: any): Mesh;
  107651. /**
  107652. * Creates a tiled ground mesh
  107653. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  107654. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  107655. * * 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
  107656. * * 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
  107657. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107658. * @param name defines the name of the mesh
  107659. * @param options defines the options used to create the mesh
  107660. * @param scene defines the hosting scene
  107661. * @returns the tiled ground mesh
  107662. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  107663. */
  107664. static CreateTiledGround(name: string, options: {
  107665. xmin: number;
  107666. zmin: number;
  107667. xmax: number;
  107668. zmax: number;
  107669. subdivisions?: {
  107670. w: number;
  107671. h: number;
  107672. };
  107673. precision?: {
  107674. w: number;
  107675. h: number;
  107676. };
  107677. updatable?: boolean;
  107678. }, scene?: Nullable<Scene>): Mesh;
  107679. /**
  107680. * Creates a ground mesh from a height map
  107681. * * The parameter `url` sets the URL of the height map image resource.
  107682. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  107683. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  107684. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  107685. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  107686. * * 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.
  107687. * * 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).
  107688. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  107689. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107690. * @param name defines the name of the mesh
  107691. * @param url defines the url to the height map
  107692. * @param options defines the options used to create the mesh
  107693. * @param scene defines the hosting scene
  107694. * @returns the ground mesh
  107695. * @see https://doc.babylonjs.com/babylon101/height_map
  107696. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  107697. */
  107698. static CreateGroundFromHeightMap(name: string, url: string, options: {
  107699. width?: number;
  107700. height?: number;
  107701. subdivisions?: number;
  107702. minHeight?: number;
  107703. maxHeight?: number;
  107704. colorFilter?: Color3;
  107705. alphaFilter?: number;
  107706. updatable?: boolean;
  107707. onReady?: (mesh: GroundMesh) => void;
  107708. }, scene?: Nullable<Scene>): GroundMesh;
  107709. }
  107710. }
  107711. declare module BABYLON {
  107712. /**
  107713. * Class containing static functions to help procedurally build meshes
  107714. */
  107715. export class TorusBuilder {
  107716. /**
  107717. * Creates a torus mesh
  107718. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  107719. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  107720. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  107721. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107722. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107723. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107724. * @param name defines the name of the mesh
  107725. * @param options defines the options used to create the mesh
  107726. * @param scene defines the hosting scene
  107727. * @returns the torus mesh
  107728. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  107729. */
  107730. static CreateTorus(name: string, options: {
  107731. diameter?: number;
  107732. thickness?: number;
  107733. tessellation?: number;
  107734. updatable?: boolean;
  107735. sideOrientation?: number;
  107736. frontUVs?: Vector4;
  107737. backUVs?: Vector4;
  107738. }, scene: any): Mesh;
  107739. }
  107740. }
  107741. declare module BABYLON {
  107742. /**
  107743. * Class containing static functions to help procedurally build meshes
  107744. */
  107745. export class CylinderBuilder {
  107746. /**
  107747. * Creates a cylinder or a cone mesh
  107748. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  107749. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  107750. * * 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.
  107751. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  107752. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  107753. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  107754. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  107755. * * 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).
  107756. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  107757. * * 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).
  107758. * * 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
  107759. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  107760. * * 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
  107761. * * 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.
  107762. * * If `enclose` is false, a ring surface is one element.
  107763. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  107764. * * 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
  107765. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107766. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107767. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107768. * @param name defines the name of the mesh
  107769. * @param options defines the options used to create the mesh
  107770. * @param scene defines the hosting scene
  107771. * @returns the cylinder mesh
  107772. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  107773. */
  107774. static CreateCylinder(name: string, options: {
  107775. height?: number;
  107776. diameterTop?: number;
  107777. diameterBottom?: number;
  107778. diameter?: number;
  107779. tessellation?: number;
  107780. subdivisions?: number;
  107781. arc?: number;
  107782. faceColors?: Color4[];
  107783. faceUV?: Vector4[];
  107784. updatable?: boolean;
  107785. hasRings?: boolean;
  107786. enclose?: boolean;
  107787. cap?: number;
  107788. sideOrientation?: number;
  107789. frontUVs?: Vector4;
  107790. backUVs?: Vector4;
  107791. }, scene: any): Mesh;
  107792. }
  107793. }
  107794. declare module BABYLON {
  107795. /**
  107796. * Options to modify the vr teleportation behavior.
  107797. */
  107798. export interface VRTeleportationOptions {
  107799. /**
  107800. * The name of the mesh which should be used as the teleportation floor. (default: null)
  107801. */
  107802. floorMeshName?: string;
  107803. /**
  107804. * A list of meshes to be used as the teleportation floor. (default: empty)
  107805. */
  107806. floorMeshes?: Mesh[];
  107807. }
  107808. /**
  107809. * Options to modify the vr experience helper's behavior.
  107810. */
  107811. export interface VRExperienceHelperOptions extends WebVROptions {
  107812. /**
  107813. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  107814. */
  107815. createDeviceOrientationCamera?: boolean;
  107816. /**
  107817. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  107818. */
  107819. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  107820. /**
  107821. * Uses the main button on the controller to toggle the laser casted. (default: true)
  107822. */
  107823. laserToggle?: boolean;
  107824. /**
  107825. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  107826. */
  107827. floorMeshes?: Mesh[];
  107828. /**
  107829. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  107830. */
  107831. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  107832. }
  107833. /**
  107834. * Event containing information after VR has been entered
  107835. */
  107836. export class OnAfterEnteringVRObservableEvent {
  107837. /**
  107838. * If entering vr was successful
  107839. */
  107840. success: boolean;
  107841. }
  107842. /**
  107843. * Helps to quickly add VR support to an existing scene.
  107844. * See http://doc.babylonjs.com/how_to/webvr_helper
  107845. */
  107846. export class VRExperienceHelper {
  107847. /** Options to modify the vr experience helper's behavior. */
  107848. webVROptions: VRExperienceHelperOptions;
  107849. private _scene;
  107850. private _position;
  107851. private _btnVR;
  107852. private _btnVRDisplayed;
  107853. private _webVRsupported;
  107854. private _webVRready;
  107855. private _webVRrequesting;
  107856. private _webVRpresenting;
  107857. private _hasEnteredVR;
  107858. private _fullscreenVRpresenting;
  107859. private _canvas;
  107860. private _webVRCamera;
  107861. private _vrDeviceOrientationCamera;
  107862. private _deviceOrientationCamera;
  107863. private _existingCamera;
  107864. private _onKeyDown;
  107865. private _onVrDisplayPresentChange;
  107866. private _onVRDisplayChanged;
  107867. private _onVRRequestPresentStart;
  107868. private _onVRRequestPresentComplete;
  107869. /**
  107870. * 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)
  107871. */
  107872. enableGazeEvenWhenNoPointerLock: boolean;
  107873. /**
  107874. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  107875. */
  107876. exitVROnDoubleTap: boolean;
  107877. /**
  107878. * Observable raised right before entering VR.
  107879. */
  107880. onEnteringVRObservable: Observable<VRExperienceHelper>;
  107881. /**
  107882. * Observable raised when entering VR has completed.
  107883. */
  107884. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  107885. /**
  107886. * Observable raised when exiting VR.
  107887. */
  107888. onExitingVRObservable: Observable<VRExperienceHelper>;
  107889. /**
  107890. * Observable raised when controller mesh is loaded.
  107891. */
  107892. onControllerMeshLoadedObservable: Observable<WebVRController>;
  107893. /** Return this.onEnteringVRObservable
  107894. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  107895. */
  107896. readonly onEnteringVR: Observable<VRExperienceHelper>;
  107897. /** Return this.onExitingVRObservable
  107898. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  107899. */
  107900. readonly onExitingVR: Observable<VRExperienceHelper>;
  107901. /** Return this.onControllerMeshLoadedObservable
  107902. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  107903. */
  107904. readonly onControllerMeshLoaded: Observable<WebVRController>;
  107905. private _rayLength;
  107906. private _useCustomVRButton;
  107907. private _teleportationRequested;
  107908. private _teleportActive;
  107909. private _floorMeshName;
  107910. private _floorMeshesCollection;
  107911. private _rotationAllowed;
  107912. private _teleportBackwardsVector;
  107913. private _teleportationTarget;
  107914. private _isDefaultTeleportationTarget;
  107915. private _postProcessMove;
  107916. private _teleportationFillColor;
  107917. private _teleportationBorderColor;
  107918. private _rotationAngle;
  107919. private _haloCenter;
  107920. private _cameraGazer;
  107921. private _padSensibilityUp;
  107922. private _padSensibilityDown;
  107923. private _leftController;
  107924. private _rightController;
  107925. /**
  107926. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  107927. */
  107928. onNewMeshSelected: Observable<AbstractMesh>;
  107929. /**
  107930. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  107931. * This observable will provide the mesh and the controller used to select the mesh
  107932. */
  107933. onMeshSelectedWithController: Observable<{
  107934. mesh: AbstractMesh;
  107935. controller: WebVRController;
  107936. }>;
  107937. /**
  107938. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  107939. */
  107940. onNewMeshPicked: Observable<PickingInfo>;
  107941. private _circleEase;
  107942. /**
  107943. * Observable raised before camera teleportation
  107944. */
  107945. onBeforeCameraTeleport: Observable<Vector3>;
  107946. /**
  107947. * Observable raised after camera teleportation
  107948. */
  107949. onAfterCameraTeleport: Observable<Vector3>;
  107950. /**
  107951. * Observable raised when current selected mesh gets unselected
  107952. */
  107953. onSelectedMeshUnselected: Observable<AbstractMesh>;
  107954. private _raySelectionPredicate;
  107955. /**
  107956. * To be optionaly changed by user to define custom ray selection
  107957. */
  107958. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  107959. /**
  107960. * To be optionaly changed by user to define custom selection logic (after ray selection)
  107961. */
  107962. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  107963. /**
  107964. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  107965. */
  107966. teleportationEnabled: boolean;
  107967. private _defaultHeight;
  107968. private _teleportationInitialized;
  107969. private _interactionsEnabled;
  107970. private _interactionsRequested;
  107971. private _displayGaze;
  107972. private _displayLaserPointer;
  107973. /**
  107974. * The mesh used to display where the user is going to teleport.
  107975. */
  107976. /**
  107977. * Sets the mesh to be used to display where the user is going to teleport.
  107978. */
  107979. teleportationTarget: Mesh;
  107980. /**
  107981. * 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
  107982. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  107983. * See http://doc.babylonjs.com/resources/baking_transformations
  107984. */
  107985. gazeTrackerMesh: Mesh;
  107986. /**
  107987. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  107988. */
  107989. updateGazeTrackerScale: boolean;
  107990. /**
  107991. * If the gaze trackers color should be updated when selecting meshes
  107992. */
  107993. updateGazeTrackerColor: boolean;
  107994. /**
  107995. * If the controller laser color should be updated when selecting meshes
  107996. */
  107997. updateControllerLaserColor: boolean;
  107998. /**
  107999. * The gaze tracking mesh corresponding to the left controller
  108000. */
  108001. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  108002. /**
  108003. * The gaze tracking mesh corresponding to the right controller
  108004. */
  108005. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  108006. /**
  108007. * If the ray of the gaze should be displayed.
  108008. */
  108009. /**
  108010. * Sets if the ray of the gaze should be displayed.
  108011. */
  108012. displayGaze: boolean;
  108013. /**
  108014. * If the ray of the LaserPointer should be displayed.
  108015. */
  108016. /**
  108017. * Sets if the ray of the LaserPointer should be displayed.
  108018. */
  108019. displayLaserPointer: boolean;
  108020. /**
  108021. * The deviceOrientationCamera used as the camera when not in VR.
  108022. */
  108023. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  108024. /**
  108025. * Based on the current WebVR support, returns the current VR camera used.
  108026. */
  108027. readonly currentVRCamera: Nullable<Camera>;
  108028. /**
  108029. * The webVRCamera which is used when in VR.
  108030. */
  108031. readonly webVRCamera: WebVRFreeCamera;
  108032. /**
  108033. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  108034. */
  108035. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  108036. /**
  108037. * The html button that is used to trigger entering into VR.
  108038. */
  108039. readonly vrButton: Nullable<HTMLButtonElement>;
  108040. private readonly _teleportationRequestInitiated;
  108041. /**
  108042. * Defines wether or not Pointer lock should be requested when switching to
  108043. * full screen.
  108044. */
  108045. requestPointerLockOnFullScreen: boolean;
  108046. /**
  108047. * Instantiates a VRExperienceHelper.
  108048. * Helps to quickly add VR support to an existing scene.
  108049. * @param scene The scene the VRExperienceHelper belongs to.
  108050. * @param webVROptions Options to modify the vr experience helper's behavior.
  108051. */
  108052. constructor(scene: Scene,
  108053. /** Options to modify the vr experience helper's behavior. */
  108054. webVROptions?: VRExperienceHelperOptions);
  108055. private _onDefaultMeshLoaded;
  108056. private _onResize;
  108057. private _onFullscreenChange;
  108058. /**
  108059. * Gets a value indicating if we are currently in VR mode.
  108060. */
  108061. readonly isInVRMode: boolean;
  108062. private onVrDisplayPresentChange;
  108063. private onVRDisplayChanged;
  108064. private moveButtonToBottomRight;
  108065. private displayVRButton;
  108066. private updateButtonVisibility;
  108067. private _cachedAngularSensibility;
  108068. /**
  108069. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  108070. * Otherwise, will use the fullscreen API.
  108071. */
  108072. enterVR(): void;
  108073. /**
  108074. * Attempt to exit VR, or fullscreen.
  108075. */
  108076. exitVR(): void;
  108077. /**
  108078. * The position of the vr experience helper.
  108079. */
  108080. /**
  108081. * Sets the position of the vr experience helper.
  108082. */
  108083. position: Vector3;
  108084. /**
  108085. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  108086. */
  108087. enableInteractions(): void;
  108088. private readonly _noControllerIsActive;
  108089. private beforeRender;
  108090. private _isTeleportationFloor;
  108091. /**
  108092. * Adds a floor mesh to be used for teleportation.
  108093. * @param floorMesh the mesh to be used for teleportation.
  108094. */
  108095. addFloorMesh(floorMesh: Mesh): void;
  108096. /**
  108097. * Removes a floor mesh from being used for teleportation.
  108098. * @param floorMesh the mesh to be removed.
  108099. */
  108100. removeFloorMesh(floorMesh: Mesh): void;
  108101. /**
  108102. * Enables interactions and teleportation using the VR controllers and gaze.
  108103. * @param vrTeleportationOptions options to modify teleportation behavior.
  108104. */
  108105. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  108106. private _onNewGamepadConnected;
  108107. private _tryEnableInteractionOnController;
  108108. private _onNewGamepadDisconnected;
  108109. private _enableInteractionOnController;
  108110. private _checkTeleportWithRay;
  108111. private _checkRotate;
  108112. private _checkTeleportBackwards;
  108113. private _enableTeleportationOnController;
  108114. private _createTeleportationCircles;
  108115. private _displayTeleportationTarget;
  108116. private _hideTeleportationTarget;
  108117. private _rotateCamera;
  108118. private _moveTeleportationSelectorTo;
  108119. private _workingVector;
  108120. private _workingQuaternion;
  108121. private _workingMatrix;
  108122. /**
  108123. * Teleports the users feet to the desired location
  108124. * @param location The location where the user's feet should be placed
  108125. */
  108126. teleportCamera(location: Vector3): void;
  108127. private _convertNormalToDirectionOfRay;
  108128. private _castRayAndSelectObject;
  108129. private _notifySelectedMeshUnselected;
  108130. /**
  108131. * Sets the color of the laser ray from the vr controllers.
  108132. * @param color new color for the ray.
  108133. */
  108134. changeLaserColor(color: Color3): void;
  108135. /**
  108136. * Sets the color of the ray from the vr headsets gaze.
  108137. * @param color new color for the ray.
  108138. */
  108139. changeGazeColor(color: Color3): void;
  108140. /**
  108141. * Exits VR and disposes of the vr experience helper
  108142. */
  108143. dispose(): void;
  108144. /**
  108145. * Gets the name of the VRExperienceHelper class
  108146. * @returns "VRExperienceHelper"
  108147. */
  108148. getClassName(): string;
  108149. }
  108150. }
  108151. declare module BABYLON {
  108152. /**
  108153. * Manages an XRSession to work with Babylon's engine
  108154. * @see https://doc.babylonjs.com/how_to/webxr
  108155. */
  108156. export class WebXRSessionManager implements IDisposable {
  108157. private scene;
  108158. /**
  108159. * Fires every time a new xrFrame arrives which can be used to update the camera
  108160. */
  108161. onXRFrameObservable: Observable<any>;
  108162. /**
  108163. * Fires when the xr session is ended either by the device or manually done
  108164. */
  108165. onXRSessionEnded: Observable<any>;
  108166. /**
  108167. * Underlying xr session
  108168. */
  108169. session: XRSession;
  108170. /**
  108171. * Type of reference space used when creating the session
  108172. */
  108173. referenceSpace: XRReferenceSpace;
  108174. /** @hidden */
  108175. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  108176. /**
  108177. * Current XR frame
  108178. */
  108179. currentFrame: Nullable<XRFrame>;
  108180. private _xrNavigator;
  108181. private baseLayer;
  108182. /**
  108183. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  108184. * @param scene The scene which the session should be created for
  108185. */
  108186. constructor(scene: Scene);
  108187. /**
  108188. * Initializes the manager
  108189. * After initialization enterXR can be called to start an XR session
  108190. * @returns Promise which resolves after it is initialized
  108191. */
  108192. initializeAsync(): Promise<void>;
  108193. /**
  108194. * Initializes an xr session
  108195. * @param xrSessionMode mode to initialize
  108196. * @returns a promise which will resolve once the session has been initialized
  108197. */
  108198. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  108199. /**
  108200. * Sets the reference space on the xr session
  108201. * @param referenceSpace space to set
  108202. * @returns a promise that will resolve once the reference space has been set
  108203. */
  108204. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  108205. /**
  108206. * Updates the render state of the session
  108207. * @param state state to set
  108208. * @returns a promise that resolves once the render state has been updated
  108209. */
  108210. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  108211. /**
  108212. * Starts rendering to the xr layer
  108213. * @returns a promise that will resolve once rendering has started
  108214. */
  108215. startRenderingToXRAsync(): Promise<void>;
  108216. /**
  108217. * Stops the xrSession and restores the renderloop
  108218. * @returns Promise which resolves after it exits XR
  108219. */
  108220. exitXRAsync(): Promise<unknown>;
  108221. /**
  108222. * Checks if a session would be supported for the creation options specified
  108223. * @param sessionMode session mode to check if supported eg. immersive-vr
  108224. * @returns true if supported
  108225. */
  108226. supportsSessionAsync(sessionMode: XRSessionMode): any;
  108227. /**
  108228. * @hidden
  108229. * Converts the render layer of xrSession to a render target
  108230. * @param session session to create render target for
  108231. * @param scene scene the new render target should be created for
  108232. */
  108233. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  108234. /**
  108235. * Disposes of the session manager
  108236. */
  108237. dispose(): void;
  108238. }
  108239. }
  108240. declare module BABYLON {
  108241. /**
  108242. * WebXR Camera which holds the views for the xrSession
  108243. * @see https://doc.babylonjs.com/how_to/webxr
  108244. */
  108245. export class WebXRCamera extends FreeCamera {
  108246. private static _TmpMatrix;
  108247. /**
  108248. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  108249. * @param name the name of the camera
  108250. * @param scene the scene to add the camera to
  108251. */
  108252. constructor(name: string, scene: Scene);
  108253. private _updateNumberOfRigCameras;
  108254. /** @hidden */
  108255. _updateForDualEyeDebugging(pupilDistance?: number): void;
  108256. /**
  108257. * Updates the cameras position from the current pose information of the XR session
  108258. * @param xrSessionManager the session containing pose information
  108259. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  108260. */
  108261. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  108262. }
  108263. }
  108264. declare module BABYLON {
  108265. /**
  108266. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  108267. */
  108268. export class WebXRManagedOutputCanvas implements IDisposable {
  108269. private helper;
  108270. private _canvas;
  108271. /**
  108272. * xrpresent context of the canvas which can be used to display/mirror xr content
  108273. */
  108274. canvasContext: WebGLRenderingContext;
  108275. /**
  108276. * xr layer for the canvas
  108277. */
  108278. xrLayer: Nullable<XRWebGLLayer>;
  108279. /**
  108280. * Initializes the xr layer for the session
  108281. * @param xrSession xr session
  108282. * @returns a promise that will resolve once the XR Layer has been created
  108283. */
  108284. initializeXRLayerAsync(xrSession: any): any;
  108285. /**
  108286. * Initializes the canvas to be added/removed upon entering/exiting xr
  108287. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  108288. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  108289. */
  108290. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  108291. /**
  108292. * Disposes of the object
  108293. */
  108294. dispose(): void;
  108295. private _setManagedOutputCanvas;
  108296. private _addCanvas;
  108297. private _removeCanvas;
  108298. }
  108299. }
  108300. declare module BABYLON {
  108301. /**
  108302. * States of the webXR experience
  108303. */
  108304. export enum WebXRState {
  108305. /**
  108306. * Transitioning to being in XR mode
  108307. */
  108308. ENTERING_XR = 0,
  108309. /**
  108310. * Transitioning to non XR mode
  108311. */
  108312. EXITING_XR = 1,
  108313. /**
  108314. * In XR mode and presenting
  108315. */
  108316. IN_XR = 2,
  108317. /**
  108318. * Not entered XR mode
  108319. */
  108320. NOT_IN_XR = 3
  108321. }
  108322. /**
  108323. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  108324. * @see https://doc.babylonjs.com/how_to/webxr
  108325. */
  108326. export class WebXRExperienceHelper implements IDisposable {
  108327. private scene;
  108328. /**
  108329. * 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
  108330. */
  108331. container: AbstractMesh;
  108332. /**
  108333. * Camera used to render xr content
  108334. */
  108335. camera: WebXRCamera;
  108336. /**
  108337. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  108338. */
  108339. state: WebXRState;
  108340. private _setState;
  108341. private static _TmpVector;
  108342. /**
  108343. * Fires when the state of the experience helper has changed
  108344. */
  108345. onStateChangedObservable: Observable<WebXRState>;
  108346. /** Session manager used to keep track of xr session */
  108347. sessionManager: WebXRSessionManager;
  108348. private _nonVRCamera;
  108349. private _originalSceneAutoClear;
  108350. private _supported;
  108351. /**
  108352. * Creates the experience helper
  108353. * @param scene the scene to attach the experience helper to
  108354. * @returns a promise for the experience helper
  108355. */
  108356. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  108357. /**
  108358. * Creates a WebXRExperienceHelper
  108359. * @param scene The scene the helper should be created in
  108360. */
  108361. private constructor();
  108362. /**
  108363. * Exits XR mode and returns the scene to its original state
  108364. * @returns promise that resolves after xr mode has exited
  108365. */
  108366. exitXRAsync(): Promise<unknown>;
  108367. /**
  108368. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  108369. * @param sessionCreationOptions options for the XR session
  108370. * @param referenceSpaceType frame of reference of the XR session
  108371. * @param outputCanvas the output canvas that will be used to enter XR mode
  108372. * @returns promise that resolves after xr mode has entered
  108373. */
  108374. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  108375. /**
  108376. * Updates the global position of the camera by moving the camera's container
  108377. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  108378. * @param position The desired global position of the camera
  108379. */
  108380. setPositionOfCameraUsingContainer(position: Vector3): void;
  108381. /**
  108382. * Rotates the xr camera by rotating the camera's container around the camera's position
  108383. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  108384. * @param rotation the desired quaternion rotation to apply to the camera
  108385. */
  108386. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  108387. /**
  108388. * Disposes of the experience helper
  108389. */
  108390. dispose(): void;
  108391. }
  108392. }
  108393. declare module BABYLON {
  108394. /**
  108395. * Button which can be used to enter a different mode of XR
  108396. */
  108397. export class WebXREnterExitUIButton {
  108398. /** button element */
  108399. element: HTMLElement;
  108400. /** XR initialization options for the button */
  108401. sessionMode: XRSessionMode;
  108402. /** Reference space type */
  108403. referenceSpaceType: XRReferenceSpaceType;
  108404. /**
  108405. * Creates a WebXREnterExitUIButton
  108406. * @param element button element
  108407. * @param sessionMode XR initialization session mode
  108408. * @param referenceSpaceType the type of reference space to be used
  108409. */
  108410. constructor(
  108411. /** button element */
  108412. element: HTMLElement,
  108413. /** XR initialization options for the button */
  108414. sessionMode: XRSessionMode,
  108415. /** Reference space type */
  108416. referenceSpaceType: XRReferenceSpaceType);
  108417. /**
  108418. * Overwritable function which can be used to update the button's visuals when the state changes
  108419. * @param activeButton the current active button in the UI
  108420. */
  108421. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  108422. }
  108423. /**
  108424. * Options to create the webXR UI
  108425. */
  108426. export class WebXREnterExitUIOptions {
  108427. /**
  108428. * Context to enter xr with
  108429. */
  108430. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  108431. /**
  108432. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  108433. */
  108434. customButtons?: Array<WebXREnterExitUIButton>;
  108435. }
  108436. /**
  108437. * UI to allow the user to enter/exit XR mode
  108438. */
  108439. export class WebXREnterExitUI implements IDisposable {
  108440. private scene;
  108441. private _overlay;
  108442. private _buttons;
  108443. private _activeButton;
  108444. /**
  108445. * Fired every time the active button is changed.
  108446. *
  108447. * When xr is entered via a button that launches xr that button will be the callback parameter
  108448. *
  108449. * When exiting xr the callback parameter will be null)
  108450. */
  108451. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  108452. /**
  108453. * Creates UI to allow the user to enter/exit XR mode
  108454. * @param scene the scene to add the ui to
  108455. * @param helper the xr experience helper to enter/exit xr with
  108456. * @param options options to configure the UI
  108457. * @returns the created ui
  108458. */
  108459. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  108460. private constructor();
  108461. private _updateButtons;
  108462. /**
  108463. * Disposes of the object
  108464. */
  108465. dispose(): void;
  108466. }
  108467. }
  108468. declare module BABYLON {
  108469. /**
  108470. * Represents an XR input
  108471. */
  108472. export class WebXRController {
  108473. private scene;
  108474. /** The underlying input source for the controller */
  108475. inputSource: XRInputSource;
  108476. private parentContainer;
  108477. /**
  108478. * 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
  108479. */
  108480. grip?: AbstractMesh;
  108481. /**
  108482. * Pointer which can be used to select objects or attach a visible laser to
  108483. */
  108484. pointer: AbstractMesh;
  108485. /**
  108486. * Event that fires when the controller is removed/disposed
  108487. */
  108488. onDisposeObservable: Observable<{}>;
  108489. private _tmpMatrix;
  108490. private _tmpQuaternion;
  108491. private _tmpVector;
  108492. /**
  108493. * Creates the controller
  108494. * @see https://doc.babylonjs.com/how_to/webxr
  108495. * @param scene the scene which the controller should be associated to
  108496. * @param inputSource the underlying input source for the controller
  108497. * @param parentContainer parent that the controller meshes should be children of
  108498. */
  108499. constructor(scene: Scene,
  108500. /** The underlying input source for the controller */
  108501. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  108502. /**
  108503. * Updates the controller pose based on the given XRFrame
  108504. * @param xrFrame xr frame to update the pose with
  108505. * @param referenceSpace reference space to use
  108506. */
  108507. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  108508. /**
  108509. * Gets a world space ray coming from the controller
  108510. * @param result the resulting ray
  108511. */
  108512. getWorldPointerRayToRef(result: Ray): void;
  108513. /**
  108514. * Disposes of the object
  108515. */
  108516. dispose(): void;
  108517. }
  108518. }
  108519. declare module BABYLON {
  108520. /**
  108521. * XR input used to track XR inputs such as controllers/rays
  108522. */
  108523. export class WebXRInput implements IDisposable {
  108524. /**
  108525. * Base experience the input listens to
  108526. */
  108527. baseExperience: WebXRExperienceHelper;
  108528. /**
  108529. * XR controllers being tracked
  108530. */
  108531. controllers: Array<WebXRController>;
  108532. private _frameObserver;
  108533. private _stateObserver;
  108534. /**
  108535. * Event when a controller has been connected/added
  108536. */
  108537. onControllerAddedObservable: Observable<WebXRController>;
  108538. /**
  108539. * Event when a controller has been removed/disconnected
  108540. */
  108541. onControllerRemovedObservable: Observable<WebXRController>;
  108542. /**
  108543. * Initializes the WebXRInput
  108544. * @param baseExperience experience helper which the input should be created for
  108545. */
  108546. constructor(
  108547. /**
  108548. * Base experience the input listens to
  108549. */
  108550. baseExperience: WebXRExperienceHelper);
  108551. private _onInputSourcesChange;
  108552. private _addAndRemoveControllers;
  108553. /**
  108554. * Disposes of the object
  108555. */
  108556. dispose(): void;
  108557. }
  108558. }
  108559. declare module BABYLON {
  108560. /**
  108561. * Enables teleportation
  108562. */
  108563. export class WebXRControllerTeleportation {
  108564. private _teleportationFillColor;
  108565. private _teleportationBorderColor;
  108566. private _tmpRay;
  108567. private _tmpVector;
  108568. /**
  108569. * Creates a WebXRControllerTeleportation
  108570. * @param input input manager to add teleportation to
  108571. * @param floorMeshes floormeshes which can be teleported to
  108572. */
  108573. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  108574. }
  108575. }
  108576. declare module BABYLON {
  108577. /**
  108578. * Handles pointer input automatically for the pointer of XR controllers
  108579. */
  108580. export class WebXRControllerPointerSelection {
  108581. private static _idCounter;
  108582. private _tmpRay;
  108583. /**
  108584. * Creates a WebXRControllerPointerSelection
  108585. * @param input input manager to setup pointer selection
  108586. */
  108587. constructor(input: WebXRInput);
  108588. private _convertNormalToDirectionOfRay;
  108589. private _updatePointerDistance;
  108590. }
  108591. }
  108592. declare module BABYLON {
  108593. /**
  108594. * Class used to represent data loading progression
  108595. */
  108596. export class SceneLoaderProgressEvent {
  108597. /** defines if data length to load can be evaluated */
  108598. readonly lengthComputable: boolean;
  108599. /** defines the loaded data length */
  108600. readonly loaded: number;
  108601. /** defines the data length to load */
  108602. readonly total: number;
  108603. /**
  108604. * Create a new progress event
  108605. * @param lengthComputable defines if data length to load can be evaluated
  108606. * @param loaded defines the loaded data length
  108607. * @param total defines the data length to load
  108608. */
  108609. constructor(
  108610. /** defines if data length to load can be evaluated */
  108611. lengthComputable: boolean,
  108612. /** defines the loaded data length */
  108613. loaded: number,
  108614. /** defines the data length to load */
  108615. total: number);
  108616. /**
  108617. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  108618. * @param event defines the source event
  108619. * @returns a new SceneLoaderProgressEvent
  108620. */
  108621. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  108622. }
  108623. /**
  108624. * Interface used by SceneLoader plugins to define supported file extensions
  108625. */
  108626. export interface ISceneLoaderPluginExtensions {
  108627. /**
  108628. * Defines the list of supported extensions
  108629. */
  108630. [extension: string]: {
  108631. isBinary: boolean;
  108632. };
  108633. }
  108634. /**
  108635. * Interface used by SceneLoader plugin factory
  108636. */
  108637. export interface ISceneLoaderPluginFactory {
  108638. /**
  108639. * Defines the name of the factory
  108640. */
  108641. name: string;
  108642. /**
  108643. * Function called to create a new plugin
  108644. * @return the new plugin
  108645. */
  108646. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  108647. /**
  108648. * Boolean indicating if the plugin can direct load specific data
  108649. */
  108650. canDirectLoad?: (data: string) => boolean;
  108651. }
  108652. /**
  108653. * Interface used to define a SceneLoader plugin
  108654. */
  108655. export interface ISceneLoaderPlugin {
  108656. /**
  108657. * The friendly name of this plugin.
  108658. */
  108659. name: string;
  108660. /**
  108661. * The file extensions supported by this plugin.
  108662. */
  108663. extensions: string | ISceneLoaderPluginExtensions;
  108664. /**
  108665. * Import meshes into a scene.
  108666. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  108667. * @param scene The scene to import into
  108668. * @param data The data to import
  108669. * @param rootUrl The root url for scene and resources
  108670. * @param meshes The meshes array to import into
  108671. * @param particleSystems The particle systems array to import into
  108672. * @param skeletons The skeletons array to import into
  108673. * @param onError The callback when import fails
  108674. * @returns True if successful or false otherwise
  108675. */
  108676. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  108677. /**
  108678. * Load into a scene.
  108679. * @param scene The scene to load into
  108680. * @param data The data to import
  108681. * @param rootUrl The root url for scene and resources
  108682. * @param onError The callback when import fails
  108683. * @returns true if successful or false otherwise
  108684. */
  108685. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  108686. /**
  108687. * The callback that returns true if the data can be directly loaded.
  108688. */
  108689. canDirectLoad?: (data: string) => boolean;
  108690. /**
  108691. * The callback that allows custom handling of the root url based on the response url.
  108692. */
  108693. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  108694. /**
  108695. * Load into an asset container.
  108696. * @param scene The scene to load into
  108697. * @param data The data to import
  108698. * @param rootUrl The root url for scene and resources
  108699. * @param onError The callback when import fails
  108700. * @returns The loaded asset container
  108701. */
  108702. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  108703. }
  108704. /**
  108705. * Interface used to define an async SceneLoader plugin
  108706. */
  108707. export interface ISceneLoaderPluginAsync {
  108708. /**
  108709. * The friendly name of this plugin.
  108710. */
  108711. name: string;
  108712. /**
  108713. * The file extensions supported by this plugin.
  108714. */
  108715. extensions: string | ISceneLoaderPluginExtensions;
  108716. /**
  108717. * Import meshes into a scene.
  108718. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  108719. * @param scene The scene to import into
  108720. * @param data The data to import
  108721. * @param rootUrl The root url for scene and resources
  108722. * @param onProgress The callback when the load progresses
  108723. * @param fileName Defines the name of the file to load
  108724. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  108725. */
  108726. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  108727. meshes: AbstractMesh[];
  108728. particleSystems: IParticleSystem[];
  108729. skeletons: Skeleton[];
  108730. animationGroups: AnimationGroup[];
  108731. }>;
  108732. /**
  108733. * Load into a scene.
  108734. * @param scene The scene to load into
  108735. * @param data The data to import
  108736. * @param rootUrl The root url for scene and resources
  108737. * @param onProgress The callback when the load progresses
  108738. * @param fileName Defines the name of the file to load
  108739. * @returns Nothing
  108740. */
  108741. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  108742. /**
  108743. * The callback that returns true if the data can be directly loaded.
  108744. */
  108745. canDirectLoad?: (data: string) => boolean;
  108746. /**
  108747. * The callback that allows custom handling of the root url based on the response url.
  108748. */
  108749. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  108750. /**
  108751. * Load into an asset container.
  108752. * @param scene The scene to load into
  108753. * @param data The data to import
  108754. * @param rootUrl The root url for scene and resources
  108755. * @param onProgress The callback when the load progresses
  108756. * @param fileName Defines the name of the file to load
  108757. * @returns The loaded asset container
  108758. */
  108759. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  108760. }
  108761. /**
  108762. * Class used to load scene from various file formats using registered plugins
  108763. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  108764. */
  108765. export class SceneLoader {
  108766. /**
  108767. * No logging while loading
  108768. */
  108769. static readonly NO_LOGGING: number;
  108770. /**
  108771. * Minimal logging while loading
  108772. */
  108773. static readonly MINIMAL_LOGGING: number;
  108774. /**
  108775. * Summary logging while loading
  108776. */
  108777. static readonly SUMMARY_LOGGING: number;
  108778. /**
  108779. * Detailled logging while loading
  108780. */
  108781. static readonly DETAILED_LOGGING: number;
  108782. /**
  108783. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  108784. */
  108785. static ForceFullSceneLoadingForIncremental: boolean;
  108786. /**
  108787. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  108788. */
  108789. static ShowLoadingScreen: boolean;
  108790. /**
  108791. * Defines the current logging level (while loading the scene)
  108792. * @ignorenaming
  108793. */
  108794. static loggingLevel: number;
  108795. /**
  108796. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  108797. */
  108798. static CleanBoneMatrixWeights: boolean;
  108799. /**
  108800. * Event raised when a plugin is used to load a scene
  108801. */
  108802. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  108803. private static _registeredPlugins;
  108804. private static _getDefaultPlugin;
  108805. private static _getPluginForExtension;
  108806. private static _getPluginForDirectLoad;
  108807. private static _getPluginForFilename;
  108808. private static _getDirectLoad;
  108809. private static _loadData;
  108810. private static _getFileInfo;
  108811. /**
  108812. * Gets a plugin that can load the given extension
  108813. * @param extension defines the extension to load
  108814. * @returns a plugin or null if none works
  108815. */
  108816. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  108817. /**
  108818. * Gets a boolean indicating that the given extension can be loaded
  108819. * @param extension defines the extension to load
  108820. * @returns true if the extension is supported
  108821. */
  108822. static IsPluginForExtensionAvailable(extension: string): boolean;
  108823. /**
  108824. * Adds a new plugin to the list of registered plugins
  108825. * @param plugin defines the plugin to add
  108826. */
  108827. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  108828. /**
  108829. * Import meshes into a scene
  108830. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  108831. * @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)
  108832. * @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)
  108833. * @param scene the instance of BABYLON.Scene to append to
  108834. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  108835. * @param onProgress a callback with a progress event for each file being loaded
  108836. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  108837. * @param pluginExtension the extension used to determine the plugin
  108838. * @returns The loaded plugin
  108839. */
  108840. 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>;
  108841. /**
  108842. * Import meshes into a scene
  108843. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  108844. * @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)
  108845. * @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)
  108846. * @param scene the instance of BABYLON.Scene to append to
  108847. * @param onProgress a callback with a progress event for each file being loaded
  108848. * @param pluginExtension the extension used to determine the plugin
  108849. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  108850. */
  108851. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  108852. meshes: AbstractMesh[];
  108853. particleSystems: IParticleSystem[];
  108854. skeletons: Skeleton[];
  108855. animationGroups: AnimationGroup[];
  108856. }>;
  108857. /**
  108858. * Load a scene
  108859. * @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)
  108860. * @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)
  108861. * @param engine is the instance of BABYLON.Engine to use to create the scene
  108862. * @param onSuccess a callback with the scene when import succeeds
  108863. * @param onProgress a callback with a progress event for each file being loaded
  108864. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  108865. * @param pluginExtension the extension used to determine the plugin
  108866. * @returns The loaded plugin
  108867. */
  108868. 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>;
  108869. /**
  108870. * Load a scene
  108871. * @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)
  108872. * @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)
  108873. * @param engine is the instance of BABYLON.Engine to use to create the scene
  108874. * @param onProgress a callback with a progress event for each file being loaded
  108875. * @param pluginExtension the extension used to determine the plugin
  108876. * @returns The loaded scene
  108877. */
  108878. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  108879. /**
  108880. * Append a scene
  108881. * @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)
  108882. * @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)
  108883. * @param scene is the instance of BABYLON.Scene to append to
  108884. * @param onSuccess a callback with the scene when import succeeds
  108885. * @param onProgress a callback with a progress event for each file being loaded
  108886. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  108887. * @param pluginExtension the extension used to determine the plugin
  108888. * @returns The loaded plugin
  108889. */
  108890. 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>;
  108891. /**
  108892. * Append a scene
  108893. * @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)
  108894. * @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)
  108895. * @param scene is the instance of BABYLON.Scene to append to
  108896. * @param onProgress a callback with a progress event for each file being loaded
  108897. * @param pluginExtension the extension used to determine the plugin
  108898. * @returns The given scene
  108899. */
  108900. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  108901. /**
  108902. * Load a scene into an asset container
  108903. * @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)
  108904. * @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)
  108905. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  108906. * @param onSuccess a callback with the scene when import succeeds
  108907. * @param onProgress a callback with a progress event for each file being loaded
  108908. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  108909. * @param pluginExtension the extension used to determine the plugin
  108910. * @returns The loaded plugin
  108911. */
  108912. 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>;
  108913. /**
  108914. * Load a scene into an asset container
  108915. * @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)
  108916. * @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)
  108917. * @param scene is the instance of Scene to append to
  108918. * @param onProgress a callback with a progress event for each file being loaded
  108919. * @param pluginExtension the extension used to determine the plugin
  108920. * @returns The loaded asset container
  108921. */
  108922. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  108923. }
  108924. }
  108925. declare module BABYLON {
  108926. /**
  108927. * Generic Controller
  108928. */
  108929. export class GenericController extends WebVRController {
  108930. /**
  108931. * Base Url for the controller model.
  108932. */
  108933. static readonly MODEL_BASE_URL: string;
  108934. /**
  108935. * File name for the controller model.
  108936. */
  108937. static readonly MODEL_FILENAME: string;
  108938. /**
  108939. * Creates a new GenericController from a gamepad
  108940. * @param vrGamepad the gamepad that the controller should be created from
  108941. */
  108942. constructor(vrGamepad: any);
  108943. /**
  108944. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  108945. * @param scene scene in which to add meshes
  108946. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  108947. */
  108948. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  108949. /**
  108950. * Called once for each button that changed state since the last frame
  108951. * @param buttonIdx Which button index changed
  108952. * @param state New state of the button
  108953. * @param changes Which properties on the state changed since last frame
  108954. */
  108955. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  108956. }
  108957. }
  108958. declare module BABYLON {
  108959. /**
  108960. * Defines the WindowsMotionController object that the state of the windows motion controller
  108961. */
  108962. export class WindowsMotionController extends WebVRController {
  108963. /**
  108964. * The base url used to load the left and right controller models
  108965. */
  108966. static MODEL_BASE_URL: string;
  108967. /**
  108968. * The name of the left controller model file
  108969. */
  108970. static MODEL_LEFT_FILENAME: string;
  108971. /**
  108972. * The name of the right controller model file
  108973. */
  108974. static MODEL_RIGHT_FILENAME: string;
  108975. /**
  108976. * The controller name prefix for this controller type
  108977. */
  108978. static readonly GAMEPAD_ID_PREFIX: string;
  108979. /**
  108980. * The controller id pattern for this controller type
  108981. */
  108982. private static readonly GAMEPAD_ID_PATTERN;
  108983. private _loadedMeshInfo;
  108984. private readonly _mapping;
  108985. /**
  108986. * Fired when the trackpad on this controller is clicked
  108987. */
  108988. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  108989. /**
  108990. * Fired when the trackpad on this controller is modified
  108991. */
  108992. onTrackpadValuesChangedObservable: Observable<StickValues>;
  108993. /**
  108994. * The current x and y values of this controller's trackpad
  108995. */
  108996. trackpad: StickValues;
  108997. /**
  108998. * Creates a new WindowsMotionController from a gamepad
  108999. * @param vrGamepad the gamepad that the controller should be created from
  109000. */
  109001. constructor(vrGamepad: any);
  109002. /**
  109003. * Fired when the trigger on this controller is modified
  109004. */
  109005. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109006. /**
  109007. * Fired when the menu button on this controller is modified
  109008. */
  109009. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109010. /**
  109011. * Fired when the grip button on this controller is modified
  109012. */
  109013. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109014. /**
  109015. * Fired when the thumbstick button on this controller is modified
  109016. */
  109017. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109018. /**
  109019. * Fired when the touchpad button on this controller is modified
  109020. */
  109021. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109022. /**
  109023. * Fired when the touchpad values on this controller are modified
  109024. */
  109025. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  109026. private _updateTrackpad;
  109027. /**
  109028. * Called once per frame by the engine.
  109029. */
  109030. update(): void;
  109031. /**
  109032. * Called once for each button that changed state since the last frame
  109033. * @param buttonIdx Which button index changed
  109034. * @param state New state of the button
  109035. * @param changes Which properties on the state changed since last frame
  109036. */
  109037. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  109038. /**
  109039. * Moves the buttons on the controller mesh based on their current state
  109040. * @param buttonName the name of the button to move
  109041. * @param buttonValue the value of the button which determines the buttons new position
  109042. */
  109043. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  109044. /**
  109045. * Moves the axis on the controller mesh based on its current state
  109046. * @param axis the index of the axis
  109047. * @param axisValue the value of the axis which determines the meshes new position
  109048. * @hidden
  109049. */
  109050. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  109051. /**
  109052. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  109053. * @param scene scene in which to add meshes
  109054. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  109055. */
  109056. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  109057. /**
  109058. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  109059. * can be transformed by button presses and axes values, based on this._mapping.
  109060. *
  109061. * @param scene scene in which the meshes exist
  109062. * @param meshes list of meshes that make up the controller model to process
  109063. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  109064. */
  109065. private processModel;
  109066. private createMeshInfo;
  109067. /**
  109068. * Gets the ray of the controller in the direction the controller is pointing
  109069. * @param length the length the resulting ray should be
  109070. * @returns a ray in the direction the controller is pointing
  109071. */
  109072. getForwardRay(length?: number): Ray;
  109073. /**
  109074. * Disposes of the controller
  109075. */
  109076. dispose(): void;
  109077. }
  109078. }
  109079. declare module BABYLON {
  109080. /**
  109081. * Oculus Touch Controller
  109082. */
  109083. export class OculusTouchController extends WebVRController {
  109084. /**
  109085. * Base Url for the controller model.
  109086. */
  109087. static MODEL_BASE_URL: string;
  109088. /**
  109089. * File name for the left controller model.
  109090. */
  109091. static MODEL_LEFT_FILENAME: string;
  109092. /**
  109093. * File name for the right controller model.
  109094. */
  109095. static MODEL_RIGHT_FILENAME: string;
  109096. /**
  109097. * Base Url for the Quest controller model.
  109098. */
  109099. static QUEST_MODEL_BASE_URL: string;
  109100. /**
  109101. * @hidden
  109102. * If the controllers are running on a device that needs the updated Quest controller models
  109103. */
  109104. static _IsQuest: boolean;
  109105. /**
  109106. * Fired when the secondary trigger on this controller is modified
  109107. */
  109108. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  109109. /**
  109110. * Fired when the thumb rest on this controller is modified
  109111. */
  109112. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  109113. /**
  109114. * Creates a new OculusTouchController from a gamepad
  109115. * @param vrGamepad the gamepad that the controller should be created from
  109116. */
  109117. constructor(vrGamepad: any);
  109118. /**
  109119. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  109120. * @param scene scene in which to add meshes
  109121. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  109122. */
  109123. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  109124. /**
  109125. * Fired when the A button on this controller is modified
  109126. */
  109127. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109128. /**
  109129. * Fired when the B button on this controller is modified
  109130. */
  109131. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109132. /**
  109133. * Fired when the X button on this controller is modified
  109134. */
  109135. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109136. /**
  109137. * Fired when the Y button on this controller is modified
  109138. */
  109139. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109140. /**
  109141. * Called once for each button that changed state since the last frame
  109142. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  109143. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  109144. * 2) secondary trigger (same)
  109145. * 3) A (right) X (left), touch, pressed = value
  109146. * 4) B / Y
  109147. * 5) thumb rest
  109148. * @param buttonIdx Which button index changed
  109149. * @param state New state of the button
  109150. * @param changes Which properties on the state changed since last frame
  109151. */
  109152. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  109153. }
  109154. }
  109155. declare module BABYLON {
  109156. /**
  109157. * Vive Controller
  109158. */
  109159. export class ViveController extends WebVRController {
  109160. /**
  109161. * Base Url for the controller model.
  109162. */
  109163. static MODEL_BASE_URL: string;
  109164. /**
  109165. * File name for the controller model.
  109166. */
  109167. static MODEL_FILENAME: string;
  109168. /**
  109169. * Creates a new ViveController from a gamepad
  109170. * @param vrGamepad the gamepad that the controller should be created from
  109171. */
  109172. constructor(vrGamepad: any);
  109173. /**
  109174. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  109175. * @param scene scene in which to add meshes
  109176. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  109177. */
  109178. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  109179. /**
  109180. * Fired when the left button on this controller is modified
  109181. */
  109182. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109183. /**
  109184. * Fired when the right button on this controller is modified
  109185. */
  109186. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109187. /**
  109188. * Fired when the menu button on this controller is modified
  109189. */
  109190. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109191. /**
  109192. * Called once for each button that changed state since the last frame
  109193. * Vive mapping:
  109194. * 0: touchpad
  109195. * 1: trigger
  109196. * 2: left AND right buttons
  109197. * 3: menu button
  109198. * @param buttonIdx Which button index changed
  109199. * @param state New state of the button
  109200. * @param changes Which properties on the state changed since last frame
  109201. */
  109202. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  109203. }
  109204. }
  109205. declare module BABYLON {
  109206. /**
  109207. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  109208. */
  109209. export class WebXRControllerModelLoader {
  109210. /**
  109211. * Creates the WebXRControllerModelLoader
  109212. * @param input xr input that creates the controllers
  109213. */
  109214. constructor(input: WebXRInput);
  109215. }
  109216. }
  109217. declare module BABYLON {
  109218. /**
  109219. * Contains an array of blocks representing the octree
  109220. */
  109221. export interface IOctreeContainer<T> {
  109222. /**
  109223. * Blocks within the octree
  109224. */
  109225. blocks: Array<OctreeBlock<T>>;
  109226. }
  109227. /**
  109228. * Class used to store a cell in an octree
  109229. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109230. */
  109231. export class OctreeBlock<T> {
  109232. /**
  109233. * Gets the content of the current block
  109234. */
  109235. entries: T[];
  109236. /**
  109237. * Gets the list of block children
  109238. */
  109239. blocks: Array<OctreeBlock<T>>;
  109240. private _depth;
  109241. private _maxDepth;
  109242. private _capacity;
  109243. private _minPoint;
  109244. private _maxPoint;
  109245. private _boundingVectors;
  109246. private _creationFunc;
  109247. /**
  109248. * Creates a new block
  109249. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  109250. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  109251. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  109252. * @param depth defines the current depth of this block in the octree
  109253. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  109254. * @param creationFunc defines a callback to call when an element is added to the block
  109255. */
  109256. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  109257. /**
  109258. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  109259. */
  109260. readonly capacity: number;
  109261. /**
  109262. * Gets the minimum vector (in world space) of the block's bounding box
  109263. */
  109264. readonly minPoint: Vector3;
  109265. /**
  109266. * Gets the maximum vector (in world space) of the block's bounding box
  109267. */
  109268. readonly maxPoint: Vector3;
  109269. /**
  109270. * Add a new element to this block
  109271. * @param entry defines the element to add
  109272. */
  109273. addEntry(entry: T): void;
  109274. /**
  109275. * Remove an element from this block
  109276. * @param entry defines the element to remove
  109277. */
  109278. removeEntry(entry: T): void;
  109279. /**
  109280. * Add an array of elements to this block
  109281. * @param entries defines the array of elements to add
  109282. */
  109283. addEntries(entries: T[]): void;
  109284. /**
  109285. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  109286. * @param frustumPlanes defines the frustum planes to test
  109287. * @param selection defines the array to store current content if selection is positive
  109288. * @param allowDuplicate defines if the selection array can contains duplicated entries
  109289. */
  109290. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  109291. /**
  109292. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  109293. * @param sphereCenter defines the bounding sphere center
  109294. * @param sphereRadius defines the bounding sphere radius
  109295. * @param selection defines the array to store current content if selection is positive
  109296. * @param allowDuplicate defines if the selection array can contains duplicated entries
  109297. */
  109298. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  109299. /**
  109300. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  109301. * @param ray defines the ray to test with
  109302. * @param selection defines the array to store current content if selection is positive
  109303. */
  109304. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  109305. /**
  109306. * Subdivide the content into child blocks (this block will then be empty)
  109307. */
  109308. createInnerBlocks(): void;
  109309. /**
  109310. * @hidden
  109311. */
  109312. 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;
  109313. }
  109314. }
  109315. declare module BABYLON {
  109316. /**
  109317. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  109318. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109319. */
  109320. export class Octree<T> {
  109321. /** 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.) */
  109322. maxDepth: number;
  109323. /**
  109324. * Blocks within the octree containing objects
  109325. */
  109326. blocks: Array<OctreeBlock<T>>;
  109327. /**
  109328. * Content stored in the octree
  109329. */
  109330. dynamicContent: T[];
  109331. private _maxBlockCapacity;
  109332. private _selectionContent;
  109333. private _creationFunc;
  109334. /**
  109335. * Creates a octree
  109336. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109337. * @param creationFunc function to be used to instatiate the octree
  109338. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  109339. * @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.)
  109340. */
  109341. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  109342. /** 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.) */
  109343. maxDepth?: number);
  109344. /**
  109345. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  109346. * @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);
  109347. * @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);
  109348. * @param entries meshes to be added to the octree blocks
  109349. */
  109350. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  109351. /**
  109352. * Adds a mesh to the octree
  109353. * @param entry Mesh to add to the octree
  109354. */
  109355. addMesh(entry: T): void;
  109356. /**
  109357. * Remove an element from the octree
  109358. * @param entry defines the element to remove
  109359. */
  109360. removeMesh(entry: T): void;
  109361. /**
  109362. * Selects an array of meshes within the frustum
  109363. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  109364. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  109365. * @returns array of meshes within the frustum
  109366. */
  109367. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  109368. /**
  109369. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  109370. * @param sphereCenter defines the bounding sphere center
  109371. * @param sphereRadius defines the bounding sphere radius
  109372. * @param allowDuplicate defines if the selection array can contains duplicated entries
  109373. * @returns an array of objects that intersect the sphere
  109374. */
  109375. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  109376. /**
  109377. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  109378. * @param ray defines the ray to test with
  109379. * @returns array of intersected objects
  109380. */
  109381. intersectsRay(ray: Ray): SmartArray<T>;
  109382. /**
  109383. * Adds a mesh into the octree block if it intersects the block
  109384. */
  109385. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  109386. /**
  109387. * Adds a submesh into the octree block if it intersects the block
  109388. */
  109389. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  109390. }
  109391. }
  109392. declare module BABYLON {
  109393. interface Scene {
  109394. /**
  109395. * @hidden
  109396. * Backing Filed
  109397. */
  109398. _selectionOctree: Octree<AbstractMesh>;
  109399. /**
  109400. * Gets the octree used to boost mesh selection (picking)
  109401. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109402. */
  109403. selectionOctree: Octree<AbstractMesh>;
  109404. /**
  109405. * Creates or updates the octree used to boost selection (picking)
  109406. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109407. * @param maxCapacity defines the maximum capacity per leaf
  109408. * @param maxDepth defines the maximum depth of the octree
  109409. * @returns an octree of AbstractMesh
  109410. */
  109411. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  109412. }
  109413. interface AbstractMesh {
  109414. /**
  109415. * @hidden
  109416. * Backing Field
  109417. */
  109418. _submeshesOctree: Octree<SubMesh>;
  109419. /**
  109420. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  109421. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  109422. * @param maxCapacity defines the maximum size of each block (64 by default)
  109423. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  109424. * @returns the new octree
  109425. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  109426. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109427. */
  109428. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  109429. }
  109430. /**
  109431. * Defines the octree scene component responsible to manage any octrees
  109432. * in a given scene.
  109433. */
  109434. export class OctreeSceneComponent {
  109435. /**
  109436. * The component name help to identify the component in the list of scene components.
  109437. */
  109438. readonly name: string;
  109439. /**
  109440. * The scene the component belongs to.
  109441. */
  109442. scene: Scene;
  109443. /**
  109444. * Indicates if the meshes have been checked to make sure they are isEnabled()
  109445. */
  109446. readonly checksIsEnabled: boolean;
  109447. /**
  109448. * Creates a new instance of the component for the given scene
  109449. * @param scene Defines the scene to register the component in
  109450. */
  109451. constructor(scene: Scene);
  109452. /**
  109453. * Registers the component in a given scene
  109454. */
  109455. register(): void;
  109456. /**
  109457. * Return the list of active meshes
  109458. * @returns the list of active meshes
  109459. */
  109460. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  109461. /**
  109462. * Return the list of active sub meshes
  109463. * @param mesh The mesh to get the candidates sub meshes from
  109464. * @returns the list of active sub meshes
  109465. */
  109466. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  109467. private _tempRay;
  109468. /**
  109469. * Return the list of sub meshes intersecting with a given local ray
  109470. * @param mesh defines the mesh to find the submesh for
  109471. * @param localRay defines the ray in local space
  109472. * @returns the list of intersecting sub meshes
  109473. */
  109474. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  109475. /**
  109476. * Return the list of sub meshes colliding with a collider
  109477. * @param mesh defines the mesh to find the submesh for
  109478. * @param collider defines the collider to evaluate the collision against
  109479. * @returns the list of colliding sub meshes
  109480. */
  109481. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  109482. /**
  109483. * Rebuilds the elements related to this component in case of
  109484. * context lost for instance.
  109485. */
  109486. rebuild(): void;
  109487. /**
  109488. * Disposes the component and the associated ressources.
  109489. */
  109490. dispose(): void;
  109491. }
  109492. }
  109493. declare module BABYLON {
  109494. /**
  109495. * Renders a layer on top of an existing scene
  109496. */
  109497. export class UtilityLayerRenderer implements IDisposable {
  109498. /** the original scene that will be rendered on top of */
  109499. originalScene: Scene;
  109500. private _pointerCaptures;
  109501. private _lastPointerEvents;
  109502. private static _DefaultUtilityLayer;
  109503. private static _DefaultKeepDepthUtilityLayer;
  109504. private _sharedGizmoLight;
  109505. private _renderCamera;
  109506. /**
  109507. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  109508. * @returns the camera that is used when rendering the utility layer
  109509. */
  109510. getRenderCamera(): Nullable<Camera>;
  109511. /**
  109512. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  109513. * @param cam the camera that should be used when rendering the utility layer
  109514. */
  109515. setRenderCamera(cam: Nullable<Camera>): void;
  109516. /**
  109517. * @hidden
  109518. * Light which used by gizmos to get light shading
  109519. */
  109520. _getSharedGizmoLight(): HemisphericLight;
  109521. /**
  109522. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  109523. */
  109524. pickUtilitySceneFirst: boolean;
  109525. /**
  109526. * 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)
  109527. */
  109528. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  109529. /**
  109530. * 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)
  109531. */
  109532. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  109533. /**
  109534. * The scene that is rendered on top of the original scene
  109535. */
  109536. utilityLayerScene: Scene;
  109537. /**
  109538. * If the utility layer should automatically be rendered on top of existing scene
  109539. */
  109540. shouldRender: boolean;
  109541. /**
  109542. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  109543. */
  109544. onlyCheckPointerDownEvents: boolean;
  109545. /**
  109546. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  109547. */
  109548. processAllEvents: boolean;
  109549. /**
  109550. * Observable raised when the pointer move from the utility layer scene to the main scene
  109551. */
  109552. onPointerOutObservable: Observable<number>;
  109553. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  109554. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  109555. private _afterRenderObserver;
  109556. private _sceneDisposeObserver;
  109557. private _originalPointerObserver;
  109558. /**
  109559. * Instantiates a UtilityLayerRenderer
  109560. * @param originalScene the original scene that will be rendered on top of
  109561. * @param handleEvents boolean indicating if the utility layer should handle events
  109562. */
  109563. constructor(
  109564. /** the original scene that will be rendered on top of */
  109565. originalScene: Scene, handleEvents?: boolean);
  109566. private _notifyObservers;
  109567. /**
  109568. * Renders the utility layers scene on top of the original scene
  109569. */
  109570. render(): void;
  109571. /**
  109572. * Disposes of the renderer
  109573. */
  109574. dispose(): void;
  109575. private _updateCamera;
  109576. }
  109577. }
  109578. declare module BABYLON {
  109579. /**
  109580. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  109581. */
  109582. export class Gizmo implements IDisposable {
  109583. /** The utility layer the gizmo will be added to */
  109584. gizmoLayer: UtilityLayerRenderer;
  109585. /**
  109586. * The root mesh of the gizmo
  109587. */
  109588. _rootMesh: Mesh;
  109589. private _attachedMesh;
  109590. /**
  109591. * Ratio for the scale of the gizmo (Default: 1)
  109592. */
  109593. scaleRatio: number;
  109594. /**
  109595. * If a custom mesh has been set (Default: false)
  109596. */
  109597. protected _customMeshSet: boolean;
  109598. /**
  109599. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  109600. * * When set, interactions will be enabled
  109601. */
  109602. attachedMesh: Nullable<AbstractMesh>;
  109603. /**
  109604. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  109605. * @param mesh The mesh to replace the default mesh of the gizmo
  109606. */
  109607. setCustomMesh(mesh: Mesh): void;
  109608. /**
  109609. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  109610. */
  109611. updateGizmoRotationToMatchAttachedMesh: boolean;
  109612. /**
  109613. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  109614. */
  109615. updateGizmoPositionToMatchAttachedMesh: boolean;
  109616. /**
  109617. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  109618. */
  109619. updateScale: boolean;
  109620. protected _interactionsEnabled: boolean;
  109621. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  109622. private _beforeRenderObserver;
  109623. private _tempVector;
  109624. /**
  109625. * Creates a gizmo
  109626. * @param gizmoLayer The utility layer the gizmo will be added to
  109627. */
  109628. constructor(
  109629. /** The utility layer the gizmo will be added to */
  109630. gizmoLayer?: UtilityLayerRenderer);
  109631. /**
  109632. * Updates the gizmo to match the attached mesh's position/rotation
  109633. */
  109634. protected _update(): void;
  109635. /**
  109636. * Disposes of the gizmo
  109637. */
  109638. dispose(): void;
  109639. }
  109640. }
  109641. declare module BABYLON {
  109642. /**
  109643. * Single plane drag gizmo
  109644. */
  109645. export class PlaneDragGizmo extends Gizmo {
  109646. /**
  109647. * Drag behavior responsible for the gizmos dragging interactions
  109648. */
  109649. dragBehavior: PointerDragBehavior;
  109650. private _pointerObserver;
  109651. /**
  109652. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  109653. */
  109654. snapDistance: number;
  109655. /**
  109656. * Event that fires each time the gizmo snaps to a new location.
  109657. * * snapDistance is the the change in distance
  109658. */
  109659. onSnapObservable: Observable<{
  109660. snapDistance: number;
  109661. }>;
  109662. private _plane;
  109663. private _coloredMaterial;
  109664. private _hoverMaterial;
  109665. private _isEnabled;
  109666. private _parent;
  109667. /** @hidden */
  109668. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  109669. /** @hidden */
  109670. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  109671. /**
  109672. * Creates a PlaneDragGizmo
  109673. * @param gizmoLayer The utility layer the gizmo will be added to
  109674. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  109675. * @param color The color of the gizmo
  109676. */
  109677. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  109678. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  109679. /**
  109680. * If the gizmo is enabled
  109681. */
  109682. isEnabled: boolean;
  109683. /**
  109684. * Disposes of the gizmo
  109685. */
  109686. dispose(): void;
  109687. }
  109688. }
  109689. declare module BABYLON {
  109690. /**
  109691. * Gizmo that enables dragging a mesh along 3 axis
  109692. */
  109693. export class PositionGizmo extends Gizmo {
  109694. /**
  109695. * Internal gizmo used for interactions on the x axis
  109696. */
  109697. xGizmo: AxisDragGizmo;
  109698. /**
  109699. * Internal gizmo used for interactions on the y axis
  109700. */
  109701. yGizmo: AxisDragGizmo;
  109702. /**
  109703. * Internal gizmo used for interactions on the z axis
  109704. */
  109705. zGizmo: AxisDragGizmo;
  109706. /**
  109707. * Internal gizmo used for interactions on the yz plane
  109708. */
  109709. xPlaneGizmo: PlaneDragGizmo;
  109710. /**
  109711. * Internal gizmo used for interactions on the xz plane
  109712. */
  109713. yPlaneGizmo: PlaneDragGizmo;
  109714. /**
  109715. * Internal gizmo used for interactions on the xy plane
  109716. */
  109717. zPlaneGizmo: PlaneDragGizmo;
  109718. /**
  109719. * private variables
  109720. */
  109721. private _meshAttached;
  109722. private _updateGizmoRotationToMatchAttachedMesh;
  109723. private _snapDistance;
  109724. private _scaleRatio;
  109725. /** Fires an event when any of it's sub gizmos are dragged */
  109726. onDragStartObservable: Observable<unknown>;
  109727. /** Fires an event when any of it's sub gizmos are released from dragging */
  109728. onDragEndObservable: Observable<unknown>;
  109729. /**
  109730. * If set to true, planar drag is enabled
  109731. */
  109732. private _planarGizmoEnabled;
  109733. attachedMesh: Nullable<AbstractMesh>;
  109734. /**
  109735. * Creates a PositionGizmo
  109736. * @param gizmoLayer The utility layer the gizmo will be added to
  109737. */
  109738. constructor(gizmoLayer?: UtilityLayerRenderer);
  109739. /**
  109740. * If the planar drag gizmo is enabled
  109741. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  109742. */
  109743. planarGizmoEnabled: boolean;
  109744. updateGizmoRotationToMatchAttachedMesh: boolean;
  109745. /**
  109746. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  109747. */
  109748. snapDistance: number;
  109749. /**
  109750. * Ratio for the scale of the gizmo (Default: 1)
  109751. */
  109752. scaleRatio: number;
  109753. /**
  109754. * Disposes of the gizmo
  109755. */
  109756. dispose(): void;
  109757. /**
  109758. * CustomMeshes are not supported by this gizmo
  109759. * @param mesh The mesh to replace the default mesh of the gizmo
  109760. */
  109761. setCustomMesh(mesh: Mesh): void;
  109762. }
  109763. }
  109764. declare module BABYLON {
  109765. /**
  109766. * Single axis drag gizmo
  109767. */
  109768. export class AxisDragGizmo extends Gizmo {
  109769. /**
  109770. * Drag behavior responsible for the gizmos dragging interactions
  109771. */
  109772. dragBehavior: PointerDragBehavior;
  109773. private _pointerObserver;
  109774. /**
  109775. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  109776. */
  109777. snapDistance: number;
  109778. /**
  109779. * Event that fires each time the gizmo snaps to a new location.
  109780. * * snapDistance is the the change in distance
  109781. */
  109782. onSnapObservable: Observable<{
  109783. snapDistance: number;
  109784. }>;
  109785. private _isEnabled;
  109786. private _parent;
  109787. private _arrow;
  109788. private _coloredMaterial;
  109789. private _hoverMaterial;
  109790. /** @hidden */
  109791. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  109792. /** @hidden */
  109793. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  109794. /**
  109795. * Creates an AxisDragGizmo
  109796. * @param gizmoLayer The utility layer the gizmo will be added to
  109797. * @param dragAxis The axis which the gizmo will be able to drag on
  109798. * @param color The color of the gizmo
  109799. */
  109800. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  109801. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  109802. /**
  109803. * If the gizmo is enabled
  109804. */
  109805. isEnabled: boolean;
  109806. /**
  109807. * Disposes of the gizmo
  109808. */
  109809. dispose(): void;
  109810. }
  109811. }
  109812. declare module BABYLON.Debug {
  109813. /**
  109814. * The Axes viewer will show 3 axes in a specific point in space
  109815. */
  109816. export class AxesViewer {
  109817. private _xAxis;
  109818. private _yAxis;
  109819. private _zAxis;
  109820. private _scaleLinesFactor;
  109821. private _instanced;
  109822. /**
  109823. * Gets the hosting scene
  109824. */
  109825. scene: Scene;
  109826. /**
  109827. * Gets or sets a number used to scale line length
  109828. */
  109829. scaleLines: number;
  109830. /** Gets the node hierarchy used to render x-axis */
  109831. readonly xAxis: TransformNode;
  109832. /** Gets the node hierarchy used to render y-axis */
  109833. readonly yAxis: TransformNode;
  109834. /** Gets the node hierarchy used to render z-axis */
  109835. readonly zAxis: TransformNode;
  109836. /**
  109837. * Creates a new AxesViewer
  109838. * @param scene defines the hosting scene
  109839. * @param scaleLines defines a number used to scale line length (1 by default)
  109840. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  109841. * @param xAxis defines the node hierarchy used to render the x-axis
  109842. * @param yAxis defines the node hierarchy used to render the y-axis
  109843. * @param zAxis defines the node hierarchy used to render the z-axis
  109844. */
  109845. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  109846. /**
  109847. * Force the viewer to update
  109848. * @param position defines the position of the viewer
  109849. * @param xaxis defines the x axis of the viewer
  109850. * @param yaxis defines the y axis of the viewer
  109851. * @param zaxis defines the z axis of the viewer
  109852. */
  109853. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  109854. /**
  109855. * Creates an instance of this axes viewer.
  109856. * @returns a new axes viewer with instanced meshes
  109857. */
  109858. createInstance(): AxesViewer;
  109859. /** Releases resources */
  109860. dispose(): void;
  109861. private static _SetRenderingGroupId;
  109862. }
  109863. }
  109864. declare module BABYLON.Debug {
  109865. /**
  109866. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  109867. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  109868. */
  109869. export class BoneAxesViewer extends AxesViewer {
  109870. /**
  109871. * Gets or sets the target mesh where to display the axes viewer
  109872. */
  109873. mesh: Nullable<Mesh>;
  109874. /**
  109875. * Gets or sets the target bone where to display the axes viewer
  109876. */
  109877. bone: Nullable<Bone>;
  109878. /** Gets current position */
  109879. pos: Vector3;
  109880. /** Gets direction of X axis */
  109881. xaxis: Vector3;
  109882. /** Gets direction of Y axis */
  109883. yaxis: Vector3;
  109884. /** Gets direction of Z axis */
  109885. zaxis: Vector3;
  109886. /**
  109887. * Creates a new BoneAxesViewer
  109888. * @param scene defines the hosting scene
  109889. * @param bone defines the target bone
  109890. * @param mesh defines the target mesh
  109891. * @param scaleLines defines a scaling factor for line length (1 by default)
  109892. */
  109893. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  109894. /**
  109895. * Force the viewer to update
  109896. */
  109897. update(): void;
  109898. /** Releases resources */
  109899. dispose(): void;
  109900. }
  109901. }
  109902. declare module BABYLON {
  109903. /**
  109904. * Interface used to define scene explorer extensibility option
  109905. */
  109906. export interface IExplorerExtensibilityOption {
  109907. /**
  109908. * Define the option label
  109909. */
  109910. label: string;
  109911. /**
  109912. * Defines the action to execute on click
  109913. */
  109914. action: (entity: any) => void;
  109915. }
  109916. /**
  109917. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  109918. */
  109919. export interface IExplorerExtensibilityGroup {
  109920. /**
  109921. * Defines a predicate to test if a given type mut be extended
  109922. */
  109923. predicate: (entity: any) => boolean;
  109924. /**
  109925. * Gets the list of options added to a type
  109926. */
  109927. entries: IExplorerExtensibilityOption[];
  109928. }
  109929. /**
  109930. * Interface used to define the options to use to create the Inspector
  109931. */
  109932. export interface IInspectorOptions {
  109933. /**
  109934. * Display in overlay mode (default: false)
  109935. */
  109936. overlay?: boolean;
  109937. /**
  109938. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  109939. */
  109940. globalRoot?: HTMLElement;
  109941. /**
  109942. * Display the Scene explorer
  109943. */
  109944. showExplorer?: boolean;
  109945. /**
  109946. * Display the property inspector
  109947. */
  109948. showInspector?: boolean;
  109949. /**
  109950. * Display in embed mode (both panes on the right)
  109951. */
  109952. embedMode?: boolean;
  109953. /**
  109954. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  109955. */
  109956. handleResize?: boolean;
  109957. /**
  109958. * Allow the panes to popup (default: true)
  109959. */
  109960. enablePopup?: boolean;
  109961. /**
  109962. * Allow the panes to be closed by users (default: true)
  109963. */
  109964. enableClose?: boolean;
  109965. /**
  109966. * Optional list of extensibility entries
  109967. */
  109968. explorerExtensibility?: IExplorerExtensibilityGroup[];
  109969. /**
  109970. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  109971. */
  109972. inspectorURL?: string;
  109973. }
  109974. interface Scene {
  109975. /**
  109976. * @hidden
  109977. * Backing field
  109978. */
  109979. _debugLayer: DebugLayer;
  109980. /**
  109981. * Gets the debug layer (aka Inspector) associated with the scene
  109982. * @see http://doc.babylonjs.com/features/playground_debuglayer
  109983. */
  109984. debugLayer: DebugLayer;
  109985. }
  109986. /**
  109987. * The debug layer (aka Inspector) is the go to tool in order to better understand
  109988. * what is happening in your scene
  109989. * @see http://doc.babylonjs.com/features/playground_debuglayer
  109990. */
  109991. export class DebugLayer {
  109992. /**
  109993. * Define the url to get the inspector script from.
  109994. * By default it uses the babylonjs CDN.
  109995. * @ignoreNaming
  109996. */
  109997. static InspectorURL: string;
  109998. private _scene;
  109999. private BJSINSPECTOR;
  110000. private _onPropertyChangedObservable?;
  110001. /**
  110002. * Observable triggered when a property is changed through the inspector.
  110003. */
  110004. readonly onPropertyChangedObservable: any;
  110005. /**
  110006. * Instantiates a new debug layer.
  110007. * The debug layer (aka Inspector) is the go to tool in order to better understand
  110008. * what is happening in your scene
  110009. * @see http://doc.babylonjs.com/features/playground_debuglayer
  110010. * @param scene Defines the scene to inspect
  110011. */
  110012. constructor(scene: Scene);
  110013. /** Creates the inspector window. */
  110014. private _createInspector;
  110015. /**
  110016. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  110017. * @param entity defines the entity to select
  110018. * @param lineContainerTitle defines the specific block to highlight
  110019. */
  110020. select(entity: any, lineContainerTitle?: string): void;
  110021. /** Get the inspector from bundle or global */
  110022. private _getGlobalInspector;
  110023. /**
  110024. * Get if the inspector is visible or not.
  110025. * @returns true if visible otherwise, false
  110026. */
  110027. isVisible(): boolean;
  110028. /**
  110029. * Hide the inspector and close its window.
  110030. */
  110031. hide(): void;
  110032. /**
  110033. * Launch the debugLayer.
  110034. * @param config Define the configuration of the inspector
  110035. * @return a promise fulfilled when the debug layer is visible
  110036. */
  110037. show(config?: IInspectorOptions): Promise<DebugLayer>;
  110038. }
  110039. }
  110040. declare module BABYLON {
  110041. /**
  110042. * Class containing static functions to help procedurally build meshes
  110043. */
  110044. export class BoxBuilder {
  110045. /**
  110046. * Creates a box mesh
  110047. * * The parameter `size` sets the size (float) of each box side (default 1)
  110048. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  110049. * * 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)
  110050. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  110051. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110052. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110053. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110054. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  110055. * @param name defines the name of the mesh
  110056. * @param options defines the options used to create the mesh
  110057. * @param scene defines the hosting scene
  110058. * @returns the box mesh
  110059. */
  110060. static CreateBox(name: string, options: {
  110061. size?: number;
  110062. width?: number;
  110063. height?: number;
  110064. depth?: number;
  110065. faceUV?: Vector4[];
  110066. faceColors?: Color4[];
  110067. sideOrientation?: number;
  110068. frontUVs?: Vector4;
  110069. backUVs?: Vector4;
  110070. wrap?: boolean;
  110071. topBaseAt?: number;
  110072. bottomBaseAt?: number;
  110073. updatable?: boolean;
  110074. }, scene?: Nullable<Scene>): Mesh;
  110075. }
  110076. }
  110077. declare module BABYLON {
  110078. /**
  110079. * Class containing static functions to help procedurally build meshes
  110080. */
  110081. export class SphereBuilder {
  110082. /**
  110083. * Creates a sphere mesh
  110084. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  110085. * * 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`)
  110086. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  110087. * * 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
  110088. * * 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)
  110089. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110090. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110091. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110092. * @param name defines the name of the mesh
  110093. * @param options defines the options used to create the mesh
  110094. * @param scene defines the hosting scene
  110095. * @returns the sphere mesh
  110096. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  110097. */
  110098. static CreateSphere(name: string, options: {
  110099. segments?: number;
  110100. diameter?: number;
  110101. diameterX?: number;
  110102. diameterY?: number;
  110103. diameterZ?: number;
  110104. arc?: number;
  110105. slice?: number;
  110106. sideOrientation?: number;
  110107. frontUVs?: Vector4;
  110108. backUVs?: Vector4;
  110109. updatable?: boolean;
  110110. }, scene?: Nullable<Scene>): Mesh;
  110111. }
  110112. }
  110113. declare module BABYLON.Debug {
  110114. /**
  110115. * Used to show the physics impostor around the specific mesh
  110116. */
  110117. export class PhysicsViewer {
  110118. /** @hidden */
  110119. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  110120. /** @hidden */
  110121. protected _meshes: Array<Nullable<AbstractMesh>>;
  110122. /** @hidden */
  110123. protected _scene: Nullable<Scene>;
  110124. /** @hidden */
  110125. protected _numMeshes: number;
  110126. /** @hidden */
  110127. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  110128. private _renderFunction;
  110129. private _utilityLayer;
  110130. private _debugBoxMesh;
  110131. private _debugSphereMesh;
  110132. private _debugCylinderMesh;
  110133. private _debugMaterial;
  110134. private _debugMeshMeshes;
  110135. /**
  110136. * Creates a new PhysicsViewer
  110137. * @param scene defines the hosting scene
  110138. */
  110139. constructor(scene: Scene);
  110140. /** @hidden */
  110141. protected _updateDebugMeshes(): void;
  110142. /**
  110143. * Renders a specified physic impostor
  110144. * @param impostor defines the impostor to render
  110145. * @param targetMesh defines the mesh represented by the impostor
  110146. * @returns the new debug mesh used to render the impostor
  110147. */
  110148. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  110149. /**
  110150. * Hides a specified physic impostor
  110151. * @param impostor defines the impostor to hide
  110152. */
  110153. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  110154. private _getDebugMaterial;
  110155. private _getDebugBoxMesh;
  110156. private _getDebugSphereMesh;
  110157. private _getDebugCylinderMesh;
  110158. private _getDebugMeshMesh;
  110159. private _getDebugMesh;
  110160. /** Releases all resources */
  110161. dispose(): void;
  110162. }
  110163. }
  110164. declare module BABYLON {
  110165. /**
  110166. * Class containing static functions to help procedurally build meshes
  110167. */
  110168. export class LinesBuilder {
  110169. /**
  110170. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  110171. * * 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
  110172. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  110173. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  110174. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  110175. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  110176. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  110177. * * 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
  110178. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  110179. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110180. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  110181. * @param name defines the name of the new line system
  110182. * @param options defines the options used to create the line system
  110183. * @param scene defines the hosting scene
  110184. * @returns a new line system mesh
  110185. */
  110186. static CreateLineSystem(name: string, options: {
  110187. lines: Vector3[][];
  110188. updatable?: boolean;
  110189. instance?: Nullable<LinesMesh>;
  110190. colors?: Nullable<Color4[][]>;
  110191. useVertexAlpha?: boolean;
  110192. }, scene: Nullable<Scene>): LinesMesh;
  110193. /**
  110194. * Creates a line mesh
  110195. * 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
  110196. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  110197. * * The parameter `points` is an array successive Vector3
  110198. * * 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
  110199. * * The optional parameter `colors` is an array of successive Color4, one per line point
  110200. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  110201. * * When updating an instance, remember that only point positions can change, not the number of points
  110202. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110203. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  110204. * @param name defines the name of the new line system
  110205. * @param options defines the options used to create the line system
  110206. * @param scene defines the hosting scene
  110207. * @returns a new line mesh
  110208. */
  110209. static CreateLines(name: string, options: {
  110210. points: Vector3[];
  110211. updatable?: boolean;
  110212. instance?: Nullable<LinesMesh>;
  110213. colors?: Color4[];
  110214. useVertexAlpha?: boolean;
  110215. }, scene?: Nullable<Scene>): LinesMesh;
  110216. /**
  110217. * Creates a dashed line mesh
  110218. * * 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
  110219. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  110220. * * The parameter `points` is an array successive Vector3
  110221. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  110222. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  110223. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  110224. * * 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
  110225. * * When updating an instance, remember that only point positions can change, not the number of points
  110226. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110227. * @param name defines the name of the mesh
  110228. * @param options defines the options used to create the mesh
  110229. * @param scene defines the hosting scene
  110230. * @returns the dashed line mesh
  110231. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  110232. */
  110233. static CreateDashedLines(name: string, options: {
  110234. points: Vector3[];
  110235. dashSize?: number;
  110236. gapSize?: number;
  110237. dashNb?: number;
  110238. updatable?: boolean;
  110239. instance?: LinesMesh;
  110240. }, scene?: Nullable<Scene>): LinesMesh;
  110241. }
  110242. }
  110243. declare module BABYLON {
  110244. /**
  110245. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  110246. * in order to better appreciate the issue one might have.
  110247. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  110248. */
  110249. export class RayHelper {
  110250. /**
  110251. * Defines the ray we are currently tryin to visualize.
  110252. */
  110253. ray: Nullable<Ray>;
  110254. private _renderPoints;
  110255. private _renderLine;
  110256. private _renderFunction;
  110257. private _scene;
  110258. private _updateToMeshFunction;
  110259. private _attachedToMesh;
  110260. private _meshSpaceDirection;
  110261. private _meshSpaceOrigin;
  110262. /**
  110263. * Helper function to create a colored helper in a scene in one line.
  110264. * @param ray Defines the ray we are currently tryin to visualize
  110265. * @param scene Defines the scene the ray is used in
  110266. * @param color Defines the color we want to see the ray in
  110267. * @returns The newly created ray helper.
  110268. */
  110269. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  110270. /**
  110271. * Instantiate a new ray helper.
  110272. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  110273. * in order to better appreciate the issue one might have.
  110274. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  110275. * @param ray Defines the ray we are currently tryin to visualize
  110276. */
  110277. constructor(ray: Ray);
  110278. /**
  110279. * Shows the ray we are willing to debug.
  110280. * @param scene Defines the scene the ray needs to be rendered in
  110281. * @param color Defines the color the ray needs to be rendered in
  110282. */
  110283. show(scene: Scene, color?: Color3): void;
  110284. /**
  110285. * Hides the ray we are debugging.
  110286. */
  110287. hide(): void;
  110288. private _render;
  110289. /**
  110290. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  110291. * @param mesh Defines the mesh we want the helper attached to
  110292. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  110293. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  110294. * @param length Defines the length of the ray
  110295. */
  110296. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  110297. /**
  110298. * Detach the ray helper from the mesh it has previously been attached to.
  110299. */
  110300. detachFromMesh(): void;
  110301. private _updateToMesh;
  110302. /**
  110303. * Dispose the helper and release its associated resources.
  110304. */
  110305. dispose(): void;
  110306. }
  110307. }
  110308. declare module BABYLON.Debug {
  110309. /**
  110310. * Class used to render a debug view of a given skeleton
  110311. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  110312. */
  110313. export class SkeletonViewer {
  110314. /** defines the skeleton to render */
  110315. skeleton: Skeleton;
  110316. /** defines the mesh attached to the skeleton */
  110317. mesh: AbstractMesh;
  110318. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  110319. autoUpdateBonesMatrices: boolean;
  110320. /** defines the rendering group id to use with the viewer */
  110321. renderingGroupId: number;
  110322. /** Gets or sets the color used to render the skeleton */
  110323. color: Color3;
  110324. private _scene;
  110325. private _debugLines;
  110326. private _debugMesh;
  110327. private _isEnabled;
  110328. private _renderFunction;
  110329. private _utilityLayer;
  110330. /**
  110331. * Returns the mesh used to render the bones
  110332. */
  110333. readonly debugMesh: Nullable<LinesMesh>;
  110334. /**
  110335. * Creates a new SkeletonViewer
  110336. * @param skeleton defines the skeleton to render
  110337. * @param mesh defines the mesh attached to the skeleton
  110338. * @param scene defines the hosting scene
  110339. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  110340. * @param renderingGroupId defines the rendering group id to use with the viewer
  110341. */
  110342. constructor(
  110343. /** defines the skeleton to render */
  110344. skeleton: Skeleton,
  110345. /** defines the mesh attached to the skeleton */
  110346. mesh: AbstractMesh, scene: Scene,
  110347. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  110348. autoUpdateBonesMatrices?: boolean,
  110349. /** defines the rendering group id to use with the viewer */
  110350. renderingGroupId?: number);
  110351. /** Gets or sets a boolean indicating if the viewer is enabled */
  110352. isEnabled: boolean;
  110353. private _getBonePosition;
  110354. private _getLinesForBonesWithLength;
  110355. private _getLinesForBonesNoLength;
  110356. /** Update the viewer to sync with current skeleton state */
  110357. update(): void;
  110358. /** Release associated resources */
  110359. dispose(): void;
  110360. }
  110361. }
  110362. declare module BABYLON {
  110363. /**
  110364. * Options to create the null engine
  110365. */
  110366. export class NullEngineOptions {
  110367. /**
  110368. * Render width (Default: 512)
  110369. */
  110370. renderWidth: number;
  110371. /**
  110372. * Render height (Default: 256)
  110373. */
  110374. renderHeight: number;
  110375. /**
  110376. * Texture size (Default: 512)
  110377. */
  110378. textureSize: number;
  110379. /**
  110380. * If delta time between frames should be constant
  110381. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110382. */
  110383. deterministicLockstep: boolean;
  110384. /**
  110385. * Maximum about of steps between frames (Default: 4)
  110386. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110387. */
  110388. lockstepMaxSteps: number;
  110389. }
  110390. /**
  110391. * The null engine class provides support for headless version of babylon.js.
  110392. * This can be used in server side scenario or for testing purposes
  110393. */
  110394. export class NullEngine extends Engine {
  110395. private _options;
  110396. /**
  110397. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  110398. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110399. * @returns true if engine is in deterministic lock step mode
  110400. */
  110401. isDeterministicLockStep(): boolean;
  110402. /**
  110403. * Gets the max steps when engine is running in deterministic lock step
  110404. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110405. * @returns the max steps
  110406. */
  110407. getLockstepMaxSteps(): number;
  110408. /**
  110409. * Gets the current hardware scaling level.
  110410. * By default the hardware scaling level is computed from the window device ratio.
  110411. * 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.
  110412. * @returns a number indicating the current hardware scaling level
  110413. */
  110414. getHardwareScalingLevel(): number;
  110415. constructor(options?: NullEngineOptions);
  110416. /**
  110417. * Creates a vertex buffer
  110418. * @param vertices the data for the vertex buffer
  110419. * @returns the new WebGL static buffer
  110420. */
  110421. createVertexBuffer(vertices: FloatArray): DataBuffer;
  110422. /**
  110423. * Creates a new index buffer
  110424. * @param indices defines the content of the index buffer
  110425. * @param updatable defines if the index buffer must be updatable
  110426. * @returns a new webGL buffer
  110427. */
  110428. createIndexBuffer(indices: IndicesArray): DataBuffer;
  110429. /**
  110430. * Clear the current render buffer or the current render target (if any is set up)
  110431. * @param color defines the color to use
  110432. * @param backBuffer defines if the back buffer must be cleared
  110433. * @param depth defines if the depth buffer must be cleared
  110434. * @param stencil defines if the stencil buffer must be cleared
  110435. */
  110436. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  110437. /**
  110438. * Gets the current render width
  110439. * @param useScreen defines if screen size must be used (or the current render target if any)
  110440. * @returns a number defining the current render width
  110441. */
  110442. getRenderWidth(useScreen?: boolean): number;
  110443. /**
  110444. * Gets the current render height
  110445. * @param useScreen defines if screen size must be used (or the current render target if any)
  110446. * @returns a number defining the current render height
  110447. */
  110448. getRenderHeight(useScreen?: boolean): number;
  110449. /**
  110450. * Set the WebGL's viewport
  110451. * @param viewport defines the viewport element to be used
  110452. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  110453. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  110454. */
  110455. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  110456. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  110457. /**
  110458. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  110459. * @param pipelineContext defines the pipeline context to use
  110460. * @param uniformsNames defines the list of uniform names
  110461. * @returns an array of webGL uniform locations
  110462. */
  110463. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  110464. /**
  110465. * Gets the lsit of active attributes for a given webGL program
  110466. * @param pipelineContext defines the pipeline context to use
  110467. * @param attributesNames defines the list of attribute names to get
  110468. * @returns an array of indices indicating the offset of each attribute
  110469. */
  110470. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  110471. /**
  110472. * Binds an effect to the webGL context
  110473. * @param effect defines the effect to bind
  110474. */
  110475. bindSamplers(effect: Effect): void;
  110476. /**
  110477. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  110478. * @param effect defines the effect to activate
  110479. */
  110480. enableEffect(effect: Effect): void;
  110481. /**
  110482. * Set various states to the webGL context
  110483. * @param culling defines backface culling state
  110484. * @param zOffset defines the value to apply to zOffset (0 by default)
  110485. * @param force defines if states must be applied even if cache is up to date
  110486. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  110487. */
  110488. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  110489. /**
  110490. * Set the value of an uniform to an array of int32
  110491. * @param uniform defines the webGL uniform location where to store the value
  110492. * @param array defines the array of int32 to store
  110493. */
  110494. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  110495. /**
  110496. * Set the value of an uniform to an array of int32 (stored as vec2)
  110497. * @param uniform defines the webGL uniform location where to store the value
  110498. * @param array defines the array of int32 to store
  110499. */
  110500. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  110501. /**
  110502. * Set the value of an uniform to an array of int32 (stored as vec3)
  110503. * @param uniform defines the webGL uniform location where to store the value
  110504. * @param array defines the array of int32 to store
  110505. */
  110506. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  110507. /**
  110508. * Set the value of an uniform to an array of int32 (stored as vec4)
  110509. * @param uniform defines the webGL uniform location where to store the value
  110510. * @param array defines the array of int32 to store
  110511. */
  110512. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  110513. /**
  110514. * Set the value of an uniform to an array of float32
  110515. * @param uniform defines the webGL uniform location where to store the value
  110516. * @param array defines the array of float32 to store
  110517. */
  110518. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  110519. /**
  110520. * Set the value of an uniform to an array of float32 (stored as vec2)
  110521. * @param uniform defines the webGL uniform location where to store the value
  110522. * @param array defines the array of float32 to store
  110523. */
  110524. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  110525. /**
  110526. * Set the value of an uniform to an array of float32 (stored as vec3)
  110527. * @param uniform defines the webGL uniform location where to store the value
  110528. * @param array defines the array of float32 to store
  110529. */
  110530. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  110531. /**
  110532. * Set the value of an uniform to an array of float32 (stored as vec4)
  110533. * @param uniform defines the webGL uniform location where to store the value
  110534. * @param array defines the array of float32 to store
  110535. */
  110536. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  110537. /**
  110538. * Set the value of an uniform to an array of number
  110539. * @param uniform defines the webGL uniform location where to store the value
  110540. * @param array defines the array of number to store
  110541. */
  110542. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  110543. /**
  110544. * Set the value of an uniform to an array of number (stored as vec2)
  110545. * @param uniform defines the webGL uniform location where to store the value
  110546. * @param array defines the array of number to store
  110547. */
  110548. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  110549. /**
  110550. * Set the value of an uniform to an array of number (stored as vec3)
  110551. * @param uniform defines the webGL uniform location where to store the value
  110552. * @param array defines the array of number to store
  110553. */
  110554. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  110555. /**
  110556. * Set the value of an uniform to an array of number (stored as vec4)
  110557. * @param uniform defines the webGL uniform location where to store the value
  110558. * @param array defines the array of number to store
  110559. */
  110560. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  110561. /**
  110562. * Set the value of an uniform to an array of float32 (stored as matrices)
  110563. * @param uniform defines the webGL uniform location where to store the value
  110564. * @param matrices defines the array of float32 to store
  110565. */
  110566. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  110567. /**
  110568. * Set the value of an uniform to a matrix (3x3)
  110569. * @param uniform defines the webGL uniform location where to store the value
  110570. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  110571. */
  110572. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  110573. /**
  110574. * Set the value of an uniform to a matrix (2x2)
  110575. * @param uniform defines the webGL uniform location where to store the value
  110576. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  110577. */
  110578. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  110579. /**
  110580. * Set the value of an uniform to a number (float)
  110581. * @param uniform defines the webGL uniform location where to store the value
  110582. * @param value defines the float number to store
  110583. */
  110584. setFloat(uniform: WebGLUniformLocation, value: number): void;
  110585. /**
  110586. * Set the value of an uniform to a vec2
  110587. * @param uniform defines the webGL uniform location where to store the value
  110588. * @param x defines the 1st component of the value
  110589. * @param y defines the 2nd component of the value
  110590. */
  110591. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  110592. /**
  110593. * Set the value of an uniform to a vec3
  110594. * @param uniform defines the webGL uniform location where to store the value
  110595. * @param x defines the 1st component of the value
  110596. * @param y defines the 2nd component of the value
  110597. * @param z defines the 3rd component of the value
  110598. */
  110599. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  110600. /**
  110601. * Set the value of an uniform to a boolean
  110602. * @param uniform defines the webGL uniform location where to store the value
  110603. * @param bool defines the boolean to store
  110604. */
  110605. setBool(uniform: WebGLUniformLocation, bool: number): void;
  110606. /**
  110607. * Set the value of an uniform to a vec4
  110608. * @param uniform defines the webGL uniform location where to store the value
  110609. * @param x defines the 1st component of the value
  110610. * @param y defines the 2nd component of the value
  110611. * @param z defines the 3rd component of the value
  110612. * @param w defines the 4th component of the value
  110613. */
  110614. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  110615. /**
  110616. * Sets the current alpha mode
  110617. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  110618. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  110619. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  110620. */
  110621. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  110622. /**
  110623. * Bind webGl buffers directly to the webGL context
  110624. * @param vertexBuffers defines the vertex buffer to bind
  110625. * @param indexBuffer defines the index buffer to bind
  110626. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  110627. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  110628. * @param effect defines the effect associated with the vertex buffer
  110629. */
  110630. bindBuffers(vertexBuffers: {
  110631. [key: string]: VertexBuffer;
  110632. }, indexBuffer: DataBuffer, effect: Effect): void;
  110633. /**
  110634. * Force the entire cache to be cleared
  110635. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  110636. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  110637. */
  110638. wipeCaches(bruteForce?: boolean): void;
  110639. /**
  110640. * Send a draw order
  110641. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  110642. * @param indexStart defines the starting index
  110643. * @param indexCount defines the number of index to draw
  110644. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  110645. */
  110646. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  110647. /**
  110648. * Draw a list of indexed primitives
  110649. * @param fillMode defines the primitive to use
  110650. * @param indexStart defines the starting index
  110651. * @param indexCount defines the number of index to draw
  110652. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  110653. */
  110654. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  110655. /**
  110656. * Draw a list of unindexed primitives
  110657. * @param fillMode defines the primitive to use
  110658. * @param verticesStart defines the index of first vertex to draw
  110659. * @param verticesCount defines the count of vertices to draw
  110660. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  110661. */
  110662. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  110663. /** @hidden */
  110664. _createTexture(): WebGLTexture;
  110665. /** @hidden */
  110666. _releaseTexture(texture: InternalTexture): void;
  110667. /**
  110668. * Usually called from Texture.ts.
  110669. * Passed information to create a WebGLTexture
  110670. * @param urlArg defines a value which contains one of the following:
  110671. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  110672. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  110673. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  110674. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  110675. * @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)
  110676. * @param scene needed for loading to the correct scene
  110677. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  110678. * @param onLoad optional callback to be called upon successful completion
  110679. * @param onError optional callback to be called upon failure
  110680. * @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
  110681. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  110682. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  110683. * @param forcedExtension defines the extension to use to pick the right loader
  110684. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  110685. * @returns a InternalTexture for assignment back into BABYLON.Texture
  110686. */
  110687. 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;
  110688. /**
  110689. * Creates a new render target texture
  110690. * @param size defines the size of the texture
  110691. * @param options defines the options used to create the texture
  110692. * @returns a new render target texture stored in an InternalTexture
  110693. */
  110694. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  110695. /**
  110696. * Update the sampling mode of a given texture
  110697. * @param samplingMode defines the required sampling mode
  110698. * @param texture defines the texture to update
  110699. */
  110700. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  110701. /**
  110702. * Binds the frame buffer to the specified texture.
  110703. * @param texture The texture to render to or null for the default canvas
  110704. * @param faceIndex The face of the texture to render to in case of cube texture
  110705. * @param requiredWidth The width of the target to render to
  110706. * @param requiredHeight The height of the target to render to
  110707. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  110708. * @param depthStencilTexture The depth stencil texture to use to render
  110709. * @param lodLevel defines le lod level to bind to the frame buffer
  110710. */
  110711. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  110712. /**
  110713. * Unbind the current render target texture from the webGL context
  110714. * @param texture defines the render target texture to unbind
  110715. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  110716. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  110717. */
  110718. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  110719. /**
  110720. * Creates a dynamic vertex buffer
  110721. * @param vertices the data for the dynamic vertex buffer
  110722. * @returns the new WebGL dynamic buffer
  110723. */
  110724. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  110725. /**
  110726. * Update the content of a dynamic texture
  110727. * @param texture defines the texture to update
  110728. * @param canvas defines the canvas containing the source
  110729. * @param invertY defines if data must be stored with Y axis inverted
  110730. * @param premulAlpha defines if alpha is stored as premultiplied
  110731. * @param format defines the format of the data
  110732. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  110733. */
  110734. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  110735. /**
  110736. * Gets a boolean indicating if all created effects are ready
  110737. * @returns true if all effects are ready
  110738. */
  110739. areAllEffectsReady(): boolean;
  110740. /**
  110741. * @hidden
  110742. * Get the current error code of the webGL context
  110743. * @returns the error code
  110744. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  110745. */
  110746. getError(): number;
  110747. /** @hidden */
  110748. _getUnpackAlignement(): number;
  110749. /** @hidden */
  110750. _unpackFlipY(value: boolean): void;
  110751. /**
  110752. * Update a dynamic index buffer
  110753. * @param indexBuffer defines the target index buffer
  110754. * @param indices defines the data to update
  110755. * @param offset defines the offset in the target index buffer where update should start
  110756. */
  110757. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  110758. /**
  110759. * Updates a dynamic vertex buffer.
  110760. * @param vertexBuffer the vertex buffer to update
  110761. * @param vertices the data used to update the vertex buffer
  110762. * @param byteOffset the byte offset of the data (optional)
  110763. * @param byteLength the byte length of the data (optional)
  110764. */
  110765. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  110766. /** @hidden */
  110767. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  110768. /** @hidden */
  110769. _bindTexture(channel: number, texture: InternalTexture): void;
  110770. protected _deleteBuffer(buffer: WebGLBuffer): void;
  110771. /**
  110772. * 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
  110773. */
  110774. releaseEffects(): void;
  110775. displayLoadingUI(): void;
  110776. hideLoadingUI(): void;
  110777. /** @hidden */
  110778. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  110779. /** @hidden */
  110780. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  110781. /** @hidden */
  110782. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  110783. /** @hidden */
  110784. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  110785. }
  110786. }
  110787. declare module BABYLON {
  110788. /** @hidden */
  110789. export class _OcclusionDataStorage {
  110790. /** @hidden */
  110791. occlusionInternalRetryCounter: number;
  110792. /** @hidden */
  110793. isOcclusionQueryInProgress: boolean;
  110794. /** @hidden */
  110795. isOccluded: boolean;
  110796. /** @hidden */
  110797. occlusionRetryCount: number;
  110798. /** @hidden */
  110799. occlusionType: number;
  110800. /** @hidden */
  110801. occlusionQueryAlgorithmType: number;
  110802. }
  110803. interface Engine {
  110804. /**
  110805. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  110806. * @return the new query
  110807. */
  110808. createQuery(): WebGLQuery;
  110809. /**
  110810. * Delete and release a webGL query
  110811. * @param query defines the query to delete
  110812. * @return the current engine
  110813. */
  110814. deleteQuery(query: WebGLQuery): Engine;
  110815. /**
  110816. * Check if a given query has resolved and got its value
  110817. * @param query defines the query to check
  110818. * @returns true if the query got its value
  110819. */
  110820. isQueryResultAvailable(query: WebGLQuery): boolean;
  110821. /**
  110822. * Gets the value of a given query
  110823. * @param query defines the query to check
  110824. * @returns the value of the query
  110825. */
  110826. getQueryResult(query: WebGLQuery): number;
  110827. /**
  110828. * Initiates an occlusion query
  110829. * @param algorithmType defines the algorithm to use
  110830. * @param query defines the query to use
  110831. * @returns the current engine
  110832. * @see http://doc.babylonjs.com/features/occlusionquery
  110833. */
  110834. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  110835. /**
  110836. * Ends an occlusion query
  110837. * @see http://doc.babylonjs.com/features/occlusionquery
  110838. * @param algorithmType defines the algorithm to use
  110839. * @returns the current engine
  110840. */
  110841. endOcclusionQuery(algorithmType: number): Engine;
  110842. /**
  110843. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  110844. * Please note that only one query can be issued at a time
  110845. * @returns a time token used to track the time span
  110846. */
  110847. startTimeQuery(): Nullable<_TimeToken>;
  110848. /**
  110849. * Ends a time query
  110850. * @param token defines the token used to measure the time span
  110851. * @returns the time spent (in ns)
  110852. */
  110853. endTimeQuery(token: _TimeToken): int;
  110854. /** @hidden */
  110855. _currentNonTimestampToken: Nullable<_TimeToken>;
  110856. /** @hidden */
  110857. _createTimeQuery(): WebGLQuery;
  110858. /** @hidden */
  110859. _deleteTimeQuery(query: WebGLQuery): void;
  110860. /** @hidden */
  110861. _getGlAlgorithmType(algorithmType: number): number;
  110862. /** @hidden */
  110863. _getTimeQueryResult(query: WebGLQuery): any;
  110864. /** @hidden */
  110865. _getTimeQueryAvailability(query: WebGLQuery): any;
  110866. }
  110867. interface AbstractMesh {
  110868. /**
  110869. * Backing filed
  110870. * @hidden
  110871. */
  110872. __occlusionDataStorage: _OcclusionDataStorage;
  110873. /**
  110874. * Access property
  110875. * @hidden
  110876. */
  110877. _occlusionDataStorage: _OcclusionDataStorage;
  110878. /**
  110879. * 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.
  110880. * The default value is -1 which means don't break the query and wait till the result
  110881. * @see http://doc.babylonjs.com/features/occlusionquery
  110882. */
  110883. occlusionRetryCount: number;
  110884. /**
  110885. * 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:
  110886. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  110887. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  110888. * * 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.
  110889. * @see http://doc.babylonjs.com/features/occlusionquery
  110890. */
  110891. occlusionType: number;
  110892. /**
  110893. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  110894. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  110895. * * 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.
  110896. * @see http://doc.babylonjs.com/features/occlusionquery
  110897. */
  110898. occlusionQueryAlgorithmType: number;
  110899. /**
  110900. * 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
  110901. * @see http://doc.babylonjs.com/features/occlusionquery
  110902. */
  110903. isOccluded: boolean;
  110904. /**
  110905. * Flag to check the progress status of the query
  110906. * @see http://doc.babylonjs.com/features/occlusionquery
  110907. */
  110908. isOcclusionQueryInProgress: boolean;
  110909. }
  110910. }
  110911. declare module BABYLON {
  110912. /** @hidden */
  110913. export var _forceTransformFeedbackToBundle: boolean;
  110914. interface Engine {
  110915. /**
  110916. * Creates a webGL transform feedback object
  110917. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  110918. * @returns the webGL transform feedback object
  110919. */
  110920. createTransformFeedback(): WebGLTransformFeedback;
  110921. /**
  110922. * Delete a webGL transform feedback object
  110923. * @param value defines the webGL transform feedback object to delete
  110924. */
  110925. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  110926. /**
  110927. * Bind a webGL transform feedback object to the webgl context
  110928. * @param value defines the webGL transform feedback object to bind
  110929. */
  110930. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  110931. /**
  110932. * Begins a transform feedback operation
  110933. * @param usePoints defines if points or triangles must be used
  110934. */
  110935. beginTransformFeedback(usePoints: boolean): void;
  110936. /**
  110937. * Ends a transform feedback operation
  110938. */
  110939. endTransformFeedback(): void;
  110940. /**
  110941. * Specify the varyings to use with transform feedback
  110942. * @param program defines the associated webGL program
  110943. * @param value defines the list of strings representing the varying names
  110944. */
  110945. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  110946. /**
  110947. * Bind a webGL buffer for a transform feedback operation
  110948. * @param value defines the webGL buffer to bind
  110949. */
  110950. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  110951. }
  110952. }
  110953. declare module BABYLON {
  110954. /**
  110955. * Creation options of the multi render target texture.
  110956. */
  110957. export interface IMultiRenderTargetOptions {
  110958. /**
  110959. * Define if the texture needs to create mip maps after render.
  110960. */
  110961. generateMipMaps?: boolean;
  110962. /**
  110963. * Define the types of all the draw buffers we want to create
  110964. */
  110965. types?: number[];
  110966. /**
  110967. * Define the sampling modes of all the draw buffers we want to create
  110968. */
  110969. samplingModes?: number[];
  110970. /**
  110971. * Define if a depth buffer is required
  110972. */
  110973. generateDepthBuffer?: boolean;
  110974. /**
  110975. * Define if a stencil buffer is required
  110976. */
  110977. generateStencilBuffer?: boolean;
  110978. /**
  110979. * Define if a depth texture is required instead of a depth buffer
  110980. */
  110981. generateDepthTexture?: boolean;
  110982. /**
  110983. * Define the number of desired draw buffers
  110984. */
  110985. textureCount?: number;
  110986. /**
  110987. * Define if aspect ratio should be adapted to the texture or stay the scene one
  110988. */
  110989. doNotChangeAspectRatio?: boolean;
  110990. /**
  110991. * Define the default type of the buffers we are creating
  110992. */
  110993. defaultType?: number;
  110994. }
  110995. /**
  110996. * A multi render target, like a render target provides the ability to render to a texture.
  110997. * Unlike the render target, it can render to several draw buffers in one draw.
  110998. * This is specially interesting in deferred rendering or for any effects requiring more than
  110999. * just one color from a single pass.
  111000. */
  111001. export class MultiRenderTarget extends RenderTargetTexture {
  111002. private _internalTextures;
  111003. private _textures;
  111004. private _multiRenderTargetOptions;
  111005. /**
  111006. * Get if draw buffers are currently supported by the used hardware and browser.
  111007. */
  111008. readonly isSupported: boolean;
  111009. /**
  111010. * Get the list of textures generated by the multi render target.
  111011. */
  111012. readonly textures: Texture[];
  111013. /**
  111014. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  111015. */
  111016. readonly depthTexture: Texture;
  111017. /**
  111018. * Set the wrapping mode on U of all the textures we are rendering to.
  111019. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  111020. */
  111021. wrapU: number;
  111022. /**
  111023. * Set the wrapping mode on V of all the textures we are rendering to.
  111024. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  111025. */
  111026. wrapV: number;
  111027. /**
  111028. * Instantiate a new multi render target texture.
  111029. * A multi render target, like a render target provides the ability to render to a texture.
  111030. * Unlike the render target, it can render to several draw buffers in one draw.
  111031. * This is specially interesting in deferred rendering or for any effects requiring more than
  111032. * just one color from a single pass.
  111033. * @param name Define the name of the texture
  111034. * @param size Define the size of the buffers to render to
  111035. * @param count Define the number of target we are rendering into
  111036. * @param scene Define the scene the texture belongs to
  111037. * @param options Define the options used to create the multi render target
  111038. */
  111039. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  111040. /** @hidden */
  111041. _rebuild(): void;
  111042. private _createInternalTextures;
  111043. private _createTextures;
  111044. /**
  111045. * Define the number of samples used if MSAA is enabled.
  111046. */
  111047. samples: number;
  111048. /**
  111049. * Resize all the textures in the multi render target.
  111050. * Be carrefull as it will recreate all the data in the new texture.
  111051. * @param size Define the new size
  111052. */
  111053. resize(size: any): void;
  111054. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  111055. /**
  111056. * Dispose the render targets and their associated resources
  111057. */
  111058. dispose(): void;
  111059. /**
  111060. * Release all the underlying texture used as draw buffers.
  111061. */
  111062. releaseInternalTextures(): void;
  111063. }
  111064. }
  111065. declare module BABYLON {
  111066. interface ThinEngine {
  111067. /**
  111068. * Unbind a list of render target textures from the webGL context
  111069. * This is used only when drawBuffer extension or webGL2 are active
  111070. * @param textures defines the render target textures to unbind
  111071. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  111072. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  111073. */
  111074. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  111075. /**
  111076. * Create a multi render target texture
  111077. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  111078. * @param size defines the size of the texture
  111079. * @param options defines the creation options
  111080. * @returns the cube texture as an InternalTexture
  111081. */
  111082. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  111083. /**
  111084. * Update the sample count for a given multiple render target texture
  111085. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  111086. * @param textures defines the textures to update
  111087. * @param samples defines the sample count to set
  111088. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  111089. */
  111090. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  111091. }
  111092. }
  111093. declare module BABYLON {
  111094. /** @hidden */
  111095. export var rgbdEncodePixelShader: {
  111096. name: string;
  111097. shader: string;
  111098. };
  111099. }
  111100. declare module BABYLON {
  111101. /** @hidden */
  111102. export var rgbdDecodePixelShader: {
  111103. name: string;
  111104. shader: string;
  111105. };
  111106. }
  111107. declare module BABYLON {
  111108. /**
  111109. * Raw texture data and descriptor sufficient for WebGL texture upload
  111110. */
  111111. export interface EnvironmentTextureInfo {
  111112. /**
  111113. * Version of the environment map
  111114. */
  111115. version: number;
  111116. /**
  111117. * Width of image
  111118. */
  111119. width: number;
  111120. /**
  111121. * Irradiance information stored in the file.
  111122. */
  111123. irradiance: any;
  111124. /**
  111125. * Specular information stored in the file.
  111126. */
  111127. specular: any;
  111128. }
  111129. /**
  111130. * Defines One Image in the file. It requires only the position in the file
  111131. * as well as the length.
  111132. */
  111133. interface BufferImageData {
  111134. /**
  111135. * Length of the image data.
  111136. */
  111137. length: number;
  111138. /**
  111139. * Position of the data from the null terminator delimiting the end of the JSON.
  111140. */
  111141. position: number;
  111142. }
  111143. /**
  111144. * Defines the specular data enclosed in the file.
  111145. * This corresponds to the version 1 of the data.
  111146. */
  111147. export interface EnvironmentTextureSpecularInfoV1 {
  111148. /**
  111149. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  111150. */
  111151. specularDataPosition?: number;
  111152. /**
  111153. * This contains all the images data needed to reconstruct the cubemap.
  111154. */
  111155. mipmaps: Array<BufferImageData>;
  111156. /**
  111157. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  111158. */
  111159. lodGenerationScale: number;
  111160. }
  111161. /**
  111162. * Sets of helpers addressing the serialization and deserialization of environment texture
  111163. * stored in a BabylonJS env file.
  111164. * Those files are usually stored as .env files.
  111165. */
  111166. export class EnvironmentTextureTools {
  111167. /**
  111168. * Magic number identifying the env file.
  111169. */
  111170. private static _MagicBytes;
  111171. /**
  111172. * Gets the environment info from an env file.
  111173. * @param data The array buffer containing the .env bytes.
  111174. * @returns the environment file info (the json header) if successfully parsed.
  111175. */
  111176. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  111177. /**
  111178. * Creates an environment texture from a loaded cube texture.
  111179. * @param texture defines the cube texture to convert in env file
  111180. * @return a promise containing the environment data if succesfull.
  111181. */
  111182. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  111183. /**
  111184. * Creates a JSON representation of the spherical data.
  111185. * @param texture defines the texture containing the polynomials
  111186. * @return the JSON representation of the spherical info
  111187. */
  111188. private static _CreateEnvTextureIrradiance;
  111189. /**
  111190. * Creates the ArrayBufferViews used for initializing environment texture image data.
  111191. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  111192. * @param info parameters that determine what views will be created for accessing the underlying buffer
  111193. * @return the views described by info providing access to the underlying buffer
  111194. */
  111195. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  111196. /**
  111197. * Uploads the texture info contained in the env file to the GPU.
  111198. * @param texture defines the internal texture to upload to
  111199. * @param arrayBuffer defines the buffer cotaining the data to load
  111200. * @param info defines the texture info retrieved through the GetEnvInfo method
  111201. * @returns a promise
  111202. */
  111203. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  111204. /**
  111205. * Uploads the levels of image data to the GPU.
  111206. * @param texture defines the internal texture to upload to
  111207. * @param imageData defines the array buffer views of image data [mipmap][face]
  111208. * @returns a promise
  111209. */
  111210. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  111211. /**
  111212. * Uploads spherical polynomials information to the texture.
  111213. * @param texture defines the texture we are trying to upload the information to
  111214. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  111215. */
  111216. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  111217. /** @hidden */
  111218. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  111219. }
  111220. }
  111221. declare module BABYLON {
  111222. /**
  111223. * Contains position and normal vectors for a vertex
  111224. */
  111225. export class PositionNormalVertex {
  111226. /** the position of the vertex (defaut: 0,0,0) */
  111227. position: Vector3;
  111228. /** the normal of the vertex (defaut: 0,1,0) */
  111229. normal: Vector3;
  111230. /**
  111231. * Creates a PositionNormalVertex
  111232. * @param position the position of the vertex (defaut: 0,0,0)
  111233. * @param normal the normal of the vertex (defaut: 0,1,0)
  111234. */
  111235. constructor(
  111236. /** the position of the vertex (defaut: 0,0,0) */
  111237. position?: Vector3,
  111238. /** the normal of the vertex (defaut: 0,1,0) */
  111239. normal?: Vector3);
  111240. /**
  111241. * Clones the PositionNormalVertex
  111242. * @returns the cloned PositionNormalVertex
  111243. */
  111244. clone(): PositionNormalVertex;
  111245. }
  111246. /**
  111247. * Contains position, normal and uv vectors for a vertex
  111248. */
  111249. export class PositionNormalTextureVertex {
  111250. /** the position of the vertex (defaut: 0,0,0) */
  111251. position: Vector3;
  111252. /** the normal of the vertex (defaut: 0,1,0) */
  111253. normal: Vector3;
  111254. /** the uv of the vertex (default: 0,0) */
  111255. uv: Vector2;
  111256. /**
  111257. * Creates a PositionNormalTextureVertex
  111258. * @param position the position of the vertex (defaut: 0,0,0)
  111259. * @param normal the normal of the vertex (defaut: 0,1,0)
  111260. * @param uv the uv of the vertex (default: 0,0)
  111261. */
  111262. constructor(
  111263. /** the position of the vertex (defaut: 0,0,0) */
  111264. position?: Vector3,
  111265. /** the normal of the vertex (defaut: 0,1,0) */
  111266. normal?: Vector3,
  111267. /** the uv of the vertex (default: 0,0) */
  111268. uv?: Vector2);
  111269. /**
  111270. * Clones the PositionNormalTextureVertex
  111271. * @returns the cloned PositionNormalTextureVertex
  111272. */
  111273. clone(): PositionNormalTextureVertex;
  111274. }
  111275. }
  111276. declare module BABYLON {
  111277. /** @hidden */
  111278. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  111279. private _genericAttributeLocation;
  111280. private _varyingLocationCount;
  111281. private _varyingLocationMap;
  111282. private _replacements;
  111283. private _textureCount;
  111284. private _uniforms;
  111285. lineProcessor(line: string): string;
  111286. attributeProcessor(attribute: string): string;
  111287. varyingProcessor(varying: string, isFragment: boolean): string;
  111288. uniformProcessor(uniform: string): string;
  111289. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  111290. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  111291. }
  111292. }
  111293. declare module BABYLON {
  111294. /**
  111295. * Container for accessors for natively-stored mesh data buffers.
  111296. */
  111297. class NativeDataBuffer extends DataBuffer {
  111298. /**
  111299. * Accessor value used to identify/retrieve a natively-stored index buffer.
  111300. */
  111301. nativeIndexBuffer?: any;
  111302. /**
  111303. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  111304. */
  111305. nativeVertexBuffer?: any;
  111306. }
  111307. /** @hidden */
  111308. export class NativeEngine extends Engine {
  111309. private readonly _native;
  111310. getHardwareScalingLevel(): number;
  111311. constructor();
  111312. /**
  111313. * Can be used to override the current requestAnimationFrame requester.
  111314. * @hidden
  111315. */
  111316. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  111317. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  111318. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  111319. createVertexBuffer(data: DataArray): NativeDataBuffer;
  111320. recordVertexArrayObject(vertexBuffers: {
  111321. [key: string]: VertexBuffer;
  111322. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  111323. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  111324. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  111325. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  111326. /**
  111327. * Draw a list of indexed primitives
  111328. * @param fillMode defines the primitive to use
  111329. * @param indexStart defines the starting index
  111330. * @param indexCount defines the number of index to draw
  111331. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  111332. */
  111333. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  111334. /**
  111335. * Draw a list of unindexed primitives
  111336. * @param fillMode defines the primitive to use
  111337. * @param verticesStart defines the index of first vertex to draw
  111338. * @param verticesCount defines the count of vertices to draw
  111339. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  111340. */
  111341. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  111342. createPipelineContext(): IPipelineContext;
  111343. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  111344. /** @hidden */
  111345. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  111346. /** @hidden */
  111347. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  111348. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  111349. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  111350. protected _setProgram(program: WebGLProgram): void;
  111351. _releaseEffect(effect: Effect): void;
  111352. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  111353. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  111354. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  111355. bindSamplers(effect: Effect): void;
  111356. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  111357. getRenderWidth(useScreen?: boolean): number;
  111358. getRenderHeight(useScreen?: boolean): number;
  111359. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  111360. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  111361. /**
  111362. * Set the z offset to apply to current rendering
  111363. * @param value defines the offset to apply
  111364. */
  111365. setZOffset(value: number): void;
  111366. /**
  111367. * Gets the current value of the zOffset
  111368. * @returns the current zOffset state
  111369. */
  111370. getZOffset(): number;
  111371. /**
  111372. * Enable or disable depth buffering
  111373. * @param enable defines the state to set
  111374. */
  111375. setDepthBuffer(enable: boolean): void;
  111376. /**
  111377. * Gets a boolean indicating if depth writing is enabled
  111378. * @returns the current depth writing state
  111379. */
  111380. getDepthWrite(): boolean;
  111381. /**
  111382. * Enable or disable depth writing
  111383. * @param enable defines the state to set
  111384. */
  111385. setDepthWrite(enable: boolean): void;
  111386. /**
  111387. * Enable or disable color writing
  111388. * @param enable defines the state to set
  111389. */
  111390. setColorWrite(enable: boolean): void;
  111391. /**
  111392. * Gets a boolean indicating if color writing is enabled
  111393. * @returns the current color writing state
  111394. */
  111395. getColorWrite(): boolean;
  111396. /**
  111397. * Sets alpha constants used by some alpha blending modes
  111398. * @param r defines the red component
  111399. * @param g defines the green component
  111400. * @param b defines the blue component
  111401. * @param a defines the alpha component
  111402. */
  111403. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  111404. /**
  111405. * Sets the current alpha mode
  111406. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  111407. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  111408. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  111409. */
  111410. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  111411. /**
  111412. * Gets the current alpha mode
  111413. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  111414. * @returns the current alpha mode
  111415. */
  111416. getAlphaMode(): number;
  111417. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  111418. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  111419. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  111420. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  111421. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  111422. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  111423. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  111424. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  111425. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  111426. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  111427. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  111428. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  111429. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  111430. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  111431. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  111432. setFloat(uniform: WebGLUniformLocation, value: number): void;
  111433. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  111434. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  111435. setBool(uniform: WebGLUniformLocation, bool: number): void;
  111436. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  111437. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  111438. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  111439. wipeCaches(bruteForce?: boolean): void;
  111440. _createTexture(): WebGLTexture;
  111441. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  111442. /**
  111443. * Usually called from BABYLON.Texture.ts.
  111444. * Passed information to create a WebGLTexture
  111445. * @param urlArg defines a value which contains one of the following:
  111446. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  111447. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  111448. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  111449. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  111450. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  111451. * @param scene needed for loading to the correct scene
  111452. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  111453. * @param onLoad optional callback to be called upon successful completion
  111454. * @param onError optional callback to be called upon failure
  111455. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  111456. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  111457. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  111458. * @param forcedExtension defines the extension to use to pick the right loader
  111459. * @returns a InternalTexture for assignment back into BABYLON.Texture
  111460. */
  111461. 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;
  111462. /**
  111463. * Creates a cube texture
  111464. * @param rootUrl defines the url where the files to load is located
  111465. * @param scene defines the current scene
  111466. * @param files defines the list of files to load (1 per face)
  111467. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  111468. * @param onLoad defines an optional callback raised when the texture is loaded
  111469. * @param onError defines an optional callback raised if there is an issue to load the texture
  111470. * @param format defines the format of the data
  111471. * @param forcedExtension defines the extension to use to pick the right loader
  111472. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  111473. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  111474. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  111475. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  111476. * @returns the cube texture as an InternalTexture
  111477. */
  111478. 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;
  111479. private _getSamplingFilter;
  111480. private static _GetNativeTextureFormat;
  111481. createRenderTargetTexture(size: number | {
  111482. width: number;
  111483. height: number;
  111484. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  111485. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  111486. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  111487. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  111488. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  111489. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  111490. /**
  111491. * Updates a dynamic vertex buffer.
  111492. * @param vertexBuffer the vertex buffer to update
  111493. * @param data the data used to update the vertex buffer
  111494. * @param byteOffset the byte offset of the data (optional)
  111495. * @param byteLength the byte length of the data (optional)
  111496. */
  111497. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  111498. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  111499. private _updateAnisotropicLevel;
  111500. private _getAddressMode;
  111501. /** @hidden */
  111502. _bindTexture(channel: number, texture: InternalTexture): void;
  111503. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  111504. releaseEffects(): void;
  111505. /** @hidden */
  111506. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  111507. /** @hidden */
  111508. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  111509. /** @hidden */
  111510. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  111511. /** @hidden */
  111512. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  111513. }
  111514. }
  111515. declare module BABYLON {
  111516. /**
  111517. * Gather the list of clipboard event types as constants.
  111518. */
  111519. export class ClipboardEventTypes {
  111520. /**
  111521. * The clipboard event is fired when a copy command is active (pressed).
  111522. */
  111523. static readonly COPY: number;
  111524. /**
  111525. * The clipboard event is fired when a cut command is active (pressed).
  111526. */
  111527. static readonly CUT: number;
  111528. /**
  111529. * The clipboard event is fired when a paste command is active (pressed).
  111530. */
  111531. static readonly PASTE: number;
  111532. }
  111533. /**
  111534. * This class is used to store clipboard related info for the onClipboardObservable event.
  111535. */
  111536. export class ClipboardInfo {
  111537. /**
  111538. * Defines the type of event (BABYLON.ClipboardEventTypes)
  111539. */
  111540. type: number;
  111541. /**
  111542. * Defines the related dom event
  111543. */
  111544. event: ClipboardEvent;
  111545. /**
  111546. *Creates an instance of ClipboardInfo.
  111547. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  111548. * @param event Defines the related dom event
  111549. */
  111550. constructor(
  111551. /**
  111552. * Defines the type of event (BABYLON.ClipboardEventTypes)
  111553. */
  111554. type: number,
  111555. /**
  111556. * Defines the related dom event
  111557. */
  111558. event: ClipboardEvent);
  111559. /**
  111560. * Get the clipboard event's type from the keycode.
  111561. * @param keyCode Defines the keyCode for the current keyboard event.
  111562. * @return {number}
  111563. */
  111564. static GetTypeFromCharacter(keyCode: number): number;
  111565. }
  111566. }
  111567. declare module BABYLON {
  111568. /**
  111569. * Google Daydream controller
  111570. */
  111571. export class DaydreamController extends WebVRController {
  111572. /**
  111573. * Base Url for the controller model.
  111574. */
  111575. static MODEL_BASE_URL: string;
  111576. /**
  111577. * File name for the controller model.
  111578. */
  111579. static MODEL_FILENAME: string;
  111580. /**
  111581. * Gamepad Id prefix used to identify Daydream Controller.
  111582. */
  111583. static readonly GAMEPAD_ID_PREFIX: string;
  111584. /**
  111585. * Creates a new DaydreamController from a gamepad
  111586. * @param vrGamepad the gamepad that the controller should be created from
  111587. */
  111588. constructor(vrGamepad: any);
  111589. /**
  111590. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  111591. * @param scene scene in which to add meshes
  111592. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  111593. */
  111594. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  111595. /**
  111596. * Called once for each button that changed state since the last frame
  111597. * @param buttonIdx Which button index changed
  111598. * @param state New state of the button
  111599. * @param changes Which properties on the state changed since last frame
  111600. */
  111601. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  111602. }
  111603. }
  111604. declare module BABYLON {
  111605. /**
  111606. * Gear VR Controller
  111607. */
  111608. export class GearVRController extends WebVRController {
  111609. /**
  111610. * Base Url for the controller model.
  111611. */
  111612. static MODEL_BASE_URL: string;
  111613. /**
  111614. * File name for the controller model.
  111615. */
  111616. static MODEL_FILENAME: string;
  111617. /**
  111618. * Gamepad Id prefix used to identify this controller.
  111619. */
  111620. static readonly GAMEPAD_ID_PREFIX: string;
  111621. private readonly _buttonIndexToObservableNameMap;
  111622. /**
  111623. * Creates a new GearVRController from a gamepad
  111624. * @param vrGamepad the gamepad that the controller should be created from
  111625. */
  111626. constructor(vrGamepad: any);
  111627. /**
  111628. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  111629. * @param scene scene in which to add meshes
  111630. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  111631. */
  111632. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  111633. /**
  111634. * Called once for each button that changed state since the last frame
  111635. * @param buttonIdx Which button index changed
  111636. * @param state New state of the button
  111637. * @param changes Which properties on the state changed since last frame
  111638. */
  111639. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  111640. }
  111641. }
  111642. declare module BABYLON {
  111643. /**
  111644. * Class containing static functions to help procedurally build meshes
  111645. */
  111646. export class PolyhedronBuilder {
  111647. /**
  111648. * Creates a polyhedron mesh
  111649. * * 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
  111650. * * The parameter `size` (positive float, default 1) sets the polygon size
  111651. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  111652. * * 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`
  111653. * * 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
  111654. * * 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)`)
  111655. * * 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
  111656. * * 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
  111657. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  111658. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  111659. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  111660. * @param name defines the name of the mesh
  111661. * @param options defines the options used to create the mesh
  111662. * @param scene defines the hosting scene
  111663. * @returns the polyhedron mesh
  111664. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  111665. */
  111666. static CreatePolyhedron(name: string, options: {
  111667. type?: number;
  111668. size?: number;
  111669. sizeX?: number;
  111670. sizeY?: number;
  111671. sizeZ?: number;
  111672. custom?: any;
  111673. faceUV?: Vector4[];
  111674. faceColors?: Color4[];
  111675. flat?: boolean;
  111676. updatable?: boolean;
  111677. sideOrientation?: number;
  111678. frontUVs?: Vector4;
  111679. backUVs?: Vector4;
  111680. }, scene?: Nullable<Scene>): Mesh;
  111681. }
  111682. }
  111683. declare module BABYLON {
  111684. /**
  111685. * Gizmo that enables scaling a mesh along 3 axis
  111686. */
  111687. export class ScaleGizmo extends Gizmo {
  111688. /**
  111689. * Internal gizmo used for interactions on the x axis
  111690. */
  111691. xGizmo: AxisScaleGizmo;
  111692. /**
  111693. * Internal gizmo used for interactions on the y axis
  111694. */
  111695. yGizmo: AxisScaleGizmo;
  111696. /**
  111697. * Internal gizmo used for interactions on the z axis
  111698. */
  111699. zGizmo: AxisScaleGizmo;
  111700. /**
  111701. * Internal gizmo used to scale all axis equally
  111702. */
  111703. uniformScaleGizmo: AxisScaleGizmo;
  111704. private _meshAttached;
  111705. private _updateGizmoRotationToMatchAttachedMesh;
  111706. private _snapDistance;
  111707. private _scaleRatio;
  111708. private _uniformScalingMesh;
  111709. private _octahedron;
  111710. /** Fires an event when any of it's sub gizmos are dragged */
  111711. onDragStartObservable: Observable<unknown>;
  111712. /** Fires an event when any of it's sub gizmos are released from dragging */
  111713. onDragEndObservable: Observable<unknown>;
  111714. attachedMesh: Nullable<AbstractMesh>;
  111715. /**
  111716. * Creates a ScaleGizmo
  111717. * @param gizmoLayer The utility layer the gizmo will be added to
  111718. */
  111719. constructor(gizmoLayer?: UtilityLayerRenderer);
  111720. updateGizmoRotationToMatchAttachedMesh: boolean;
  111721. /**
  111722. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  111723. */
  111724. snapDistance: number;
  111725. /**
  111726. * Ratio for the scale of the gizmo (Default: 1)
  111727. */
  111728. scaleRatio: number;
  111729. /**
  111730. * Disposes of the gizmo
  111731. */
  111732. dispose(): void;
  111733. }
  111734. }
  111735. declare module BABYLON {
  111736. /**
  111737. * Single axis scale gizmo
  111738. */
  111739. export class AxisScaleGizmo extends Gizmo {
  111740. /**
  111741. * Drag behavior responsible for the gizmos dragging interactions
  111742. */
  111743. dragBehavior: PointerDragBehavior;
  111744. private _pointerObserver;
  111745. /**
  111746. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  111747. */
  111748. snapDistance: number;
  111749. /**
  111750. * Event that fires each time the gizmo snaps to a new location.
  111751. * * snapDistance is the the change in distance
  111752. */
  111753. onSnapObservable: Observable<{
  111754. snapDistance: number;
  111755. }>;
  111756. /**
  111757. * If the scaling operation should be done on all axis (default: false)
  111758. */
  111759. uniformScaling: boolean;
  111760. private _isEnabled;
  111761. private _parent;
  111762. private _arrow;
  111763. private _coloredMaterial;
  111764. private _hoverMaterial;
  111765. /**
  111766. * Creates an AxisScaleGizmo
  111767. * @param gizmoLayer The utility layer the gizmo will be added to
  111768. * @param dragAxis The axis which the gizmo will be able to scale on
  111769. * @param color The color of the gizmo
  111770. */
  111771. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  111772. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  111773. /**
  111774. * If the gizmo is enabled
  111775. */
  111776. isEnabled: boolean;
  111777. /**
  111778. * Disposes of the gizmo
  111779. */
  111780. dispose(): void;
  111781. /**
  111782. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  111783. * @param mesh The mesh to replace the default mesh of the gizmo
  111784. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  111785. */
  111786. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  111787. }
  111788. }
  111789. declare module BABYLON {
  111790. /**
  111791. * Bounding box gizmo
  111792. */
  111793. export class BoundingBoxGizmo extends Gizmo {
  111794. private _lineBoundingBox;
  111795. private _rotateSpheresParent;
  111796. private _scaleBoxesParent;
  111797. private _boundingDimensions;
  111798. private _renderObserver;
  111799. private _pointerObserver;
  111800. private _scaleDragSpeed;
  111801. private _tmpQuaternion;
  111802. private _tmpVector;
  111803. private _tmpRotationMatrix;
  111804. /**
  111805. * 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)
  111806. */
  111807. ignoreChildren: boolean;
  111808. /**
  111809. * 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)
  111810. */
  111811. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  111812. /**
  111813. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  111814. */
  111815. rotationSphereSize: number;
  111816. /**
  111817. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  111818. */
  111819. scaleBoxSize: number;
  111820. /**
  111821. * 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)
  111822. */
  111823. fixedDragMeshScreenSize: boolean;
  111824. /**
  111825. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  111826. */
  111827. fixedDragMeshScreenSizeDistanceFactor: number;
  111828. /**
  111829. * Fired when a rotation sphere or scale box is dragged
  111830. */
  111831. onDragStartObservable: Observable<{}>;
  111832. /**
  111833. * Fired when a scale box is dragged
  111834. */
  111835. onScaleBoxDragObservable: Observable<{}>;
  111836. /**
  111837. * Fired when a scale box drag is ended
  111838. */
  111839. onScaleBoxDragEndObservable: Observable<{}>;
  111840. /**
  111841. * Fired when a rotation sphere is dragged
  111842. */
  111843. onRotationSphereDragObservable: Observable<{}>;
  111844. /**
  111845. * Fired when a rotation sphere drag is ended
  111846. */
  111847. onRotationSphereDragEndObservable: Observable<{}>;
  111848. /**
  111849. * 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)
  111850. */
  111851. scalePivot: Nullable<Vector3>;
  111852. /**
  111853. * Mesh used as a pivot to rotate the attached mesh
  111854. */
  111855. private _anchorMesh;
  111856. private _existingMeshScale;
  111857. private _dragMesh;
  111858. private pointerDragBehavior;
  111859. private coloredMaterial;
  111860. private hoverColoredMaterial;
  111861. /**
  111862. * Sets the color of the bounding box gizmo
  111863. * @param color the color to set
  111864. */
  111865. setColor(color: Color3): void;
  111866. /**
  111867. * Creates an BoundingBoxGizmo
  111868. * @param gizmoLayer The utility layer the gizmo will be added to
  111869. * @param color The color of the gizmo
  111870. */
  111871. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  111872. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  111873. private _selectNode;
  111874. /**
  111875. * Updates the bounding box information for the Gizmo
  111876. */
  111877. updateBoundingBox(): void;
  111878. private _updateRotationSpheres;
  111879. private _updateScaleBoxes;
  111880. /**
  111881. * Enables rotation on the specified axis and disables rotation on the others
  111882. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  111883. */
  111884. setEnabledRotationAxis(axis: string): void;
  111885. /**
  111886. * Enables/disables scaling
  111887. * @param enable if scaling should be enabled
  111888. */
  111889. setEnabledScaling(enable: boolean): void;
  111890. private _updateDummy;
  111891. /**
  111892. * Enables a pointer drag behavior on the bounding box of the gizmo
  111893. */
  111894. enableDragBehavior(): void;
  111895. /**
  111896. * Disposes of the gizmo
  111897. */
  111898. dispose(): void;
  111899. /**
  111900. * 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)
  111901. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  111902. * @returns the bounding box mesh with the passed in mesh as a child
  111903. */
  111904. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  111905. /**
  111906. * CustomMeshes are not supported by this gizmo
  111907. * @param mesh The mesh to replace the default mesh of the gizmo
  111908. */
  111909. setCustomMesh(mesh: Mesh): void;
  111910. }
  111911. }
  111912. declare module BABYLON {
  111913. /**
  111914. * Single plane rotation gizmo
  111915. */
  111916. export class PlaneRotationGizmo extends Gizmo {
  111917. /**
  111918. * Drag behavior responsible for the gizmos dragging interactions
  111919. */
  111920. dragBehavior: PointerDragBehavior;
  111921. private _pointerObserver;
  111922. /**
  111923. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  111924. */
  111925. snapDistance: number;
  111926. /**
  111927. * Event that fires each time the gizmo snaps to a new location.
  111928. * * snapDistance is the the change in distance
  111929. */
  111930. onSnapObservable: Observable<{
  111931. snapDistance: number;
  111932. }>;
  111933. private _isEnabled;
  111934. private _parent;
  111935. /**
  111936. * Creates a PlaneRotationGizmo
  111937. * @param gizmoLayer The utility layer the gizmo will be added to
  111938. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  111939. * @param color The color of the gizmo
  111940. * @param tessellation Amount of tessellation to be used when creating rotation circles
  111941. * @param useEulerRotation Use and update Euler angle instead of quaternion
  111942. */
  111943. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  111944. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  111945. /**
  111946. * If the gizmo is enabled
  111947. */
  111948. isEnabled: boolean;
  111949. /**
  111950. * Disposes of the gizmo
  111951. */
  111952. dispose(): void;
  111953. }
  111954. }
  111955. declare module BABYLON {
  111956. /**
  111957. * Gizmo that enables rotating a mesh along 3 axis
  111958. */
  111959. export class RotationGizmo extends Gizmo {
  111960. /**
  111961. * Internal gizmo used for interactions on the x axis
  111962. */
  111963. xGizmo: PlaneRotationGizmo;
  111964. /**
  111965. * Internal gizmo used for interactions on the y axis
  111966. */
  111967. yGizmo: PlaneRotationGizmo;
  111968. /**
  111969. * Internal gizmo used for interactions on the z axis
  111970. */
  111971. zGizmo: PlaneRotationGizmo;
  111972. /** Fires an event when any of it's sub gizmos are dragged */
  111973. onDragStartObservable: Observable<unknown>;
  111974. /** Fires an event when any of it's sub gizmos are released from dragging */
  111975. onDragEndObservable: Observable<unknown>;
  111976. private _meshAttached;
  111977. attachedMesh: Nullable<AbstractMesh>;
  111978. /**
  111979. * Creates a RotationGizmo
  111980. * @param gizmoLayer The utility layer the gizmo will be added to
  111981. * @param tessellation Amount of tessellation to be used when creating rotation circles
  111982. * @param useEulerRotation Use and update Euler angle instead of quaternion
  111983. */
  111984. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  111985. updateGizmoRotationToMatchAttachedMesh: boolean;
  111986. /**
  111987. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  111988. */
  111989. snapDistance: number;
  111990. /**
  111991. * Ratio for the scale of the gizmo (Default: 1)
  111992. */
  111993. scaleRatio: number;
  111994. /**
  111995. * Disposes of the gizmo
  111996. */
  111997. dispose(): void;
  111998. /**
  111999. * CustomMeshes are not supported by this gizmo
  112000. * @param mesh The mesh to replace the default mesh of the gizmo
  112001. */
  112002. setCustomMesh(mesh: Mesh): void;
  112003. }
  112004. }
  112005. declare module BABYLON {
  112006. /**
  112007. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  112008. */
  112009. export class GizmoManager implements IDisposable {
  112010. private scene;
  112011. /**
  112012. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  112013. */
  112014. gizmos: {
  112015. positionGizmo: Nullable<PositionGizmo>;
  112016. rotationGizmo: Nullable<RotationGizmo>;
  112017. scaleGizmo: Nullable<ScaleGizmo>;
  112018. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  112019. };
  112020. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  112021. clearGizmoOnEmptyPointerEvent: boolean;
  112022. /** Fires an event when the manager is attached to a mesh */
  112023. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  112024. private _gizmosEnabled;
  112025. private _pointerObserver;
  112026. private _attachedMesh;
  112027. private _boundingBoxColor;
  112028. private _defaultUtilityLayer;
  112029. private _defaultKeepDepthUtilityLayer;
  112030. /**
  112031. * When bounding box gizmo is enabled, this can be used to track drag/end events
  112032. */
  112033. boundingBoxDragBehavior: SixDofDragBehavior;
  112034. /**
  112035. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  112036. */
  112037. attachableMeshes: Nullable<Array<AbstractMesh>>;
  112038. /**
  112039. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  112040. */
  112041. usePointerToAttachGizmos: boolean;
  112042. /**
  112043. * Utility layer that the bounding box gizmo belongs to
  112044. */
  112045. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  112046. /**
  112047. * Utility layer that all gizmos besides bounding box belong to
  112048. */
  112049. readonly utilityLayer: UtilityLayerRenderer;
  112050. /**
  112051. * Instatiates a gizmo manager
  112052. * @param scene the scene to overlay the gizmos on top of
  112053. */
  112054. constructor(scene: Scene);
  112055. /**
  112056. * Attaches a set of gizmos to the specified mesh
  112057. * @param mesh The mesh the gizmo's should be attached to
  112058. */
  112059. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  112060. /**
  112061. * If the position gizmo is enabled
  112062. */
  112063. positionGizmoEnabled: boolean;
  112064. /**
  112065. * If the rotation gizmo is enabled
  112066. */
  112067. rotationGizmoEnabled: boolean;
  112068. /**
  112069. * If the scale gizmo is enabled
  112070. */
  112071. scaleGizmoEnabled: boolean;
  112072. /**
  112073. * If the boundingBox gizmo is enabled
  112074. */
  112075. boundingBoxGizmoEnabled: boolean;
  112076. /**
  112077. * Disposes of the gizmo manager
  112078. */
  112079. dispose(): void;
  112080. }
  112081. }
  112082. declare module BABYLON {
  112083. /**
  112084. * A directional light is defined by a direction (what a surprise!).
  112085. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  112086. * 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.
  112087. * Documentation: https://doc.babylonjs.com/babylon101/lights
  112088. */
  112089. export class DirectionalLight extends ShadowLight {
  112090. private _shadowFrustumSize;
  112091. /**
  112092. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  112093. */
  112094. /**
  112095. * Specifies a fix frustum size for the shadow generation.
  112096. */
  112097. shadowFrustumSize: number;
  112098. private _shadowOrthoScale;
  112099. /**
  112100. * Gets the shadow projection scale against the optimal computed one.
  112101. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  112102. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  112103. */
  112104. /**
  112105. * Sets the shadow projection scale against the optimal computed one.
  112106. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  112107. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  112108. */
  112109. shadowOrthoScale: number;
  112110. /**
  112111. * Automatically compute the projection matrix to best fit (including all the casters)
  112112. * on each frame.
  112113. */
  112114. autoUpdateExtends: boolean;
  112115. private _orthoLeft;
  112116. private _orthoRight;
  112117. private _orthoTop;
  112118. private _orthoBottom;
  112119. /**
  112120. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  112121. * The directional light is emitted from everywhere in the given direction.
  112122. * It can cast shadows.
  112123. * Documentation : https://doc.babylonjs.com/babylon101/lights
  112124. * @param name The friendly name of the light
  112125. * @param direction The direction of the light
  112126. * @param scene The scene the light belongs to
  112127. */
  112128. constructor(name: string, direction: Vector3, scene: Scene);
  112129. /**
  112130. * Returns the string "DirectionalLight".
  112131. * @return The class name
  112132. */
  112133. getClassName(): string;
  112134. /**
  112135. * Returns the integer 1.
  112136. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  112137. */
  112138. getTypeID(): number;
  112139. /**
  112140. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  112141. * Returns the DirectionalLight Shadow projection matrix.
  112142. */
  112143. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  112144. /**
  112145. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  112146. * Returns the DirectionalLight Shadow projection matrix.
  112147. */
  112148. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  112149. /**
  112150. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  112151. * Returns the DirectionalLight Shadow projection matrix.
  112152. */
  112153. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  112154. protected _buildUniformLayout(): void;
  112155. /**
  112156. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  112157. * @param effect The effect to update
  112158. * @param lightIndex The index of the light in the effect to update
  112159. * @returns The directional light
  112160. */
  112161. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  112162. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  112163. /**
  112164. * Gets the minZ used for shadow according to both the scene and the light.
  112165. *
  112166. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  112167. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  112168. * @param activeCamera The camera we are returning the min for
  112169. * @returns the depth min z
  112170. */
  112171. getDepthMinZ(activeCamera: Camera): number;
  112172. /**
  112173. * Gets the maxZ used for shadow according to both the scene and the light.
  112174. *
  112175. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  112176. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  112177. * @param activeCamera The camera we are returning the max for
  112178. * @returns the depth max z
  112179. */
  112180. getDepthMaxZ(activeCamera: Camera): number;
  112181. /**
  112182. * Prepares the list of defines specific to the light type.
  112183. * @param defines the list of defines
  112184. * @param lightIndex defines the index of the light for the effect
  112185. */
  112186. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  112187. }
  112188. }
  112189. declare module BABYLON {
  112190. /**
  112191. * Class containing static functions to help procedurally build meshes
  112192. */
  112193. export class HemisphereBuilder {
  112194. /**
  112195. * Creates a hemisphere mesh
  112196. * @param name defines the name of the mesh
  112197. * @param options defines the options used to create the mesh
  112198. * @param scene defines the hosting scene
  112199. * @returns the hemisphere mesh
  112200. */
  112201. static CreateHemisphere(name: string, options: {
  112202. segments?: number;
  112203. diameter?: number;
  112204. sideOrientation?: number;
  112205. }, scene: any): Mesh;
  112206. }
  112207. }
  112208. declare module BABYLON {
  112209. /**
  112210. * A spot light is defined by a position, a direction, an angle, and an exponent.
  112211. * These values define a cone of light starting from the position, emitting toward the direction.
  112212. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  112213. * and the exponent defines the speed of the decay of the light with distance (reach).
  112214. * Documentation: https://doc.babylonjs.com/babylon101/lights
  112215. */
  112216. export class SpotLight extends ShadowLight {
  112217. private _angle;
  112218. private _innerAngle;
  112219. private _cosHalfAngle;
  112220. private _lightAngleScale;
  112221. private _lightAngleOffset;
  112222. /**
  112223. * Gets the cone angle of the spot light in Radians.
  112224. */
  112225. /**
  112226. * Sets the cone angle of the spot light in Radians.
  112227. */
  112228. angle: number;
  112229. /**
  112230. * Only used in gltf falloff mode, this defines the angle where
  112231. * the directional falloff will start before cutting at angle which could be seen
  112232. * as outer angle.
  112233. */
  112234. /**
  112235. * Only used in gltf falloff mode, this defines the angle where
  112236. * the directional falloff will start before cutting at angle which could be seen
  112237. * as outer angle.
  112238. */
  112239. innerAngle: number;
  112240. private _shadowAngleScale;
  112241. /**
  112242. * Allows scaling the angle of the light for shadow generation only.
  112243. */
  112244. /**
  112245. * Allows scaling the angle of the light for shadow generation only.
  112246. */
  112247. shadowAngleScale: number;
  112248. /**
  112249. * The light decay speed with the distance from the emission spot.
  112250. */
  112251. exponent: number;
  112252. private _projectionTextureMatrix;
  112253. /**
  112254. * Allows reading the projecton texture
  112255. */
  112256. readonly projectionTextureMatrix: Matrix;
  112257. protected _projectionTextureLightNear: number;
  112258. /**
  112259. * Gets the near clip of the Spotlight for texture projection.
  112260. */
  112261. /**
  112262. * Sets the near clip of the Spotlight for texture projection.
  112263. */
  112264. projectionTextureLightNear: number;
  112265. protected _projectionTextureLightFar: number;
  112266. /**
  112267. * Gets the far clip of the Spotlight for texture projection.
  112268. */
  112269. /**
  112270. * Sets the far clip of the Spotlight for texture projection.
  112271. */
  112272. projectionTextureLightFar: number;
  112273. protected _projectionTextureUpDirection: Vector3;
  112274. /**
  112275. * Gets the Up vector of the Spotlight for texture projection.
  112276. */
  112277. /**
  112278. * Sets the Up vector of the Spotlight for texture projection.
  112279. */
  112280. projectionTextureUpDirection: Vector3;
  112281. private _projectionTexture;
  112282. /**
  112283. * Gets the projection texture of the light.
  112284. */
  112285. /**
  112286. * Sets the projection texture of the light.
  112287. */
  112288. projectionTexture: Nullable<BaseTexture>;
  112289. private _projectionTextureViewLightDirty;
  112290. private _projectionTextureProjectionLightDirty;
  112291. private _projectionTextureDirty;
  112292. private _projectionTextureViewTargetVector;
  112293. private _projectionTextureViewLightMatrix;
  112294. private _projectionTextureProjectionLightMatrix;
  112295. private _projectionTextureScalingMatrix;
  112296. /**
  112297. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  112298. * It can cast shadows.
  112299. * Documentation : https://doc.babylonjs.com/babylon101/lights
  112300. * @param name The light friendly name
  112301. * @param position The position of the spot light in the scene
  112302. * @param direction The direction of the light in the scene
  112303. * @param angle The cone angle of the light in Radians
  112304. * @param exponent The light decay speed with the distance from the emission spot
  112305. * @param scene The scene the lights belongs to
  112306. */
  112307. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  112308. /**
  112309. * Returns the string "SpotLight".
  112310. * @returns the class name
  112311. */
  112312. getClassName(): string;
  112313. /**
  112314. * Returns the integer 2.
  112315. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  112316. */
  112317. getTypeID(): number;
  112318. /**
  112319. * Overrides the direction setter to recompute the projection texture view light Matrix.
  112320. */
  112321. protected _setDirection(value: Vector3): void;
  112322. /**
  112323. * Overrides the position setter to recompute the projection texture view light Matrix.
  112324. */
  112325. protected _setPosition(value: Vector3): void;
  112326. /**
  112327. * 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.
  112328. * Returns the SpotLight.
  112329. */
  112330. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  112331. protected _computeProjectionTextureViewLightMatrix(): void;
  112332. protected _computeProjectionTextureProjectionLightMatrix(): void;
  112333. /**
  112334. * Main function for light texture projection matrix computing.
  112335. */
  112336. protected _computeProjectionTextureMatrix(): void;
  112337. protected _buildUniformLayout(): void;
  112338. private _computeAngleValues;
  112339. /**
  112340. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  112341. * @param effect The effect to update
  112342. * @param lightIndex The index of the light in the effect to update
  112343. * @returns The spot light
  112344. */
  112345. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  112346. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  112347. /**
  112348. * Disposes the light and the associated resources.
  112349. */
  112350. dispose(): void;
  112351. /**
  112352. * Prepares the list of defines specific to the light type.
  112353. * @param defines the list of defines
  112354. * @param lightIndex defines the index of the light for the effect
  112355. */
  112356. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  112357. }
  112358. }
  112359. declare module BABYLON {
  112360. /**
  112361. * Gizmo that enables viewing a light
  112362. */
  112363. export class LightGizmo extends Gizmo {
  112364. private _lightMesh;
  112365. private _material;
  112366. private cachedPosition;
  112367. private cachedForward;
  112368. /**
  112369. * Creates a LightGizmo
  112370. * @param gizmoLayer The utility layer the gizmo will be added to
  112371. */
  112372. constructor(gizmoLayer?: UtilityLayerRenderer);
  112373. private _light;
  112374. /**
  112375. * The light that the gizmo is attached to
  112376. */
  112377. light: Nullable<Light>;
  112378. /**
  112379. * Gets the material used to render the light gizmo
  112380. */
  112381. readonly material: StandardMaterial;
  112382. /**
  112383. * @hidden
  112384. * Updates the gizmo to match the attached mesh's position/rotation
  112385. */
  112386. protected _update(): void;
  112387. private static _Scale;
  112388. /**
  112389. * Creates the lines for a light mesh
  112390. */
  112391. private static _createLightLines;
  112392. /**
  112393. * Disposes of the light gizmo
  112394. */
  112395. dispose(): void;
  112396. private static _CreateHemisphericLightMesh;
  112397. private static _CreatePointLightMesh;
  112398. private static _CreateSpotLightMesh;
  112399. private static _CreateDirectionalLightMesh;
  112400. }
  112401. }
  112402. declare module BABYLON {
  112403. /** @hidden */
  112404. export var backgroundFragmentDeclaration: {
  112405. name: string;
  112406. shader: string;
  112407. };
  112408. }
  112409. declare module BABYLON {
  112410. /** @hidden */
  112411. export var backgroundUboDeclaration: {
  112412. name: string;
  112413. shader: string;
  112414. };
  112415. }
  112416. declare module BABYLON {
  112417. /** @hidden */
  112418. export var backgroundPixelShader: {
  112419. name: string;
  112420. shader: string;
  112421. };
  112422. }
  112423. declare module BABYLON {
  112424. /** @hidden */
  112425. export var backgroundVertexDeclaration: {
  112426. name: string;
  112427. shader: string;
  112428. };
  112429. }
  112430. declare module BABYLON {
  112431. /** @hidden */
  112432. export var backgroundVertexShader: {
  112433. name: string;
  112434. shader: string;
  112435. };
  112436. }
  112437. declare module BABYLON {
  112438. /**
  112439. * Background material used to create an efficient environement around your scene.
  112440. */
  112441. export class BackgroundMaterial extends PushMaterial {
  112442. /**
  112443. * Standard reflectance value at parallel view angle.
  112444. */
  112445. static StandardReflectance0: number;
  112446. /**
  112447. * Standard reflectance value at grazing angle.
  112448. */
  112449. static StandardReflectance90: number;
  112450. protected _primaryColor: Color3;
  112451. /**
  112452. * Key light Color (multiply against the environement texture)
  112453. */
  112454. primaryColor: Color3;
  112455. protected __perceptualColor: Nullable<Color3>;
  112456. /**
  112457. * Experimental Internal Use Only.
  112458. *
  112459. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  112460. * This acts as a helper to set the primary color to a more "human friendly" value.
  112461. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  112462. * output color as close as possible from the chosen value.
  112463. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  112464. * part of lighting setup.)
  112465. */
  112466. _perceptualColor: Nullable<Color3>;
  112467. protected _primaryColorShadowLevel: float;
  112468. /**
  112469. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  112470. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  112471. */
  112472. primaryColorShadowLevel: float;
  112473. protected _primaryColorHighlightLevel: float;
  112474. /**
  112475. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  112476. * The primary color is used at the level chosen to define what the white area would look.
  112477. */
  112478. primaryColorHighlightLevel: float;
  112479. protected _reflectionTexture: Nullable<BaseTexture>;
  112480. /**
  112481. * Reflection Texture used in the material.
  112482. * Should be author in a specific way for the best result (refer to the documentation).
  112483. */
  112484. reflectionTexture: Nullable<BaseTexture>;
  112485. protected _reflectionBlur: float;
  112486. /**
  112487. * Reflection Texture level of blur.
  112488. *
  112489. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  112490. * texture twice.
  112491. */
  112492. reflectionBlur: float;
  112493. protected _diffuseTexture: Nullable<BaseTexture>;
  112494. /**
  112495. * Diffuse Texture used in the material.
  112496. * Should be author in a specific way for the best result (refer to the documentation).
  112497. */
  112498. diffuseTexture: Nullable<BaseTexture>;
  112499. protected _shadowLights: Nullable<IShadowLight[]>;
  112500. /**
  112501. * Specify the list of lights casting shadow on the material.
  112502. * All scene shadow lights will be included if null.
  112503. */
  112504. shadowLights: Nullable<IShadowLight[]>;
  112505. protected _shadowLevel: float;
  112506. /**
  112507. * Helps adjusting the shadow to a softer level if required.
  112508. * 0 means black shadows and 1 means no shadows.
  112509. */
  112510. shadowLevel: float;
  112511. protected _sceneCenter: Vector3;
  112512. /**
  112513. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  112514. * It is usually zero but might be interesting to modify according to your setup.
  112515. */
  112516. sceneCenter: Vector3;
  112517. protected _opacityFresnel: boolean;
  112518. /**
  112519. * This helps specifying that the material is falling off to the sky box at grazing angle.
  112520. * This helps ensuring a nice transition when the camera goes under the ground.
  112521. */
  112522. opacityFresnel: boolean;
  112523. protected _reflectionFresnel: boolean;
  112524. /**
  112525. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  112526. * This helps adding a mirror texture on the ground.
  112527. */
  112528. reflectionFresnel: boolean;
  112529. protected _reflectionFalloffDistance: number;
  112530. /**
  112531. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  112532. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  112533. */
  112534. reflectionFalloffDistance: number;
  112535. protected _reflectionAmount: number;
  112536. /**
  112537. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  112538. */
  112539. reflectionAmount: number;
  112540. protected _reflectionReflectance0: number;
  112541. /**
  112542. * This specifies the weight of the reflection at grazing angle.
  112543. */
  112544. reflectionReflectance0: number;
  112545. protected _reflectionReflectance90: number;
  112546. /**
  112547. * This specifies the weight of the reflection at a perpendicular point of view.
  112548. */
  112549. reflectionReflectance90: number;
  112550. /**
  112551. * Sets the reflection reflectance fresnel values according to the default standard
  112552. * empirically know to work well :-)
  112553. */
  112554. reflectionStandardFresnelWeight: number;
  112555. protected _useRGBColor: boolean;
  112556. /**
  112557. * Helps to directly use the maps channels instead of their level.
  112558. */
  112559. useRGBColor: boolean;
  112560. protected _enableNoise: boolean;
  112561. /**
  112562. * This helps reducing the banding effect that could occur on the background.
  112563. */
  112564. enableNoise: boolean;
  112565. /**
  112566. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  112567. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  112568. * Recommended to be keep at 1.0 except for special cases.
  112569. */
  112570. fovMultiplier: number;
  112571. private _fovMultiplier;
  112572. /**
  112573. * Enable the FOV adjustment feature controlled by fovMultiplier.
  112574. */
  112575. useEquirectangularFOV: boolean;
  112576. private _maxSimultaneousLights;
  112577. /**
  112578. * Number of Simultaneous lights allowed on the material.
  112579. */
  112580. maxSimultaneousLights: int;
  112581. /**
  112582. * Default configuration related to image processing available in the Background Material.
  112583. */
  112584. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  112585. /**
  112586. * Keep track of the image processing observer to allow dispose and replace.
  112587. */
  112588. private _imageProcessingObserver;
  112589. /**
  112590. * Attaches a new image processing configuration to the PBR Material.
  112591. * @param configuration (if null the scene configuration will be use)
  112592. */
  112593. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  112594. /**
  112595. * Gets the image processing configuration used either in this material.
  112596. */
  112597. /**
  112598. * Sets the Default image processing configuration used either in the this material.
  112599. *
  112600. * If sets to null, the scene one is in use.
  112601. */
  112602. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  112603. /**
  112604. * Gets wether the color curves effect is enabled.
  112605. */
  112606. /**
  112607. * Sets wether the color curves effect is enabled.
  112608. */
  112609. cameraColorCurvesEnabled: boolean;
  112610. /**
  112611. * Gets wether the color grading effect is enabled.
  112612. */
  112613. /**
  112614. * Gets wether the color grading effect is enabled.
  112615. */
  112616. cameraColorGradingEnabled: boolean;
  112617. /**
  112618. * Gets wether tonemapping is enabled or not.
  112619. */
  112620. /**
  112621. * Sets wether tonemapping is enabled or not
  112622. */
  112623. cameraToneMappingEnabled: boolean;
  112624. /**
  112625. * The camera exposure used on this material.
  112626. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  112627. * This corresponds to a photographic exposure.
  112628. */
  112629. /**
  112630. * The camera exposure used on this material.
  112631. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  112632. * This corresponds to a photographic exposure.
  112633. */
  112634. cameraExposure: float;
  112635. /**
  112636. * Gets The camera contrast used on this material.
  112637. */
  112638. /**
  112639. * Sets The camera contrast used on this material.
  112640. */
  112641. cameraContrast: float;
  112642. /**
  112643. * Gets the Color Grading 2D Lookup Texture.
  112644. */
  112645. /**
  112646. * Sets the Color Grading 2D Lookup Texture.
  112647. */
  112648. cameraColorGradingTexture: Nullable<BaseTexture>;
  112649. /**
  112650. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  112651. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  112652. * 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;
  112653. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  112654. */
  112655. /**
  112656. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  112657. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  112658. * 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;
  112659. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  112660. */
  112661. cameraColorCurves: Nullable<ColorCurves>;
  112662. /**
  112663. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  112664. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  112665. */
  112666. switchToBGR: boolean;
  112667. private _renderTargets;
  112668. private _reflectionControls;
  112669. private _white;
  112670. private _primaryShadowColor;
  112671. private _primaryHighlightColor;
  112672. /**
  112673. * Instantiates a Background Material in the given scene
  112674. * @param name The friendly name of the material
  112675. * @param scene The scene to add the material to
  112676. */
  112677. constructor(name: string, scene: Scene);
  112678. /**
  112679. * Gets a boolean indicating that current material needs to register RTT
  112680. */
  112681. readonly hasRenderTargetTextures: boolean;
  112682. /**
  112683. * The entire material has been created in order to prevent overdraw.
  112684. * @returns false
  112685. */
  112686. needAlphaTesting(): boolean;
  112687. /**
  112688. * The entire material has been created in order to prevent overdraw.
  112689. * @returns true if blending is enable
  112690. */
  112691. needAlphaBlending(): boolean;
  112692. /**
  112693. * Checks wether the material is ready to be rendered for a given mesh.
  112694. * @param mesh The mesh to render
  112695. * @param subMesh The submesh to check against
  112696. * @param useInstances Specify wether or not the material is used with instances
  112697. * @returns true if all the dependencies are ready (Textures, Effects...)
  112698. */
  112699. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  112700. /**
  112701. * Compute the primary color according to the chosen perceptual color.
  112702. */
  112703. private _computePrimaryColorFromPerceptualColor;
  112704. /**
  112705. * Compute the highlights and shadow colors according to their chosen levels.
  112706. */
  112707. private _computePrimaryColors;
  112708. /**
  112709. * Build the uniform buffer used in the material.
  112710. */
  112711. buildUniformLayout(): void;
  112712. /**
  112713. * Unbind the material.
  112714. */
  112715. unbind(): void;
  112716. /**
  112717. * Bind only the world matrix to the material.
  112718. * @param world The world matrix to bind.
  112719. */
  112720. bindOnlyWorldMatrix(world: Matrix): void;
  112721. /**
  112722. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  112723. * @param world The world matrix to bind.
  112724. * @param subMesh The submesh to bind for.
  112725. */
  112726. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  112727. /**
  112728. * Checks to see if a texture is used in the material.
  112729. * @param texture - Base texture to use.
  112730. * @returns - Boolean specifying if a texture is used in the material.
  112731. */
  112732. hasTexture(texture: BaseTexture): boolean;
  112733. /**
  112734. * Dispose the material.
  112735. * @param forceDisposeEffect Force disposal of the associated effect.
  112736. * @param forceDisposeTextures Force disposal of the associated textures.
  112737. */
  112738. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  112739. /**
  112740. * Clones the material.
  112741. * @param name The cloned name.
  112742. * @returns The cloned material.
  112743. */
  112744. clone(name: string): BackgroundMaterial;
  112745. /**
  112746. * Serializes the current material to its JSON representation.
  112747. * @returns The JSON representation.
  112748. */
  112749. serialize(): any;
  112750. /**
  112751. * Gets the class name of the material
  112752. * @returns "BackgroundMaterial"
  112753. */
  112754. getClassName(): string;
  112755. /**
  112756. * Parse a JSON input to create back a background material.
  112757. * @param source The JSON data to parse
  112758. * @param scene The scene to create the parsed material in
  112759. * @param rootUrl The root url of the assets the material depends upon
  112760. * @returns the instantiated BackgroundMaterial.
  112761. */
  112762. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  112763. }
  112764. }
  112765. declare module BABYLON {
  112766. /**
  112767. * Represents the different options available during the creation of
  112768. * a Environment helper.
  112769. *
  112770. * This can control the default ground, skybox and image processing setup of your scene.
  112771. */
  112772. export interface IEnvironmentHelperOptions {
  112773. /**
  112774. * Specifies wether or not to create a ground.
  112775. * True by default.
  112776. */
  112777. createGround: boolean;
  112778. /**
  112779. * Specifies the ground size.
  112780. * 15 by default.
  112781. */
  112782. groundSize: number;
  112783. /**
  112784. * The texture used on the ground for the main color.
  112785. * Comes from the BabylonJS CDN by default.
  112786. *
  112787. * Remarks: Can be either a texture or a url.
  112788. */
  112789. groundTexture: string | BaseTexture;
  112790. /**
  112791. * The color mixed in the ground texture by default.
  112792. * BabylonJS clearColor by default.
  112793. */
  112794. groundColor: Color3;
  112795. /**
  112796. * Specifies the ground opacity.
  112797. * 1 by default.
  112798. */
  112799. groundOpacity: number;
  112800. /**
  112801. * Enables the ground to receive shadows.
  112802. * True by default.
  112803. */
  112804. enableGroundShadow: boolean;
  112805. /**
  112806. * Helps preventing the shadow to be fully black on the ground.
  112807. * 0.5 by default.
  112808. */
  112809. groundShadowLevel: number;
  112810. /**
  112811. * Creates a mirror texture attach to the ground.
  112812. * false by default.
  112813. */
  112814. enableGroundMirror: boolean;
  112815. /**
  112816. * Specifies the ground mirror size ratio.
  112817. * 0.3 by default as the default kernel is 64.
  112818. */
  112819. groundMirrorSizeRatio: number;
  112820. /**
  112821. * Specifies the ground mirror blur kernel size.
  112822. * 64 by default.
  112823. */
  112824. groundMirrorBlurKernel: number;
  112825. /**
  112826. * Specifies the ground mirror visibility amount.
  112827. * 1 by default
  112828. */
  112829. groundMirrorAmount: number;
  112830. /**
  112831. * Specifies the ground mirror reflectance weight.
  112832. * This uses the standard weight of the background material to setup the fresnel effect
  112833. * of the mirror.
  112834. * 1 by default.
  112835. */
  112836. groundMirrorFresnelWeight: number;
  112837. /**
  112838. * Specifies the ground mirror Falloff distance.
  112839. * This can helps reducing the size of the reflection.
  112840. * 0 by Default.
  112841. */
  112842. groundMirrorFallOffDistance: number;
  112843. /**
  112844. * Specifies the ground mirror texture type.
  112845. * Unsigned Int by Default.
  112846. */
  112847. groundMirrorTextureType: number;
  112848. /**
  112849. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  112850. * the shown objects.
  112851. */
  112852. groundYBias: number;
  112853. /**
  112854. * Specifies wether or not to create a skybox.
  112855. * True by default.
  112856. */
  112857. createSkybox: boolean;
  112858. /**
  112859. * Specifies the skybox size.
  112860. * 20 by default.
  112861. */
  112862. skyboxSize: number;
  112863. /**
  112864. * The texture used on the skybox for the main color.
  112865. * Comes from the BabylonJS CDN by default.
  112866. *
  112867. * Remarks: Can be either a texture or a url.
  112868. */
  112869. skyboxTexture: string | BaseTexture;
  112870. /**
  112871. * The color mixed in the skybox texture by default.
  112872. * BabylonJS clearColor by default.
  112873. */
  112874. skyboxColor: Color3;
  112875. /**
  112876. * The background rotation around the Y axis of the scene.
  112877. * This helps aligning the key lights of your scene with the background.
  112878. * 0 by default.
  112879. */
  112880. backgroundYRotation: number;
  112881. /**
  112882. * Compute automatically the size of the elements to best fit with the scene.
  112883. */
  112884. sizeAuto: boolean;
  112885. /**
  112886. * Default position of the rootMesh if autoSize is not true.
  112887. */
  112888. rootPosition: Vector3;
  112889. /**
  112890. * Sets up the image processing in the scene.
  112891. * true by default.
  112892. */
  112893. setupImageProcessing: boolean;
  112894. /**
  112895. * The texture used as your environment texture in the scene.
  112896. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  112897. *
  112898. * Remarks: Can be either a texture or a url.
  112899. */
  112900. environmentTexture: string | BaseTexture;
  112901. /**
  112902. * The value of the exposure to apply to the scene.
  112903. * 0.6 by default if setupImageProcessing is true.
  112904. */
  112905. cameraExposure: number;
  112906. /**
  112907. * The value of the contrast to apply to the scene.
  112908. * 1.6 by default if setupImageProcessing is true.
  112909. */
  112910. cameraContrast: number;
  112911. /**
  112912. * Specifies wether or not tonemapping should be enabled in the scene.
  112913. * true by default if setupImageProcessing is true.
  112914. */
  112915. toneMappingEnabled: boolean;
  112916. }
  112917. /**
  112918. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  112919. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  112920. * It also helps with the default setup of your imageProcessing configuration.
  112921. */
  112922. export class EnvironmentHelper {
  112923. /**
  112924. * Default ground texture URL.
  112925. */
  112926. private static _groundTextureCDNUrl;
  112927. /**
  112928. * Default skybox texture URL.
  112929. */
  112930. private static _skyboxTextureCDNUrl;
  112931. /**
  112932. * Default environment texture URL.
  112933. */
  112934. private static _environmentTextureCDNUrl;
  112935. /**
  112936. * Creates the default options for the helper.
  112937. */
  112938. private static _getDefaultOptions;
  112939. private _rootMesh;
  112940. /**
  112941. * Gets the root mesh created by the helper.
  112942. */
  112943. readonly rootMesh: Mesh;
  112944. private _skybox;
  112945. /**
  112946. * Gets the skybox created by the helper.
  112947. */
  112948. readonly skybox: Nullable<Mesh>;
  112949. private _skyboxTexture;
  112950. /**
  112951. * Gets the skybox texture created by the helper.
  112952. */
  112953. readonly skyboxTexture: Nullable<BaseTexture>;
  112954. private _skyboxMaterial;
  112955. /**
  112956. * Gets the skybox material created by the helper.
  112957. */
  112958. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  112959. private _ground;
  112960. /**
  112961. * Gets the ground mesh created by the helper.
  112962. */
  112963. readonly ground: Nullable<Mesh>;
  112964. private _groundTexture;
  112965. /**
  112966. * Gets the ground texture created by the helper.
  112967. */
  112968. readonly groundTexture: Nullable<BaseTexture>;
  112969. private _groundMirror;
  112970. /**
  112971. * Gets the ground mirror created by the helper.
  112972. */
  112973. readonly groundMirror: Nullable<MirrorTexture>;
  112974. /**
  112975. * Gets the ground mirror render list to helps pushing the meshes
  112976. * you wish in the ground reflection.
  112977. */
  112978. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  112979. private _groundMaterial;
  112980. /**
  112981. * Gets the ground material created by the helper.
  112982. */
  112983. readonly groundMaterial: Nullable<BackgroundMaterial>;
  112984. /**
  112985. * Stores the creation options.
  112986. */
  112987. private readonly _scene;
  112988. private _options;
  112989. /**
  112990. * This observable will be notified with any error during the creation of the environment,
  112991. * mainly texture creation errors.
  112992. */
  112993. onErrorObservable: Observable<{
  112994. message?: string;
  112995. exception?: any;
  112996. }>;
  112997. /**
  112998. * constructor
  112999. * @param options Defines the options we want to customize the helper
  113000. * @param scene The scene to add the material to
  113001. */
  113002. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  113003. /**
  113004. * Updates the background according to the new options
  113005. * @param options
  113006. */
  113007. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  113008. /**
  113009. * Sets the primary color of all the available elements.
  113010. * @param color the main color to affect to the ground and the background
  113011. */
  113012. setMainColor(color: Color3): void;
  113013. /**
  113014. * Setup the image processing according to the specified options.
  113015. */
  113016. private _setupImageProcessing;
  113017. /**
  113018. * Setup the environment texture according to the specified options.
  113019. */
  113020. private _setupEnvironmentTexture;
  113021. /**
  113022. * Setup the background according to the specified options.
  113023. */
  113024. private _setupBackground;
  113025. /**
  113026. * Get the scene sizes according to the setup.
  113027. */
  113028. private _getSceneSize;
  113029. /**
  113030. * Setup the ground according to the specified options.
  113031. */
  113032. private _setupGround;
  113033. /**
  113034. * Setup the ground material according to the specified options.
  113035. */
  113036. private _setupGroundMaterial;
  113037. /**
  113038. * Setup the ground diffuse texture according to the specified options.
  113039. */
  113040. private _setupGroundDiffuseTexture;
  113041. /**
  113042. * Setup the ground mirror texture according to the specified options.
  113043. */
  113044. private _setupGroundMirrorTexture;
  113045. /**
  113046. * Setup the ground to receive the mirror texture.
  113047. */
  113048. private _setupMirrorInGroundMaterial;
  113049. /**
  113050. * Setup the skybox according to the specified options.
  113051. */
  113052. private _setupSkybox;
  113053. /**
  113054. * Setup the skybox material according to the specified options.
  113055. */
  113056. private _setupSkyboxMaterial;
  113057. /**
  113058. * Setup the skybox reflection texture according to the specified options.
  113059. */
  113060. private _setupSkyboxReflectionTexture;
  113061. private _errorHandler;
  113062. /**
  113063. * Dispose all the elements created by the Helper.
  113064. */
  113065. dispose(): void;
  113066. }
  113067. }
  113068. declare module BABYLON {
  113069. /**
  113070. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  113071. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  113072. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  113073. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  113074. */
  113075. export class PhotoDome extends TransformNode {
  113076. /**
  113077. * Define the image as a Monoscopic panoramic 360 image.
  113078. */
  113079. static readonly MODE_MONOSCOPIC: number;
  113080. /**
  113081. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  113082. */
  113083. static readonly MODE_TOPBOTTOM: number;
  113084. /**
  113085. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  113086. */
  113087. static readonly MODE_SIDEBYSIDE: number;
  113088. private _useDirectMapping;
  113089. /**
  113090. * The texture being displayed on the sphere
  113091. */
  113092. protected _photoTexture: Texture;
  113093. /**
  113094. * Gets or sets the texture being displayed on the sphere
  113095. */
  113096. photoTexture: Texture;
  113097. /**
  113098. * Observable raised when an error occured while loading the 360 image
  113099. */
  113100. onLoadErrorObservable: Observable<string>;
  113101. /**
  113102. * The skybox material
  113103. */
  113104. protected _material: BackgroundMaterial;
  113105. /**
  113106. * The surface used for the skybox
  113107. */
  113108. protected _mesh: Mesh;
  113109. /**
  113110. * Gets the mesh used for the skybox.
  113111. */
  113112. readonly mesh: Mesh;
  113113. /**
  113114. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  113115. * Also see the options.resolution property.
  113116. */
  113117. fovMultiplier: number;
  113118. private _imageMode;
  113119. /**
  113120. * Gets or set the current video mode for the video. It can be:
  113121. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  113122. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  113123. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  113124. */
  113125. imageMode: number;
  113126. /**
  113127. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  113128. * @param name Element's name, child elements will append suffixes for their own names.
  113129. * @param urlsOfPhoto defines the url of the photo to display
  113130. * @param options defines an object containing optional or exposed sub element properties
  113131. * @param onError defines a callback called when an error occured while loading the texture
  113132. */
  113133. constructor(name: string, urlOfPhoto: string, options: {
  113134. resolution?: number;
  113135. size?: number;
  113136. useDirectMapping?: boolean;
  113137. faceForward?: boolean;
  113138. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  113139. private _onBeforeCameraRenderObserver;
  113140. private _changeImageMode;
  113141. /**
  113142. * Releases resources associated with this node.
  113143. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  113144. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  113145. */
  113146. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  113147. }
  113148. }
  113149. declare module BABYLON {
  113150. /**
  113151. * Class used to host RGBD texture specific utilities
  113152. */
  113153. export class RGBDTextureTools {
  113154. /**
  113155. * Expand the RGBD Texture from RGBD to Half Float if possible.
  113156. * @param texture the texture to expand.
  113157. */
  113158. static ExpandRGBDTexture(texture: Texture): void;
  113159. }
  113160. }
  113161. declare module BABYLON {
  113162. /**
  113163. * Class used to host texture specific utilities
  113164. */
  113165. export class BRDFTextureTools {
  113166. /**
  113167. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  113168. * @param scene defines the hosting scene
  113169. * @returns the environment BRDF texture
  113170. */
  113171. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  113172. private static _environmentBRDFBase64Texture;
  113173. }
  113174. }
  113175. declare module BABYLON {
  113176. /**
  113177. * @hidden
  113178. */
  113179. export interface IMaterialClearCoatDefines {
  113180. CLEARCOAT: boolean;
  113181. CLEARCOAT_DEFAULTIOR: boolean;
  113182. CLEARCOAT_TEXTURE: boolean;
  113183. CLEARCOAT_TEXTUREDIRECTUV: number;
  113184. CLEARCOAT_BUMP: boolean;
  113185. CLEARCOAT_BUMPDIRECTUV: number;
  113186. CLEARCOAT_TINT: boolean;
  113187. CLEARCOAT_TINT_TEXTURE: boolean;
  113188. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  113189. /** @hidden */
  113190. _areTexturesDirty: boolean;
  113191. }
  113192. /**
  113193. * Define the code related to the clear coat parameters of the pbr material.
  113194. */
  113195. export class PBRClearCoatConfiguration {
  113196. /**
  113197. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  113198. * The default fits with a polyurethane material.
  113199. */
  113200. private static readonly _DefaultIndexOfRefraction;
  113201. private _isEnabled;
  113202. /**
  113203. * Defines if the clear coat is enabled in the material.
  113204. */
  113205. isEnabled: boolean;
  113206. /**
  113207. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  113208. */
  113209. intensity: number;
  113210. /**
  113211. * Defines the clear coat layer roughness.
  113212. */
  113213. roughness: number;
  113214. private _indexOfRefraction;
  113215. /**
  113216. * Defines the index of refraction of the clear coat.
  113217. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  113218. * The default fits with a polyurethane material.
  113219. * Changing the default value is more performance intensive.
  113220. */
  113221. indexOfRefraction: number;
  113222. private _texture;
  113223. /**
  113224. * Stores the clear coat values in a texture.
  113225. */
  113226. texture: Nullable<BaseTexture>;
  113227. private _bumpTexture;
  113228. /**
  113229. * Define the clear coat specific bump texture.
  113230. */
  113231. bumpTexture: Nullable<BaseTexture>;
  113232. private _isTintEnabled;
  113233. /**
  113234. * Defines if the clear coat tint is enabled in the material.
  113235. */
  113236. isTintEnabled: boolean;
  113237. /**
  113238. * Defines the clear coat tint of the material.
  113239. * This is only use if tint is enabled
  113240. */
  113241. tintColor: Color3;
  113242. /**
  113243. * Defines the distance at which the tint color should be found in the
  113244. * clear coat media.
  113245. * This is only use if tint is enabled
  113246. */
  113247. tintColorAtDistance: number;
  113248. /**
  113249. * Defines the clear coat layer thickness.
  113250. * This is only use if tint is enabled
  113251. */
  113252. tintThickness: number;
  113253. private _tintTexture;
  113254. /**
  113255. * Stores the clear tint values in a texture.
  113256. * rgb is tint
  113257. * a is a thickness factor
  113258. */
  113259. tintTexture: Nullable<BaseTexture>;
  113260. /** @hidden */
  113261. private _internalMarkAllSubMeshesAsTexturesDirty;
  113262. /** @hidden */
  113263. _markAllSubMeshesAsTexturesDirty(): void;
  113264. /**
  113265. * Instantiate a new istance of clear coat configuration.
  113266. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  113267. */
  113268. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  113269. /**
  113270. * Gets wehter the submesh is ready to be used or not.
  113271. * @param defines the list of "defines" to update.
  113272. * @param scene defines the scene the material belongs to.
  113273. * @param engine defines the engine the material belongs to.
  113274. * @param disableBumpMap defines wether the material disables bump or not.
  113275. * @returns - boolean indicating that the submesh is ready or not.
  113276. */
  113277. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  113278. /**
  113279. * Checks to see if a texture is used in the material.
  113280. * @param defines the list of "defines" to update.
  113281. * @param scene defines the scene to the material belongs to.
  113282. */
  113283. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  113284. /**
  113285. * Binds the material data.
  113286. * @param uniformBuffer defines the Uniform buffer to fill in.
  113287. * @param scene defines the scene the material belongs to.
  113288. * @param engine defines the engine the material belongs to.
  113289. * @param disableBumpMap defines wether the material disables bump or not.
  113290. * @param isFrozen defines wether the material is frozen or not.
  113291. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  113292. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  113293. */
  113294. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  113295. /**
  113296. * Checks to see if a texture is used in the material.
  113297. * @param texture - Base texture to use.
  113298. * @returns - Boolean specifying if a texture is used in the material.
  113299. */
  113300. hasTexture(texture: BaseTexture): boolean;
  113301. /**
  113302. * Returns an array of the actively used textures.
  113303. * @param activeTextures Array of BaseTextures
  113304. */
  113305. getActiveTextures(activeTextures: BaseTexture[]): void;
  113306. /**
  113307. * Returns the animatable textures.
  113308. * @param animatables Array of animatable textures.
  113309. */
  113310. getAnimatables(animatables: IAnimatable[]): void;
  113311. /**
  113312. * Disposes the resources of the material.
  113313. * @param forceDisposeTextures - Forces the disposal of all textures.
  113314. */
  113315. dispose(forceDisposeTextures?: boolean): void;
  113316. /**
  113317. * Get the current class name of the texture useful for serialization or dynamic coding.
  113318. * @returns "PBRClearCoatConfiguration"
  113319. */
  113320. getClassName(): string;
  113321. /**
  113322. * Add fallbacks to the effect fallbacks list.
  113323. * @param defines defines the Base texture to use.
  113324. * @param fallbacks defines the current fallback list.
  113325. * @param currentRank defines the current fallback rank.
  113326. * @returns the new fallback rank.
  113327. */
  113328. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  113329. /**
  113330. * Add the required uniforms to the current list.
  113331. * @param uniforms defines the current uniform list.
  113332. */
  113333. static AddUniforms(uniforms: string[]): void;
  113334. /**
  113335. * Add the required samplers to the current list.
  113336. * @param samplers defines the current sampler list.
  113337. */
  113338. static AddSamplers(samplers: string[]): void;
  113339. /**
  113340. * Add the required uniforms to the current buffer.
  113341. * @param uniformBuffer defines the current uniform buffer.
  113342. */
  113343. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  113344. /**
  113345. * Makes a duplicate of the current configuration into another one.
  113346. * @param clearCoatConfiguration define the config where to copy the info
  113347. */
  113348. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  113349. /**
  113350. * Serializes this clear coat configuration.
  113351. * @returns - An object with the serialized config.
  113352. */
  113353. serialize(): any;
  113354. /**
  113355. * Parses a anisotropy Configuration from a serialized object.
  113356. * @param source - Serialized object.
  113357. * @param scene Defines the scene we are parsing for
  113358. * @param rootUrl Defines the rootUrl to load from
  113359. */
  113360. parse(source: any, scene: Scene, rootUrl: string): void;
  113361. }
  113362. }
  113363. declare module BABYLON {
  113364. /**
  113365. * @hidden
  113366. */
  113367. export interface IMaterialAnisotropicDefines {
  113368. ANISOTROPIC: boolean;
  113369. ANISOTROPIC_TEXTURE: boolean;
  113370. ANISOTROPIC_TEXTUREDIRECTUV: number;
  113371. MAINUV1: boolean;
  113372. _areTexturesDirty: boolean;
  113373. _needUVs: boolean;
  113374. }
  113375. /**
  113376. * Define the code related to the anisotropic parameters of the pbr material.
  113377. */
  113378. export class PBRAnisotropicConfiguration {
  113379. private _isEnabled;
  113380. /**
  113381. * Defines if the anisotropy is enabled in the material.
  113382. */
  113383. isEnabled: boolean;
  113384. /**
  113385. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  113386. */
  113387. intensity: number;
  113388. /**
  113389. * Defines if the effect is along the tangents, bitangents or in between.
  113390. * By default, the effect is "strectching" the highlights along the tangents.
  113391. */
  113392. direction: Vector2;
  113393. private _texture;
  113394. /**
  113395. * Stores the anisotropy values in a texture.
  113396. * rg is direction (like normal from -1 to 1)
  113397. * b is a intensity
  113398. */
  113399. texture: Nullable<BaseTexture>;
  113400. /** @hidden */
  113401. private _internalMarkAllSubMeshesAsTexturesDirty;
  113402. /** @hidden */
  113403. _markAllSubMeshesAsTexturesDirty(): void;
  113404. /**
  113405. * Instantiate a new istance of anisotropy configuration.
  113406. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  113407. */
  113408. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  113409. /**
  113410. * Specifies that the submesh is ready to be used.
  113411. * @param defines the list of "defines" to update.
  113412. * @param scene defines the scene the material belongs to.
  113413. * @returns - boolean indicating that the submesh is ready or not.
  113414. */
  113415. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  113416. /**
  113417. * Checks to see if a texture is used in the material.
  113418. * @param defines the list of "defines" to update.
  113419. * @param mesh the mesh we are preparing the defines for.
  113420. * @param scene defines the scene the material belongs to.
  113421. */
  113422. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  113423. /**
  113424. * Binds the material data.
  113425. * @param uniformBuffer defines the Uniform buffer to fill in.
  113426. * @param scene defines the scene the material belongs to.
  113427. * @param isFrozen defines wether the material is frozen or not.
  113428. */
  113429. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  113430. /**
  113431. * Checks to see if a texture is used in the material.
  113432. * @param texture - Base texture to use.
  113433. * @returns - Boolean specifying if a texture is used in the material.
  113434. */
  113435. hasTexture(texture: BaseTexture): boolean;
  113436. /**
  113437. * Returns an array of the actively used textures.
  113438. * @param activeTextures Array of BaseTextures
  113439. */
  113440. getActiveTextures(activeTextures: BaseTexture[]): void;
  113441. /**
  113442. * Returns the animatable textures.
  113443. * @param animatables Array of animatable textures.
  113444. */
  113445. getAnimatables(animatables: IAnimatable[]): void;
  113446. /**
  113447. * Disposes the resources of the material.
  113448. * @param forceDisposeTextures - Forces the disposal of all textures.
  113449. */
  113450. dispose(forceDisposeTextures?: boolean): void;
  113451. /**
  113452. * Get the current class name of the texture useful for serialization or dynamic coding.
  113453. * @returns "PBRAnisotropicConfiguration"
  113454. */
  113455. getClassName(): string;
  113456. /**
  113457. * Add fallbacks to the effect fallbacks list.
  113458. * @param defines defines the Base texture to use.
  113459. * @param fallbacks defines the current fallback list.
  113460. * @param currentRank defines the current fallback rank.
  113461. * @returns the new fallback rank.
  113462. */
  113463. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  113464. /**
  113465. * Add the required uniforms to the current list.
  113466. * @param uniforms defines the current uniform list.
  113467. */
  113468. static AddUniforms(uniforms: string[]): void;
  113469. /**
  113470. * Add the required uniforms to the current buffer.
  113471. * @param uniformBuffer defines the current uniform buffer.
  113472. */
  113473. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  113474. /**
  113475. * Add the required samplers to the current list.
  113476. * @param samplers defines the current sampler list.
  113477. */
  113478. static AddSamplers(samplers: string[]): void;
  113479. /**
  113480. * Makes a duplicate of the current configuration into another one.
  113481. * @param anisotropicConfiguration define the config where to copy the info
  113482. */
  113483. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  113484. /**
  113485. * Serializes this anisotropy configuration.
  113486. * @returns - An object with the serialized config.
  113487. */
  113488. serialize(): any;
  113489. /**
  113490. * Parses a anisotropy Configuration from a serialized object.
  113491. * @param source - Serialized object.
  113492. * @param scene Defines the scene we are parsing for
  113493. * @param rootUrl Defines the rootUrl to load from
  113494. */
  113495. parse(source: any, scene: Scene, rootUrl: string): void;
  113496. }
  113497. }
  113498. declare module BABYLON {
  113499. /**
  113500. * @hidden
  113501. */
  113502. export interface IMaterialBRDFDefines {
  113503. BRDF_V_HEIGHT_CORRELATED: boolean;
  113504. MS_BRDF_ENERGY_CONSERVATION: boolean;
  113505. SPHERICAL_HARMONICS: boolean;
  113506. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  113507. /** @hidden */
  113508. _areMiscDirty: boolean;
  113509. }
  113510. /**
  113511. * Define the code related to the BRDF parameters of the pbr material.
  113512. */
  113513. export class PBRBRDFConfiguration {
  113514. /**
  113515. * Default value used for the energy conservation.
  113516. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  113517. */
  113518. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  113519. /**
  113520. * Default value used for the Smith Visibility Height Correlated mode.
  113521. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  113522. */
  113523. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  113524. /**
  113525. * Default value used for the IBL diffuse part.
  113526. * This can help switching back to the polynomials mode globally which is a tiny bit
  113527. * less GPU intensive at the drawback of a lower quality.
  113528. */
  113529. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  113530. /**
  113531. * Default value used for activating energy conservation for the specular workflow.
  113532. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  113533. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  113534. */
  113535. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  113536. private _useEnergyConservation;
  113537. /**
  113538. * Defines if the material uses energy conservation.
  113539. */
  113540. useEnergyConservation: boolean;
  113541. private _useSmithVisibilityHeightCorrelated;
  113542. /**
  113543. * LEGACY Mode set to false
  113544. * Defines if the material uses height smith correlated visibility term.
  113545. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  113546. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  113547. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  113548. * Not relying on height correlated will also disable energy conservation.
  113549. */
  113550. useSmithVisibilityHeightCorrelated: boolean;
  113551. private _useSphericalHarmonics;
  113552. /**
  113553. * LEGACY Mode set to false
  113554. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  113555. * diffuse part of the IBL.
  113556. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  113557. * to the ground truth.
  113558. */
  113559. useSphericalHarmonics: boolean;
  113560. private _useSpecularGlossinessInputEnergyConservation;
  113561. /**
  113562. * Defines if the material uses energy conservation, when the specular workflow is active.
  113563. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  113564. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  113565. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  113566. */
  113567. useSpecularGlossinessInputEnergyConservation: boolean;
  113568. /** @hidden */
  113569. private _internalMarkAllSubMeshesAsMiscDirty;
  113570. /** @hidden */
  113571. _markAllSubMeshesAsMiscDirty(): void;
  113572. /**
  113573. * Instantiate a new istance of clear coat configuration.
  113574. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  113575. */
  113576. constructor(markAllSubMeshesAsMiscDirty: () => void);
  113577. /**
  113578. * Checks to see if a texture is used in the material.
  113579. * @param defines the list of "defines" to update.
  113580. */
  113581. prepareDefines(defines: IMaterialBRDFDefines): void;
  113582. /**
  113583. * Get the current class name of the texture useful for serialization or dynamic coding.
  113584. * @returns "PBRClearCoatConfiguration"
  113585. */
  113586. getClassName(): string;
  113587. /**
  113588. * Makes a duplicate of the current configuration into another one.
  113589. * @param brdfConfiguration define the config where to copy the info
  113590. */
  113591. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  113592. /**
  113593. * Serializes this BRDF configuration.
  113594. * @returns - An object with the serialized config.
  113595. */
  113596. serialize(): any;
  113597. /**
  113598. * Parses a anisotropy Configuration from a serialized object.
  113599. * @param source - Serialized object.
  113600. * @param scene Defines the scene we are parsing for
  113601. * @param rootUrl Defines the rootUrl to load from
  113602. */
  113603. parse(source: any, scene: Scene, rootUrl: string): void;
  113604. }
  113605. }
  113606. declare module BABYLON {
  113607. /**
  113608. * @hidden
  113609. */
  113610. export interface IMaterialSheenDefines {
  113611. SHEEN: boolean;
  113612. SHEEN_TEXTURE: boolean;
  113613. SHEEN_TEXTUREDIRECTUV: number;
  113614. SHEEN_LINKWITHALBEDO: boolean;
  113615. /** @hidden */
  113616. _areTexturesDirty: boolean;
  113617. }
  113618. /**
  113619. * Define the code related to the Sheen parameters of the pbr material.
  113620. */
  113621. export class PBRSheenConfiguration {
  113622. private _isEnabled;
  113623. /**
  113624. * Defines if the material uses sheen.
  113625. */
  113626. isEnabled: boolean;
  113627. private _linkSheenWithAlbedo;
  113628. /**
  113629. * Defines if the sheen is linked to the sheen color.
  113630. */
  113631. linkSheenWithAlbedo: boolean;
  113632. /**
  113633. * Defines the sheen intensity.
  113634. */
  113635. intensity: number;
  113636. /**
  113637. * Defines the sheen color.
  113638. */
  113639. color: Color3;
  113640. private _texture;
  113641. /**
  113642. * Stores the sheen tint values in a texture.
  113643. * rgb is tint
  113644. * a is a intensity
  113645. */
  113646. texture: Nullable<BaseTexture>;
  113647. /** @hidden */
  113648. private _internalMarkAllSubMeshesAsTexturesDirty;
  113649. /** @hidden */
  113650. _markAllSubMeshesAsTexturesDirty(): void;
  113651. /**
  113652. * Instantiate a new istance of clear coat configuration.
  113653. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  113654. */
  113655. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  113656. /**
  113657. * Specifies that the submesh is ready to be used.
  113658. * @param defines the list of "defines" to update.
  113659. * @param scene defines the scene the material belongs to.
  113660. * @returns - boolean indicating that the submesh is ready or not.
  113661. */
  113662. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  113663. /**
  113664. * Checks to see if a texture is used in the material.
  113665. * @param defines the list of "defines" to update.
  113666. * @param scene defines the scene the material belongs to.
  113667. */
  113668. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  113669. /**
  113670. * Binds the material data.
  113671. * @param uniformBuffer defines the Uniform buffer to fill in.
  113672. * @param scene defines the scene the material belongs to.
  113673. * @param isFrozen defines wether the material is frozen or not.
  113674. */
  113675. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  113676. /**
  113677. * Checks to see if a texture is used in the material.
  113678. * @param texture - Base texture to use.
  113679. * @returns - Boolean specifying if a texture is used in the material.
  113680. */
  113681. hasTexture(texture: BaseTexture): boolean;
  113682. /**
  113683. * Returns an array of the actively used textures.
  113684. * @param activeTextures Array of BaseTextures
  113685. */
  113686. getActiveTextures(activeTextures: BaseTexture[]): void;
  113687. /**
  113688. * Returns the animatable textures.
  113689. * @param animatables Array of animatable textures.
  113690. */
  113691. getAnimatables(animatables: IAnimatable[]): void;
  113692. /**
  113693. * Disposes the resources of the material.
  113694. * @param forceDisposeTextures - Forces the disposal of all textures.
  113695. */
  113696. dispose(forceDisposeTextures?: boolean): void;
  113697. /**
  113698. * Get the current class name of the texture useful for serialization or dynamic coding.
  113699. * @returns "PBRSheenConfiguration"
  113700. */
  113701. getClassName(): string;
  113702. /**
  113703. * Add fallbacks to the effect fallbacks list.
  113704. * @param defines defines the Base texture to use.
  113705. * @param fallbacks defines the current fallback list.
  113706. * @param currentRank defines the current fallback rank.
  113707. * @returns the new fallback rank.
  113708. */
  113709. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  113710. /**
  113711. * Add the required uniforms to the current list.
  113712. * @param uniforms defines the current uniform list.
  113713. */
  113714. static AddUniforms(uniforms: string[]): void;
  113715. /**
  113716. * Add the required uniforms to the current buffer.
  113717. * @param uniformBuffer defines the current uniform buffer.
  113718. */
  113719. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  113720. /**
  113721. * Add the required samplers to the current list.
  113722. * @param samplers defines the current sampler list.
  113723. */
  113724. static AddSamplers(samplers: string[]): void;
  113725. /**
  113726. * Makes a duplicate of the current configuration into another one.
  113727. * @param sheenConfiguration define the config where to copy the info
  113728. */
  113729. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  113730. /**
  113731. * Serializes this BRDF configuration.
  113732. * @returns - An object with the serialized config.
  113733. */
  113734. serialize(): any;
  113735. /**
  113736. * Parses a anisotropy Configuration from a serialized object.
  113737. * @param source - Serialized object.
  113738. * @param scene Defines the scene we are parsing for
  113739. * @param rootUrl Defines the rootUrl to load from
  113740. */
  113741. parse(source: any, scene: Scene, rootUrl: string): void;
  113742. }
  113743. }
  113744. declare module BABYLON {
  113745. /**
  113746. * @hidden
  113747. */
  113748. export interface IMaterialSubSurfaceDefines {
  113749. SUBSURFACE: boolean;
  113750. SS_REFRACTION: boolean;
  113751. SS_TRANSLUCENCY: boolean;
  113752. SS_SCATERRING: boolean;
  113753. SS_THICKNESSANDMASK_TEXTURE: boolean;
  113754. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  113755. SS_REFRACTIONMAP_3D: boolean;
  113756. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  113757. SS_LODINREFRACTIONALPHA: boolean;
  113758. SS_GAMMAREFRACTION: boolean;
  113759. SS_RGBDREFRACTION: boolean;
  113760. SS_LINEARSPECULARREFRACTION: boolean;
  113761. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  113762. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  113763. /** @hidden */
  113764. _areTexturesDirty: boolean;
  113765. }
  113766. /**
  113767. * Define the code related to the sub surface parameters of the pbr material.
  113768. */
  113769. export class PBRSubSurfaceConfiguration {
  113770. private _isRefractionEnabled;
  113771. /**
  113772. * Defines if the refraction is enabled in the material.
  113773. */
  113774. isRefractionEnabled: boolean;
  113775. private _isTranslucencyEnabled;
  113776. /**
  113777. * Defines if the translucency is enabled in the material.
  113778. */
  113779. isTranslucencyEnabled: boolean;
  113780. private _isScatteringEnabled;
  113781. /**
  113782. * Defines the refraction intensity of the material.
  113783. * The refraction when enabled replaces the Diffuse part of the material.
  113784. * The intensity helps transitionning between diffuse and refraction.
  113785. */
  113786. refractionIntensity: number;
  113787. /**
  113788. * Defines the translucency intensity of the material.
  113789. * When translucency has been enabled, this defines how much of the "translucency"
  113790. * is addded to the diffuse part of the material.
  113791. */
  113792. translucencyIntensity: number;
  113793. /**
  113794. * Defines the scattering intensity of the material.
  113795. * When scattering has been enabled, this defines how much of the "scattered light"
  113796. * is addded to the diffuse part of the material.
  113797. */
  113798. scatteringIntensity: number;
  113799. private _thicknessTexture;
  113800. /**
  113801. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  113802. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  113803. * 0 would mean minimumThickness
  113804. * 1 would mean maximumThickness
  113805. * The other channels might be use as a mask to vary the different effects intensity.
  113806. */
  113807. thicknessTexture: Nullable<BaseTexture>;
  113808. private _refractionTexture;
  113809. /**
  113810. * Defines the texture to use for refraction.
  113811. */
  113812. refractionTexture: Nullable<BaseTexture>;
  113813. private _indexOfRefraction;
  113814. /**
  113815. * Defines the index of refraction used in the material.
  113816. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  113817. */
  113818. indexOfRefraction: number;
  113819. private _invertRefractionY;
  113820. /**
  113821. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  113822. */
  113823. invertRefractionY: boolean;
  113824. private _linkRefractionWithTransparency;
  113825. /**
  113826. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  113827. * Materials half opaque for instance using refraction could benefit from this control.
  113828. */
  113829. linkRefractionWithTransparency: boolean;
  113830. /**
  113831. * Defines the minimum thickness stored in the thickness map.
  113832. * If no thickness map is defined, this value will be used to simulate thickness.
  113833. */
  113834. minimumThickness: number;
  113835. /**
  113836. * Defines the maximum thickness stored in the thickness map.
  113837. */
  113838. maximumThickness: number;
  113839. /**
  113840. * Defines the volume tint of the material.
  113841. * This is used for both translucency and scattering.
  113842. */
  113843. tintColor: Color3;
  113844. /**
  113845. * Defines the distance at which the tint color should be found in the media.
  113846. * This is used for refraction only.
  113847. */
  113848. tintColorAtDistance: number;
  113849. /**
  113850. * Defines how far each channel transmit through the media.
  113851. * It is defined as a color to simplify it selection.
  113852. */
  113853. diffusionDistance: Color3;
  113854. private _useMaskFromThicknessTexture;
  113855. /**
  113856. * Stores the intensity of the different subsurface effects in the thickness texture.
  113857. * * the green channel is the translucency intensity.
  113858. * * the blue channel is the scattering intensity.
  113859. * * the alpha channel is the refraction intensity.
  113860. */
  113861. useMaskFromThicknessTexture: boolean;
  113862. /** @hidden */
  113863. private _internalMarkAllSubMeshesAsTexturesDirty;
  113864. /** @hidden */
  113865. _markAllSubMeshesAsTexturesDirty(): void;
  113866. /**
  113867. * Instantiate a new istance of sub surface configuration.
  113868. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  113869. */
  113870. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  113871. /**
  113872. * Gets wehter the submesh is ready to be used or not.
  113873. * @param defines the list of "defines" to update.
  113874. * @param scene defines the scene the material belongs to.
  113875. * @returns - boolean indicating that the submesh is ready or not.
  113876. */
  113877. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  113878. /**
  113879. * Checks to see if a texture is used in the material.
  113880. * @param defines the list of "defines" to update.
  113881. * @param scene defines the scene to the material belongs to.
  113882. */
  113883. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  113884. /**
  113885. * Binds the material data.
  113886. * @param uniformBuffer defines the Uniform buffer to fill in.
  113887. * @param scene defines the scene the material belongs to.
  113888. * @param engine defines the engine the material belongs to.
  113889. * @param isFrozen defines wether the material is frozen or not.
  113890. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  113891. */
  113892. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  113893. /**
  113894. * Unbinds the material from the mesh.
  113895. * @param activeEffect defines the effect that should be unbound from.
  113896. * @returns true if unbound, otherwise false
  113897. */
  113898. unbind(activeEffect: Effect): boolean;
  113899. /**
  113900. * Returns the texture used for refraction or null if none is used.
  113901. * @param scene defines the scene the material belongs to.
  113902. * @returns - Refraction texture if present. If no refraction texture and refraction
  113903. * is linked with transparency, returns environment texture. Otherwise, returns null.
  113904. */
  113905. private _getRefractionTexture;
  113906. /**
  113907. * Returns true if alpha blending should be disabled.
  113908. */
  113909. readonly disableAlphaBlending: boolean;
  113910. /**
  113911. * Fills the list of render target textures.
  113912. * @param renderTargets the list of render targets to update
  113913. */
  113914. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  113915. /**
  113916. * Checks to see if a texture is used in the material.
  113917. * @param texture - Base texture to use.
  113918. * @returns - Boolean specifying if a texture is used in the material.
  113919. */
  113920. hasTexture(texture: BaseTexture): boolean;
  113921. /**
  113922. * Gets a boolean indicating that current material needs to register RTT
  113923. * @returns true if this uses a render target otherwise false.
  113924. */
  113925. hasRenderTargetTextures(): boolean;
  113926. /**
  113927. * Returns an array of the actively used textures.
  113928. * @param activeTextures Array of BaseTextures
  113929. */
  113930. getActiveTextures(activeTextures: BaseTexture[]): void;
  113931. /**
  113932. * Returns the animatable textures.
  113933. * @param animatables Array of animatable textures.
  113934. */
  113935. getAnimatables(animatables: IAnimatable[]): void;
  113936. /**
  113937. * Disposes the resources of the material.
  113938. * @param forceDisposeTextures - Forces the disposal of all textures.
  113939. */
  113940. dispose(forceDisposeTextures?: boolean): void;
  113941. /**
  113942. * Get the current class name of the texture useful for serialization or dynamic coding.
  113943. * @returns "PBRSubSurfaceConfiguration"
  113944. */
  113945. getClassName(): string;
  113946. /**
  113947. * Add fallbacks to the effect fallbacks list.
  113948. * @param defines defines the Base texture to use.
  113949. * @param fallbacks defines the current fallback list.
  113950. * @param currentRank defines the current fallback rank.
  113951. * @returns the new fallback rank.
  113952. */
  113953. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  113954. /**
  113955. * Add the required uniforms to the current list.
  113956. * @param uniforms defines the current uniform list.
  113957. */
  113958. static AddUniforms(uniforms: string[]): void;
  113959. /**
  113960. * Add the required samplers to the current list.
  113961. * @param samplers defines the current sampler list.
  113962. */
  113963. static AddSamplers(samplers: string[]): void;
  113964. /**
  113965. * Add the required uniforms to the current buffer.
  113966. * @param uniformBuffer defines the current uniform buffer.
  113967. */
  113968. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  113969. /**
  113970. * Makes a duplicate of the current configuration into another one.
  113971. * @param configuration define the config where to copy the info
  113972. */
  113973. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  113974. /**
  113975. * Serializes this Sub Surface configuration.
  113976. * @returns - An object with the serialized config.
  113977. */
  113978. serialize(): any;
  113979. /**
  113980. * Parses a anisotropy Configuration from a serialized object.
  113981. * @param source - Serialized object.
  113982. * @param scene Defines the scene we are parsing for
  113983. * @param rootUrl Defines the rootUrl to load from
  113984. */
  113985. parse(source: any, scene: Scene, rootUrl: string): void;
  113986. }
  113987. }
  113988. declare module BABYLON {
  113989. /** @hidden */
  113990. export var pbrFragmentDeclaration: {
  113991. name: string;
  113992. shader: string;
  113993. };
  113994. }
  113995. declare module BABYLON {
  113996. /** @hidden */
  113997. export var pbrUboDeclaration: {
  113998. name: string;
  113999. shader: string;
  114000. };
  114001. }
  114002. declare module BABYLON {
  114003. /** @hidden */
  114004. export var pbrFragmentExtraDeclaration: {
  114005. name: string;
  114006. shader: string;
  114007. };
  114008. }
  114009. declare module BABYLON {
  114010. /** @hidden */
  114011. export var pbrFragmentSamplersDeclaration: {
  114012. name: string;
  114013. shader: string;
  114014. };
  114015. }
  114016. declare module BABYLON {
  114017. /** @hidden */
  114018. export var pbrHelperFunctions: {
  114019. name: string;
  114020. shader: string;
  114021. };
  114022. }
  114023. declare module BABYLON {
  114024. /** @hidden */
  114025. export var harmonicsFunctions: {
  114026. name: string;
  114027. shader: string;
  114028. };
  114029. }
  114030. declare module BABYLON {
  114031. /** @hidden */
  114032. export var pbrDirectLightingSetupFunctions: {
  114033. name: string;
  114034. shader: string;
  114035. };
  114036. }
  114037. declare module BABYLON {
  114038. /** @hidden */
  114039. export var pbrDirectLightingFalloffFunctions: {
  114040. name: string;
  114041. shader: string;
  114042. };
  114043. }
  114044. declare module BABYLON {
  114045. /** @hidden */
  114046. export var pbrBRDFFunctions: {
  114047. name: string;
  114048. shader: string;
  114049. };
  114050. }
  114051. declare module BABYLON {
  114052. /** @hidden */
  114053. export var pbrDirectLightingFunctions: {
  114054. name: string;
  114055. shader: string;
  114056. };
  114057. }
  114058. declare module BABYLON {
  114059. /** @hidden */
  114060. export var pbrIBLFunctions: {
  114061. name: string;
  114062. shader: string;
  114063. };
  114064. }
  114065. declare module BABYLON {
  114066. /** @hidden */
  114067. export var pbrDebug: {
  114068. name: string;
  114069. shader: string;
  114070. };
  114071. }
  114072. declare module BABYLON {
  114073. /** @hidden */
  114074. export var pbrPixelShader: {
  114075. name: string;
  114076. shader: string;
  114077. };
  114078. }
  114079. declare module BABYLON {
  114080. /** @hidden */
  114081. export var pbrVertexDeclaration: {
  114082. name: string;
  114083. shader: string;
  114084. };
  114085. }
  114086. declare module BABYLON {
  114087. /** @hidden */
  114088. export var pbrVertexShader: {
  114089. name: string;
  114090. shader: string;
  114091. };
  114092. }
  114093. declare module BABYLON {
  114094. /**
  114095. * Manages the defines for the PBR Material.
  114096. * @hidden
  114097. */
  114098. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  114099. PBR: boolean;
  114100. MAINUV1: boolean;
  114101. MAINUV2: boolean;
  114102. UV1: boolean;
  114103. UV2: boolean;
  114104. ALBEDO: boolean;
  114105. ALBEDODIRECTUV: number;
  114106. VERTEXCOLOR: boolean;
  114107. AMBIENT: boolean;
  114108. AMBIENTDIRECTUV: number;
  114109. AMBIENTINGRAYSCALE: boolean;
  114110. OPACITY: boolean;
  114111. VERTEXALPHA: boolean;
  114112. OPACITYDIRECTUV: number;
  114113. OPACITYRGB: boolean;
  114114. ALPHATEST: boolean;
  114115. DEPTHPREPASS: boolean;
  114116. ALPHABLEND: boolean;
  114117. ALPHAFROMALBEDO: boolean;
  114118. ALPHATESTVALUE: string;
  114119. SPECULAROVERALPHA: boolean;
  114120. RADIANCEOVERALPHA: boolean;
  114121. ALPHAFRESNEL: boolean;
  114122. LINEARALPHAFRESNEL: boolean;
  114123. PREMULTIPLYALPHA: boolean;
  114124. EMISSIVE: boolean;
  114125. EMISSIVEDIRECTUV: number;
  114126. REFLECTIVITY: boolean;
  114127. REFLECTIVITYDIRECTUV: number;
  114128. SPECULARTERM: boolean;
  114129. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  114130. MICROSURFACEAUTOMATIC: boolean;
  114131. LODBASEDMICROSFURACE: boolean;
  114132. MICROSURFACEMAP: boolean;
  114133. MICROSURFACEMAPDIRECTUV: number;
  114134. METALLICWORKFLOW: boolean;
  114135. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  114136. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  114137. METALLNESSSTOREINMETALMAPBLUE: boolean;
  114138. AOSTOREINMETALMAPRED: boolean;
  114139. ENVIRONMENTBRDF: boolean;
  114140. ENVIRONMENTBRDF_RGBD: boolean;
  114141. NORMAL: boolean;
  114142. TANGENT: boolean;
  114143. BUMP: boolean;
  114144. BUMPDIRECTUV: number;
  114145. OBJECTSPACE_NORMALMAP: boolean;
  114146. PARALLAX: boolean;
  114147. PARALLAXOCCLUSION: boolean;
  114148. NORMALXYSCALE: boolean;
  114149. LIGHTMAP: boolean;
  114150. LIGHTMAPDIRECTUV: number;
  114151. USELIGHTMAPASSHADOWMAP: boolean;
  114152. GAMMALIGHTMAP: boolean;
  114153. RGBDLIGHTMAP: boolean;
  114154. REFLECTION: boolean;
  114155. REFLECTIONMAP_3D: boolean;
  114156. REFLECTIONMAP_SPHERICAL: boolean;
  114157. REFLECTIONMAP_PLANAR: boolean;
  114158. REFLECTIONMAP_CUBIC: boolean;
  114159. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  114160. REFLECTIONMAP_PROJECTION: boolean;
  114161. REFLECTIONMAP_SKYBOX: boolean;
  114162. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  114163. REFLECTIONMAP_EXPLICIT: boolean;
  114164. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  114165. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  114166. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  114167. INVERTCUBICMAP: boolean;
  114168. USESPHERICALFROMREFLECTIONMAP: boolean;
  114169. USEIRRADIANCEMAP: boolean;
  114170. SPHERICAL_HARMONICS: boolean;
  114171. USESPHERICALINVERTEX: boolean;
  114172. REFLECTIONMAP_OPPOSITEZ: boolean;
  114173. LODINREFLECTIONALPHA: boolean;
  114174. GAMMAREFLECTION: boolean;
  114175. RGBDREFLECTION: boolean;
  114176. LINEARSPECULARREFLECTION: boolean;
  114177. RADIANCEOCCLUSION: boolean;
  114178. HORIZONOCCLUSION: boolean;
  114179. INSTANCES: boolean;
  114180. NUM_BONE_INFLUENCERS: number;
  114181. BonesPerMesh: number;
  114182. BONETEXTURE: boolean;
  114183. NONUNIFORMSCALING: boolean;
  114184. MORPHTARGETS: boolean;
  114185. MORPHTARGETS_NORMAL: boolean;
  114186. MORPHTARGETS_TANGENT: boolean;
  114187. MORPHTARGETS_UV: boolean;
  114188. NUM_MORPH_INFLUENCERS: number;
  114189. IMAGEPROCESSING: boolean;
  114190. VIGNETTE: boolean;
  114191. VIGNETTEBLENDMODEMULTIPLY: boolean;
  114192. VIGNETTEBLENDMODEOPAQUE: boolean;
  114193. TONEMAPPING: boolean;
  114194. TONEMAPPING_ACES: boolean;
  114195. CONTRAST: boolean;
  114196. COLORCURVES: boolean;
  114197. COLORGRADING: boolean;
  114198. COLORGRADING3D: boolean;
  114199. SAMPLER3DGREENDEPTH: boolean;
  114200. SAMPLER3DBGRMAP: boolean;
  114201. IMAGEPROCESSINGPOSTPROCESS: boolean;
  114202. EXPOSURE: boolean;
  114203. MULTIVIEW: boolean;
  114204. USEPHYSICALLIGHTFALLOFF: boolean;
  114205. USEGLTFLIGHTFALLOFF: boolean;
  114206. TWOSIDEDLIGHTING: boolean;
  114207. SHADOWFLOAT: boolean;
  114208. CLIPPLANE: boolean;
  114209. CLIPPLANE2: boolean;
  114210. CLIPPLANE3: boolean;
  114211. CLIPPLANE4: boolean;
  114212. POINTSIZE: boolean;
  114213. FOG: boolean;
  114214. LOGARITHMICDEPTH: boolean;
  114215. FORCENORMALFORWARD: boolean;
  114216. SPECULARAA: boolean;
  114217. CLEARCOAT: boolean;
  114218. CLEARCOAT_DEFAULTIOR: boolean;
  114219. CLEARCOAT_TEXTURE: boolean;
  114220. CLEARCOAT_TEXTUREDIRECTUV: number;
  114221. CLEARCOAT_BUMP: boolean;
  114222. CLEARCOAT_BUMPDIRECTUV: number;
  114223. CLEARCOAT_TINT: boolean;
  114224. CLEARCOAT_TINT_TEXTURE: boolean;
  114225. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  114226. ANISOTROPIC: boolean;
  114227. ANISOTROPIC_TEXTURE: boolean;
  114228. ANISOTROPIC_TEXTUREDIRECTUV: number;
  114229. BRDF_V_HEIGHT_CORRELATED: boolean;
  114230. MS_BRDF_ENERGY_CONSERVATION: boolean;
  114231. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  114232. SHEEN: boolean;
  114233. SHEEN_TEXTURE: boolean;
  114234. SHEEN_TEXTUREDIRECTUV: number;
  114235. SHEEN_LINKWITHALBEDO: boolean;
  114236. SUBSURFACE: boolean;
  114237. SS_REFRACTION: boolean;
  114238. SS_TRANSLUCENCY: boolean;
  114239. SS_SCATERRING: boolean;
  114240. SS_THICKNESSANDMASK_TEXTURE: boolean;
  114241. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  114242. SS_REFRACTIONMAP_3D: boolean;
  114243. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  114244. SS_LODINREFRACTIONALPHA: boolean;
  114245. SS_GAMMAREFRACTION: boolean;
  114246. SS_RGBDREFRACTION: boolean;
  114247. SS_LINEARSPECULARREFRACTION: boolean;
  114248. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  114249. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  114250. UNLIT: boolean;
  114251. DEBUGMODE: number;
  114252. /**
  114253. * Initializes the PBR Material defines.
  114254. */
  114255. constructor();
  114256. /**
  114257. * Resets the PBR Material defines.
  114258. */
  114259. reset(): void;
  114260. }
  114261. /**
  114262. * The Physically based material base class of BJS.
  114263. *
  114264. * This offers the main features of a standard PBR material.
  114265. * For more information, please refer to the documentation :
  114266. * https://doc.babylonjs.com/how_to/physically_based_rendering
  114267. */
  114268. export abstract class PBRBaseMaterial extends PushMaterial {
  114269. /**
  114270. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  114271. */
  114272. static readonly PBRMATERIAL_OPAQUE: number;
  114273. /**
  114274. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  114275. */
  114276. static readonly PBRMATERIAL_ALPHATEST: number;
  114277. /**
  114278. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  114279. */
  114280. static readonly PBRMATERIAL_ALPHABLEND: number;
  114281. /**
  114282. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  114283. * They are also discarded below the alpha cutoff threshold to improve performances.
  114284. */
  114285. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  114286. /**
  114287. * Defines the default value of how much AO map is occluding the analytical lights
  114288. * (point spot...).
  114289. */
  114290. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  114291. /**
  114292. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  114293. */
  114294. static readonly LIGHTFALLOFF_PHYSICAL: number;
  114295. /**
  114296. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  114297. * to enhance interoperability with other engines.
  114298. */
  114299. static readonly LIGHTFALLOFF_GLTF: number;
  114300. /**
  114301. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  114302. * to enhance interoperability with other materials.
  114303. */
  114304. static readonly LIGHTFALLOFF_STANDARD: number;
  114305. /**
  114306. * Intensity of the direct lights e.g. the four lights available in your scene.
  114307. * This impacts both the direct diffuse and specular highlights.
  114308. */
  114309. protected _directIntensity: number;
  114310. /**
  114311. * Intensity of the emissive part of the material.
  114312. * This helps controlling the emissive effect without modifying the emissive color.
  114313. */
  114314. protected _emissiveIntensity: number;
  114315. /**
  114316. * Intensity of the environment e.g. how much the environment will light the object
  114317. * either through harmonics for rough material or through the refelction for shiny ones.
  114318. */
  114319. protected _environmentIntensity: number;
  114320. /**
  114321. * This is a special control allowing the reduction of the specular highlights coming from the
  114322. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  114323. */
  114324. protected _specularIntensity: number;
  114325. /**
  114326. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  114327. */
  114328. private _lightingInfos;
  114329. /**
  114330. * Debug Control allowing disabling the bump map on this material.
  114331. */
  114332. protected _disableBumpMap: boolean;
  114333. /**
  114334. * AKA Diffuse Texture in standard nomenclature.
  114335. */
  114336. protected _albedoTexture: Nullable<BaseTexture>;
  114337. /**
  114338. * AKA Occlusion Texture in other nomenclature.
  114339. */
  114340. protected _ambientTexture: Nullable<BaseTexture>;
  114341. /**
  114342. * AKA Occlusion Texture Intensity in other nomenclature.
  114343. */
  114344. protected _ambientTextureStrength: number;
  114345. /**
  114346. * Defines how much the AO map is occluding the analytical lights (point spot...).
  114347. * 1 means it completely occludes it
  114348. * 0 mean it has no impact
  114349. */
  114350. protected _ambientTextureImpactOnAnalyticalLights: number;
  114351. /**
  114352. * Stores the alpha values in a texture.
  114353. */
  114354. protected _opacityTexture: Nullable<BaseTexture>;
  114355. /**
  114356. * Stores the reflection values in a texture.
  114357. */
  114358. protected _reflectionTexture: Nullable<BaseTexture>;
  114359. /**
  114360. * Stores the emissive values in a texture.
  114361. */
  114362. protected _emissiveTexture: Nullable<BaseTexture>;
  114363. /**
  114364. * AKA Specular texture in other nomenclature.
  114365. */
  114366. protected _reflectivityTexture: Nullable<BaseTexture>;
  114367. /**
  114368. * Used to switch from specular/glossiness to metallic/roughness workflow.
  114369. */
  114370. protected _metallicTexture: Nullable<BaseTexture>;
  114371. /**
  114372. * Specifies the metallic scalar of the metallic/roughness workflow.
  114373. * Can also be used to scale the metalness values of the metallic texture.
  114374. */
  114375. protected _metallic: Nullable<number>;
  114376. /**
  114377. * Specifies the roughness scalar of the metallic/roughness workflow.
  114378. * Can also be used to scale the roughness values of the metallic texture.
  114379. */
  114380. protected _roughness: Nullable<number>;
  114381. /**
  114382. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  114383. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  114384. */
  114385. protected _microSurfaceTexture: Nullable<BaseTexture>;
  114386. /**
  114387. * Stores surface normal data used to displace a mesh in a texture.
  114388. */
  114389. protected _bumpTexture: Nullable<BaseTexture>;
  114390. /**
  114391. * Stores the pre-calculated light information of a mesh in a texture.
  114392. */
  114393. protected _lightmapTexture: Nullable<BaseTexture>;
  114394. /**
  114395. * The color of a material in ambient lighting.
  114396. */
  114397. protected _ambientColor: Color3;
  114398. /**
  114399. * AKA Diffuse Color in other nomenclature.
  114400. */
  114401. protected _albedoColor: Color3;
  114402. /**
  114403. * AKA Specular Color in other nomenclature.
  114404. */
  114405. protected _reflectivityColor: Color3;
  114406. /**
  114407. * The color applied when light is reflected from a material.
  114408. */
  114409. protected _reflectionColor: Color3;
  114410. /**
  114411. * The color applied when light is emitted from a material.
  114412. */
  114413. protected _emissiveColor: Color3;
  114414. /**
  114415. * AKA Glossiness in other nomenclature.
  114416. */
  114417. protected _microSurface: number;
  114418. /**
  114419. * Specifies that the material will use the light map as a show map.
  114420. */
  114421. protected _useLightmapAsShadowmap: boolean;
  114422. /**
  114423. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  114424. * makes the reflect vector face the model (under horizon).
  114425. */
  114426. protected _useHorizonOcclusion: boolean;
  114427. /**
  114428. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  114429. * too much the area relying on ambient texture to define their ambient occlusion.
  114430. */
  114431. protected _useRadianceOcclusion: boolean;
  114432. /**
  114433. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  114434. */
  114435. protected _useAlphaFromAlbedoTexture: boolean;
  114436. /**
  114437. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  114438. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  114439. */
  114440. protected _useSpecularOverAlpha: boolean;
  114441. /**
  114442. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  114443. */
  114444. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  114445. /**
  114446. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  114447. */
  114448. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  114449. /**
  114450. * Specifies if the metallic texture contains the roughness information in its green channel.
  114451. */
  114452. protected _useRoughnessFromMetallicTextureGreen: boolean;
  114453. /**
  114454. * Specifies if the metallic texture contains the metallness information in its blue channel.
  114455. */
  114456. protected _useMetallnessFromMetallicTextureBlue: boolean;
  114457. /**
  114458. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  114459. */
  114460. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  114461. /**
  114462. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  114463. */
  114464. protected _useAmbientInGrayScale: boolean;
  114465. /**
  114466. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  114467. * The material will try to infer what glossiness each pixel should be.
  114468. */
  114469. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  114470. /**
  114471. * Defines the falloff type used in this material.
  114472. * It by default is Physical.
  114473. */
  114474. protected _lightFalloff: number;
  114475. /**
  114476. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  114477. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  114478. */
  114479. protected _useRadianceOverAlpha: boolean;
  114480. /**
  114481. * Allows using an object space normal map (instead of tangent space).
  114482. */
  114483. protected _useObjectSpaceNormalMap: boolean;
  114484. /**
  114485. * Allows using the bump map in parallax mode.
  114486. */
  114487. protected _useParallax: boolean;
  114488. /**
  114489. * Allows using the bump map in parallax occlusion mode.
  114490. */
  114491. protected _useParallaxOcclusion: boolean;
  114492. /**
  114493. * Controls the scale bias of the parallax mode.
  114494. */
  114495. protected _parallaxScaleBias: number;
  114496. /**
  114497. * If sets to true, disables all the lights affecting the material.
  114498. */
  114499. protected _disableLighting: boolean;
  114500. /**
  114501. * Number of Simultaneous lights allowed on the material.
  114502. */
  114503. protected _maxSimultaneousLights: number;
  114504. /**
  114505. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  114506. */
  114507. protected _invertNormalMapX: boolean;
  114508. /**
  114509. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  114510. */
  114511. protected _invertNormalMapY: boolean;
  114512. /**
  114513. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  114514. */
  114515. protected _twoSidedLighting: boolean;
  114516. /**
  114517. * Defines the alpha limits in alpha test mode.
  114518. */
  114519. protected _alphaCutOff: number;
  114520. /**
  114521. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  114522. */
  114523. protected _forceAlphaTest: boolean;
  114524. /**
  114525. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  114526. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  114527. */
  114528. protected _useAlphaFresnel: boolean;
  114529. /**
  114530. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  114531. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  114532. */
  114533. protected _useLinearAlphaFresnel: boolean;
  114534. /**
  114535. * The transparency mode of the material.
  114536. */
  114537. protected _transparencyMode: Nullable<number>;
  114538. /**
  114539. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  114540. * from cos thetav and roughness:
  114541. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  114542. */
  114543. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  114544. /**
  114545. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  114546. */
  114547. protected _forceIrradianceInFragment: boolean;
  114548. /**
  114549. * Force normal to face away from face.
  114550. */
  114551. protected _forceNormalForward: boolean;
  114552. /**
  114553. * Enables specular anti aliasing in the PBR shader.
  114554. * It will both interacts on the Geometry for analytical and IBL lighting.
  114555. * It also prefilter the roughness map based on the bump values.
  114556. */
  114557. protected _enableSpecularAntiAliasing: boolean;
  114558. /**
  114559. * Default configuration related to image processing available in the PBR Material.
  114560. */
  114561. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  114562. /**
  114563. * Keep track of the image processing observer to allow dispose and replace.
  114564. */
  114565. private _imageProcessingObserver;
  114566. /**
  114567. * Attaches a new image processing configuration to the PBR Material.
  114568. * @param configuration
  114569. */
  114570. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  114571. /**
  114572. * Stores the available render targets.
  114573. */
  114574. private _renderTargets;
  114575. /**
  114576. * Sets the global ambient color for the material used in lighting calculations.
  114577. */
  114578. private _globalAmbientColor;
  114579. /**
  114580. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  114581. */
  114582. private _useLogarithmicDepth;
  114583. /**
  114584. * If set to true, no lighting calculations will be applied.
  114585. */
  114586. private _unlit;
  114587. private _debugMode;
  114588. /**
  114589. * @hidden
  114590. * This is reserved for the inspector.
  114591. * Defines the material debug mode.
  114592. * It helps seeing only some components of the material while troubleshooting.
  114593. */
  114594. debugMode: number;
  114595. /**
  114596. * @hidden
  114597. * This is reserved for the inspector.
  114598. * Specify from where on screen the debug mode should start.
  114599. * The value goes from -1 (full screen) to 1 (not visible)
  114600. * It helps with side by side comparison against the final render
  114601. * This defaults to -1
  114602. */
  114603. private debugLimit;
  114604. /**
  114605. * @hidden
  114606. * This is reserved for the inspector.
  114607. * As the default viewing range might not be enough (if the ambient is really small for instance)
  114608. * You can use the factor to better multiply the final value.
  114609. */
  114610. private debugFactor;
  114611. /**
  114612. * Defines the clear coat layer parameters for the material.
  114613. */
  114614. readonly clearCoat: PBRClearCoatConfiguration;
  114615. /**
  114616. * Defines the anisotropic parameters for the material.
  114617. */
  114618. readonly anisotropy: PBRAnisotropicConfiguration;
  114619. /**
  114620. * Defines the BRDF parameters for the material.
  114621. */
  114622. readonly brdf: PBRBRDFConfiguration;
  114623. /**
  114624. * Defines the Sheen parameters for the material.
  114625. */
  114626. readonly sheen: PBRSheenConfiguration;
  114627. /**
  114628. * Defines the SubSurface parameters for the material.
  114629. */
  114630. readonly subSurface: PBRSubSurfaceConfiguration;
  114631. /**
  114632. * Custom callback helping to override the default shader used in the material.
  114633. */
  114634. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  114635. protected _rebuildInParallel: boolean;
  114636. /**
  114637. * Instantiates a new PBRMaterial instance.
  114638. *
  114639. * @param name The material name
  114640. * @param scene The scene the material will be use in.
  114641. */
  114642. constructor(name: string, scene: Scene);
  114643. /**
  114644. * Gets a boolean indicating that current material needs to register RTT
  114645. */
  114646. readonly hasRenderTargetTextures: boolean;
  114647. /**
  114648. * Gets the name of the material class.
  114649. */
  114650. getClassName(): string;
  114651. /**
  114652. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  114653. */
  114654. /**
  114655. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  114656. */
  114657. useLogarithmicDepth: boolean;
  114658. /**
  114659. * Gets the current transparency mode.
  114660. */
  114661. /**
  114662. * Sets the transparency mode of the material.
  114663. *
  114664. * | Value | Type | Description |
  114665. * | ----- | ----------------------------------- | ----------- |
  114666. * | 0 | OPAQUE | |
  114667. * | 1 | ALPHATEST | |
  114668. * | 2 | ALPHABLEND | |
  114669. * | 3 | ALPHATESTANDBLEND | |
  114670. *
  114671. */
  114672. transparencyMode: Nullable<number>;
  114673. /**
  114674. * Returns true if alpha blending should be disabled.
  114675. */
  114676. private readonly _disableAlphaBlending;
  114677. /**
  114678. * Specifies whether or not this material should be rendered in alpha blend mode.
  114679. */
  114680. needAlphaBlending(): boolean;
  114681. /**
  114682. * Specifies if the mesh will require alpha blending.
  114683. * @param mesh - BJS mesh.
  114684. */
  114685. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  114686. /**
  114687. * Specifies whether or not this material should be rendered in alpha test mode.
  114688. */
  114689. needAlphaTesting(): boolean;
  114690. /**
  114691. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  114692. */
  114693. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  114694. /**
  114695. * Gets the texture used for the alpha test.
  114696. */
  114697. getAlphaTestTexture(): Nullable<BaseTexture>;
  114698. /**
  114699. * Specifies that the submesh is ready to be used.
  114700. * @param mesh - BJS mesh.
  114701. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  114702. * @param useInstances - Specifies that instances should be used.
  114703. * @returns - boolean indicating that the submesh is ready or not.
  114704. */
  114705. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  114706. /**
  114707. * Specifies if the material uses metallic roughness workflow.
  114708. * @returns boolean specifiying if the material uses metallic roughness workflow.
  114709. */
  114710. isMetallicWorkflow(): boolean;
  114711. private _prepareEffect;
  114712. private _prepareDefines;
  114713. /**
  114714. * Force shader compilation
  114715. */
  114716. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  114717. clipPlane: boolean;
  114718. }>): void;
  114719. /**
  114720. * Initializes the uniform buffer layout for the shader.
  114721. */
  114722. buildUniformLayout(): void;
  114723. /**
  114724. * Unbinds the material from the mesh
  114725. */
  114726. unbind(): void;
  114727. /**
  114728. * Binds the submesh data.
  114729. * @param world - The world matrix.
  114730. * @param mesh - The BJS mesh.
  114731. * @param subMesh - A submesh of the BJS mesh.
  114732. */
  114733. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  114734. /**
  114735. * Returns the animatable textures.
  114736. * @returns - Array of animatable textures.
  114737. */
  114738. getAnimatables(): IAnimatable[];
  114739. /**
  114740. * Returns the texture used for reflections.
  114741. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  114742. */
  114743. private _getReflectionTexture;
  114744. /**
  114745. * Returns an array of the actively used textures.
  114746. * @returns - Array of BaseTextures
  114747. */
  114748. getActiveTextures(): BaseTexture[];
  114749. /**
  114750. * Checks to see if a texture is used in the material.
  114751. * @param texture - Base texture to use.
  114752. * @returns - Boolean specifying if a texture is used in the material.
  114753. */
  114754. hasTexture(texture: BaseTexture): boolean;
  114755. /**
  114756. * Disposes the resources of the material.
  114757. * @param forceDisposeEffect - Forces the disposal of effects.
  114758. * @param forceDisposeTextures - Forces the disposal of all textures.
  114759. */
  114760. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  114761. }
  114762. }
  114763. declare module BABYLON {
  114764. /**
  114765. * The Physically based material of BJS.
  114766. *
  114767. * This offers the main features of a standard PBR material.
  114768. * For more information, please refer to the documentation :
  114769. * https://doc.babylonjs.com/how_to/physically_based_rendering
  114770. */
  114771. export class PBRMaterial extends PBRBaseMaterial {
  114772. /**
  114773. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  114774. */
  114775. static readonly PBRMATERIAL_OPAQUE: number;
  114776. /**
  114777. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  114778. */
  114779. static readonly PBRMATERIAL_ALPHATEST: number;
  114780. /**
  114781. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  114782. */
  114783. static readonly PBRMATERIAL_ALPHABLEND: number;
  114784. /**
  114785. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  114786. * They are also discarded below the alpha cutoff threshold to improve performances.
  114787. */
  114788. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  114789. /**
  114790. * Defines the default value of how much AO map is occluding the analytical lights
  114791. * (point spot...).
  114792. */
  114793. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  114794. /**
  114795. * Intensity of the direct lights e.g. the four lights available in your scene.
  114796. * This impacts both the direct diffuse and specular highlights.
  114797. */
  114798. directIntensity: number;
  114799. /**
  114800. * Intensity of the emissive part of the material.
  114801. * This helps controlling the emissive effect without modifying the emissive color.
  114802. */
  114803. emissiveIntensity: number;
  114804. /**
  114805. * Intensity of the environment e.g. how much the environment will light the object
  114806. * either through harmonics for rough material or through the refelction for shiny ones.
  114807. */
  114808. environmentIntensity: number;
  114809. /**
  114810. * This is a special control allowing the reduction of the specular highlights coming from the
  114811. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  114812. */
  114813. specularIntensity: number;
  114814. /**
  114815. * Debug Control allowing disabling the bump map on this material.
  114816. */
  114817. disableBumpMap: boolean;
  114818. /**
  114819. * AKA Diffuse Texture in standard nomenclature.
  114820. */
  114821. albedoTexture: BaseTexture;
  114822. /**
  114823. * AKA Occlusion Texture in other nomenclature.
  114824. */
  114825. ambientTexture: BaseTexture;
  114826. /**
  114827. * AKA Occlusion Texture Intensity in other nomenclature.
  114828. */
  114829. ambientTextureStrength: number;
  114830. /**
  114831. * Defines how much the AO map is occluding the analytical lights (point spot...).
  114832. * 1 means it completely occludes it
  114833. * 0 mean it has no impact
  114834. */
  114835. ambientTextureImpactOnAnalyticalLights: number;
  114836. /**
  114837. * Stores the alpha values in a texture.
  114838. */
  114839. opacityTexture: BaseTexture;
  114840. /**
  114841. * Stores the reflection values in a texture.
  114842. */
  114843. reflectionTexture: Nullable<BaseTexture>;
  114844. /**
  114845. * Stores the emissive values in a texture.
  114846. */
  114847. emissiveTexture: BaseTexture;
  114848. /**
  114849. * AKA Specular texture in other nomenclature.
  114850. */
  114851. reflectivityTexture: BaseTexture;
  114852. /**
  114853. * Used to switch from specular/glossiness to metallic/roughness workflow.
  114854. */
  114855. metallicTexture: BaseTexture;
  114856. /**
  114857. * Specifies the metallic scalar of the metallic/roughness workflow.
  114858. * Can also be used to scale the metalness values of the metallic texture.
  114859. */
  114860. metallic: Nullable<number>;
  114861. /**
  114862. * Specifies the roughness scalar of the metallic/roughness workflow.
  114863. * Can also be used to scale the roughness values of the metallic texture.
  114864. */
  114865. roughness: Nullable<number>;
  114866. /**
  114867. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  114868. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  114869. */
  114870. microSurfaceTexture: BaseTexture;
  114871. /**
  114872. * Stores surface normal data used to displace a mesh in a texture.
  114873. */
  114874. bumpTexture: BaseTexture;
  114875. /**
  114876. * Stores the pre-calculated light information of a mesh in a texture.
  114877. */
  114878. lightmapTexture: BaseTexture;
  114879. /**
  114880. * Stores the refracted light information in a texture.
  114881. */
  114882. refractionTexture: Nullable<BaseTexture>;
  114883. /**
  114884. * The color of a material in ambient lighting.
  114885. */
  114886. ambientColor: Color3;
  114887. /**
  114888. * AKA Diffuse Color in other nomenclature.
  114889. */
  114890. albedoColor: Color3;
  114891. /**
  114892. * AKA Specular Color in other nomenclature.
  114893. */
  114894. reflectivityColor: Color3;
  114895. /**
  114896. * The color reflected from the material.
  114897. */
  114898. reflectionColor: Color3;
  114899. /**
  114900. * The color emitted from the material.
  114901. */
  114902. emissiveColor: Color3;
  114903. /**
  114904. * AKA Glossiness in other nomenclature.
  114905. */
  114906. microSurface: number;
  114907. /**
  114908. * source material index of refraction (IOR)' / 'destination material IOR.
  114909. */
  114910. indexOfRefraction: number;
  114911. /**
  114912. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  114913. */
  114914. invertRefractionY: boolean;
  114915. /**
  114916. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  114917. * Materials half opaque for instance using refraction could benefit from this control.
  114918. */
  114919. linkRefractionWithTransparency: boolean;
  114920. /**
  114921. * If true, the light map contains occlusion information instead of lighting info.
  114922. */
  114923. useLightmapAsShadowmap: boolean;
  114924. /**
  114925. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  114926. */
  114927. useAlphaFromAlbedoTexture: boolean;
  114928. /**
  114929. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  114930. */
  114931. forceAlphaTest: boolean;
  114932. /**
  114933. * Defines the alpha limits in alpha test mode.
  114934. */
  114935. alphaCutOff: number;
  114936. /**
  114937. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  114938. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  114939. */
  114940. useSpecularOverAlpha: boolean;
  114941. /**
  114942. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  114943. */
  114944. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  114945. /**
  114946. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  114947. */
  114948. useRoughnessFromMetallicTextureAlpha: boolean;
  114949. /**
  114950. * Specifies if the metallic texture contains the roughness information in its green channel.
  114951. */
  114952. useRoughnessFromMetallicTextureGreen: boolean;
  114953. /**
  114954. * Specifies if the metallic texture contains the metallness information in its blue channel.
  114955. */
  114956. useMetallnessFromMetallicTextureBlue: boolean;
  114957. /**
  114958. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  114959. */
  114960. useAmbientOcclusionFromMetallicTextureRed: boolean;
  114961. /**
  114962. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  114963. */
  114964. useAmbientInGrayScale: boolean;
  114965. /**
  114966. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  114967. * The material will try to infer what glossiness each pixel should be.
  114968. */
  114969. useAutoMicroSurfaceFromReflectivityMap: boolean;
  114970. /**
  114971. * BJS is using an harcoded light falloff based on a manually sets up range.
  114972. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  114973. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  114974. */
  114975. /**
  114976. * BJS is using an harcoded light falloff based on a manually sets up range.
  114977. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  114978. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  114979. */
  114980. usePhysicalLightFalloff: boolean;
  114981. /**
  114982. * In order to support the falloff compatibility with gltf, a special mode has been added
  114983. * to reproduce the gltf light falloff.
  114984. */
  114985. /**
  114986. * In order to support the falloff compatibility with gltf, a special mode has been added
  114987. * to reproduce the gltf light falloff.
  114988. */
  114989. useGLTFLightFalloff: boolean;
  114990. /**
  114991. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  114992. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  114993. */
  114994. useRadianceOverAlpha: boolean;
  114995. /**
  114996. * Allows using an object space normal map (instead of tangent space).
  114997. */
  114998. useObjectSpaceNormalMap: boolean;
  114999. /**
  115000. * Allows using the bump map in parallax mode.
  115001. */
  115002. useParallax: boolean;
  115003. /**
  115004. * Allows using the bump map in parallax occlusion mode.
  115005. */
  115006. useParallaxOcclusion: boolean;
  115007. /**
  115008. * Controls the scale bias of the parallax mode.
  115009. */
  115010. parallaxScaleBias: number;
  115011. /**
  115012. * If sets to true, disables all the lights affecting the material.
  115013. */
  115014. disableLighting: boolean;
  115015. /**
  115016. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  115017. */
  115018. forceIrradianceInFragment: boolean;
  115019. /**
  115020. * Number of Simultaneous lights allowed on the material.
  115021. */
  115022. maxSimultaneousLights: number;
  115023. /**
  115024. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  115025. */
  115026. invertNormalMapX: boolean;
  115027. /**
  115028. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  115029. */
  115030. invertNormalMapY: boolean;
  115031. /**
  115032. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  115033. */
  115034. twoSidedLighting: boolean;
  115035. /**
  115036. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  115037. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  115038. */
  115039. useAlphaFresnel: boolean;
  115040. /**
  115041. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  115042. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  115043. */
  115044. useLinearAlphaFresnel: boolean;
  115045. /**
  115046. * Let user defines the brdf lookup texture used for IBL.
  115047. * A default 8bit version is embedded but you could point at :
  115048. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  115049. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  115050. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  115051. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  115052. */
  115053. environmentBRDFTexture: Nullable<BaseTexture>;
  115054. /**
  115055. * Force normal to face away from face.
  115056. */
  115057. forceNormalForward: boolean;
  115058. /**
  115059. * Enables specular anti aliasing in the PBR shader.
  115060. * It will both interacts on the Geometry for analytical and IBL lighting.
  115061. * It also prefilter the roughness map based on the bump values.
  115062. */
  115063. enableSpecularAntiAliasing: boolean;
  115064. /**
  115065. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  115066. * makes the reflect vector face the model (under horizon).
  115067. */
  115068. useHorizonOcclusion: boolean;
  115069. /**
  115070. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  115071. * too much the area relying on ambient texture to define their ambient occlusion.
  115072. */
  115073. useRadianceOcclusion: boolean;
  115074. /**
  115075. * If set to true, no lighting calculations will be applied.
  115076. */
  115077. unlit: boolean;
  115078. /**
  115079. * Gets the image processing configuration used either in this material.
  115080. */
  115081. /**
  115082. * Sets the Default image processing configuration used either in the this material.
  115083. *
  115084. * If sets to null, the scene one is in use.
  115085. */
  115086. imageProcessingConfiguration: ImageProcessingConfiguration;
  115087. /**
  115088. * Gets wether the color curves effect is enabled.
  115089. */
  115090. /**
  115091. * Sets wether the color curves effect is enabled.
  115092. */
  115093. cameraColorCurvesEnabled: boolean;
  115094. /**
  115095. * Gets wether the color grading effect is enabled.
  115096. */
  115097. /**
  115098. * Gets wether the color grading effect is enabled.
  115099. */
  115100. cameraColorGradingEnabled: boolean;
  115101. /**
  115102. * Gets wether tonemapping is enabled or not.
  115103. */
  115104. /**
  115105. * Sets wether tonemapping is enabled or not
  115106. */
  115107. cameraToneMappingEnabled: boolean;
  115108. /**
  115109. * The camera exposure used on this material.
  115110. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  115111. * This corresponds to a photographic exposure.
  115112. */
  115113. /**
  115114. * The camera exposure used on this material.
  115115. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  115116. * This corresponds to a photographic exposure.
  115117. */
  115118. cameraExposure: number;
  115119. /**
  115120. * Gets The camera contrast used on this material.
  115121. */
  115122. /**
  115123. * Sets The camera contrast used on this material.
  115124. */
  115125. cameraContrast: number;
  115126. /**
  115127. * Gets the Color Grading 2D Lookup Texture.
  115128. */
  115129. /**
  115130. * Sets the Color Grading 2D Lookup Texture.
  115131. */
  115132. cameraColorGradingTexture: Nullable<BaseTexture>;
  115133. /**
  115134. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  115135. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  115136. * 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;
  115137. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  115138. */
  115139. /**
  115140. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  115141. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  115142. * 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;
  115143. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  115144. */
  115145. cameraColorCurves: Nullable<ColorCurves>;
  115146. /**
  115147. * Instantiates a new PBRMaterial instance.
  115148. *
  115149. * @param name The material name
  115150. * @param scene The scene the material will be use in.
  115151. */
  115152. constructor(name: string, scene: Scene);
  115153. /**
  115154. * Returns the name of this material class.
  115155. */
  115156. getClassName(): string;
  115157. /**
  115158. * Makes a duplicate of the current material.
  115159. * @param name - name to use for the new material.
  115160. */
  115161. clone(name: string): PBRMaterial;
  115162. /**
  115163. * Serializes this PBR Material.
  115164. * @returns - An object with the serialized material.
  115165. */
  115166. serialize(): any;
  115167. /**
  115168. * Parses a PBR Material from a serialized object.
  115169. * @param source - Serialized object.
  115170. * @param scene - BJS scene instance.
  115171. * @param rootUrl - url for the scene object
  115172. * @returns - PBRMaterial
  115173. */
  115174. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  115175. }
  115176. }
  115177. declare module BABYLON {
  115178. /**
  115179. * Direct draw surface info
  115180. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  115181. */
  115182. export interface DDSInfo {
  115183. /**
  115184. * Width of the texture
  115185. */
  115186. width: number;
  115187. /**
  115188. * Width of the texture
  115189. */
  115190. height: number;
  115191. /**
  115192. * Number of Mipmaps for the texture
  115193. * @see https://en.wikipedia.org/wiki/Mipmap
  115194. */
  115195. mipmapCount: number;
  115196. /**
  115197. * If the textures format is a known fourCC format
  115198. * @see https://www.fourcc.org/
  115199. */
  115200. isFourCC: boolean;
  115201. /**
  115202. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  115203. */
  115204. isRGB: boolean;
  115205. /**
  115206. * If the texture is a lumincance format
  115207. */
  115208. isLuminance: boolean;
  115209. /**
  115210. * If this is a cube texture
  115211. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  115212. */
  115213. isCube: boolean;
  115214. /**
  115215. * If the texture is a compressed format eg. FOURCC_DXT1
  115216. */
  115217. isCompressed: boolean;
  115218. /**
  115219. * The dxgiFormat of the texture
  115220. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  115221. */
  115222. dxgiFormat: number;
  115223. /**
  115224. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  115225. */
  115226. textureType: number;
  115227. /**
  115228. * Sphericle polynomial created for the dds texture
  115229. */
  115230. sphericalPolynomial?: SphericalPolynomial;
  115231. }
  115232. /**
  115233. * Class used to provide DDS decompression tools
  115234. */
  115235. export class DDSTools {
  115236. /**
  115237. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  115238. */
  115239. static StoreLODInAlphaChannel: boolean;
  115240. /**
  115241. * Gets DDS information from an array buffer
  115242. * @param arrayBuffer defines the array buffer to read data from
  115243. * @returns the DDS information
  115244. */
  115245. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  115246. private static _FloatView;
  115247. private static _Int32View;
  115248. private static _ToHalfFloat;
  115249. private static _FromHalfFloat;
  115250. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  115251. private static _GetHalfFloatRGBAArrayBuffer;
  115252. private static _GetFloatRGBAArrayBuffer;
  115253. private static _GetFloatAsUIntRGBAArrayBuffer;
  115254. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  115255. private static _GetRGBAArrayBuffer;
  115256. private static _ExtractLongWordOrder;
  115257. private static _GetRGBArrayBuffer;
  115258. private static _GetLuminanceArrayBuffer;
  115259. /**
  115260. * Uploads DDS Levels to a Babylon Texture
  115261. * @hidden
  115262. */
  115263. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  115264. }
  115265. interface ThinEngine {
  115266. /**
  115267. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  115268. * @param rootUrl defines the url where the file to load is located
  115269. * @param scene defines the current scene
  115270. * @param lodScale defines scale to apply to the mip map selection
  115271. * @param lodOffset defines offset to apply to the mip map selection
  115272. * @param onLoad defines an optional callback raised when the texture is loaded
  115273. * @param onError defines an optional callback raised if there is an issue to load the texture
  115274. * @param format defines the format of the data
  115275. * @param forcedExtension defines the extension to use to pick the right loader
  115276. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  115277. * @returns the cube texture as an InternalTexture
  115278. */
  115279. 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;
  115280. }
  115281. }
  115282. declare module BABYLON {
  115283. /**
  115284. * Implementation of the DDS Texture Loader.
  115285. * @hidden
  115286. */
  115287. export class _DDSTextureLoader implements IInternalTextureLoader {
  115288. /**
  115289. * Defines wether the loader supports cascade loading the different faces.
  115290. */
  115291. readonly supportCascades: boolean;
  115292. /**
  115293. * This returns if the loader support the current file information.
  115294. * @param extension defines the file extension of the file being loaded
  115295. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115296. * @param fallback defines the fallback internal texture if any
  115297. * @param isBase64 defines whether the texture is encoded as a base64
  115298. * @param isBuffer defines whether the texture data are stored as a buffer
  115299. * @returns true if the loader can load the specified file
  115300. */
  115301. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  115302. /**
  115303. * Transform the url before loading if required.
  115304. * @param rootUrl the url of the texture
  115305. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115306. * @returns the transformed texture
  115307. */
  115308. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  115309. /**
  115310. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  115311. * @param rootUrl the url of the texture
  115312. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115313. * @returns the fallback texture
  115314. */
  115315. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  115316. /**
  115317. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  115318. * @param data contains the texture data
  115319. * @param texture defines the BabylonJS internal texture
  115320. * @param createPolynomials will be true if polynomials have been requested
  115321. * @param onLoad defines the callback to trigger once the texture is ready
  115322. * @param onError defines the callback to trigger in case of error
  115323. */
  115324. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  115325. /**
  115326. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  115327. * @param data contains the texture data
  115328. * @param texture defines the BabylonJS internal texture
  115329. * @param callback defines the method to call once ready to upload
  115330. */
  115331. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  115332. }
  115333. }
  115334. declare module BABYLON {
  115335. /**
  115336. * Implementation of the ENV Texture Loader.
  115337. * @hidden
  115338. */
  115339. export class _ENVTextureLoader implements IInternalTextureLoader {
  115340. /**
  115341. * Defines wether the loader supports cascade loading the different faces.
  115342. */
  115343. readonly supportCascades: boolean;
  115344. /**
  115345. * This returns if the loader support the current file information.
  115346. * @param extension defines the file extension of the file being loaded
  115347. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115348. * @param fallback defines the fallback internal texture if any
  115349. * @param isBase64 defines whether the texture is encoded as a base64
  115350. * @param isBuffer defines whether the texture data are stored as a buffer
  115351. * @returns true if the loader can load the specified file
  115352. */
  115353. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  115354. /**
  115355. * Transform the url before loading if required.
  115356. * @param rootUrl the url of the texture
  115357. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115358. * @returns the transformed texture
  115359. */
  115360. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  115361. /**
  115362. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  115363. * @param rootUrl the url of the texture
  115364. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115365. * @returns the fallback texture
  115366. */
  115367. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  115368. /**
  115369. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  115370. * @param data contains the texture data
  115371. * @param texture defines the BabylonJS internal texture
  115372. * @param createPolynomials will be true if polynomials have been requested
  115373. * @param onLoad defines the callback to trigger once the texture is ready
  115374. * @param onError defines the callback to trigger in case of error
  115375. */
  115376. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  115377. /**
  115378. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  115379. * @param data contains the texture data
  115380. * @param texture defines the BabylonJS internal texture
  115381. * @param callback defines the method to call once ready to upload
  115382. */
  115383. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  115384. }
  115385. }
  115386. declare module BABYLON {
  115387. /**
  115388. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  115389. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  115390. */
  115391. export class KhronosTextureContainer {
  115392. /** contents of the KTX container file */
  115393. arrayBuffer: any;
  115394. private static HEADER_LEN;
  115395. private static COMPRESSED_2D;
  115396. private static COMPRESSED_3D;
  115397. private static TEX_2D;
  115398. private static TEX_3D;
  115399. /**
  115400. * Gets the openGL type
  115401. */
  115402. glType: number;
  115403. /**
  115404. * Gets the openGL type size
  115405. */
  115406. glTypeSize: number;
  115407. /**
  115408. * Gets the openGL format
  115409. */
  115410. glFormat: number;
  115411. /**
  115412. * Gets the openGL internal format
  115413. */
  115414. glInternalFormat: number;
  115415. /**
  115416. * Gets the base internal format
  115417. */
  115418. glBaseInternalFormat: number;
  115419. /**
  115420. * Gets image width in pixel
  115421. */
  115422. pixelWidth: number;
  115423. /**
  115424. * Gets image height in pixel
  115425. */
  115426. pixelHeight: number;
  115427. /**
  115428. * Gets image depth in pixels
  115429. */
  115430. pixelDepth: number;
  115431. /**
  115432. * Gets the number of array elements
  115433. */
  115434. numberOfArrayElements: number;
  115435. /**
  115436. * Gets the number of faces
  115437. */
  115438. numberOfFaces: number;
  115439. /**
  115440. * Gets the number of mipmap levels
  115441. */
  115442. numberOfMipmapLevels: number;
  115443. /**
  115444. * Gets the bytes of key value data
  115445. */
  115446. bytesOfKeyValueData: number;
  115447. /**
  115448. * Gets the load type
  115449. */
  115450. loadType: number;
  115451. /**
  115452. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  115453. */
  115454. isInvalid: boolean;
  115455. /**
  115456. * Creates a new KhronosTextureContainer
  115457. * @param arrayBuffer contents of the KTX container file
  115458. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  115459. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  115460. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  115461. */
  115462. constructor(
  115463. /** contents of the KTX container file */
  115464. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  115465. /**
  115466. * Uploads KTX content to a Babylon Texture.
  115467. * It is assumed that the texture has already been created & is currently bound
  115468. * @hidden
  115469. */
  115470. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  115471. private _upload2DCompressedLevels;
  115472. }
  115473. }
  115474. declare module BABYLON {
  115475. /**
  115476. * Implementation of the KTX Texture Loader.
  115477. * @hidden
  115478. */
  115479. export class _KTXTextureLoader implements IInternalTextureLoader {
  115480. /**
  115481. * Defines wether the loader supports cascade loading the different faces.
  115482. */
  115483. readonly supportCascades: boolean;
  115484. /**
  115485. * This returns if the loader support the current file information.
  115486. * @param extension defines the file extension of the file being loaded
  115487. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115488. * @param fallback defines the fallback internal texture if any
  115489. * @param isBase64 defines whether the texture is encoded as a base64
  115490. * @param isBuffer defines whether the texture data are stored as a buffer
  115491. * @returns true if the loader can load the specified file
  115492. */
  115493. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  115494. /**
  115495. * Transform the url before loading if required.
  115496. * @param rootUrl the url of the texture
  115497. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115498. * @returns the transformed texture
  115499. */
  115500. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  115501. /**
  115502. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  115503. * @param rootUrl the url of the texture
  115504. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115505. * @returns the fallback texture
  115506. */
  115507. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  115508. /**
  115509. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  115510. * @param data contains the texture data
  115511. * @param texture defines the BabylonJS internal texture
  115512. * @param createPolynomials will be true if polynomials have been requested
  115513. * @param onLoad defines the callback to trigger once the texture is ready
  115514. * @param onError defines the callback to trigger in case of error
  115515. */
  115516. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  115517. /**
  115518. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  115519. * @param data contains the texture data
  115520. * @param texture defines the BabylonJS internal texture
  115521. * @param callback defines the method to call once ready to upload
  115522. */
  115523. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  115524. }
  115525. }
  115526. declare module BABYLON {
  115527. /**
  115528. * Options for the default xr helper
  115529. */
  115530. export class WebXRDefaultExperienceOptions {
  115531. /**
  115532. * Floor meshes that should be used for teleporting
  115533. */
  115534. floorMeshes: Array<AbstractMesh>;
  115535. }
  115536. /**
  115537. * Default experience which provides a similar setup to the previous webVRExperience
  115538. */
  115539. export class WebXRDefaultExperience {
  115540. /**
  115541. * Base experience
  115542. */
  115543. baseExperience: WebXRExperienceHelper;
  115544. /**
  115545. * Input experience extension
  115546. */
  115547. input: WebXRInput;
  115548. /**
  115549. * Loads the controller models
  115550. */
  115551. controllerModelLoader: WebXRControllerModelLoader;
  115552. /**
  115553. * Enables laser pointer and selection
  115554. */
  115555. pointerSelection: WebXRControllerPointerSelection;
  115556. /**
  115557. * Enables teleportation
  115558. */
  115559. teleportation: WebXRControllerTeleportation;
  115560. /**
  115561. * Enables ui for enetering/exiting xr
  115562. */
  115563. enterExitUI: WebXREnterExitUI;
  115564. /**
  115565. * Default output canvas xr should render to
  115566. */
  115567. outputCanvas: WebXRManagedOutputCanvas;
  115568. /**
  115569. * Creates the default xr experience
  115570. * @param scene scene
  115571. * @param options options for basic configuration
  115572. * @returns resulting WebXRDefaultExperience
  115573. */
  115574. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  115575. private constructor();
  115576. /**
  115577. * DIsposes of the experience helper
  115578. */
  115579. dispose(): void;
  115580. }
  115581. }
  115582. declare module BABYLON {
  115583. /** @hidden */
  115584. export var _forceSceneHelpersToBundle: boolean;
  115585. interface Scene {
  115586. /**
  115587. * Creates a default light for the scene.
  115588. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  115589. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  115590. */
  115591. createDefaultLight(replace?: boolean): void;
  115592. /**
  115593. * Creates a default camera for the scene.
  115594. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  115595. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  115596. * @param replace has default false, when true replaces the active camera in the scene
  115597. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  115598. */
  115599. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  115600. /**
  115601. * Creates a default camera and a default light.
  115602. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  115603. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  115604. * @param replace has the default false, when true replaces the active camera/light in the scene
  115605. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  115606. */
  115607. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  115608. /**
  115609. * Creates a new sky box
  115610. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  115611. * @param environmentTexture defines the texture to use as environment texture
  115612. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  115613. * @param scale defines the overall scale of the skybox
  115614. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  115615. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  115616. * @returns a new mesh holding the sky box
  115617. */
  115618. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  115619. /**
  115620. * Creates a new environment
  115621. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  115622. * @param options defines the options you can use to configure the environment
  115623. * @returns the new EnvironmentHelper
  115624. */
  115625. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  115626. /**
  115627. * Creates a new VREXperienceHelper
  115628. * @see http://doc.babylonjs.com/how_to/webvr_helper
  115629. * @param webVROptions defines the options used to create the new VREXperienceHelper
  115630. * @returns a new VREXperienceHelper
  115631. */
  115632. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  115633. /**
  115634. * Creates a new WebXRDefaultExperience
  115635. * @see http://doc.babylonjs.com/how_to/webxr
  115636. * @param options experience options
  115637. * @returns a promise for a new WebXRDefaultExperience
  115638. */
  115639. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  115640. }
  115641. }
  115642. declare module BABYLON {
  115643. /**
  115644. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  115645. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  115646. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  115647. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  115648. */
  115649. export class VideoDome extends TransformNode {
  115650. /**
  115651. * Define the video source as a Monoscopic panoramic 360 video.
  115652. */
  115653. static readonly MODE_MONOSCOPIC: number;
  115654. /**
  115655. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  115656. */
  115657. static readonly MODE_TOPBOTTOM: number;
  115658. /**
  115659. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  115660. */
  115661. static readonly MODE_SIDEBYSIDE: number;
  115662. private _halfDome;
  115663. private _useDirectMapping;
  115664. /**
  115665. * The video texture being displayed on the sphere
  115666. */
  115667. protected _videoTexture: VideoTexture;
  115668. /**
  115669. * Gets the video texture being displayed on the sphere
  115670. */
  115671. readonly videoTexture: VideoTexture;
  115672. /**
  115673. * The skybox material
  115674. */
  115675. protected _material: BackgroundMaterial;
  115676. /**
  115677. * The surface used for the skybox
  115678. */
  115679. protected _mesh: Mesh;
  115680. /**
  115681. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  115682. */
  115683. private _halfDomeMask;
  115684. /**
  115685. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  115686. * Also see the options.resolution property.
  115687. */
  115688. fovMultiplier: number;
  115689. private _videoMode;
  115690. /**
  115691. * Gets or set the current video mode for the video. It can be:
  115692. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  115693. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  115694. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  115695. */
  115696. videoMode: number;
  115697. /**
  115698. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  115699. *
  115700. */
  115701. /**
  115702. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  115703. */
  115704. halfDome: boolean;
  115705. /**
  115706. * Oberserver used in Stereoscopic VR Mode.
  115707. */
  115708. private _onBeforeCameraRenderObserver;
  115709. /**
  115710. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  115711. * @param name Element's name, child elements will append suffixes for their own names.
  115712. * @param urlsOrVideo defines the url(s) or the video element to use
  115713. * @param options An object containing optional or exposed sub element properties
  115714. */
  115715. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  115716. resolution?: number;
  115717. clickToPlay?: boolean;
  115718. autoPlay?: boolean;
  115719. loop?: boolean;
  115720. size?: number;
  115721. poster?: string;
  115722. faceForward?: boolean;
  115723. useDirectMapping?: boolean;
  115724. halfDomeMode?: boolean;
  115725. }, scene: Scene);
  115726. private _changeVideoMode;
  115727. /**
  115728. * Releases resources associated with this node.
  115729. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  115730. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  115731. */
  115732. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  115733. }
  115734. }
  115735. declare module BABYLON {
  115736. /**
  115737. * This class can be used to get instrumentation data from a Babylon engine
  115738. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  115739. */
  115740. export class EngineInstrumentation implements IDisposable {
  115741. /**
  115742. * Define the instrumented engine.
  115743. */
  115744. engine: Engine;
  115745. private _captureGPUFrameTime;
  115746. private _gpuFrameTimeToken;
  115747. private _gpuFrameTime;
  115748. private _captureShaderCompilationTime;
  115749. private _shaderCompilationTime;
  115750. private _onBeginFrameObserver;
  115751. private _onEndFrameObserver;
  115752. private _onBeforeShaderCompilationObserver;
  115753. private _onAfterShaderCompilationObserver;
  115754. /**
  115755. * Gets the perf counter used for GPU frame time
  115756. */
  115757. readonly gpuFrameTimeCounter: PerfCounter;
  115758. /**
  115759. * Gets the GPU frame time capture status
  115760. */
  115761. /**
  115762. * Enable or disable the GPU frame time capture
  115763. */
  115764. captureGPUFrameTime: boolean;
  115765. /**
  115766. * Gets the perf counter used for shader compilation time
  115767. */
  115768. readonly shaderCompilationTimeCounter: PerfCounter;
  115769. /**
  115770. * Gets the shader compilation time capture status
  115771. */
  115772. /**
  115773. * Enable or disable the shader compilation time capture
  115774. */
  115775. captureShaderCompilationTime: boolean;
  115776. /**
  115777. * Instantiates a new engine instrumentation.
  115778. * This class can be used to get instrumentation data from a Babylon engine
  115779. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  115780. * @param engine Defines the engine to instrument
  115781. */
  115782. constructor(
  115783. /**
  115784. * Define the instrumented engine.
  115785. */
  115786. engine: Engine);
  115787. /**
  115788. * Dispose and release associated resources.
  115789. */
  115790. dispose(): void;
  115791. }
  115792. }
  115793. declare module BABYLON {
  115794. /**
  115795. * This class can be used to get instrumentation data from a Babylon engine
  115796. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  115797. */
  115798. export class SceneInstrumentation implements IDisposable {
  115799. /**
  115800. * Defines the scene to instrument
  115801. */
  115802. scene: Scene;
  115803. private _captureActiveMeshesEvaluationTime;
  115804. private _activeMeshesEvaluationTime;
  115805. private _captureRenderTargetsRenderTime;
  115806. private _renderTargetsRenderTime;
  115807. private _captureFrameTime;
  115808. private _frameTime;
  115809. private _captureRenderTime;
  115810. private _renderTime;
  115811. private _captureInterFrameTime;
  115812. private _interFrameTime;
  115813. private _captureParticlesRenderTime;
  115814. private _particlesRenderTime;
  115815. private _captureSpritesRenderTime;
  115816. private _spritesRenderTime;
  115817. private _capturePhysicsTime;
  115818. private _physicsTime;
  115819. private _captureAnimationsTime;
  115820. private _animationsTime;
  115821. private _captureCameraRenderTime;
  115822. private _cameraRenderTime;
  115823. private _onBeforeActiveMeshesEvaluationObserver;
  115824. private _onAfterActiveMeshesEvaluationObserver;
  115825. private _onBeforeRenderTargetsRenderObserver;
  115826. private _onAfterRenderTargetsRenderObserver;
  115827. private _onAfterRenderObserver;
  115828. private _onBeforeDrawPhaseObserver;
  115829. private _onAfterDrawPhaseObserver;
  115830. private _onBeforeAnimationsObserver;
  115831. private _onBeforeParticlesRenderingObserver;
  115832. private _onAfterParticlesRenderingObserver;
  115833. private _onBeforeSpritesRenderingObserver;
  115834. private _onAfterSpritesRenderingObserver;
  115835. private _onBeforePhysicsObserver;
  115836. private _onAfterPhysicsObserver;
  115837. private _onAfterAnimationsObserver;
  115838. private _onBeforeCameraRenderObserver;
  115839. private _onAfterCameraRenderObserver;
  115840. /**
  115841. * Gets the perf counter used for active meshes evaluation time
  115842. */
  115843. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  115844. /**
  115845. * Gets the active meshes evaluation time capture status
  115846. */
  115847. /**
  115848. * Enable or disable the active meshes evaluation time capture
  115849. */
  115850. captureActiveMeshesEvaluationTime: boolean;
  115851. /**
  115852. * Gets the perf counter used for render targets render time
  115853. */
  115854. readonly renderTargetsRenderTimeCounter: PerfCounter;
  115855. /**
  115856. * Gets the render targets render time capture status
  115857. */
  115858. /**
  115859. * Enable or disable the render targets render time capture
  115860. */
  115861. captureRenderTargetsRenderTime: boolean;
  115862. /**
  115863. * Gets the perf counter used for particles render time
  115864. */
  115865. readonly particlesRenderTimeCounter: PerfCounter;
  115866. /**
  115867. * Gets the particles render time capture status
  115868. */
  115869. /**
  115870. * Enable or disable the particles render time capture
  115871. */
  115872. captureParticlesRenderTime: boolean;
  115873. /**
  115874. * Gets the perf counter used for sprites render time
  115875. */
  115876. readonly spritesRenderTimeCounter: PerfCounter;
  115877. /**
  115878. * Gets the sprites render time capture status
  115879. */
  115880. /**
  115881. * Enable or disable the sprites render time capture
  115882. */
  115883. captureSpritesRenderTime: boolean;
  115884. /**
  115885. * Gets the perf counter used for physics time
  115886. */
  115887. readonly physicsTimeCounter: PerfCounter;
  115888. /**
  115889. * Gets the physics time capture status
  115890. */
  115891. /**
  115892. * Enable or disable the physics time capture
  115893. */
  115894. capturePhysicsTime: boolean;
  115895. /**
  115896. * Gets the perf counter used for animations time
  115897. */
  115898. readonly animationsTimeCounter: PerfCounter;
  115899. /**
  115900. * Gets the animations time capture status
  115901. */
  115902. /**
  115903. * Enable or disable the animations time capture
  115904. */
  115905. captureAnimationsTime: boolean;
  115906. /**
  115907. * Gets the perf counter used for frame time capture
  115908. */
  115909. readonly frameTimeCounter: PerfCounter;
  115910. /**
  115911. * Gets the frame time capture status
  115912. */
  115913. /**
  115914. * Enable or disable the frame time capture
  115915. */
  115916. captureFrameTime: boolean;
  115917. /**
  115918. * Gets the perf counter used for inter-frames time capture
  115919. */
  115920. readonly interFrameTimeCounter: PerfCounter;
  115921. /**
  115922. * Gets the inter-frames time capture status
  115923. */
  115924. /**
  115925. * Enable or disable the inter-frames time capture
  115926. */
  115927. captureInterFrameTime: boolean;
  115928. /**
  115929. * Gets the perf counter used for render time capture
  115930. */
  115931. readonly renderTimeCounter: PerfCounter;
  115932. /**
  115933. * Gets the render time capture status
  115934. */
  115935. /**
  115936. * Enable or disable the render time capture
  115937. */
  115938. captureRenderTime: boolean;
  115939. /**
  115940. * Gets the perf counter used for camera render time capture
  115941. */
  115942. readonly cameraRenderTimeCounter: PerfCounter;
  115943. /**
  115944. * Gets the camera render time capture status
  115945. */
  115946. /**
  115947. * Enable or disable the camera render time capture
  115948. */
  115949. captureCameraRenderTime: boolean;
  115950. /**
  115951. * Gets the perf counter used for draw calls
  115952. */
  115953. readonly drawCallsCounter: PerfCounter;
  115954. /**
  115955. * Instantiates a new scene instrumentation.
  115956. * This class can be used to get instrumentation data from a Babylon engine
  115957. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  115958. * @param scene Defines the scene to instrument
  115959. */
  115960. constructor(
  115961. /**
  115962. * Defines the scene to instrument
  115963. */
  115964. scene: Scene);
  115965. /**
  115966. * Dispose and release associated resources.
  115967. */
  115968. dispose(): void;
  115969. }
  115970. }
  115971. declare module BABYLON {
  115972. /** @hidden */
  115973. export var glowMapGenerationPixelShader: {
  115974. name: string;
  115975. shader: string;
  115976. };
  115977. }
  115978. declare module BABYLON {
  115979. /** @hidden */
  115980. export var glowMapGenerationVertexShader: {
  115981. name: string;
  115982. shader: string;
  115983. };
  115984. }
  115985. declare module BABYLON {
  115986. /**
  115987. * Effect layer options. This helps customizing the behaviour
  115988. * of the effect layer.
  115989. */
  115990. export interface IEffectLayerOptions {
  115991. /**
  115992. * Multiplication factor apply to the canvas size to compute the render target size
  115993. * used to generated the objects (the smaller the faster).
  115994. */
  115995. mainTextureRatio: number;
  115996. /**
  115997. * Enforces a fixed size texture to ensure effect stability across devices.
  115998. */
  115999. mainTextureFixedSize?: number;
  116000. /**
  116001. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  116002. */
  116003. alphaBlendingMode: number;
  116004. /**
  116005. * The camera attached to the layer.
  116006. */
  116007. camera: Nullable<Camera>;
  116008. /**
  116009. * The rendering group to draw the layer in.
  116010. */
  116011. renderingGroupId: number;
  116012. }
  116013. /**
  116014. * The effect layer Helps adding post process effect blended with the main pass.
  116015. *
  116016. * This can be for instance use to generate glow or higlight effects on the scene.
  116017. *
  116018. * The effect layer class can not be used directly and is intented to inherited from to be
  116019. * customized per effects.
  116020. */
  116021. export abstract class EffectLayer {
  116022. private _vertexBuffers;
  116023. private _indexBuffer;
  116024. private _cachedDefines;
  116025. private _effectLayerMapGenerationEffect;
  116026. private _effectLayerOptions;
  116027. private _mergeEffect;
  116028. protected _scene: Scene;
  116029. protected _engine: Engine;
  116030. protected _maxSize: number;
  116031. protected _mainTextureDesiredSize: ISize;
  116032. protected _mainTexture: RenderTargetTexture;
  116033. protected _shouldRender: boolean;
  116034. protected _postProcesses: PostProcess[];
  116035. protected _textures: BaseTexture[];
  116036. protected _emissiveTextureAndColor: {
  116037. texture: Nullable<BaseTexture>;
  116038. color: Color4;
  116039. };
  116040. /**
  116041. * The name of the layer
  116042. */
  116043. name: string;
  116044. /**
  116045. * The clear color of the texture used to generate the glow map.
  116046. */
  116047. neutralColor: Color4;
  116048. /**
  116049. * Specifies wether the highlight layer is enabled or not.
  116050. */
  116051. isEnabled: boolean;
  116052. /**
  116053. * Gets the camera attached to the layer.
  116054. */
  116055. readonly camera: Nullable<Camera>;
  116056. /**
  116057. * Gets the rendering group id the layer should render in.
  116058. */
  116059. renderingGroupId: number;
  116060. /**
  116061. * An event triggered when the effect layer has been disposed.
  116062. */
  116063. onDisposeObservable: Observable<EffectLayer>;
  116064. /**
  116065. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  116066. */
  116067. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  116068. /**
  116069. * An event triggered when the generated texture is being merged in the scene.
  116070. */
  116071. onBeforeComposeObservable: Observable<EffectLayer>;
  116072. /**
  116073. * An event triggered when the generated texture has been merged in the scene.
  116074. */
  116075. onAfterComposeObservable: Observable<EffectLayer>;
  116076. /**
  116077. * An event triggered when the efffect layer changes its size.
  116078. */
  116079. onSizeChangedObservable: Observable<EffectLayer>;
  116080. /** @hidden */
  116081. static _SceneComponentInitialization: (scene: Scene) => void;
  116082. /**
  116083. * Instantiates a new effect Layer and references it in the scene.
  116084. * @param name The name of the layer
  116085. * @param scene The scene to use the layer in
  116086. */
  116087. constructor(
  116088. /** The Friendly of the effect in the scene */
  116089. name: string, scene: Scene);
  116090. /**
  116091. * Get the effect name of the layer.
  116092. * @return The effect name
  116093. */
  116094. abstract getEffectName(): string;
  116095. /**
  116096. * Checks for the readiness of the element composing the layer.
  116097. * @param subMesh the mesh to check for
  116098. * @param useInstances specify wether or not to use instances to render the mesh
  116099. * @return true if ready otherwise, false
  116100. */
  116101. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  116102. /**
  116103. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  116104. * @returns true if the effect requires stencil during the main canvas render pass.
  116105. */
  116106. abstract needStencil(): boolean;
  116107. /**
  116108. * Create the merge effect. This is the shader use to blit the information back
  116109. * to the main canvas at the end of the scene rendering.
  116110. * @returns The effect containing the shader used to merge the effect on the main canvas
  116111. */
  116112. protected abstract _createMergeEffect(): Effect;
  116113. /**
  116114. * Creates the render target textures and post processes used in the effect layer.
  116115. */
  116116. protected abstract _createTextureAndPostProcesses(): void;
  116117. /**
  116118. * Implementation specific of rendering the generating effect on the main canvas.
  116119. * @param effect The effect used to render through
  116120. */
  116121. protected abstract _internalRender(effect: Effect): void;
  116122. /**
  116123. * Sets the required values for both the emissive texture and and the main color.
  116124. */
  116125. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  116126. /**
  116127. * Free any resources and references associated to a mesh.
  116128. * Internal use
  116129. * @param mesh The mesh to free.
  116130. */
  116131. abstract _disposeMesh(mesh: Mesh): void;
  116132. /**
  116133. * Serializes this layer (Glow or Highlight for example)
  116134. * @returns a serialized layer object
  116135. */
  116136. abstract serialize?(): any;
  116137. /**
  116138. * Initializes the effect layer with the required options.
  116139. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  116140. */
  116141. protected _init(options: Partial<IEffectLayerOptions>): void;
  116142. /**
  116143. * Generates the index buffer of the full screen quad blending to the main canvas.
  116144. */
  116145. private _generateIndexBuffer;
  116146. /**
  116147. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  116148. */
  116149. private _generateVertexBuffer;
  116150. /**
  116151. * Sets the main texture desired size which is the closest power of two
  116152. * of the engine canvas size.
  116153. */
  116154. private _setMainTextureSize;
  116155. /**
  116156. * Creates the main texture for the effect layer.
  116157. */
  116158. protected _createMainTexture(): void;
  116159. /**
  116160. * Adds specific effects defines.
  116161. * @param defines The defines to add specifics to.
  116162. */
  116163. protected _addCustomEffectDefines(defines: string[]): void;
  116164. /**
  116165. * Checks for the readiness of the element composing the layer.
  116166. * @param subMesh the mesh to check for
  116167. * @param useInstances specify wether or not to use instances to render the mesh
  116168. * @param emissiveTexture the associated emissive texture used to generate the glow
  116169. * @return true if ready otherwise, false
  116170. */
  116171. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  116172. /**
  116173. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  116174. */
  116175. render(): void;
  116176. /**
  116177. * Determine if a given mesh will be used in the current effect.
  116178. * @param mesh mesh to test
  116179. * @returns true if the mesh will be used
  116180. */
  116181. hasMesh(mesh: AbstractMesh): boolean;
  116182. /**
  116183. * Returns true if the layer contains information to display, otherwise false.
  116184. * @returns true if the glow layer should be rendered
  116185. */
  116186. shouldRender(): boolean;
  116187. /**
  116188. * Returns true if the mesh should render, otherwise false.
  116189. * @param mesh The mesh to render
  116190. * @returns true if it should render otherwise false
  116191. */
  116192. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  116193. /**
  116194. * Returns true if the mesh can be rendered, otherwise false.
  116195. * @param mesh The mesh to render
  116196. * @param material The material used on the mesh
  116197. * @returns true if it can be rendered otherwise false
  116198. */
  116199. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  116200. /**
  116201. * Returns true if the mesh should render, otherwise false.
  116202. * @param mesh The mesh to render
  116203. * @returns true if it should render otherwise false
  116204. */
  116205. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  116206. /**
  116207. * Renders the submesh passed in parameter to the generation map.
  116208. */
  116209. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  116210. /**
  116211. * Rebuild the required buffers.
  116212. * @hidden Internal use only.
  116213. */
  116214. _rebuild(): void;
  116215. /**
  116216. * Dispose only the render target textures and post process.
  116217. */
  116218. private _disposeTextureAndPostProcesses;
  116219. /**
  116220. * Dispose the highlight layer and free resources.
  116221. */
  116222. dispose(): void;
  116223. /**
  116224. * Gets the class name of the effect layer
  116225. * @returns the string with the class name of the effect layer
  116226. */
  116227. getClassName(): string;
  116228. /**
  116229. * Creates an effect layer from parsed effect layer data
  116230. * @param parsedEffectLayer defines effect layer data
  116231. * @param scene defines the current scene
  116232. * @param rootUrl defines the root URL containing the effect layer information
  116233. * @returns a parsed effect Layer
  116234. */
  116235. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  116236. }
  116237. }
  116238. declare module BABYLON {
  116239. interface AbstractScene {
  116240. /**
  116241. * The list of effect layers (highlights/glow) added to the scene
  116242. * @see http://doc.babylonjs.com/how_to/highlight_layer
  116243. * @see http://doc.babylonjs.com/how_to/glow_layer
  116244. */
  116245. effectLayers: Array<EffectLayer>;
  116246. /**
  116247. * Removes the given effect layer from this scene.
  116248. * @param toRemove defines the effect layer to remove
  116249. * @returns the index of the removed effect layer
  116250. */
  116251. removeEffectLayer(toRemove: EffectLayer): number;
  116252. /**
  116253. * Adds the given effect layer to this scene
  116254. * @param newEffectLayer defines the effect layer to add
  116255. */
  116256. addEffectLayer(newEffectLayer: EffectLayer): void;
  116257. }
  116258. /**
  116259. * Defines the layer scene component responsible to manage any effect layers
  116260. * in a given scene.
  116261. */
  116262. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  116263. /**
  116264. * The component name helpfull to identify the component in the list of scene components.
  116265. */
  116266. readonly name: string;
  116267. /**
  116268. * The scene the component belongs to.
  116269. */
  116270. scene: Scene;
  116271. private _engine;
  116272. private _renderEffects;
  116273. private _needStencil;
  116274. private _previousStencilState;
  116275. /**
  116276. * Creates a new instance of the component for the given scene
  116277. * @param scene Defines the scene to register the component in
  116278. */
  116279. constructor(scene: Scene);
  116280. /**
  116281. * Registers the component in a given scene
  116282. */
  116283. register(): void;
  116284. /**
  116285. * Rebuilds the elements related to this component in case of
  116286. * context lost for instance.
  116287. */
  116288. rebuild(): void;
  116289. /**
  116290. * Serializes the component data to the specified json object
  116291. * @param serializationObject The object to serialize to
  116292. */
  116293. serialize(serializationObject: any): void;
  116294. /**
  116295. * Adds all the elements from the container to the scene
  116296. * @param container the container holding the elements
  116297. */
  116298. addFromContainer(container: AbstractScene): void;
  116299. /**
  116300. * Removes all the elements in the container from the scene
  116301. * @param container contains the elements to remove
  116302. * @param dispose if the removed element should be disposed (default: false)
  116303. */
  116304. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  116305. /**
  116306. * Disposes the component and the associated ressources.
  116307. */
  116308. dispose(): void;
  116309. private _isReadyForMesh;
  116310. private _renderMainTexture;
  116311. private _setStencil;
  116312. private _setStencilBack;
  116313. private _draw;
  116314. private _drawCamera;
  116315. private _drawRenderingGroup;
  116316. }
  116317. }
  116318. declare module BABYLON {
  116319. /** @hidden */
  116320. export var glowMapMergePixelShader: {
  116321. name: string;
  116322. shader: string;
  116323. };
  116324. }
  116325. declare module BABYLON {
  116326. /** @hidden */
  116327. export var glowMapMergeVertexShader: {
  116328. name: string;
  116329. shader: string;
  116330. };
  116331. }
  116332. declare module BABYLON {
  116333. interface AbstractScene {
  116334. /**
  116335. * Return a the first highlight layer of the scene with a given name.
  116336. * @param name The name of the highlight layer to look for.
  116337. * @return The highlight layer if found otherwise null.
  116338. */
  116339. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  116340. }
  116341. /**
  116342. * Glow layer options. This helps customizing the behaviour
  116343. * of the glow layer.
  116344. */
  116345. export interface IGlowLayerOptions {
  116346. /**
  116347. * Multiplication factor apply to the canvas size to compute the render target size
  116348. * used to generated the glowing objects (the smaller the faster).
  116349. */
  116350. mainTextureRatio: number;
  116351. /**
  116352. * Enforces a fixed size texture to ensure resize independant blur.
  116353. */
  116354. mainTextureFixedSize?: number;
  116355. /**
  116356. * How big is the kernel of the blur texture.
  116357. */
  116358. blurKernelSize: number;
  116359. /**
  116360. * The camera attached to the layer.
  116361. */
  116362. camera: Nullable<Camera>;
  116363. /**
  116364. * Enable MSAA by chosing the number of samples.
  116365. */
  116366. mainTextureSamples?: number;
  116367. /**
  116368. * The rendering group to draw the layer in.
  116369. */
  116370. renderingGroupId: number;
  116371. }
  116372. /**
  116373. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  116374. *
  116375. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  116376. * glowy meshes to your scene.
  116377. *
  116378. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  116379. */
  116380. export class GlowLayer extends EffectLayer {
  116381. /**
  116382. * Effect Name of the layer.
  116383. */
  116384. static readonly EffectName: string;
  116385. /**
  116386. * The default blur kernel size used for the glow.
  116387. */
  116388. static DefaultBlurKernelSize: number;
  116389. /**
  116390. * The default texture size ratio used for the glow.
  116391. */
  116392. static DefaultTextureRatio: number;
  116393. /**
  116394. * Sets the kernel size of the blur.
  116395. */
  116396. /**
  116397. * Gets the kernel size of the blur.
  116398. */
  116399. blurKernelSize: number;
  116400. /**
  116401. * Sets the glow intensity.
  116402. */
  116403. /**
  116404. * Gets the glow intensity.
  116405. */
  116406. intensity: number;
  116407. private _options;
  116408. private _intensity;
  116409. private _horizontalBlurPostprocess1;
  116410. private _verticalBlurPostprocess1;
  116411. private _horizontalBlurPostprocess2;
  116412. private _verticalBlurPostprocess2;
  116413. private _blurTexture1;
  116414. private _blurTexture2;
  116415. private _postProcesses1;
  116416. private _postProcesses2;
  116417. private _includedOnlyMeshes;
  116418. private _excludedMeshes;
  116419. /**
  116420. * Callback used to let the user override the color selection on a per mesh basis
  116421. */
  116422. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  116423. /**
  116424. * Callback used to let the user override the texture selection on a per mesh basis
  116425. */
  116426. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  116427. /**
  116428. * Instantiates a new glow Layer and references it to the scene.
  116429. * @param name The name of the layer
  116430. * @param scene The scene to use the layer in
  116431. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  116432. */
  116433. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  116434. /**
  116435. * Get the effect name of the layer.
  116436. * @return The effect name
  116437. */
  116438. getEffectName(): string;
  116439. /**
  116440. * Create the merge effect. This is the shader use to blit the information back
  116441. * to the main canvas at the end of the scene rendering.
  116442. */
  116443. protected _createMergeEffect(): Effect;
  116444. /**
  116445. * Creates the render target textures and post processes used in the glow layer.
  116446. */
  116447. protected _createTextureAndPostProcesses(): void;
  116448. /**
  116449. * Checks for the readiness of the element composing the layer.
  116450. * @param subMesh the mesh to check for
  116451. * @param useInstances specify wether or not to use instances to render the mesh
  116452. * @param emissiveTexture the associated emissive texture used to generate the glow
  116453. * @return true if ready otherwise, false
  116454. */
  116455. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  116456. /**
  116457. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  116458. */
  116459. needStencil(): boolean;
  116460. /**
  116461. * Returns true if the mesh can be rendered, otherwise false.
  116462. * @param mesh The mesh to render
  116463. * @param material The material used on the mesh
  116464. * @returns true if it can be rendered otherwise false
  116465. */
  116466. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  116467. /**
  116468. * Implementation specific of rendering the generating effect on the main canvas.
  116469. * @param effect The effect used to render through
  116470. */
  116471. protected _internalRender(effect: Effect): void;
  116472. /**
  116473. * Sets the required values for both the emissive texture and and the main color.
  116474. */
  116475. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  116476. /**
  116477. * Returns true if the mesh should render, otherwise false.
  116478. * @param mesh The mesh to render
  116479. * @returns true if it should render otherwise false
  116480. */
  116481. protected _shouldRenderMesh(mesh: Mesh): boolean;
  116482. /**
  116483. * Adds specific effects defines.
  116484. * @param defines The defines to add specifics to.
  116485. */
  116486. protected _addCustomEffectDefines(defines: string[]): void;
  116487. /**
  116488. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  116489. * @param mesh The mesh to exclude from the glow layer
  116490. */
  116491. addExcludedMesh(mesh: Mesh): void;
  116492. /**
  116493. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  116494. * @param mesh The mesh to remove
  116495. */
  116496. removeExcludedMesh(mesh: Mesh): void;
  116497. /**
  116498. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  116499. * @param mesh The mesh to include in the glow layer
  116500. */
  116501. addIncludedOnlyMesh(mesh: Mesh): void;
  116502. /**
  116503. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  116504. * @param mesh The mesh to remove
  116505. */
  116506. removeIncludedOnlyMesh(mesh: Mesh): void;
  116507. /**
  116508. * Determine if a given mesh will be used in the glow layer
  116509. * @param mesh The mesh to test
  116510. * @returns true if the mesh will be highlighted by the current glow layer
  116511. */
  116512. hasMesh(mesh: AbstractMesh): boolean;
  116513. /**
  116514. * Free any resources and references associated to a mesh.
  116515. * Internal use
  116516. * @param mesh The mesh to free.
  116517. * @hidden
  116518. */
  116519. _disposeMesh(mesh: Mesh): void;
  116520. /**
  116521. * Gets the class name of the effect layer
  116522. * @returns the string with the class name of the effect layer
  116523. */
  116524. getClassName(): string;
  116525. /**
  116526. * Serializes this glow layer
  116527. * @returns a serialized glow layer object
  116528. */
  116529. serialize(): any;
  116530. /**
  116531. * Creates a Glow Layer from parsed glow layer data
  116532. * @param parsedGlowLayer defines glow layer data
  116533. * @param scene defines the current scene
  116534. * @param rootUrl defines the root URL containing the glow layer information
  116535. * @returns a parsed Glow Layer
  116536. */
  116537. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  116538. }
  116539. }
  116540. declare module BABYLON {
  116541. /** @hidden */
  116542. export var glowBlurPostProcessPixelShader: {
  116543. name: string;
  116544. shader: string;
  116545. };
  116546. }
  116547. declare module BABYLON {
  116548. interface AbstractScene {
  116549. /**
  116550. * Return a the first highlight layer of the scene with a given name.
  116551. * @param name The name of the highlight layer to look for.
  116552. * @return The highlight layer if found otherwise null.
  116553. */
  116554. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  116555. }
  116556. /**
  116557. * Highlight layer options. This helps customizing the behaviour
  116558. * of the highlight layer.
  116559. */
  116560. export interface IHighlightLayerOptions {
  116561. /**
  116562. * Multiplication factor apply to the canvas size to compute the render target size
  116563. * used to generated the glowing objects (the smaller the faster).
  116564. */
  116565. mainTextureRatio: number;
  116566. /**
  116567. * Enforces a fixed size texture to ensure resize independant blur.
  116568. */
  116569. mainTextureFixedSize?: number;
  116570. /**
  116571. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  116572. * of the picture to blur (the smaller the faster).
  116573. */
  116574. blurTextureSizeRatio: number;
  116575. /**
  116576. * How big in texel of the blur texture is the vertical blur.
  116577. */
  116578. blurVerticalSize: number;
  116579. /**
  116580. * How big in texel of the blur texture is the horizontal blur.
  116581. */
  116582. blurHorizontalSize: number;
  116583. /**
  116584. * Alpha blending mode used to apply the blur. Default is combine.
  116585. */
  116586. alphaBlendingMode: number;
  116587. /**
  116588. * The camera attached to the layer.
  116589. */
  116590. camera: Nullable<Camera>;
  116591. /**
  116592. * Should we display highlight as a solid stroke?
  116593. */
  116594. isStroke?: boolean;
  116595. /**
  116596. * The rendering group to draw the layer in.
  116597. */
  116598. renderingGroupId: number;
  116599. }
  116600. /**
  116601. * The highlight layer Helps adding a glow effect around a mesh.
  116602. *
  116603. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  116604. * glowy meshes to your scene.
  116605. *
  116606. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  116607. */
  116608. export class HighlightLayer extends EffectLayer {
  116609. name: string;
  116610. /**
  116611. * Effect Name of the highlight layer.
  116612. */
  116613. static readonly EffectName: string;
  116614. /**
  116615. * The neutral color used during the preparation of the glow effect.
  116616. * This is black by default as the blend operation is a blend operation.
  116617. */
  116618. static NeutralColor: Color4;
  116619. /**
  116620. * Stencil value used for glowing meshes.
  116621. */
  116622. static GlowingMeshStencilReference: number;
  116623. /**
  116624. * Stencil value used for the other meshes in the scene.
  116625. */
  116626. static NormalMeshStencilReference: number;
  116627. /**
  116628. * Specifies whether or not the inner glow is ACTIVE in the layer.
  116629. */
  116630. innerGlow: boolean;
  116631. /**
  116632. * Specifies whether or not the outer glow is ACTIVE in the layer.
  116633. */
  116634. outerGlow: boolean;
  116635. /**
  116636. * Specifies the horizontal size of the blur.
  116637. */
  116638. /**
  116639. * Gets the horizontal size of the blur.
  116640. */
  116641. blurHorizontalSize: number;
  116642. /**
  116643. * Specifies the vertical size of the blur.
  116644. */
  116645. /**
  116646. * Gets the vertical size of the blur.
  116647. */
  116648. blurVerticalSize: number;
  116649. /**
  116650. * An event triggered when the highlight layer is being blurred.
  116651. */
  116652. onBeforeBlurObservable: Observable<HighlightLayer>;
  116653. /**
  116654. * An event triggered when the highlight layer has been blurred.
  116655. */
  116656. onAfterBlurObservable: Observable<HighlightLayer>;
  116657. private _instanceGlowingMeshStencilReference;
  116658. private _options;
  116659. private _downSamplePostprocess;
  116660. private _horizontalBlurPostprocess;
  116661. private _verticalBlurPostprocess;
  116662. private _blurTexture;
  116663. private _meshes;
  116664. private _excludedMeshes;
  116665. /**
  116666. * Instantiates a new highlight Layer and references it to the scene..
  116667. * @param name The name of the layer
  116668. * @param scene The scene to use the layer in
  116669. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  116670. */
  116671. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  116672. /**
  116673. * Get the effect name of the layer.
  116674. * @return The effect name
  116675. */
  116676. getEffectName(): string;
  116677. /**
  116678. * Create the merge effect. This is the shader use to blit the information back
  116679. * to the main canvas at the end of the scene rendering.
  116680. */
  116681. protected _createMergeEffect(): Effect;
  116682. /**
  116683. * Creates the render target textures and post processes used in the highlight layer.
  116684. */
  116685. protected _createTextureAndPostProcesses(): void;
  116686. /**
  116687. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  116688. */
  116689. needStencil(): boolean;
  116690. /**
  116691. * Checks for the readiness of the element composing the layer.
  116692. * @param subMesh the mesh to check for
  116693. * @param useInstances specify wether or not to use instances to render the mesh
  116694. * @param emissiveTexture the associated emissive texture used to generate the glow
  116695. * @return true if ready otherwise, false
  116696. */
  116697. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  116698. /**
  116699. * Implementation specific of rendering the generating effect on the main canvas.
  116700. * @param effect The effect used to render through
  116701. */
  116702. protected _internalRender(effect: Effect): void;
  116703. /**
  116704. * Returns true if the layer contains information to display, otherwise false.
  116705. */
  116706. shouldRender(): boolean;
  116707. /**
  116708. * Returns true if the mesh should render, otherwise false.
  116709. * @param mesh The mesh to render
  116710. * @returns true if it should render otherwise false
  116711. */
  116712. protected _shouldRenderMesh(mesh: Mesh): boolean;
  116713. /**
  116714. * Sets the required values for both the emissive texture and and the main color.
  116715. */
  116716. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  116717. /**
  116718. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  116719. * @param mesh The mesh to exclude from the highlight layer
  116720. */
  116721. addExcludedMesh(mesh: Mesh): void;
  116722. /**
  116723. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  116724. * @param mesh The mesh to highlight
  116725. */
  116726. removeExcludedMesh(mesh: Mesh): void;
  116727. /**
  116728. * Determine if a given mesh will be highlighted by the current HighlightLayer
  116729. * @param mesh mesh to test
  116730. * @returns true if the mesh will be highlighted by the current HighlightLayer
  116731. */
  116732. hasMesh(mesh: AbstractMesh): boolean;
  116733. /**
  116734. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  116735. * @param mesh The mesh to highlight
  116736. * @param color The color of the highlight
  116737. * @param glowEmissiveOnly Extract the glow from the emissive texture
  116738. */
  116739. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  116740. /**
  116741. * Remove a mesh from the highlight layer in order to make it stop glowing.
  116742. * @param mesh The mesh to highlight
  116743. */
  116744. removeMesh(mesh: Mesh): void;
  116745. /**
  116746. * Force the stencil to the normal expected value for none glowing parts
  116747. */
  116748. private _defaultStencilReference;
  116749. /**
  116750. * Free any resources and references associated to a mesh.
  116751. * Internal use
  116752. * @param mesh The mesh to free.
  116753. * @hidden
  116754. */
  116755. _disposeMesh(mesh: Mesh): void;
  116756. /**
  116757. * Dispose the highlight layer and free resources.
  116758. */
  116759. dispose(): void;
  116760. /**
  116761. * Gets the class name of the effect layer
  116762. * @returns the string with the class name of the effect layer
  116763. */
  116764. getClassName(): string;
  116765. /**
  116766. * Serializes this Highlight layer
  116767. * @returns a serialized Highlight layer object
  116768. */
  116769. serialize(): any;
  116770. /**
  116771. * Creates a Highlight layer from parsed Highlight layer data
  116772. * @param parsedHightlightLayer defines the Highlight layer data
  116773. * @param scene defines the current scene
  116774. * @param rootUrl defines the root URL containing the Highlight layer information
  116775. * @returns a parsed Highlight layer
  116776. */
  116777. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  116778. }
  116779. }
  116780. declare module BABYLON {
  116781. interface AbstractScene {
  116782. /**
  116783. * The list of layers (background and foreground) of the scene
  116784. */
  116785. layers: Array<Layer>;
  116786. }
  116787. /**
  116788. * Defines the layer scene component responsible to manage any layers
  116789. * in a given scene.
  116790. */
  116791. export class LayerSceneComponent implements ISceneComponent {
  116792. /**
  116793. * The component name helpfull to identify the component in the list of scene components.
  116794. */
  116795. readonly name: string;
  116796. /**
  116797. * The scene the component belongs to.
  116798. */
  116799. scene: Scene;
  116800. private _engine;
  116801. /**
  116802. * Creates a new instance of the component for the given scene
  116803. * @param scene Defines the scene to register the component in
  116804. */
  116805. constructor(scene: Scene);
  116806. /**
  116807. * Registers the component in a given scene
  116808. */
  116809. register(): void;
  116810. /**
  116811. * Rebuilds the elements related to this component in case of
  116812. * context lost for instance.
  116813. */
  116814. rebuild(): void;
  116815. /**
  116816. * Disposes the component and the associated ressources.
  116817. */
  116818. dispose(): void;
  116819. private _draw;
  116820. private _drawCameraPredicate;
  116821. private _drawCameraBackground;
  116822. private _drawCameraForeground;
  116823. private _drawRenderTargetPredicate;
  116824. private _drawRenderTargetBackground;
  116825. private _drawRenderTargetForeground;
  116826. /**
  116827. * Adds all the elements from the container to the scene
  116828. * @param container the container holding the elements
  116829. */
  116830. addFromContainer(container: AbstractScene): void;
  116831. /**
  116832. * Removes all the elements in the container from the scene
  116833. * @param container contains the elements to remove
  116834. * @param dispose if the removed element should be disposed (default: false)
  116835. */
  116836. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  116837. }
  116838. }
  116839. declare module BABYLON {
  116840. /** @hidden */
  116841. export var layerPixelShader: {
  116842. name: string;
  116843. shader: string;
  116844. };
  116845. }
  116846. declare module BABYLON {
  116847. /** @hidden */
  116848. export var layerVertexShader: {
  116849. name: string;
  116850. shader: string;
  116851. };
  116852. }
  116853. declare module BABYLON {
  116854. /**
  116855. * This represents a full screen 2d layer.
  116856. * This can be useful to display a picture in the background of your scene for instance.
  116857. * @see https://www.babylonjs-playground.com/#08A2BS#1
  116858. */
  116859. export class Layer {
  116860. /**
  116861. * Define the name of the layer.
  116862. */
  116863. name: string;
  116864. /**
  116865. * Define the texture the layer should display.
  116866. */
  116867. texture: Nullable<Texture>;
  116868. /**
  116869. * Is the layer in background or foreground.
  116870. */
  116871. isBackground: boolean;
  116872. /**
  116873. * Define the color of the layer (instead of texture).
  116874. */
  116875. color: Color4;
  116876. /**
  116877. * Define the scale of the layer in order to zoom in out of the texture.
  116878. */
  116879. scale: Vector2;
  116880. /**
  116881. * Define an offset for the layer in order to shift the texture.
  116882. */
  116883. offset: Vector2;
  116884. /**
  116885. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  116886. */
  116887. alphaBlendingMode: number;
  116888. /**
  116889. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  116890. * Alpha test will not mix with the background color in case of transparency.
  116891. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  116892. */
  116893. alphaTest: boolean;
  116894. /**
  116895. * Define a mask to restrict the layer to only some of the scene cameras.
  116896. */
  116897. layerMask: number;
  116898. /**
  116899. * Define the list of render target the layer is visible into.
  116900. */
  116901. renderTargetTextures: RenderTargetTexture[];
  116902. /**
  116903. * Define if the layer is only used in renderTarget or if it also
  116904. * renders in the main frame buffer of the canvas.
  116905. */
  116906. renderOnlyInRenderTargetTextures: boolean;
  116907. private _scene;
  116908. private _vertexBuffers;
  116909. private _indexBuffer;
  116910. private _effect;
  116911. private _alphaTestEffect;
  116912. /**
  116913. * An event triggered when the layer is disposed.
  116914. */
  116915. onDisposeObservable: Observable<Layer>;
  116916. private _onDisposeObserver;
  116917. /**
  116918. * Back compatibility with callback before the onDisposeObservable existed.
  116919. * The set callback will be triggered when the layer has been disposed.
  116920. */
  116921. onDispose: () => void;
  116922. /**
  116923. * An event triggered before rendering the scene
  116924. */
  116925. onBeforeRenderObservable: Observable<Layer>;
  116926. private _onBeforeRenderObserver;
  116927. /**
  116928. * Back compatibility with callback before the onBeforeRenderObservable existed.
  116929. * The set callback will be triggered just before rendering the layer.
  116930. */
  116931. onBeforeRender: () => void;
  116932. /**
  116933. * An event triggered after rendering the scene
  116934. */
  116935. onAfterRenderObservable: Observable<Layer>;
  116936. private _onAfterRenderObserver;
  116937. /**
  116938. * Back compatibility with callback before the onAfterRenderObservable existed.
  116939. * The set callback will be triggered just after rendering the layer.
  116940. */
  116941. onAfterRender: () => void;
  116942. /**
  116943. * Instantiates a new layer.
  116944. * This represents a full screen 2d layer.
  116945. * This can be useful to display a picture in the background of your scene for instance.
  116946. * @see https://www.babylonjs-playground.com/#08A2BS#1
  116947. * @param name Define the name of the layer in the scene
  116948. * @param imgUrl Define the url of the texture to display in the layer
  116949. * @param scene Define the scene the layer belongs to
  116950. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  116951. * @param color Defines a color for the layer
  116952. */
  116953. constructor(
  116954. /**
  116955. * Define the name of the layer.
  116956. */
  116957. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  116958. private _createIndexBuffer;
  116959. /** @hidden */
  116960. _rebuild(): void;
  116961. /**
  116962. * Renders the layer in the scene.
  116963. */
  116964. render(): void;
  116965. /**
  116966. * Disposes and releases the associated ressources.
  116967. */
  116968. dispose(): void;
  116969. }
  116970. }
  116971. declare module BABYLON {
  116972. /** @hidden */
  116973. export var lensFlarePixelShader: {
  116974. name: string;
  116975. shader: string;
  116976. };
  116977. }
  116978. declare module BABYLON {
  116979. /** @hidden */
  116980. export var lensFlareVertexShader: {
  116981. name: string;
  116982. shader: string;
  116983. };
  116984. }
  116985. declare module BABYLON {
  116986. /**
  116987. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  116988. * It is usually composed of several `lensFlare`.
  116989. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  116990. */
  116991. export class LensFlareSystem {
  116992. /**
  116993. * Define the name of the lens flare system
  116994. */
  116995. name: string;
  116996. /**
  116997. * List of lens flares used in this system.
  116998. */
  116999. lensFlares: LensFlare[];
  117000. /**
  117001. * Define a limit from the border the lens flare can be visible.
  117002. */
  117003. borderLimit: number;
  117004. /**
  117005. * Define a viewport border we do not want to see the lens flare in.
  117006. */
  117007. viewportBorder: number;
  117008. /**
  117009. * Define a predicate which could limit the list of meshes able to occlude the effect.
  117010. */
  117011. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  117012. /**
  117013. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  117014. */
  117015. layerMask: number;
  117016. /**
  117017. * Define the id of the lens flare system in the scene.
  117018. * (equal to name by default)
  117019. */
  117020. id: string;
  117021. private _scene;
  117022. private _emitter;
  117023. private _vertexBuffers;
  117024. private _indexBuffer;
  117025. private _effect;
  117026. private _positionX;
  117027. private _positionY;
  117028. private _isEnabled;
  117029. /** @hidden */
  117030. static _SceneComponentInitialization: (scene: Scene) => void;
  117031. /**
  117032. * Instantiates a lens flare system.
  117033. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  117034. * It is usually composed of several `lensFlare`.
  117035. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117036. * @param name Define the name of the lens flare system in the scene
  117037. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  117038. * @param scene Define the scene the lens flare system belongs to
  117039. */
  117040. constructor(
  117041. /**
  117042. * Define the name of the lens flare system
  117043. */
  117044. name: string, emitter: any, scene: Scene);
  117045. /**
  117046. * Define if the lens flare system is enabled.
  117047. */
  117048. isEnabled: boolean;
  117049. /**
  117050. * Get the scene the effects belongs to.
  117051. * @returns the scene holding the lens flare system
  117052. */
  117053. getScene(): Scene;
  117054. /**
  117055. * Get the emitter of the lens flare system.
  117056. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  117057. * @returns the emitter of the lens flare system
  117058. */
  117059. getEmitter(): any;
  117060. /**
  117061. * Set the emitter of the lens flare system.
  117062. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  117063. * @param newEmitter Define the new emitter of the system
  117064. */
  117065. setEmitter(newEmitter: any): void;
  117066. /**
  117067. * Get the lens flare system emitter position.
  117068. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  117069. * @returns the position
  117070. */
  117071. getEmitterPosition(): Vector3;
  117072. /**
  117073. * @hidden
  117074. */
  117075. computeEffectivePosition(globalViewport: Viewport): boolean;
  117076. /** @hidden */
  117077. _isVisible(): boolean;
  117078. /**
  117079. * @hidden
  117080. */
  117081. render(): boolean;
  117082. /**
  117083. * Dispose and release the lens flare with its associated resources.
  117084. */
  117085. dispose(): void;
  117086. /**
  117087. * Parse a lens flare system from a JSON repressentation
  117088. * @param parsedLensFlareSystem Define the JSON to parse
  117089. * @param scene Define the scene the parsed system should be instantiated in
  117090. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  117091. * @returns the parsed system
  117092. */
  117093. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  117094. /**
  117095. * Serialize the current Lens Flare System into a JSON representation.
  117096. * @returns the serialized JSON
  117097. */
  117098. serialize(): any;
  117099. }
  117100. }
  117101. declare module BABYLON {
  117102. /**
  117103. * This represents one of the lens effect in a `lensFlareSystem`.
  117104. * It controls one of the indiviual texture used in the effect.
  117105. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117106. */
  117107. export class LensFlare {
  117108. /**
  117109. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  117110. */
  117111. size: number;
  117112. /**
  117113. * 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.
  117114. */
  117115. position: number;
  117116. /**
  117117. * Define the lens color.
  117118. */
  117119. color: Color3;
  117120. /**
  117121. * Define the lens texture.
  117122. */
  117123. texture: Nullable<Texture>;
  117124. /**
  117125. * Define the alpha mode to render this particular lens.
  117126. */
  117127. alphaMode: number;
  117128. private _system;
  117129. /**
  117130. * Creates a new Lens Flare.
  117131. * This represents one of the lens effect in a `lensFlareSystem`.
  117132. * It controls one of the indiviual texture used in the effect.
  117133. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117134. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  117135. * @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.
  117136. * @param color Define the lens color
  117137. * @param imgUrl Define the lens texture url
  117138. * @param system Define the `lensFlareSystem` this flare is part of
  117139. * @returns The newly created Lens Flare
  117140. */
  117141. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  117142. /**
  117143. * Instantiates a new Lens Flare.
  117144. * This represents one of the lens effect in a `lensFlareSystem`.
  117145. * It controls one of the indiviual texture used in the effect.
  117146. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117147. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  117148. * @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.
  117149. * @param color Define the lens color
  117150. * @param imgUrl Define the lens texture url
  117151. * @param system Define the `lensFlareSystem` this flare is part of
  117152. */
  117153. constructor(
  117154. /**
  117155. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  117156. */
  117157. size: number,
  117158. /**
  117159. * 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.
  117160. */
  117161. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  117162. /**
  117163. * Dispose and release the lens flare with its associated resources.
  117164. */
  117165. dispose(): void;
  117166. }
  117167. }
  117168. declare module BABYLON {
  117169. interface AbstractScene {
  117170. /**
  117171. * The list of lens flare system added to the scene
  117172. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117173. */
  117174. lensFlareSystems: Array<LensFlareSystem>;
  117175. /**
  117176. * Removes the given lens flare system from this scene.
  117177. * @param toRemove The lens flare system to remove
  117178. * @returns The index of the removed lens flare system
  117179. */
  117180. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  117181. /**
  117182. * Adds the given lens flare system to this scene
  117183. * @param newLensFlareSystem The lens flare system to add
  117184. */
  117185. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  117186. /**
  117187. * Gets a lens flare system using its name
  117188. * @param name defines the name to look for
  117189. * @returns the lens flare system or null if not found
  117190. */
  117191. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  117192. /**
  117193. * Gets a lens flare system using its id
  117194. * @param id defines the id to look for
  117195. * @returns the lens flare system or null if not found
  117196. */
  117197. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  117198. }
  117199. /**
  117200. * Defines the lens flare scene component responsible to manage any lens flares
  117201. * in a given scene.
  117202. */
  117203. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  117204. /**
  117205. * The component name helpfull to identify the component in the list of scene components.
  117206. */
  117207. readonly name: string;
  117208. /**
  117209. * The scene the component belongs to.
  117210. */
  117211. scene: Scene;
  117212. /**
  117213. * Creates a new instance of the component for the given scene
  117214. * @param scene Defines the scene to register the component in
  117215. */
  117216. constructor(scene: Scene);
  117217. /**
  117218. * Registers the component in a given scene
  117219. */
  117220. register(): void;
  117221. /**
  117222. * Rebuilds the elements related to this component in case of
  117223. * context lost for instance.
  117224. */
  117225. rebuild(): void;
  117226. /**
  117227. * Adds all the elements from the container to the scene
  117228. * @param container the container holding the elements
  117229. */
  117230. addFromContainer(container: AbstractScene): void;
  117231. /**
  117232. * Removes all the elements in the container from the scene
  117233. * @param container contains the elements to remove
  117234. * @param dispose if the removed element should be disposed (default: false)
  117235. */
  117236. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  117237. /**
  117238. * Serializes the component data to the specified json object
  117239. * @param serializationObject The object to serialize to
  117240. */
  117241. serialize(serializationObject: any): void;
  117242. /**
  117243. * Disposes the component and the associated ressources.
  117244. */
  117245. dispose(): void;
  117246. private _draw;
  117247. }
  117248. }
  117249. declare module BABYLON {
  117250. /**
  117251. * Defines the shadow generator component responsible to manage any shadow generators
  117252. * in a given scene.
  117253. */
  117254. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  117255. /**
  117256. * The component name helpfull to identify the component in the list of scene components.
  117257. */
  117258. readonly name: string;
  117259. /**
  117260. * The scene the component belongs to.
  117261. */
  117262. scene: Scene;
  117263. /**
  117264. * Creates a new instance of the component for the given scene
  117265. * @param scene Defines the scene to register the component in
  117266. */
  117267. constructor(scene: Scene);
  117268. /**
  117269. * Registers the component in a given scene
  117270. */
  117271. register(): void;
  117272. /**
  117273. * Rebuilds the elements related to this component in case of
  117274. * context lost for instance.
  117275. */
  117276. rebuild(): void;
  117277. /**
  117278. * Serializes the component data to the specified json object
  117279. * @param serializationObject The object to serialize to
  117280. */
  117281. serialize(serializationObject: any): void;
  117282. /**
  117283. * Adds all the elements from the container to the scene
  117284. * @param container the container holding the elements
  117285. */
  117286. addFromContainer(container: AbstractScene): void;
  117287. /**
  117288. * Removes all the elements in the container from the scene
  117289. * @param container contains the elements to remove
  117290. * @param dispose if the removed element should be disposed (default: false)
  117291. */
  117292. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  117293. /**
  117294. * Rebuilds the elements related to this component in case of
  117295. * context lost for instance.
  117296. */
  117297. dispose(): void;
  117298. private _gatherRenderTargets;
  117299. }
  117300. }
  117301. declare module BABYLON {
  117302. /**
  117303. * A point light is a light defined by an unique point in world space.
  117304. * The light is emitted in every direction from this point.
  117305. * A good example of a point light is a standard light bulb.
  117306. * Documentation: https://doc.babylonjs.com/babylon101/lights
  117307. */
  117308. export class PointLight extends ShadowLight {
  117309. private _shadowAngle;
  117310. /**
  117311. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  117312. * This specifies what angle the shadow will use to be created.
  117313. *
  117314. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  117315. */
  117316. /**
  117317. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  117318. * This specifies what angle the shadow will use to be created.
  117319. *
  117320. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  117321. */
  117322. shadowAngle: number;
  117323. /**
  117324. * Gets the direction if it has been set.
  117325. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  117326. */
  117327. /**
  117328. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  117329. */
  117330. direction: Vector3;
  117331. /**
  117332. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  117333. * A PointLight emits the light in every direction.
  117334. * It can cast shadows.
  117335. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  117336. * ```javascript
  117337. * var pointLight = new PointLight("pl", camera.position, scene);
  117338. * ```
  117339. * Documentation : https://doc.babylonjs.com/babylon101/lights
  117340. * @param name The light friendly name
  117341. * @param position The position of the point light in the scene
  117342. * @param scene The scene the lights belongs to
  117343. */
  117344. constructor(name: string, position: Vector3, scene: Scene);
  117345. /**
  117346. * Returns the string "PointLight"
  117347. * @returns the class name
  117348. */
  117349. getClassName(): string;
  117350. /**
  117351. * Returns the integer 0.
  117352. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  117353. */
  117354. getTypeID(): number;
  117355. /**
  117356. * Specifies wether or not the shadowmap should be a cube texture.
  117357. * @returns true if the shadowmap needs to be a cube texture.
  117358. */
  117359. needCube(): boolean;
  117360. /**
  117361. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  117362. * @param faceIndex The index of the face we are computed the direction to generate shadow
  117363. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  117364. */
  117365. getShadowDirection(faceIndex?: number): Vector3;
  117366. /**
  117367. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  117368. * - fov = PI / 2
  117369. * - aspect ratio : 1.0
  117370. * - z-near and far equal to the active camera minZ and maxZ.
  117371. * Returns the PointLight.
  117372. */
  117373. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  117374. protected _buildUniformLayout(): void;
  117375. /**
  117376. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  117377. * @param effect The effect to update
  117378. * @param lightIndex The index of the light in the effect to update
  117379. * @returns The point light
  117380. */
  117381. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  117382. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  117383. /**
  117384. * Prepares the list of defines specific to the light type.
  117385. * @param defines the list of defines
  117386. * @param lightIndex defines the index of the light for the effect
  117387. */
  117388. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  117389. }
  117390. }
  117391. declare module BABYLON {
  117392. /**
  117393. * Header information of HDR texture files.
  117394. */
  117395. export interface HDRInfo {
  117396. /**
  117397. * The height of the texture in pixels.
  117398. */
  117399. height: number;
  117400. /**
  117401. * The width of the texture in pixels.
  117402. */
  117403. width: number;
  117404. /**
  117405. * The index of the beginning of the data in the binary file.
  117406. */
  117407. dataPosition: number;
  117408. }
  117409. /**
  117410. * This groups tools to convert HDR texture to native colors array.
  117411. */
  117412. export class HDRTools {
  117413. private static Ldexp;
  117414. private static Rgbe2float;
  117415. private static readStringLine;
  117416. /**
  117417. * Reads header information from an RGBE texture stored in a native array.
  117418. * More information on this format are available here:
  117419. * https://en.wikipedia.org/wiki/RGBE_image_format
  117420. *
  117421. * @param uint8array The binary file stored in native array.
  117422. * @return The header information.
  117423. */
  117424. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  117425. /**
  117426. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  117427. * This RGBE texture needs to store the information as a panorama.
  117428. *
  117429. * More information on this format are available here:
  117430. * https://en.wikipedia.org/wiki/RGBE_image_format
  117431. *
  117432. * @param buffer The binary file stored in an array buffer.
  117433. * @param size The expected size of the extracted cubemap.
  117434. * @return The Cube Map information.
  117435. */
  117436. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  117437. /**
  117438. * Returns the pixels data extracted from an RGBE texture.
  117439. * This pixels will be stored left to right up to down in the R G B order in one array.
  117440. *
  117441. * More information on this format are available here:
  117442. * https://en.wikipedia.org/wiki/RGBE_image_format
  117443. *
  117444. * @param uint8array The binary file stored in an array buffer.
  117445. * @param hdrInfo The header information of the file.
  117446. * @return The pixels data in RGB right to left up to down order.
  117447. */
  117448. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  117449. private static RGBE_ReadPixels_RLE;
  117450. }
  117451. }
  117452. declare module BABYLON {
  117453. /**
  117454. * This represents a texture coming from an HDR input.
  117455. *
  117456. * The only supported format is currently panorama picture stored in RGBE format.
  117457. * Example of such files can be found on HDRLib: http://hdrlib.com/
  117458. */
  117459. export class HDRCubeTexture extends BaseTexture {
  117460. private static _facesMapping;
  117461. private _generateHarmonics;
  117462. private _noMipmap;
  117463. private _textureMatrix;
  117464. private _size;
  117465. private _onLoad;
  117466. private _onError;
  117467. /**
  117468. * The texture URL.
  117469. */
  117470. url: string;
  117471. /**
  117472. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  117473. */
  117474. coordinatesMode: number;
  117475. protected _isBlocking: boolean;
  117476. /**
  117477. * Sets wether or not the texture is blocking during loading.
  117478. */
  117479. /**
  117480. * Gets wether or not the texture is blocking during loading.
  117481. */
  117482. isBlocking: boolean;
  117483. protected _rotationY: number;
  117484. /**
  117485. * Sets texture matrix rotation angle around Y axis in radians.
  117486. */
  117487. /**
  117488. * Gets texture matrix rotation angle around Y axis radians.
  117489. */
  117490. rotationY: number;
  117491. /**
  117492. * Gets or sets the center of the bounding box associated with the cube texture
  117493. * It must define where the camera used to render the texture was set
  117494. */
  117495. boundingBoxPosition: Vector3;
  117496. private _boundingBoxSize;
  117497. /**
  117498. * Gets or sets the size of the bounding box associated with the cube texture
  117499. * When defined, the cubemap will switch to local mode
  117500. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  117501. * @example https://www.babylonjs-playground.com/#RNASML
  117502. */
  117503. boundingBoxSize: Vector3;
  117504. /**
  117505. * Instantiates an HDRTexture from the following parameters.
  117506. *
  117507. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  117508. * @param scene The scene the texture will be used in
  117509. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  117510. * @param noMipmap Forces to not generate the mipmap if true
  117511. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  117512. * @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)
  117513. * @param reserved Reserved flag for internal use.
  117514. */
  117515. 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>);
  117516. /**
  117517. * Get the current class name of the texture useful for serialization or dynamic coding.
  117518. * @returns "HDRCubeTexture"
  117519. */
  117520. getClassName(): string;
  117521. /**
  117522. * Occurs when the file is raw .hdr file.
  117523. */
  117524. private loadTexture;
  117525. clone(): HDRCubeTexture;
  117526. delayLoad(): void;
  117527. /**
  117528. * Get the texture reflection matrix used to rotate/transform the reflection.
  117529. * @returns the reflection matrix
  117530. */
  117531. getReflectionTextureMatrix(): Matrix;
  117532. /**
  117533. * Set the texture reflection matrix used to rotate/transform the reflection.
  117534. * @param value Define the reflection matrix to set
  117535. */
  117536. setReflectionTextureMatrix(value: Matrix): void;
  117537. /**
  117538. * Parses a JSON representation of an HDR Texture in order to create the texture
  117539. * @param parsedTexture Define the JSON representation
  117540. * @param scene Define the scene the texture should be created in
  117541. * @param rootUrl Define the root url in case we need to load relative dependencies
  117542. * @returns the newly created texture after parsing
  117543. */
  117544. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  117545. serialize(): any;
  117546. }
  117547. }
  117548. declare module BABYLON {
  117549. /**
  117550. * Class used to control physics engine
  117551. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  117552. */
  117553. export class PhysicsEngine implements IPhysicsEngine {
  117554. private _physicsPlugin;
  117555. /**
  117556. * Global value used to control the smallest number supported by the simulation
  117557. */
  117558. static Epsilon: number;
  117559. private _impostors;
  117560. private _joints;
  117561. /**
  117562. * Gets the gravity vector used by the simulation
  117563. */
  117564. gravity: Vector3;
  117565. /**
  117566. * Factory used to create the default physics plugin.
  117567. * @returns The default physics plugin
  117568. */
  117569. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  117570. /**
  117571. * Creates a new Physics Engine
  117572. * @param gravity defines the gravity vector used by the simulation
  117573. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  117574. */
  117575. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  117576. /**
  117577. * Sets the gravity vector used by the simulation
  117578. * @param gravity defines the gravity vector to use
  117579. */
  117580. setGravity(gravity: Vector3): void;
  117581. /**
  117582. * Set the time step of the physics engine.
  117583. * Default is 1/60.
  117584. * To slow it down, enter 1/600 for example.
  117585. * To speed it up, 1/30
  117586. * @param newTimeStep defines the new timestep to apply to this world.
  117587. */
  117588. setTimeStep(newTimeStep?: number): void;
  117589. /**
  117590. * Get the time step of the physics engine.
  117591. * @returns the current time step
  117592. */
  117593. getTimeStep(): number;
  117594. /**
  117595. * Release all resources
  117596. */
  117597. dispose(): void;
  117598. /**
  117599. * Gets the name of the current physics plugin
  117600. * @returns the name of the plugin
  117601. */
  117602. getPhysicsPluginName(): string;
  117603. /**
  117604. * Adding a new impostor for the impostor tracking.
  117605. * This will be done by the impostor itself.
  117606. * @param impostor the impostor to add
  117607. */
  117608. addImpostor(impostor: PhysicsImpostor): void;
  117609. /**
  117610. * Remove an impostor from the engine.
  117611. * This impostor and its mesh will not longer be updated by the physics engine.
  117612. * @param impostor the impostor to remove
  117613. */
  117614. removeImpostor(impostor: PhysicsImpostor): void;
  117615. /**
  117616. * Add a joint to the physics engine
  117617. * @param mainImpostor defines the main impostor to which the joint is added.
  117618. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  117619. * @param joint defines the joint that will connect both impostors.
  117620. */
  117621. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  117622. /**
  117623. * Removes a joint from the simulation
  117624. * @param mainImpostor defines the impostor used with the joint
  117625. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  117626. * @param joint defines the joint to remove
  117627. */
  117628. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  117629. /**
  117630. * Called by the scene. No need to call it.
  117631. * @param delta defines the timespam between frames
  117632. */
  117633. _step(delta: number): void;
  117634. /**
  117635. * Gets the current plugin used to run the simulation
  117636. * @returns current plugin
  117637. */
  117638. getPhysicsPlugin(): IPhysicsEnginePlugin;
  117639. /**
  117640. * Gets the list of physic impostors
  117641. * @returns an array of PhysicsImpostor
  117642. */
  117643. getImpostors(): Array<PhysicsImpostor>;
  117644. /**
  117645. * Gets the impostor for a physics enabled object
  117646. * @param object defines the object impersonated by the impostor
  117647. * @returns the PhysicsImpostor or null if not found
  117648. */
  117649. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  117650. /**
  117651. * Gets the impostor for a physics body object
  117652. * @param body defines physics body used by the impostor
  117653. * @returns the PhysicsImpostor or null if not found
  117654. */
  117655. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  117656. /**
  117657. * Does a raycast in the physics world
  117658. * @param from when should the ray start?
  117659. * @param to when should the ray end?
  117660. * @returns PhysicsRaycastResult
  117661. */
  117662. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  117663. }
  117664. }
  117665. declare module BABYLON {
  117666. /** @hidden */
  117667. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  117668. private _useDeltaForWorldStep;
  117669. world: any;
  117670. name: string;
  117671. private _physicsMaterials;
  117672. private _fixedTimeStep;
  117673. private _cannonRaycastResult;
  117674. private _raycastResult;
  117675. private _physicsBodysToRemoveAfterStep;
  117676. BJSCANNON: any;
  117677. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  117678. setGravity(gravity: Vector3): void;
  117679. setTimeStep(timeStep: number): void;
  117680. getTimeStep(): number;
  117681. executeStep(delta: number): void;
  117682. private _removeMarkedPhysicsBodiesFromWorld;
  117683. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  117684. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  117685. generatePhysicsBody(impostor: PhysicsImpostor): void;
  117686. private _processChildMeshes;
  117687. removePhysicsBody(impostor: PhysicsImpostor): void;
  117688. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  117689. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  117690. private _addMaterial;
  117691. private _checkWithEpsilon;
  117692. private _createShape;
  117693. private _createHeightmap;
  117694. private _minus90X;
  117695. private _plus90X;
  117696. private _tmpPosition;
  117697. private _tmpDeltaPosition;
  117698. private _tmpUnityRotation;
  117699. private _updatePhysicsBodyTransformation;
  117700. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  117701. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  117702. isSupported(): boolean;
  117703. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  117704. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  117705. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  117706. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  117707. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  117708. getBodyMass(impostor: PhysicsImpostor): number;
  117709. getBodyFriction(impostor: PhysicsImpostor): number;
  117710. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  117711. getBodyRestitution(impostor: PhysicsImpostor): number;
  117712. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  117713. sleepBody(impostor: PhysicsImpostor): void;
  117714. wakeUpBody(impostor: PhysicsImpostor): void;
  117715. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  117716. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  117717. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  117718. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  117719. getRadius(impostor: PhysicsImpostor): number;
  117720. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  117721. dispose(): void;
  117722. private _extendNamespace;
  117723. /**
  117724. * Does a raycast in the physics world
  117725. * @param from when should the ray start?
  117726. * @param to when should the ray end?
  117727. * @returns PhysicsRaycastResult
  117728. */
  117729. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  117730. }
  117731. }
  117732. declare module BABYLON {
  117733. /** @hidden */
  117734. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  117735. world: any;
  117736. name: string;
  117737. BJSOIMO: any;
  117738. private _raycastResult;
  117739. constructor(iterations?: number, oimoInjection?: any);
  117740. setGravity(gravity: Vector3): void;
  117741. setTimeStep(timeStep: number): void;
  117742. getTimeStep(): number;
  117743. private _tmpImpostorsArray;
  117744. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  117745. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  117746. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  117747. generatePhysicsBody(impostor: PhysicsImpostor): void;
  117748. private _tmpPositionVector;
  117749. removePhysicsBody(impostor: PhysicsImpostor): void;
  117750. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  117751. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  117752. isSupported(): boolean;
  117753. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  117754. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  117755. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  117756. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  117757. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  117758. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  117759. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  117760. getBodyMass(impostor: PhysicsImpostor): number;
  117761. getBodyFriction(impostor: PhysicsImpostor): number;
  117762. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  117763. getBodyRestitution(impostor: PhysicsImpostor): number;
  117764. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  117765. sleepBody(impostor: PhysicsImpostor): void;
  117766. wakeUpBody(impostor: PhysicsImpostor): void;
  117767. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  117768. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  117769. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  117770. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  117771. getRadius(impostor: PhysicsImpostor): number;
  117772. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  117773. dispose(): void;
  117774. /**
  117775. * Does a raycast in the physics world
  117776. * @param from when should the ray start?
  117777. * @param to when should the ray end?
  117778. * @returns PhysicsRaycastResult
  117779. */
  117780. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  117781. }
  117782. }
  117783. declare module BABYLON {
  117784. /**
  117785. * Class containing static functions to help procedurally build meshes
  117786. */
  117787. export class RibbonBuilder {
  117788. /**
  117789. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  117790. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  117791. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  117792. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  117793. * * 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
  117794. * * 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
  117795. * * 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
  117796. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117797. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117798. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  117799. * * 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
  117800. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  117801. * * 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
  117802. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  117803. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117804. * @param name defines the name of the mesh
  117805. * @param options defines the options used to create the mesh
  117806. * @param scene defines the hosting scene
  117807. * @returns the ribbon mesh
  117808. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  117809. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  117810. */
  117811. static CreateRibbon(name: string, options: {
  117812. pathArray: Vector3[][];
  117813. closeArray?: boolean;
  117814. closePath?: boolean;
  117815. offset?: number;
  117816. updatable?: boolean;
  117817. sideOrientation?: number;
  117818. frontUVs?: Vector4;
  117819. backUVs?: Vector4;
  117820. instance?: Mesh;
  117821. invertUV?: boolean;
  117822. uvs?: Vector2[];
  117823. colors?: Color4[];
  117824. }, scene?: Nullable<Scene>): Mesh;
  117825. }
  117826. }
  117827. declare module BABYLON {
  117828. /**
  117829. * Class containing static functions to help procedurally build meshes
  117830. */
  117831. export class ShapeBuilder {
  117832. /**
  117833. * 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.
  117834. * * 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.
  117835. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  117836. * * 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.
  117837. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  117838. * * 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
  117839. * * 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
  117840. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  117841. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117842. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117843. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  117844. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  117845. * @param name defines the name of the mesh
  117846. * @param options defines the options used to create the mesh
  117847. * @param scene defines the hosting scene
  117848. * @returns the extruded shape mesh
  117849. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  117850. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  117851. */
  117852. static ExtrudeShape(name: string, options: {
  117853. shape: Vector3[];
  117854. path: Vector3[];
  117855. scale?: number;
  117856. rotation?: number;
  117857. cap?: number;
  117858. updatable?: boolean;
  117859. sideOrientation?: number;
  117860. frontUVs?: Vector4;
  117861. backUVs?: Vector4;
  117862. instance?: Mesh;
  117863. invertUV?: boolean;
  117864. }, scene?: Nullable<Scene>): Mesh;
  117865. /**
  117866. * Creates an custom extruded shape mesh.
  117867. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  117868. * * 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.
  117869. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  117870. * * 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
  117871. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  117872. * * 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
  117873. * * It must returns a float value that will be the scale value applied to the shape on each path point
  117874. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  117875. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  117876. * * 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
  117877. * * 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
  117878. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  117879. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117880. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117881. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  117882. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117883. * @param name defines the name of the mesh
  117884. * @param options defines the options used to create the mesh
  117885. * @param scene defines the hosting scene
  117886. * @returns the custom extruded shape mesh
  117887. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  117888. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  117889. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  117890. */
  117891. static ExtrudeShapeCustom(name: string, options: {
  117892. shape: Vector3[];
  117893. path: Vector3[];
  117894. scaleFunction?: any;
  117895. rotationFunction?: any;
  117896. ribbonCloseArray?: boolean;
  117897. ribbonClosePath?: boolean;
  117898. cap?: number;
  117899. updatable?: boolean;
  117900. sideOrientation?: number;
  117901. frontUVs?: Vector4;
  117902. backUVs?: Vector4;
  117903. instance?: Mesh;
  117904. invertUV?: boolean;
  117905. }, scene?: Nullable<Scene>): Mesh;
  117906. private static _ExtrudeShapeGeneric;
  117907. }
  117908. }
  117909. declare module BABYLON {
  117910. /**
  117911. * AmmoJS Physics plugin
  117912. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  117913. * @see https://github.com/kripken/ammo.js/
  117914. */
  117915. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  117916. private _useDeltaForWorldStep;
  117917. /**
  117918. * Reference to the Ammo library
  117919. */
  117920. bjsAMMO: any;
  117921. /**
  117922. * Created ammoJS world which physics bodies are added to
  117923. */
  117924. world: any;
  117925. /**
  117926. * Name of the plugin
  117927. */
  117928. name: string;
  117929. private _timeStep;
  117930. private _fixedTimeStep;
  117931. private _maxSteps;
  117932. private _tmpQuaternion;
  117933. private _tmpAmmoTransform;
  117934. private _tmpAmmoQuaternion;
  117935. private _tmpAmmoConcreteContactResultCallback;
  117936. private _collisionConfiguration;
  117937. private _dispatcher;
  117938. private _overlappingPairCache;
  117939. private _solver;
  117940. private _softBodySolver;
  117941. private _tmpAmmoVectorA;
  117942. private _tmpAmmoVectorB;
  117943. private _tmpAmmoVectorC;
  117944. private _tmpAmmoVectorD;
  117945. private _tmpContactCallbackResult;
  117946. private _tmpAmmoVectorRCA;
  117947. private _tmpAmmoVectorRCB;
  117948. private _raycastResult;
  117949. private static readonly DISABLE_COLLISION_FLAG;
  117950. private static readonly KINEMATIC_FLAG;
  117951. private static readonly DISABLE_DEACTIVATION_FLAG;
  117952. /**
  117953. * Initializes the ammoJS plugin
  117954. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  117955. * @param ammoInjection can be used to inject your own ammo reference
  117956. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  117957. */
  117958. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  117959. /**
  117960. * Sets the gravity of the physics world (m/(s^2))
  117961. * @param gravity Gravity to set
  117962. */
  117963. setGravity(gravity: Vector3): void;
  117964. /**
  117965. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  117966. * @param timeStep timestep to use in seconds
  117967. */
  117968. setTimeStep(timeStep: number): void;
  117969. /**
  117970. * 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)
  117971. * @param fixedTimeStep fixedTimeStep to use in seconds
  117972. */
  117973. setFixedTimeStep(fixedTimeStep: number): void;
  117974. /**
  117975. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  117976. * @param maxSteps the maximum number of steps by the physics engine per frame
  117977. */
  117978. setMaxSteps(maxSteps: number): void;
  117979. /**
  117980. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  117981. * @returns the current timestep in seconds
  117982. */
  117983. getTimeStep(): number;
  117984. private _isImpostorInContact;
  117985. private _isImpostorPairInContact;
  117986. private _stepSimulation;
  117987. /**
  117988. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  117989. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  117990. * After the step the babylon meshes are set to the position of the physics imposters
  117991. * @param delta amount of time to step forward
  117992. * @param impostors array of imposters to update before/after the step
  117993. */
  117994. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  117995. /**
  117996. * Update babylon mesh to match physics world object
  117997. * @param impostor imposter to match
  117998. */
  117999. private _afterSoftStep;
  118000. /**
  118001. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  118002. * @param impostor imposter to match
  118003. */
  118004. private _ropeStep;
  118005. /**
  118006. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  118007. * @param impostor imposter to match
  118008. */
  118009. private _softbodyOrClothStep;
  118010. private _tmpVector;
  118011. private _tmpMatrix;
  118012. /**
  118013. * Applies an impulse on the imposter
  118014. * @param impostor imposter to apply impulse to
  118015. * @param force amount of force to be applied to the imposter
  118016. * @param contactPoint the location to apply the impulse on the imposter
  118017. */
  118018. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  118019. /**
  118020. * Applies a force on the imposter
  118021. * @param impostor imposter to apply force
  118022. * @param force amount of force to be applied to the imposter
  118023. * @param contactPoint the location to apply the force on the imposter
  118024. */
  118025. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  118026. /**
  118027. * Creates a physics body using the plugin
  118028. * @param impostor the imposter to create the physics body on
  118029. */
  118030. generatePhysicsBody(impostor: PhysicsImpostor): void;
  118031. /**
  118032. * Removes the physics body from the imposter and disposes of the body's memory
  118033. * @param impostor imposter to remove the physics body from
  118034. */
  118035. removePhysicsBody(impostor: PhysicsImpostor): void;
  118036. /**
  118037. * Generates a joint
  118038. * @param impostorJoint the imposter joint to create the joint with
  118039. */
  118040. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  118041. /**
  118042. * Removes a joint
  118043. * @param impostorJoint the imposter joint to remove the joint from
  118044. */
  118045. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  118046. private _addMeshVerts;
  118047. /**
  118048. * Initialise the soft body vertices to match its object's (mesh) vertices
  118049. * Softbody vertices (nodes) are in world space and to match this
  118050. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  118051. * @param impostor to create the softbody for
  118052. */
  118053. private _softVertexData;
  118054. /**
  118055. * Create an impostor's soft body
  118056. * @param impostor to create the softbody for
  118057. */
  118058. private _createSoftbody;
  118059. /**
  118060. * Create cloth for an impostor
  118061. * @param impostor to create the softbody for
  118062. */
  118063. private _createCloth;
  118064. /**
  118065. * Create rope for an impostor
  118066. * @param impostor to create the softbody for
  118067. */
  118068. private _createRope;
  118069. private _addHullVerts;
  118070. private _createShape;
  118071. /**
  118072. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  118073. * @param impostor imposter containing the physics body and babylon object
  118074. */
  118075. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  118076. /**
  118077. * Sets the babylon object's position/rotation from the physics body's position/rotation
  118078. * @param impostor imposter containing the physics body and babylon object
  118079. * @param newPosition new position
  118080. * @param newRotation new rotation
  118081. */
  118082. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  118083. /**
  118084. * If this plugin is supported
  118085. * @returns true if its supported
  118086. */
  118087. isSupported(): boolean;
  118088. /**
  118089. * Sets the linear velocity of the physics body
  118090. * @param impostor imposter to set the velocity on
  118091. * @param velocity velocity to set
  118092. */
  118093. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  118094. /**
  118095. * Sets the angular velocity of the physics body
  118096. * @param impostor imposter to set the velocity on
  118097. * @param velocity velocity to set
  118098. */
  118099. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  118100. /**
  118101. * gets the linear velocity
  118102. * @param impostor imposter to get linear velocity from
  118103. * @returns linear velocity
  118104. */
  118105. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  118106. /**
  118107. * gets the angular velocity
  118108. * @param impostor imposter to get angular velocity from
  118109. * @returns angular velocity
  118110. */
  118111. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  118112. /**
  118113. * Sets the mass of physics body
  118114. * @param impostor imposter to set the mass on
  118115. * @param mass mass to set
  118116. */
  118117. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  118118. /**
  118119. * Gets the mass of the physics body
  118120. * @param impostor imposter to get the mass from
  118121. * @returns mass
  118122. */
  118123. getBodyMass(impostor: PhysicsImpostor): number;
  118124. /**
  118125. * Gets friction of the impostor
  118126. * @param impostor impostor to get friction from
  118127. * @returns friction value
  118128. */
  118129. getBodyFriction(impostor: PhysicsImpostor): number;
  118130. /**
  118131. * Sets friction of the impostor
  118132. * @param impostor impostor to set friction on
  118133. * @param friction friction value
  118134. */
  118135. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  118136. /**
  118137. * Gets restitution of the impostor
  118138. * @param impostor impostor to get restitution from
  118139. * @returns restitution value
  118140. */
  118141. getBodyRestitution(impostor: PhysicsImpostor): number;
  118142. /**
  118143. * Sets resitution of the impostor
  118144. * @param impostor impostor to set resitution on
  118145. * @param restitution resitution value
  118146. */
  118147. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  118148. /**
  118149. * Gets pressure inside the impostor
  118150. * @param impostor impostor to get pressure from
  118151. * @returns pressure value
  118152. */
  118153. getBodyPressure(impostor: PhysicsImpostor): number;
  118154. /**
  118155. * Sets pressure inside a soft body impostor
  118156. * Cloth and rope must remain 0 pressure
  118157. * @param impostor impostor to set pressure on
  118158. * @param pressure pressure value
  118159. */
  118160. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  118161. /**
  118162. * Gets stiffness of the impostor
  118163. * @param impostor impostor to get stiffness from
  118164. * @returns pressure value
  118165. */
  118166. getBodyStiffness(impostor: PhysicsImpostor): number;
  118167. /**
  118168. * Sets stiffness of the impostor
  118169. * @param impostor impostor to set stiffness on
  118170. * @param stiffness stiffness value from 0 to 1
  118171. */
  118172. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  118173. /**
  118174. * Gets velocityIterations of the impostor
  118175. * @param impostor impostor to get velocity iterations from
  118176. * @returns velocityIterations value
  118177. */
  118178. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  118179. /**
  118180. * Sets velocityIterations of the impostor
  118181. * @param impostor impostor to set velocity iterations on
  118182. * @param velocityIterations velocityIterations value
  118183. */
  118184. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  118185. /**
  118186. * Gets positionIterations of the impostor
  118187. * @param impostor impostor to get position iterations from
  118188. * @returns positionIterations value
  118189. */
  118190. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  118191. /**
  118192. * Sets positionIterations of the impostor
  118193. * @param impostor impostor to set position on
  118194. * @param positionIterations positionIterations value
  118195. */
  118196. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  118197. /**
  118198. * Append an anchor to a cloth object
  118199. * @param impostor is the cloth impostor to add anchor to
  118200. * @param otherImpostor is the rigid impostor to anchor to
  118201. * @param width ratio across width from 0 to 1
  118202. * @param height ratio up height from 0 to 1
  118203. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  118204. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  118205. */
  118206. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  118207. /**
  118208. * Append an hook to a rope object
  118209. * @param impostor is the rope impostor to add hook to
  118210. * @param otherImpostor is the rigid impostor to hook to
  118211. * @param length ratio along the rope from 0 to 1
  118212. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  118213. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  118214. */
  118215. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  118216. /**
  118217. * Sleeps the physics body and stops it from being active
  118218. * @param impostor impostor to sleep
  118219. */
  118220. sleepBody(impostor: PhysicsImpostor): void;
  118221. /**
  118222. * Activates the physics body
  118223. * @param impostor impostor to activate
  118224. */
  118225. wakeUpBody(impostor: PhysicsImpostor): void;
  118226. /**
  118227. * Updates the distance parameters of the joint
  118228. * @param joint joint to update
  118229. * @param maxDistance maximum distance of the joint
  118230. * @param minDistance minimum distance of the joint
  118231. */
  118232. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  118233. /**
  118234. * Sets a motor on the joint
  118235. * @param joint joint to set motor on
  118236. * @param speed speed of the motor
  118237. * @param maxForce maximum force of the motor
  118238. * @param motorIndex index of the motor
  118239. */
  118240. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  118241. /**
  118242. * Sets the motors limit
  118243. * @param joint joint to set limit on
  118244. * @param upperLimit upper limit
  118245. * @param lowerLimit lower limit
  118246. */
  118247. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  118248. /**
  118249. * Syncs the position and rotation of a mesh with the impostor
  118250. * @param mesh mesh to sync
  118251. * @param impostor impostor to update the mesh with
  118252. */
  118253. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  118254. /**
  118255. * Gets the radius of the impostor
  118256. * @param impostor impostor to get radius from
  118257. * @returns the radius
  118258. */
  118259. getRadius(impostor: PhysicsImpostor): number;
  118260. /**
  118261. * Gets the box size of the impostor
  118262. * @param impostor impostor to get box size from
  118263. * @param result the resulting box size
  118264. */
  118265. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  118266. /**
  118267. * Disposes of the impostor
  118268. */
  118269. dispose(): void;
  118270. /**
  118271. * Does a raycast in the physics world
  118272. * @param from when should the ray start?
  118273. * @param to when should the ray end?
  118274. * @returns PhysicsRaycastResult
  118275. */
  118276. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  118277. }
  118278. }
  118279. declare module BABYLON {
  118280. interface AbstractScene {
  118281. /**
  118282. * The list of reflection probes added to the scene
  118283. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  118284. */
  118285. reflectionProbes: Array<ReflectionProbe>;
  118286. /**
  118287. * Removes the given reflection probe from this scene.
  118288. * @param toRemove The reflection probe to remove
  118289. * @returns The index of the removed reflection probe
  118290. */
  118291. removeReflectionProbe(toRemove: ReflectionProbe): number;
  118292. /**
  118293. * Adds the given reflection probe to this scene.
  118294. * @param newReflectionProbe The reflection probe to add
  118295. */
  118296. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  118297. }
  118298. /**
  118299. * Class used to generate realtime reflection / refraction cube textures
  118300. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  118301. */
  118302. export class ReflectionProbe {
  118303. /** defines the name of the probe */
  118304. name: string;
  118305. private _scene;
  118306. private _renderTargetTexture;
  118307. private _projectionMatrix;
  118308. private _viewMatrix;
  118309. private _target;
  118310. private _add;
  118311. private _attachedMesh;
  118312. private _invertYAxis;
  118313. /** Gets or sets probe position (center of the cube map) */
  118314. position: Vector3;
  118315. /**
  118316. * Creates a new reflection probe
  118317. * @param name defines the name of the probe
  118318. * @param size defines the texture resolution (for each face)
  118319. * @param scene defines the hosting scene
  118320. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  118321. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  118322. */
  118323. constructor(
  118324. /** defines the name of the probe */
  118325. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  118326. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  118327. samples: number;
  118328. /** Gets or sets the refresh rate to use (on every frame by default) */
  118329. refreshRate: number;
  118330. /**
  118331. * Gets the hosting scene
  118332. * @returns a Scene
  118333. */
  118334. getScene(): Scene;
  118335. /** Gets the internal CubeTexture used to render to */
  118336. readonly cubeTexture: RenderTargetTexture;
  118337. /** Gets the list of meshes to render */
  118338. readonly renderList: Nullable<AbstractMesh[]>;
  118339. /**
  118340. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  118341. * @param mesh defines the mesh to attach to
  118342. */
  118343. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  118344. /**
  118345. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  118346. * @param renderingGroupId The rendering group id corresponding to its index
  118347. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  118348. */
  118349. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  118350. /**
  118351. * Clean all associated resources
  118352. */
  118353. dispose(): void;
  118354. /**
  118355. * Converts the reflection probe information to a readable string for debug purpose.
  118356. * @param fullDetails Supports for multiple levels of logging within scene loading
  118357. * @returns the human readable reflection probe info
  118358. */
  118359. toString(fullDetails?: boolean): string;
  118360. /**
  118361. * Get the class name of the relfection probe.
  118362. * @returns "ReflectionProbe"
  118363. */
  118364. getClassName(): string;
  118365. /**
  118366. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  118367. * @returns The JSON representation of the texture
  118368. */
  118369. serialize(): any;
  118370. /**
  118371. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  118372. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  118373. * @param scene Define the scene the parsed reflection probe should be instantiated in
  118374. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  118375. * @returns The parsed reflection probe if successful
  118376. */
  118377. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  118378. }
  118379. }
  118380. declare module BABYLON {
  118381. /** @hidden */
  118382. export var _BabylonLoaderRegistered: boolean;
  118383. }
  118384. declare module BABYLON {
  118385. /**
  118386. * The Physically based simple base material of BJS.
  118387. *
  118388. * This enables better naming and convention enforcements on top of the pbrMaterial.
  118389. * It is used as the base class for both the specGloss and metalRough conventions.
  118390. */
  118391. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  118392. /**
  118393. * Number of Simultaneous lights allowed on the material.
  118394. */
  118395. maxSimultaneousLights: number;
  118396. /**
  118397. * If sets to true, disables all the lights affecting the material.
  118398. */
  118399. disableLighting: boolean;
  118400. /**
  118401. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  118402. */
  118403. environmentTexture: BaseTexture;
  118404. /**
  118405. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  118406. */
  118407. invertNormalMapX: boolean;
  118408. /**
  118409. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  118410. */
  118411. invertNormalMapY: boolean;
  118412. /**
  118413. * Normal map used in the model.
  118414. */
  118415. normalTexture: BaseTexture;
  118416. /**
  118417. * Emissivie color used to self-illuminate the model.
  118418. */
  118419. emissiveColor: Color3;
  118420. /**
  118421. * Emissivie texture used to self-illuminate the model.
  118422. */
  118423. emissiveTexture: BaseTexture;
  118424. /**
  118425. * Occlusion Channel Strenght.
  118426. */
  118427. occlusionStrength: number;
  118428. /**
  118429. * Occlusion Texture of the material (adding extra occlusion effects).
  118430. */
  118431. occlusionTexture: BaseTexture;
  118432. /**
  118433. * Defines the alpha limits in alpha test mode.
  118434. */
  118435. alphaCutOff: number;
  118436. /**
  118437. * Gets the current double sided mode.
  118438. */
  118439. /**
  118440. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  118441. */
  118442. doubleSided: boolean;
  118443. /**
  118444. * Stores the pre-calculated light information of a mesh in a texture.
  118445. */
  118446. lightmapTexture: BaseTexture;
  118447. /**
  118448. * If true, the light map contains occlusion information instead of lighting info.
  118449. */
  118450. useLightmapAsShadowmap: boolean;
  118451. /**
  118452. * Instantiates a new PBRMaterial instance.
  118453. *
  118454. * @param name The material name
  118455. * @param scene The scene the material will be use in.
  118456. */
  118457. constructor(name: string, scene: Scene);
  118458. getClassName(): string;
  118459. }
  118460. }
  118461. declare module BABYLON {
  118462. /**
  118463. * The PBR material of BJS following the metal roughness convention.
  118464. *
  118465. * This fits to the PBR convention in the GLTF definition:
  118466. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  118467. */
  118468. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  118469. /**
  118470. * The base color has two different interpretations depending on the value of metalness.
  118471. * When the material is a metal, the base color is the specific measured reflectance value
  118472. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  118473. * of the material.
  118474. */
  118475. baseColor: Color3;
  118476. /**
  118477. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  118478. * well as opacity information in the alpha channel.
  118479. */
  118480. baseTexture: BaseTexture;
  118481. /**
  118482. * Specifies the metallic scalar value of the material.
  118483. * Can also be used to scale the metalness values of the metallic texture.
  118484. */
  118485. metallic: number;
  118486. /**
  118487. * Specifies the roughness scalar value of the material.
  118488. * Can also be used to scale the roughness values of the metallic texture.
  118489. */
  118490. roughness: number;
  118491. /**
  118492. * Texture containing both the metallic value in the B channel and the
  118493. * roughness value in the G channel to keep better precision.
  118494. */
  118495. metallicRoughnessTexture: BaseTexture;
  118496. /**
  118497. * Instantiates a new PBRMetalRoughnessMaterial instance.
  118498. *
  118499. * @param name The material name
  118500. * @param scene The scene the material will be use in.
  118501. */
  118502. constructor(name: string, scene: Scene);
  118503. /**
  118504. * Return the currrent class name of the material.
  118505. */
  118506. getClassName(): string;
  118507. /**
  118508. * Makes a duplicate of the current material.
  118509. * @param name - name to use for the new material.
  118510. */
  118511. clone(name: string): PBRMetallicRoughnessMaterial;
  118512. /**
  118513. * Serialize the material to a parsable JSON object.
  118514. */
  118515. serialize(): any;
  118516. /**
  118517. * Parses a JSON object correponding to the serialize function.
  118518. */
  118519. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  118520. }
  118521. }
  118522. declare module BABYLON {
  118523. /**
  118524. * The PBR material of BJS following the specular glossiness convention.
  118525. *
  118526. * This fits to the PBR convention in the GLTF definition:
  118527. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  118528. */
  118529. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  118530. /**
  118531. * Specifies the diffuse color of the material.
  118532. */
  118533. diffuseColor: Color3;
  118534. /**
  118535. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  118536. * channel.
  118537. */
  118538. diffuseTexture: BaseTexture;
  118539. /**
  118540. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  118541. */
  118542. specularColor: Color3;
  118543. /**
  118544. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  118545. */
  118546. glossiness: number;
  118547. /**
  118548. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  118549. */
  118550. specularGlossinessTexture: BaseTexture;
  118551. /**
  118552. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  118553. *
  118554. * @param name The material name
  118555. * @param scene The scene the material will be use in.
  118556. */
  118557. constructor(name: string, scene: Scene);
  118558. /**
  118559. * Return the currrent class name of the material.
  118560. */
  118561. getClassName(): string;
  118562. /**
  118563. * Makes a duplicate of the current material.
  118564. * @param name - name to use for the new material.
  118565. */
  118566. clone(name: string): PBRSpecularGlossinessMaterial;
  118567. /**
  118568. * Serialize the material to a parsable JSON object.
  118569. */
  118570. serialize(): any;
  118571. /**
  118572. * Parses a JSON object correponding to the serialize function.
  118573. */
  118574. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  118575. }
  118576. }
  118577. declare module BABYLON {
  118578. /**
  118579. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  118580. * It can help converting any input color in a desired output one. This can then be used to create effects
  118581. * from sepia, black and white to sixties or futuristic rendering...
  118582. *
  118583. * The only supported format is currently 3dl.
  118584. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  118585. */
  118586. export class ColorGradingTexture extends BaseTexture {
  118587. /**
  118588. * The current texture matrix. (will always be identity in color grading texture)
  118589. */
  118590. private _textureMatrix;
  118591. /**
  118592. * The texture URL.
  118593. */
  118594. url: string;
  118595. /**
  118596. * Empty line regex stored for GC.
  118597. */
  118598. private static _noneEmptyLineRegex;
  118599. private _engine;
  118600. /**
  118601. * Instantiates a ColorGradingTexture from the following parameters.
  118602. *
  118603. * @param url The location of the color gradind data (currently only supporting 3dl)
  118604. * @param scene The scene the texture will be used in
  118605. */
  118606. constructor(url: string, scene: Scene);
  118607. /**
  118608. * Returns the texture matrix used in most of the material.
  118609. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  118610. */
  118611. getTextureMatrix(): Matrix;
  118612. /**
  118613. * Occurs when the file being loaded is a .3dl LUT file.
  118614. */
  118615. private load3dlTexture;
  118616. /**
  118617. * Starts the loading process of the texture.
  118618. */
  118619. private loadTexture;
  118620. /**
  118621. * Clones the color gradind texture.
  118622. */
  118623. clone(): ColorGradingTexture;
  118624. /**
  118625. * Called during delayed load for textures.
  118626. */
  118627. delayLoad(): void;
  118628. /**
  118629. * Parses a color grading texture serialized by Babylon.
  118630. * @param parsedTexture The texture information being parsedTexture
  118631. * @param scene The scene to load the texture in
  118632. * @param rootUrl The root url of the data assets to load
  118633. * @return A color gradind texture
  118634. */
  118635. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  118636. /**
  118637. * Serializes the LUT texture to json format.
  118638. */
  118639. serialize(): any;
  118640. }
  118641. }
  118642. declare module BABYLON {
  118643. /**
  118644. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  118645. */
  118646. export class EquiRectangularCubeTexture extends BaseTexture {
  118647. /** The six faces of the cube. */
  118648. private static _FacesMapping;
  118649. private _noMipmap;
  118650. private _onLoad;
  118651. private _onError;
  118652. /** The size of the cubemap. */
  118653. private _size;
  118654. /** The buffer of the image. */
  118655. private _buffer;
  118656. /** The width of the input image. */
  118657. private _width;
  118658. /** The height of the input image. */
  118659. private _height;
  118660. /** The URL to the image. */
  118661. url: string;
  118662. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  118663. coordinatesMode: number;
  118664. /**
  118665. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  118666. * @param url The location of the image
  118667. * @param scene The scene the texture will be used in
  118668. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  118669. * @param noMipmap Forces to not generate the mipmap if true
  118670. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  118671. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  118672. * @param onLoad — defines a callback called when texture is loaded
  118673. * @param onError — defines a callback called if there is an error
  118674. */
  118675. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  118676. /**
  118677. * Load the image data, by putting the image on a canvas and extracting its buffer.
  118678. */
  118679. private loadImage;
  118680. /**
  118681. * Convert the image buffer into a cubemap and create a CubeTexture.
  118682. */
  118683. private loadTexture;
  118684. /**
  118685. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  118686. * @param buffer The ArrayBuffer that should be converted.
  118687. * @returns The buffer as Float32Array.
  118688. */
  118689. private getFloat32ArrayFromArrayBuffer;
  118690. /**
  118691. * Get the current class name of the texture useful for serialization or dynamic coding.
  118692. * @returns "EquiRectangularCubeTexture"
  118693. */
  118694. getClassName(): string;
  118695. /**
  118696. * Create a clone of the current EquiRectangularCubeTexture and return it.
  118697. * @returns A clone of the current EquiRectangularCubeTexture.
  118698. */
  118699. clone(): EquiRectangularCubeTexture;
  118700. }
  118701. }
  118702. declare module BABYLON {
  118703. /**
  118704. * Based on jsTGALoader - Javascript loader for TGA file
  118705. * By Vincent Thibault
  118706. * @see http://blog.robrowser.com/javascript-tga-loader.html
  118707. */
  118708. export class TGATools {
  118709. private static _TYPE_INDEXED;
  118710. private static _TYPE_RGB;
  118711. private static _TYPE_GREY;
  118712. private static _TYPE_RLE_INDEXED;
  118713. private static _TYPE_RLE_RGB;
  118714. private static _TYPE_RLE_GREY;
  118715. private static _ORIGIN_MASK;
  118716. private static _ORIGIN_SHIFT;
  118717. private static _ORIGIN_BL;
  118718. private static _ORIGIN_BR;
  118719. private static _ORIGIN_UL;
  118720. private static _ORIGIN_UR;
  118721. /**
  118722. * Gets the header of a TGA file
  118723. * @param data defines the TGA data
  118724. * @returns the header
  118725. */
  118726. static GetTGAHeader(data: Uint8Array): any;
  118727. /**
  118728. * Uploads TGA content to a Babylon Texture
  118729. * @hidden
  118730. */
  118731. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  118732. /** @hidden */
  118733. 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;
  118734. /** @hidden */
  118735. 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;
  118736. /** @hidden */
  118737. 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;
  118738. /** @hidden */
  118739. 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;
  118740. /** @hidden */
  118741. 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;
  118742. /** @hidden */
  118743. 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;
  118744. }
  118745. }
  118746. declare module BABYLON {
  118747. /**
  118748. * Implementation of the TGA Texture Loader.
  118749. * @hidden
  118750. */
  118751. export class _TGATextureLoader implements IInternalTextureLoader {
  118752. /**
  118753. * Defines wether the loader supports cascade loading the different faces.
  118754. */
  118755. readonly supportCascades: boolean;
  118756. /**
  118757. * This returns if the loader support the current file information.
  118758. * @param extension defines the file extension of the file being loaded
  118759. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118760. * @param fallback defines the fallback internal texture if any
  118761. * @param isBase64 defines whether the texture is encoded as a base64
  118762. * @param isBuffer defines whether the texture data are stored as a buffer
  118763. * @returns true if the loader can load the specified file
  118764. */
  118765. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  118766. /**
  118767. * Transform the url before loading if required.
  118768. * @param rootUrl the url of the texture
  118769. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118770. * @returns the transformed texture
  118771. */
  118772. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  118773. /**
  118774. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  118775. * @param rootUrl the url of the texture
  118776. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118777. * @returns the fallback texture
  118778. */
  118779. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  118780. /**
  118781. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  118782. * @param data contains the texture data
  118783. * @param texture defines the BabylonJS internal texture
  118784. * @param createPolynomials will be true if polynomials have been requested
  118785. * @param onLoad defines the callback to trigger once the texture is ready
  118786. * @param onError defines the callback to trigger in case of error
  118787. */
  118788. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  118789. /**
  118790. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  118791. * @param data contains the texture data
  118792. * @param texture defines the BabylonJS internal texture
  118793. * @param callback defines the method to call once ready to upload
  118794. */
  118795. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  118796. }
  118797. }
  118798. declare module BABYLON {
  118799. /**
  118800. * Info about the .basis files
  118801. */
  118802. class BasisFileInfo {
  118803. /**
  118804. * If the file has alpha
  118805. */
  118806. hasAlpha: boolean;
  118807. /**
  118808. * Info about each image of the basis file
  118809. */
  118810. images: Array<{
  118811. levels: Array<{
  118812. width: number;
  118813. height: number;
  118814. transcodedPixels: ArrayBufferView;
  118815. }>;
  118816. }>;
  118817. }
  118818. /**
  118819. * Result of transcoding a basis file
  118820. */
  118821. class TranscodeResult {
  118822. /**
  118823. * Info about the .basis file
  118824. */
  118825. fileInfo: BasisFileInfo;
  118826. /**
  118827. * Format to use when loading the file
  118828. */
  118829. format: number;
  118830. }
  118831. /**
  118832. * Configuration options for the Basis transcoder
  118833. */
  118834. export class BasisTranscodeConfiguration {
  118835. /**
  118836. * Supported compression formats used to determine the supported output format of the transcoder
  118837. */
  118838. supportedCompressionFormats?: {
  118839. /**
  118840. * etc1 compression format
  118841. */
  118842. etc1?: boolean;
  118843. /**
  118844. * s3tc compression format
  118845. */
  118846. s3tc?: boolean;
  118847. /**
  118848. * pvrtc compression format
  118849. */
  118850. pvrtc?: boolean;
  118851. /**
  118852. * etc2 compression format
  118853. */
  118854. etc2?: boolean;
  118855. };
  118856. /**
  118857. * If mipmap levels should be loaded for transcoded images (Default: true)
  118858. */
  118859. loadMipmapLevels?: boolean;
  118860. /**
  118861. * Index of a single image to load (Default: all images)
  118862. */
  118863. loadSingleImage?: number;
  118864. }
  118865. /**
  118866. * Used to load .Basis files
  118867. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  118868. */
  118869. export class BasisTools {
  118870. private static _IgnoreSupportedFormats;
  118871. /**
  118872. * URL to use when loading the basis transcoder
  118873. */
  118874. static JSModuleURL: string;
  118875. /**
  118876. * URL to use when loading the wasm module for the transcoder
  118877. */
  118878. static WasmModuleURL: string;
  118879. /**
  118880. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  118881. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  118882. * @returns internal format corresponding to the Basis format
  118883. */
  118884. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  118885. private static _WorkerPromise;
  118886. private static _Worker;
  118887. private static _actionId;
  118888. private static _CreateWorkerAsync;
  118889. /**
  118890. * Transcodes a loaded image file to compressed pixel data
  118891. * @param imageData image data to transcode
  118892. * @param config configuration options for the transcoding
  118893. * @returns a promise resulting in the transcoded image
  118894. */
  118895. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  118896. /**
  118897. * Loads a texture from the transcode result
  118898. * @param texture texture load to
  118899. * @param transcodeResult the result of transcoding the basis file to load from
  118900. */
  118901. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  118902. }
  118903. }
  118904. declare module BABYLON {
  118905. /**
  118906. * Loader for .basis file format
  118907. */
  118908. export class _BasisTextureLoader implements IInternalTextureLoader {
  118909. /**
  118910. * Defines whether the loader supports cascade loading the different faces.
  118911. */
  118912. readonly supportCascades: boolean;
  118913. /**
  118914. * This returns if the loader support the current file information.
  118915. * @param extension defines the file extension of the file being loaded
  118916. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118917. * @param fallback defines the fallback internal texture if any
  118918. * @param isBase64 defines whether the texture is encoded as a base64
  118919. * @param isBuffer defines whether the texture data are stored as a buffer
  118920. * @returns true if the loader can load the specified file
  118921. */
  118922. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  118923. /**
  118924. * Transform the url before loading if required.
  118925. * @param rootUrl the url of the texture
  118926. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118927. * @returns the transformed texture
  118928. */
  118929. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  118930. /**
  118931. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  118932. * @param rootUrl the url of the texture
  118933. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118934. * @returns the fallback texture
  118935. */
  118936. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  118937. /**
  118938. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  118939. * @param data contains the texture data
  118940. * @param texture defines the BabylonJS internal texture
  118941. * @param createPolynomials will be true if polynomials have been requested
  118942. * @param onLoad defines the callback to trigger once the texture is ready
  118943. * @param onError defines the callback to trigger in case of error
  118944. */
  118945. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  118946. /**
  118947. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  118948. * @param data contains the texture data
  118949. * @param texture defines the BabylonJS internal texture
  118950. * @param callback defines the method to call once ready to upload
  118951. */
  118952. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  118953. }
  118954. }
  118955. declare module BABYLON {
  118956. /**
  118957. * 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.
  118958. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  118959. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  118960. */
  118961. export class CustomProceduralTexture extends ProceduralTexture {
  118962. private _animate;
  118963. private _time;
  118964. private _config;
  118965. private _texturePath;
  118966. /**
  118967. * Instantiates a new Custom Procedural Texture.
  118968. * 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.
  118969. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  118970. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  118971. * @param name Define the name of the texture
  118972. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  118973. * @param size Define the size of the texture to create
  118974. * @param scene Define the scene the texture belongs to
  118975. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  118976. * @param generateMipMaps Define if the texture should creates mip maps or not
  118977. */
  118978. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  118979. private _loadJson;
  118980. /**
  118981. * Is the texture ready to be used ? (rendered at least once)
  118982. * @returns true if ready, otherwise, false.
  118983. */
  118984. isReady(): boolean;
  118985. /**
  118986. * Render the texture to its associated render target.
  118987. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  118988. */
  118989. render(useCameraPostProcess?: boolean): void;
  118990. /**
  118991. * Update the list of dependant textures samplers in the shader.
  118992. */
  118993. updateTextures(): void;
  118994. /**
  118995. * Update the uniform values of the procedural texture in the shader.
  118996. */
  118997. updateShaderUniforms(): void;
  118998. /**
  118999. * Define if the texture animates or not.
  119000. */
  119001. animate: boolean;
  119002. }
  119003. }
  119004. declare module BABYLON {
  119005. /** @hidden */
  119006. export var noisePixelShader: {
  119007. name: string;
  119008. shader: string;
  119009. };
  119010. }
  119011. declare module BABYLON {
  119012. /**
  119013. * Class used to generate noise procedural textures
  119014. */
  119015. export class NoiseProceduralTexture extends ProceduralTexture {
  119016. private _time;
  119017. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  119018. brightness: number;
  119019. /** Defines the number of octaves to process */
  119020. octaves: number;
  119021. /** Defines the level of persistence (0.8 by default) */
  119022. persistence: number;
  119023. /** Gets or sets animation speed factor (default is 1) */
  119024. animationSpeedFactor: number;
  119025. /**
  119026. * Creates a new NoiseProceduralTexture
  119027. * @param name defines the name fo the texture
  119028. * @param size defines the size of the texture (default is 256)
  119029. * @param scene defines the hosting scene
  119030. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  119031. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  119032. */
  119033. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  119034. private _updateShaderUniforms;
  119035. protected _getDefines(): string;
  119036. /** Generate the current state of the procedural texture */
  119037. render(useCameraPostProcess?: boolean): void;
  119038. /**
  119039. * Serializes this noise procedural texture
  119040. * @returns a serialized noise procedural texture object
  119041. */
  119042. serialize(): any;
  119043. /**
  119044. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  119045. * @param parsedTexture defines parsed texture data
  119046. * @param scene defines the current scene
  119047. * @param rootUrl defines the root URL containing noise procedural texture information
  119048. * @returns a parsed NoiseProceduralTexture
  119049. */
  119050. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  119051. }
  119052. }
  119053. declare module BABYLON {
  119054. /**
  119055. * Raw cube texture where the raw buffers are passed in
  119056. */
  119057. export class RawCubeTexture extends CubeTexture {
  119058. /**
  119059. * Creates a cube texture where the raw buffers are passed in.
  119060. * @param scene defines the scene the texture is attached to
  119061. * @param data defines the array of data to use to create each face
  119062. * @param size defines the size of the textures
  119063. * @param format defines the format of the data
  119064. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  119065. * @param generateMipMaps defines if the engine should generate the mip levels
  119066. * @param invertY defines if data must be stored with Y axis inverted
  119067. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  119068. * @param compression defines the compression used (null by default)
  119069. */
  119070. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  119071. /**
  119072. * Updates the raw cube texture.
  119073. * @param data defines the data to store
  119074. * @param format defines the data format
  119075. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  119076. * @param invertY defines if data must be stored with Y axis inverted
  119077. * @param compression defines the compression used (null by default)
  119078. * @param level defines which level of the texture to update
  119079. */
  119080. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  119081. /**
  119082. * Updates a raw cube texture with RGBD encoded data.
  119083. * @param data defines the array of data [mipmap][face] to use to create each face
  119084. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  119085. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  119086. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  119087. * @returns a promsie that resolves when the operation is complete
  119088. */
  119089. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  119090. /**
  119091. * Clones the raw cube texture.
  119092. * @return a new cube texture
  119093. */
  119094. clone(): CubeTexture;
  119095. /** @hidden */
  119096. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  119097. }
  119098. }
  119099. declare module BABYLON {
  119100. /**
  119101. * Class used to store 3D textures containing user data
  119102. */
  119103. export class RawTexture3D extends Texture {
  119104. /** Gets or sets the texture format to use */
  119105. format: number;
  119106. private _engine;
  119107. /**
  119108. * Create a new RawTexture3D
  119109. * @param data defines the data of the texture
  119110. * @param width defines the width of the texture
  119111. * @param height defines the height of the texture
  119112. * @param depth defines the depth of the texture
  119113. * @param format defines the texture format to use
  119114. * @param scene defines the hosting scene
  119115. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  119116. * @param invertY defines if texture must be stored with Y axis inverted
  119117. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  119118. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  119119. */
  119120. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  119121. /** Gets or sets the texture format to use */
  119122. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  119123. /**
  119124. * Update the texture with new data
  119125. * @param data defines the data to store in the texture
  119126. */
  119127. update(data: ArrayBufferView): void;
  119128. }
  119129. }
  119130. declare module BABYLON {
  119131. /**
  119132. * Creates a refraction texture used by refraction channel of the standard material.
  119133. * It is like a mirror but to see through a material.
  119134. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  119135. */
  119136. export class RefractionTexture extends RenderTargetTexture {
  119137. /**
  119138. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  119139. * 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.
  119140. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  119141. */
  119142. refractionPlane: Plane;
  119143. /**
  119144. * Define how deep under the surface we should see.
  119145. */
  119146. depth: number;
  119147. /**
  119148. * Creates a refraction texture used by refraction channel of the standard material.
  119149. * It is like a mirror but to see through a material.
  119150. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  119151. * @param name Define the texture name
  119152. * @param size Define the size of the underlying texture
  119153. * @param scene Define the scene the refraction belongs to
  119154. * @param generateMipMaps Define if we need to generate mips level for the refraction
  119155. */
  119156. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  119157. /**
  119158. * Clone the refraction texture.
  119159. * @returns the cloned texture
  119160. */
  119161. clone(): RefractionTexture;
  119162. /**
  119163. * Serialize the texture to a JSON representation you could use in Parse later on
  119164. * @returns the serialized JSON representation
  119165. */
  119166. serialize(): any;
  119167. }
  119168. }
  119169. declare module BABYLON {
  119170. /**
  119171. * Defines the options related to the creation of an HtmlElementTexture
  119172. */
  119173. export interface IHtmlElementTextureOptions {
  119174. /**
  119175. * Defines wether mip maps should be created or not.
  119176. */
  119177. generateMipMaps?: boolean;
  119178. /**
  119179. * Defines the sampling mode of the texture.
  119180. */
  119181. samplingMode?: number;
  119182. /**
  119183. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  119184. */
  119185. engine: Nullable<Engine>;
  119186. /**
  119187. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  119188. */
  119189. scene: Nullable<Scene>;
  119190. }
  119191. /**
  119192. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  119193. * To be as efficient as possible depending on your constraints nothing aside the first upload
  119194. * is automatically managed.
  119195. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  119196. * in your application.
  119197. *
  119198. * As the update is not automatic, you need to call them manually.
  119199. */
  119200. export class HtmlElementTexture extends BaseTexture {
  119201. /**
  119202. * The texture URL.
  119203. */
  119204. element: HTMLVideoElement | HTMLCanvasElement;
  119205. private static readonly DefaultOptions;
  119206. private _textureMatrix;
  119207. private _engine;
  119208. private _isVideo;
  119209. private _generateMipMaps;
  119210. private _samplingMode;
  119211. /**
  119212. * Instantiates a HtmlElementTexture from the following parameters.
  119213. *
  119214. * @param name Defines the name of the texture
  119215. * @param element Defines the video or canvas the texture is filled with
  119216. * @param options Defines the other none mandatory texture creation options
  119217. */
  119218. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  119219. private _createInternalTexture;
  119220. /**
  119221. * Returns the texture matrix used in most of the material.
  119222. */
  119223. getTextureMatrix(): Matrix;
  119224. /**
  119225. * Updates the content of the texture.
  119226. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  119227. */
  119228. update(invertY?: Nullable<boolean>): void;
  119229. }
  119230. }
  119231. declare module BABYLON {
  119232. /**
  119233. * Enum used to define the target of a block
  119234. */
  119235. export enum NodeMaterialBlockTargets {
  119236. /** Vertex shader */
  119237. Vertex = 1,
  119238. /** Fragment shader */
  119239. Fragment = 2,
  119240. /** Neutral */
  119241. Neutral = 4,
  119242. /** Vertex and Fragment */
  119243. VertexAndFragment = 3
  119244. }
  119245. }
  119246. declare module BABYLON {
  119247. /**
  119248. * Defines the kind of connection point for node based material
  119249. */
  119250. export enum NodeMaterialBlockConnectionPointTypes {
  119251. /** Float */
  119252. Float = 1,
  119253. /** Int */
  119254. Int = 2,
  119255. /** Vector2 */
  119256. Vector2 = 4,
  119257. /** Vector3 */
  119258. Vector3 = 8,
  119259. /** Vector4 */
  119260. Vector4 = 16,
  119261. /** Color3 */
  119262. Color3 = 32,
  119263. /** Color4 */
  119264. Color4 = 64,
  119265. /** Matrix */
  119266. Matrix = 128,
  119267. /** Detect type based on connection */
  119268. AutoDetect = 1024,
  119269. /** Output type that will be defined by input type */
  119270. BasedOnInput = 2048
  119271. }
  119272. }
  119273. declare module BABYLON {
  119274. /**
  119275. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  119276. */
  119277. export enum NodeMaterialBlockConnectionPointMode {
  119278. /** Value is an uniform */
  119279. Uniform = 0,
  119280. /** Value is a mesh attribute */
  119281. Attribute = 1,
  119282. /** Value is a varying between vertex and fragment shaders */
  119283. Varying = 2,
  119284. /** Mode is undefined */
  119285. Undefined = 3
  119286. }
  119287. }
  119288. declare module BABYLON {
  119289. /**
  119290. * Enum used to define system values e.g. values automatically provided by the system
  119291. */
  119292. export enum NodeMaterialSystemValues {
  119293. /** World */
  119294. World = 1,
  119295. /** View */
  119296. View = 2,
  119297. /** Projection */
  119298. Projection = 3,
  119299. /** ViewProjection */
  119300. ViewProjection = 4,
  119301. /** WorldView */
  119302. WorldView = 5,
  119303. /** WorldViewProjection */
  119304. WorldViewProjection = 6,
  119305. /** CameraPosition */
  119306. CameraPosition = 7,
  119307. /** Fog Color */
  119308. FogColor = 8,
  119309. /** Delta time */
  119310. DeltaTime = 9
  119311. }
  119312. }
  119313. declare module BABYLON {
  119314. /**
  119315. * Root class for all node material optimizers
  119316. */
  119317. export class NodeMaterialOptimizer {
  119318. /**
  119319. * Function used to optimize a NodeMaterial graph
  119320. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  119321. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  119322. */
  119323. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  119324. }
  119325. }
  119326. declare module BABYLON {
  119327. /**
  119328. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  119329. */
  119330. export class TransformBlock extends NodeMaterialBlock {
  119331. /**
  119332. * Defines the value to use to complement W value to transform it to a Vector4
  119333. */
  119334. complementW: number;
  119335. /**
  119336. * Defines the value to use to complement z value to transform it to a Vector4
  119337. */
  119338. complementZ: number;
  119339. /**
  119340. * Creates a new TransformBlock
  119341. * @param name defines the block name
  119342. */
  119343. constructor(name: string);
  119344. /**
  119345. * Gets the current class name
  119346. * @returns the class name
  119347. */
  119348. getClassName(): string;
  119349. /**
  119350. * Gets the vector input
  119351. */
  119352. readonly vector: NodeMaterialConnectionPoint;
  119353. /**
  119354. * Gets the output component
  119355. */
  119356. readonly output: NodeMaterialConnectionPoint;
  119357. /**
  119358. * Gets the matrix transform input
  119359. */
  119360. readonly transform: NodeMaterialConnectionPoint;
  119361. protected _buildBlock(state: NodeMaterialBuildState): this;
  119362. serialize(): any;
  119363. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119364. protected _dumpPropertiesCode(): string;
  119365. }
  119366. }
  119367. declare module BABYLON {
  119368. /**
  119369. * Block used to output the vertex position
  119370. */
  119371. export class VertexOutputBlock extends NodeMaterialBlock {
  119372. /**
  119373. * Creates a new VertexOutputBlock
  119374. * @param name defines the block name
  119375. */
  119376. constructor(name: string);
  119377. /**
  119378. * Gets the current class name
  119379. * @returns the class name
  119380. */
  119381. getClassName(): string;
  119382. /**
  119383. * Gets the vector input component
  119384. */
  119385. readonly vector: NodeMaterialConnectionPoint;
  119386. protected _buildBlock(state: NodeMaterialBuildState): this;
  119387. }
  119388. }
  119389. declare module BABYLON {
  119390. /**
  119391. * Block used to output the final color
  119392. */
  119393. export class FragmentOutputBlock extends NodeMaterialBlock {
  119394. /**
  119395. * Create a new FragmentOutputBlock
  119396. * @param name defines the block name
  119397. */
  119398. constructor(name: string);
  119399. /**
  119400. * Gets the current class name
  119401. * @returns the class name
  119402. */
  119403. getClassName(): string;
  119404. /**
  119405. * Gets the rgba input component
  119406. */
  119407. readonly rgba: NodeMaterialConnectionPoint;
  119408. /**
  119409. * Gets the rgb input component
  119410. */
  119411. readonly rgb: NodeMaterialConnectionPoint;
  119412. /**
  119413. * Gets the a input component
  119414. */
  119415. readonly a: NodeMaterialConnectionPoint;
  119416. protected _buildBlock(state: NodeMaterialBuildState): this;
  119417. }
  119418. }
  119419. declare module BABYLON {
  119420. /**
  119421. * Block used to read a reflection texture from a sampler
  119422. */
  119423. export class ReflectionTextureBlock extends NodeMaterialBlock {
  119424. private _define3DName;
  119425. private _defineCubicName;
  119426. private _defineExplicitName;
  119427. private _defineProjectionName;
  119428. private _defineLocalCubicName;
  119429. private _defineSphericalName;
  119430. private _definePlanarName;
  119431. private _defineEquirectangularName;
  119432. private _defineMirroredEquirectangularFixedName;
  119433. private _defineEquirectangularFixedName;
  119434. private _defineSkyboxName;
  119435. private _cubeSamplerName;
  119436. private _2DSamplerName;
  119437. private _positionUVWName;
  119438. private _directionWName;
  119439. private _reflectionCoordsName;
  119440. private _reflection2DCoordsName;
  119441. private _reflectionColorName;
  119442. private _reflectionMatrixName;
  119443. /**
  119444. * Gets or sets the texture associated with the node
  119445. */
  119446. texture: Nullable<BaseTexture>;
  119447. /**
  119448. * Create a new TextureBlock
  119449. * @param name defines the block name
  119450. */
  119451. constructor(name: string);
  119452. /**
  119453. * Gets the current class name
  119454. * @returns the class name
  119455. */
  119456. getClassName(): string;
  119457. /**
  119458. * Gets the world position input component
  119459. */
  119460. readonly position: NodeMaterialConnectionPoint;
  119461. /**
  119462. * Gets the world position input component
  119463. */
  119464. readonly worldPosition: NodeMaterialConnectionPoint;
  119465. /**
  119466. * Gets the world normal input component
  119467. */
  119468. readonly worldNormal: NodeMaterialConnectionPoint;
  119469. /**
  119470. * Gets the world input component
  119471. */
  119472. readonly world: NodeMaterialConnectionPoint;
  119473. /**
  119474. * Gets the camera (or eye) position component
  119475. */
  119476. readonly cameraPosition: NodeMaterialConnectionPoint;
  119477. /**
  119478. * Gets the view input component
  119479. */
  119480. readonly view: NodeMaterialConnectionPoint;
  119481. /**
  119482. * Gets the rgb output component
  119483. */
  119484. readonly rgb: NodeMaterialConnectionPoint;
  119485. /**
  119486. * Gets the r output component
  119487. */
  119488. readonly r: NodeMaterialConnectionPoint;
  119489. /**
  119490. * Gets the g output component
  119491. */
  119492. readonly g: NodeMaterialConnectionPoint;
  119493. /**
  119494. * Gets the b output component
  119495. */
  119496. readonly b: NodeMaterialConnectionPoint;
  119497. autoConfigure(material: NodeMaterial): void;
  119498. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119499. isReady(): boolean;
  119500. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119501. private _injectVertexCode;
  119502. private _writeOutput;
  119503. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  119504. serialize(): any;
  119505. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119506. }
  119507. }
  119508. declare module BABYLON {
  119509. /**
  119510. * Interface used to configure the node material editor
  119511. */
  119512. export interface INodeMaterialEditorOptions {
  119513. /** Define the URl to load node editor script */
  119514. editorURL?: string;
  119515. }
  119516. /** @hidden */
  119517. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  119518. /** BONES */
  119519. NUM_BONE_INFLUENCERS: number;
  119520. BonesPerMesh: number;
  119521. BONETEXTURE: boolean;
  119522. /** MORPH TARGETS */
  119523. MORPHTARGETS: boolean;
  119524. MORPHTARGETS_NORMAL: boolean;
  119525. MORPHTARGETS_TANGENT: boolean;
  119526. MORPHTARGETS_UV: boolean;
  119527. NUM_MORPH_INFLUENCERS: number;
  119528. /** IMAGE PROCESSING */
  119529. IMAGEPROCESSING: boolean;
  119530. VIGNETTE: boolean;
  119531. VIGNETTEBLENDMODEMULTIPLY: boolean;
  119532. VIGNETTEBLENDMODEOPAQUE: boolean;
  119533. TONEMAPPING: boolean;
  119534. TONEMAPPING_ACES: boolean;
  119535. CONTRAST: boolean;
  119536. EXPOSURE: boolean;
  119537. COLORCURVES: boolean;
  119538. COLORGRADING: boolean;
  119539. COLORGRADING3D: boolean;
  119540. SAMPLER3DGREENDEPTH: boolean;
  119541. SAMPLER3DBGRMAP: boolean;
  119542. IMAGEPROCESSINGPOSTPROCESS: boolean;
  119543. /** MISC. */
  119544. BUMPDIRECTUV: number;
  119545. constructor();
  119546. setValue(name: string, value: boolean): void;
  119547. }
  119548. /**
  119549. * Class used to configure NodeMaterial
  119550. */
  119551. export interface INodeMaterialOptions {
  119552. /**
  119553. * Defines if blocks should emit comments
  119554. */
  119555. emitComments: boolean;
  119556. }
  119557. /**
  119558. * Class used to create a node based material built by assembling shader blocks
  119559. */
  119560. export class NodeMaterial extends PushMaterial {
  119561. private static _BuildIdGenerator;
  119562. private _options;
  119563. private _vertexCompilationState;
  119564. private _fragmentCompilationState;
  119565. private _sharedData;
  119566. private _buildId;
  119567. private _buildWasSuccessful;
  119568. private _cachedWorldViewMatrix;
  119569. private _cachedWorldViewProjectionMatrix;
  119570. private _optimizers;
  119571. private _animationFrame;
  119572. /** Define the URl to load node editor script */
  119573. static EditorURL: string;
  119574. private BJSNODEMATERIALEDITOR;
  119575. /** Get the inspector from bundle or global */
  119576. private _getGlobalNodeMaterialEditor;
  119577. /**
  119578. * 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)
  119579. */
  119580. ignoreAlpha: boolean;
  119581. /**
  119582. * Defines the maximum number of lights that can be used in the material
  119583. */
  119584. maxSimultaneousLights: number;
  119585. /**
  119586. * Observable raised when the material is built
  119587. */
  119588. onBuildObservable: Observable<NodeMaterial>;
  119589. /**
  119590. * Gets or sets the root nodes of the material vertex shader
  119591. */
  119592. _vertexOutputNodes: NodeMaterialBlock[];
  119593. /**
  119594. * Gets or sets the root nodes of the material fragment (pixel) shader
  119595. */
  119596. _fragmentOutputNodes: NodeMaterialBlock[];
  119597. /** Gets or sets options to control the node material overall behavior */
  119598. options: INodeMaterialOptions;
  119599. /**
  119600. * Default configuration related to image processing available in the standard Material.
  119601. */
  119602. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  119603. /**
  119604. * Gets the image processing configuration used either in this material.
  119605. */
  119606. /**
  119607. * Sets the Default image processing configuration used either in the this material.
  119608. *
  119609. * If sets to null, the scene one is in use.
  119610. */
  119611. imageProcessingConfiguration: ImageProcessingConfiguration;
  119612. /**
  119613. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  119614. */
  119615. attachedBlocks: NodeMaterialBlock[];
  119616. /**
  119617. * Create a new node based material
  119618. * @param name defines the material name
  119619. * @param scene defines the hosting scene
  119620. * @param options defines creation option
  119621. */
  119622. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  119623. /**
  119624. * Gets the current class name of the material e.g. "NodeMaterial"
  119625. * @returns the class name
  119626. */
  119627. getClassName(): string;
  119628. /**
  119629. * Keep track of the image processing observer to allow dispose and replace.
  119630. */
  119631. private _imageProcessingObserver;
  119632. /**
  119633. * Attaches a new image processing configuration to the Standard Material.
  119634. * @param configuration
  119635. */
  119636. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  119637. /**
  119638. * Get a block by its name
  119639. * @param name defines the name of the block to retrieve
  119640. * @returns the required block or null if not found
  119641. */
  119642. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  119643. /**
  119644. * Get a block by its name
  119645. * @param predicate defines the predicate used to find the good candidate
  119646. * @returns the required block or null if not found
  119647. */
  119648. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  119649. /**
  119650. * Get an input block by its name
  119651. * @param predicate defines the predicate used to find the good candidate
  119652. * @returns the required input block or null if not found
  119653. */
  119654. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  119655. /**
  119656. * Gets the list of input blocks attached to this material
  119657. * @returns an array of InputBlocks
  119658. */
  119659. getInputBlocks(): InputBlock[];
  119660. /**
  119661. * Adds a new optimizer to the list of optimizers
  119662. * @param optimizer defines the optimizers to add
  119663. * @returns the current material
  119664. */
  119665. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  119666. /**
  119667. * Remove an optimizer from the list of optimizers
  119668. * @param optimizer defines the optimizers to remove
  119669. * @returns the current material
  119670. */
  119671. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  119672. /**
  119673. * Add a new block to the list of output nodes
  119674. * @param node defines the node to add
  119675. * @returns the current material
  119676. */
  119677. addOutputNode(node: NodeMaterialBlock): this;
  119678. /**
  119679. * Remove a block from the list of root nodes
  119680. * @param node defines the node to remove
  119681. * @returns the current material
  119682. */
  119683. removeOutputNode(node: NodeMaterialBlock): this;
  119684. private _addVertexOutputNode;
  119685. private _removeVertexOutputNode;
  119686. private _addFragmentOutputNode;
  119687. private _removeFragmentOutputNode;
  119688. /**
  119689. * Specifies if the material will require alpha blending
  119690. * @returns a boolean specifying if alpha blending is needed
  119691. */
  119692. needAlphaBlending(): boolean;
  119693. /**
  119694. * Specifies if this material should be rendered in alpha test mode
  119695. * @returns a boolean specifying if an alpha test is needed.
  119696. */
  119697. needAlphaTesting(): boolean;
  119698. private _initializeBlock;
  119699. private _resetDualBlocks;
  119700. /**
  119701. * Build the material and generates the inner effect
  119702. * @param verbose defines if the build should log activity
  119703. */
  119704. build(verbose?: boolean): void;
  119705. /**
  119706. * Runs an otpimization phase to try to improve the shader code
  119707. */
  119708. optimize(): void;
  119709. private _prepareDefinesForAttributes;
  119710. /**
  119711. * Get if the submesh is ready to be used and all its information available.
  119712. * Child classes can use it to update shaders
  119713. * @param mesh defines the mesh to check
  119714. * @param subMesh defines which submesh to check
  119715. * @param useInstances specifies that instances should be used
  119716. * @returns a boolean indicating that the submesh is ready or not
  119717. */
  119718. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  119719. /**
  119720. * Get a string representing the shaders built by the current node graph
  119721. */
  119722. readonly compiledShaders: string;
  119723. /**
  119724. * Binds the world matrix to the material
  119725. * @param world defines the world transformation matrix
  119726. */
  119727. bindOnlyWorldMatrix(world: Matrix): void;
  119728. /**
  119729. * Binds the submesh to this material by preparing the effect and shader to draw
  119730. * @param world defines the world transformation matrix
  119731. * @param mesh defines the mesh containing the submesh
  119732. * @param subMesh defines the submesh to bind the material to
  119733. */
  119734. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  119735. /**
  119736. * Gets the active textures from the material
  119737. * @returns an array of textures
  119738. */
  119739. getActiveTextures(): BaseTexture[];
  119740. /**
  119741. * Gets the list of texture blocks
  119742. * @returns an array of texture blocks
  119743. */
  119744. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  119745. /**
  119746. * Specifies if the material uses a texture
  119747. * @param texture defines the texture to check against the material
  119748. * @returns a boolean specifying if the material uses the texture
  119749. */
  119750. hasTexture(texture: BaseTexture): boolean;
  119751. /**
  119752. * Disposes the material
  119753. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  119754. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  119755. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  119756. */
  119757. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  119758. /** Creates the node editor window. */
  119759. private _createNodeEditor;
  119760. /**
  119761. * Launch the node material editor
  119762. * @param config Define the configuration of the editor
  119763. * @return a promise fulfilled when the node editor is visible
  119764. */
  119765. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  119766. /**
  119767. * Clear the current material
  119768. */
  119769. clear(): void;
  119770. /**
  119771. * Clear the current material and set it to a default state
  119772. */
  119773. setToDefault(): void;
  119774. /**
  119775. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  119776. * @param url defines the url to load from
  119777. * @returns a promise that will fullfil when the material is fully loaded
  119778. */
  119779. loadAsync(url: string): Promise<unknown>;
  119780. private _gatherBlocks;
  119781. /**
  119782. * Generate a string containing the code declaration required to create an equivalent of this material
  119783. * @returns a string
  119784. */
  119785. generateCode(): string;
  119786. /**
  119787. * Serializes this material in a JSON representation
  119788. * @returns the serialized material object
  119789. */
  119790. serialize(): any;
  119791. private _restoreConnections;
  119792. /**
  119793. * Clear the current graph and load a new one from a serialization object
  119794. * @param source defines the JSON representation of the material
  119795. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  119796. */
  119797. loadFromSerialization(source: any, rootUrl?: string): void;
  119798. /**
  119799. * Creates a node material from parsed material data
  119800. * @param source defines the JSON representation of the material
  119801. * @param scene defines the hosting scene
  119802. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  119803. * @returns a new node material
  119804. */
  119805. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  119806. /**
  119807. * Creates a new node material set to default basic configuration
  119808. * @param name defines the name of the material
  119809. * @param scene defines the hosting scene
  119810. * @returns a new NodeMaterial
  119811. */
  119812. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  119813. }
  119814. }
  119815. declare module BABYLON {
  119816. /**
  119817. * Block used to read a texture from a sampler
  119818. */
  119819. export class TextureBlock extends NodeMaterialBlock {
  119820. private _defineName;
  119821. private _linearDefineName;
  119822. private _samplerName;
  119823. private _transformedUVName;
  119824. private _textureTransformName;
  119825. private _textureInfoName;
  119826. private _mainUVName;
  119827. private _mainUVDefineName;
  119828. /**
  119829. * Gets or sets the texture associated with the node
  119830. */
  119831. texture: Nullable<Texture>;
  119832. /**
  119833. * Create a new TextureBlock
  119834. * @param name defines the block name
  119835. */
  119836. constructor(name: string);
  119837. /**
  119838. * Gets the current class name
  119839. * @returns the class name
  119840. */
  119841. getClassName(): string;
  119842. /**
  119843. * Gets the uv input component
  119844. */
  119845. readonly uv: NodeMaterialConnectionPoint;
  119846. /**
  119847. * Gets the rgba output component
  119848. */
  119849. readonly rgba: NodeMaterialConnectionPoint;
  119850. /**
  119851. * Gets the rgb output component
  119852. */
  119853. readonly rgb: NodeMaterialConnectionPoint;
  119854. /**
  119855. * Gets the r output component
  119856. */
  119857. readonly r: NodeMaterialConnectionPoint;
  119858. /**
  119859. * Gets the g output component
  119860. */
  119861. readonly g: NodeMaterialConnectionPoint;
  119862. /**
  119863. * Gets the b output component
  119864. */
  119865. readonly b: NodeMaterialConnectionPoint;
  119866. /**
  119867. * Gets the a output component
  119868. */
  119869. readonly a: NodeMaterialConnectionPoint;
  119870. readonly target: NodeMaterialBlockTargets;
  119871. autoConfigure(material: NodeMaterial): void;
  119872. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  119873. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119874. isReady(): boolean;
  119875. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119876. private readonly _isMixed;
  119877. private _injectVertexCode;
  119878. private _writeOutput;
  119879. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  119880. protected _dumpPropertiesCode(): string;
  119881. serialize(): any;
  119882. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119883. }
  119884. }
  119885. declare module BABYLON {
  119886. /**
  119887. * Class used to store shared data between 2 NodeMaterialBuildState
  119888. */
  119889. export class NodeMaterialBuildStateSharedData {
  119890. /**
  119891. * Gets the list of emitted varyings
  119892. */
  119893. temps: string[];
  119894. /**
  119895. * Gets the list of emitted varyings
  119896. */
  119897. varyings: string[];
  119898. /**
  119899. * Gets the varying declaration string
  119900. */
  119901. varyingDeclaration: string;
  119902. /**
  119903. * Input blocks
  119904. */
  119905. inputBlocks: InputBlock[];
  119906. /**
  119907. * Input blocks
  119908. */
  119909. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  119910. /**
  119911. * Bindable blocks (Blocks that need to set data to the effect)
  119912. */
  119913. bindableBlocks: NodeMaterialBlock[];
  119914. /**
  119915. * List of blocks that can provide a compilation fallback
  119916. */
  119917. blocksWithFallbacks: NodeMaterialBlock[];
  119918. /**
  119919. * List of blocks that can provide a define update
  119920. */
  119921. blocksWithDefines: NodeMaterialBlock[];
  119922. /**
  119923. * List of blocks that can provide a repeatable content
  119924. */
  119925. repeatableContentBlocks: NodeMaterialBlock[];
  119926. /**
  119927. * List of blocks that can provide a dynamic list of uniforms
  119928. */
  119929. dynamicUniformBlocks: NodeMaterialBlock[];
  119930. /**
  119931. * List of blocks that can block the isReady function for the material
  119932. */
  119933. blockingBlocks: NodeMaterialBlock[];
  119934. /**
  119935. * Gets the list of animated inputs
  119936. */
  119937. animatedInputs: InputBlock[];
  119938. /**
  119939. * Build Id used to avoid multiple recompilations
  119940. */
  119941. buildId: number;
  119942. /** List of emitted variables */
  119943. variableNames: {
  119944. [key: string]: number;
  119945. };
  119946. /** List of emitted defines */
  119947. defineNames: {
  119948. [key: string]: number;
  119949. };
  119950. /** Should emit comments? */
  119951. emitComments: boolean;
  119952. /** Emit build activity */
  119953. verbose: boolean;
  119954. /** Gets or sets the hosting scene */
  119955. scene: Scene;
  119956. /**
  119957. * Gets the compilation hints emitted at compilation time
  119958. */
  119959. hints: {
  119960. needWorldViewMatrix: boolean;
  119961. needWorldViewProjectionMatrix: boolean;
  119962. needAlphaBlending: boolean;
  119963. needAlphaTesting: boolean;
  119964. };
  119965. /**
  119966. * List of compilation checks
  119967. */
  119968. checks: {
  119969. emitVertex: boolean;
  119970. emitFragment: boolean;
  119971. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  119972. };
  119973. /** Creates a new shared data */
  119974. constructor();
  119975. /**
  119976. * Emits console errors and exceptions if there is a failing check
  119977. */
  119978. emitErrors(): void;
  119979. }
  119980. }
  119981. declare module BABYLON {
  119982. /**
  119983. * Class used to store node based material build state
  119984. */
  119985. export class NodeMaterialBuildState {
  119986. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  119987. supportUniformBuffers: boolean;
  119988. /**
  119989. * Gets the list of emitted attributes
  119990. */
  119991. attributes: string[];
  119992. /**
  119993. * Gets the list of emitted uniforms
  119994. */
  119995. uniforms: string[];
  119996. /**
  119997. * Gets the list of emitted constants
  119998. */
  119999. constants: string[];
  120000. /**
  120001. * Gets the list of emitted uniform buffers
  120002. */
  120003. uniformBuffers: string[];
  120004. /**
  120005. * Gets the list of emitted samplers
  120006. */
  120007. samplers: string[];
  120008. /**
  120009. * Gets the list of emitted functions
  120010. */
  120011. functions: {
  120012. [key: string]: string;
  120013. };
  120014. /**
  120015. * Gets the list of emitted extensions
  120016. */
  120017. extensions: {
  120018. [key: string]: string;
  120019. };
  120020. /**
  120021. * Gets the target of the compilation state
  120022. */
  120023. target: NodeMaterialBlockTargets;
  120024. /**
  120025. * Gets the list of emitted counters
  120026. */
  120027. counters: {
  120028. [key: string]: number;
  120029. };
  120030. /**
  120031. * Shared data between multiple NodeMaterialBuildState instances
  120032. */
  120033. sharedData: NodeMaterialBuildStateSharedData;
  120034. /** @hidden */
  120035. _vertexState: NodeMaterialBuildState;
  120036. /** @hidden */
  120037. _attributeDeclaration: string;
  120038. /** @hidden */
  120039. _uniformDeclaration: string;
  120040. /** @hidden */
  120041. _constantDeclaration: string;
  120042. /** @hidden */
  120043. _samplerDeclaration: string;
  120044. /** @hidden */
  120045. _varyingTransfer: string;
  120046. private _repeatableContentAnchorIndex;
  120047. /** @hidden */
  120048. _builtCompilationString: string;
  120049. /**
  120050. * Gets the emitted compilation strings
  120051. */
  120052. compilationString: string;
  120053. /**
  120054. * Finalize the compilation strings
  120055. * @param state defines the current compilation state
  120056. */
  120057. finalize(state: NodeMaterialBuildState): void;
  120058. /** @hidden */
  120059. readonly _repeatableContentAnchor: string;
  120060. /** @hidden */
  120061. _getFreeVariableName(prefix: string): string;
  120062. /** @hidden */
  120063. _getFreeDefineName(prefix: string): string;
  120064. /** @hidden */
  120065. _excludeVariableName(name: string): void;
  120066. /** @hidden */
  120067. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  120068. /** @hidden */
  120069. _emitExtension(name: string, extension: string): void;
  120070. /** @hidden */
  120071. _emitFunction(name: string, code: string, comments: string): void;
  120072. /** @hidden */
  120073. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  120074. replaceStrings?: {
  120075. search: RegExp;
  120076. replace: string;
  120077. }[];
  120078. repeatKey?: string;
  120079. }): string;
  120080. /** @hidden */
  120081. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  120082. repeatKey?: string;
  120083. removeAttributes?: boolean;
  120084. removeUniforms?: boolean;
  120085. removeVaryings?: boolean;
  120086. removeIfDef?: boolean;
  120087. replaceStrings?: {
  120088. search: RegExp;
  120089. replace: string;
  120090. }[];
  120091. }, storeKey?: string): void;
  120092. /** @hidden */
  120093. _registerTempVariable(name: string): boolean;
  120094. /** @hidden */
  120095. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  120096. /** @hidden */
  120097. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  120098. /** @hidden */
  120099. _emitFloat(value: number): string;
  120100. }
  120101. }
  120102. declare module BABYLON {
  120103. /**
  120104. * Defines a block that can be used inside a node based material
  120105. */
  120106. export class NodeMaterialBlock {
  120107. private _buildId;
  120108. private _buildTarget;
  120109. private _target;
  120110. private _isFinalMerger;
  120111. private _isInput;
  120112. /** @hidden */
  120113. _codeVariableName: string;
  120114. /** @hidden */
  120115. _inputs: NodeMaterialConnectionPoint[];
  120116. /** @hidden */
  120117. _outputs: NodeMaterialConnectionPoint[];
  120118. /** @hidden */
  120119. _preparationId: number;
  120120. /**
  120121. * Gets or sets the name of the block
  120122. */
  120123. name: string;
  120124. /**
  120125. * Gets or sets the unique id of the node
  120126. */
  120127. uniqueId: number;
  120128. /**
  120129. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  120130. */
  120131. readonly isFinalMerger: boolean;
  120132. /**
  120133. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  120134. */
  120135. readonly isInput: boolean;
  120136. /**
  120137. * Gets or sets the build Id
  120138. */
  120139. buildId: number;
  120140. /**
  120141. * Gets or sets the target of the block
  120142. */
  120143. target: NodeMaterialBlockTargets;
  120144. /**
  120145. * Gets the list of input points
  120146. */
  120147. readonly inputs: NodeMaterialConnectionPoint[];
  120148. /** Gets the list of output points */
  120149. readonly outputs: NodeMaterialConnectionPoint[];
  120150. /**
  120151. * Find an input by its name
  120152. * @param name defines the name of the input to look for
  120153. * @returns the input or null if not found
  120154. */
  120155. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  120156. /**
  120157. * Find an output by its name
  120158. * @param name defines the name of the outputto look for
  120159. * @returns the output or null if not found
  120160. */
  120161. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  120162. /**
  120163. * Creates a new NodeMaterialBlock
  120164. * @param name defines the block name
  120165. * @param target defines the target of that block (Vertex by default)
  120166. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  120167. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  120168. */
  120169. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  120170. /**
  120171. * Initialize the block and prepare the context for build
  120172. * @param state defines the state that will be used for the build
  120173. */
  120174. initialize(state: NodeMaterialBuildState): void;
  120175. /**
  120176. * Bind data to effect. Will only be called for blocks with isBindable === true
  120177. * @param effect defines the effect to bind data to
  120178. * @param nodeMaterial defines the hosting NodeMaterial
  120179. * @param mesh defines the mesh that will be rendered
  120180. */
  120181. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120182. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  120183. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  120184. protected _writeFloat(value: number): string;
  120185. /**
  120186. * Gets the current class name e.g. "NodeMaterialBlock"
  120187. * @returns the class name
  120188. */
  120189. getClassName(): string;
  120190. /**
  120191. * Register a new input. Must be called inside a block constructor
  120192. * @param name defines the connection point name
  120193. * @param type defines the connection point type
  120194. * @param isOptional defines a boolean indicating that this input can be omitted
  120195. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  120196. * @returns the current block
  120197. */
  120198. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  120199. /**
  120200. * Register a new output. Must be called inside a block constructor
  120201. * @param name defines the connection point name
  120202. * @param type defines the connection point type
  120203. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  120204. * @returns the current block
  120205. */
  120206. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  120207. /**
  120208. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  120209. * @param forOutput defines an optional connection point to check compatibility with
  120210. * @returns the first available input or null
  120211. */
  120212. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  120213. /**
  120214. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  120215. * @param forBlock defines an optional block to check compatibility with
  120216. * @returns the first available input or null
  120217. */
  120218. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  120219. /**
  120220. * Gets the sibling of the given output
  120221. * @param current defines the current output
  120222. * @returns the next output in the list or null
  120223. */
  120224. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  120225. /**
  120226. * Connect current block with another block
  120227. * @param other defines the block to connect with
  120228. * @param options define the various options to help pick the right connections
  120229. * @returns the current block
  120230. */
  120231. connectTo(other: NodeMaterialBlock, options?: {
  120232. input?: string;
  120233. output?: string;
  120234. outputSwizzle?: string;
  120235. }): this | undefined;
  120236. protected _buildBlock(state: NodeMaterialBuildState): void;
  120237. /**
  120238. * Add uniforms, samplers and uniform buffers at compilation time
  120239. * @param state defines the state to update
  120240. * @param nodeMaterial defines the node material requesting the update
  120241. * @param defines defines the material defines to update
  120242. */
  120243. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120244. /**
  120245. * Add potential fallbacks if shader compilation fails
  120246. * @param mesh defines the mesh to be rendered
  120247. * @param fallbacks defines the current prioritized list of fallbacks
  120248. */
  120249. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  120250. /**
  120251. * Initialize defines for shader compilation
  120252. * @param mesh defines the mesh to be rendered
  120253. * @param nodeMaterial defines the node material requesting the update
  120254. * @param defines defines the material defines to update
  120255. * @param useInstances specifies that instances should be used
  120256. */
  120257. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  120258. /**
  120259. * Update defines for shader compilation
  120260. * @param mesh defines the mesh to be rendered
  120261. * @param nodeMaterial defines the node material requesting the update
  120262. * @param defines defines the material defines to update
  120263. * @param useInstances specifies that instances should be used
  120264. */
  120265. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  120266. /**
  120267. * Lets the block try to connect some inputs automatically
  120268. * @param material defines the hosting NodeMaterial
  120269. */
  120270. autoConfigure(material: NodeMaterial): void;
  120271. /**
  120272. * Function called when a block is declared as repeatable content generator
  120273. * @param vertexShaderState defines the current compilation state for the vertex shader
  120274. * @param fragmentShaderState defines the current compilation state for the fragment shader
  120275. * @param mesh defines the mesh to be rendered
  120276. * @param defines defines the material defines to update
  120277. */
  120278. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  120279. /**
  120280. * Checks if the block is ready
  120281. * @param mesh defines the mesh to be rendered
  120282. * @param nodeMaterial defines the node material requesting the update
  120283. * @param defines defines the material defines to update
  120284. * @param useInstances specifies that instances should be used
  120285. * @returns true if the block is ready
  120286. */
  120287. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  120288. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  120289. private _processBuild;
  120290. /**
  120291. * Compile the current node and generate the shader code
  120292. * @param state defines the current compilation state (uniforms, samplers, current string)
  120293. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  120294. * @returns true if already built
  120295. */
  120296. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  120297. protected _inputRename(name: string): string;
  120298. protected _outputRename(name: string): string;
  120299. protected _dumpPropertiesCode(): string;
  120300. /** @hidden */
  120301. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  120302. /**
  120303. * Clone the current block to a new identical block
  120304. * @param scene defines the hosting scene
  120305. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  120306. * @returns a copy of the current block
  120307. */
  120308. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  120309. /**
  120310. * Serializes this block in a JSON representation
  120311. * @returns the serialized block object
  120312. */
  120313. serialize(): any;
  120314. /** @hidden */
  120315. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120316. }
  120317. }
  120318. declare module BABYLON {
  120319. /**
  120320. * Enum defining the type of animations supported by InputBlock
  120321. */
  120322. export enum AnimatedInputBlockTypes {
  120323. /** No animation */
  120324. None = 0,
  120325. /** Time based animation. Will only work for floats */
  120326. Time = 1
  120327. }
  120328. }
  120329. declare module BABYLON {
  120330. /**
  120331. * Block used to expose an input value
  120332. */
  120333. export class InputBlock extends NodeMaterialBlock {
  120334. private _mode;
  120335. private _associatedVariableName;
  120336. private _storedValue;
  120337. private _valueCallback;
  120338. private _type;
  120339. private _animationType;
  120340. /** Gets or set a value used to limit the range of float values */
  120341. min: number;
  120342. /** Gets or set a value used to limit the range of float values */
  120343. max: number;
  120344. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  120345. matrixMode: number;
  120346. /** @hidden */
  120347. _systemValue: Nullable<NodeMaterialSystemValues>;
  120348. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  120349. visibleInInspector: boolean;
  120350. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  120351. isConstant: boolean;
  120352. /**
  120353. * Gets or sets the connection point type (default is float)
  120354. */
  120355. readonly type: NodeMaterialBlockConnectionPointTypes;
  120356. /**
  120357. * Creates a new InputBlock
  120358. * @param name defines the block name
  120359. * @param target defines the target of that block (Vertex by default)
  120360. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  120361. */
  120362. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  120363. /**
  120364. * Gets the output component
  120365. */
  120366. readonly output: NodeMaterialConnectionPoint;
  120367. /**
  120368. * Set the source of this connection point to a vertex attribute
  120369. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  120370. * @returns the current connection point
  120371. */
  120372. setAsAttribute(attributeName?: string): InputBlock;
  120373. /**
  120374. * Set the source of this connection point to a system value
  120375. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  120376. * @returns the current connection point
  120377. */
  120378. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  120379. /**
  120380. * Gets or sets the value of that point.
  120381. * Please note that this value will be ignored if valueCallback is defined
  120382. */
  120383. value: any;
  120384. /**
  120385. * Gets or sets a callback used to get the value of that point.
  120386. * Please note that setting this value will force the connection point to ignore the value property
  120387. */
  120388. valueCallback: () => any;
  120389. /**
  120390. * Gets or sets the associated variable name in the shader
  120391. */
  120392. associatedVariableName: string;
  120393. /** Gets or sets the type of animation applied to the input */
  120394. animationType: AnimatedInputBlockTypes;
  120395. /**
  120396. * Gets a boolean indicating that this connection point not defined yet
  120397. */
  120398. readonly isUndefined: boolean;
  120399. /**
  120400. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  120401. * In this case the connection point name must be the name of the uniform to use.
  120402. * Can only be set on inputs
  120403. */
  120404. isUniform: boolean;
  120405. /**
  120406. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  120407. * In this case the connection point name must be the name of the attribute to use
  120408. * Can only be set on inputs
  120409. */
  120410. isAttribute: boolean;
  120411. /**
  120412. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  120413. * Can only be set on exit points
  120414. */
  120415. isVarying: boolean;
  120416. /**
  120417. * Gets a boolean indicating that the current connection point is a system value
  120418. */
  120419. readonly isSystemValue: boolean;
  120420. /**
  120421. * Gets or sets the current well known value or null if not defined as a system value
  120422. */
  120423. systemValue: Nullable<NodeMaterialSystemValues>;
  120424. /**
  120425. * Gets the current class name
  120426. * @returns the class name
  120427. */
  120428. getClassName(): string;
  120429. /**
  120430. * Animate the input if animationType !== None
  120431. * @param scene defines the rendering scene
  120432. */
  120433. animate(scene: Scene): void;
  120434. private _emitDefine;
  120435. initialize(state: NodeMaterialBuildState): void;
  120436. /**
  120437. * Set the input block to its default value (based on its type)
  120438. */
  120439. setDefaultValue(): void;
  120440. private _emitConstant;
  120441. private _emit;
  120442. /** @hidden */
  120443. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  120444. /** @hidden */
  120445. _transmit(effect: Effect, scene: Scene): void;
  120446. protected _buildBlock(state: NodeMaterialBuildState): void;
  120447. protected _dumpPropertiesCode(): string;
  120448. serialize(): any;
  120449. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120450. }
  120451. }
  120452. declare module BABYLON {
  120453. /**
  120454. * Defines a connection point for a block
  120455. */
  120456. export class NodeMaterialConnectionPoint {
  120457. /** @hidden */
  120458. _ownerBlock: NodeMaterialBlock;
  120459. /** @hidden */
  120460. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  120461. private _endpoints;
  120462. private _associatedVariableName;
  120463. /** @hidden */
  120464. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  120465. /** @hidden */
  120466. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  120467. private _type;
  120468. /** @hidden */
  120469. _enforceAssociatedVariableName: boolean;
  120470. /**
  120471. * Gets or sets the additional types supported by this connection point
  120472. */
  120473. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  120474. /**
  120475. * Gets or sets the additional types excluded by this connection point
  120476. */
  120477. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  120478. /**
  120479. * Gets or sets the associated variable name in the shader
  120480. */
  120481. associatedVariableName: string;
  120482. /**
  120483. * Gets or sets the connection point type (default is float)
  120484. */
  120485. type: NodeMaterialBlockConnectionPointTypes;
  120486. /**
  120487. * Gets or sets the connection point name
  120488. */
  120489. name: string;
  120490. /**
  120491. * Gets or sets a boolean indicating that this connection point can be omitted
  120492. */
  120493. isOptional: boolean;
  120494. /**
  120495. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  120496. */
  120497. define: string;
  120498. /** Gets or sets the target of that connection point */
  120499. target: NodeMaterialBlockTargets;
  120500. /**
  120501. * Gets a boolean indicating that the current point is connected
  120502. */
  120503. readonly isConnected: boolean;
  120504. /**
  120505. * Gets a boolean indicating that the current point is connected to an input block
  120506. */
  120507. readonly isConnectedToInputBlock: boolean;
  120508. /**
  120509. * Gets a the connected input block (if any)
  120510. */
  120511. readonly connectInputBlock: Nullable<InputBlock>;
  120512. /** Get the other side of the connection (if any) */
  120513. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  120514. /** Get the block that owns this connection point */
  120515. readonly ownerBlock: NodeMaterialBlock;
  120516. /** Get the block connected on the other side of this connection (if any) */
  120517. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  120518. /** Get the block connected on the endpoints of this connection (if any) */
  120519. readonly connectedBlocks: Array<NodeMaterialBlock>;
  120520. /** Gets the list of connected endpoints */
  120521. readonly endpoints: NodeMaterialConnectionPoint[];
  120522. /** Gets a boolean indicating if that output point is connected to at least one input */
  120523. readonly hasEndpoints: boolean;
  120524. /**
  120525. * Creates a new connection point
  120526. * @param name defines the connection point name
  120527. * @param ownerBlock defines the block hosting this connection point
  120528. */
  120529. constructor(name: string, ownerBlock: NodeMaterialBlock);
  120530. /**
  120531. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  120532. * @returns the class name
  120533. */
  120534. getClassName(): string;
  120535. /**
  120536. * Gets an boolean indicating if the current point can be connected to another point
  120537. * @param connectionPoint defines the other connection point
  120538. * @returns true if the connection is possible
  120539. */
  120540. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  120541. /**
  120542. * Connect this point to another connection point
  120543. * @param connectionPoint defines the other connection point
  120544. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  120545. * @returns the current connection point
  120546. */
  120547. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  120548. /**
  120549. * Disconnect this point from one of his endpoint
  120550. * @param endpoint defines the other connection point
  120551. * @returns the current connection point
  120552. */
  120553. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  120554. /**
  120555. * Serializes this point in a JSON representation
  120556. * @returns the serialized point object
  120557. */
  120558. serialize(): any;
  120559. }
  120560. }
  120561. declare module BABYLON {
  120562. /**
  120563. * Block used to add support for vertex skinning (bones)
  120564. */
  120565. export class BonesBlock extends NodeMaterialBlock {
  120566. /**
  120567. * Creates a new BonesBlock
  120568. * @param name defines the block name
  120569. */
  120570. constructor(name: string);
  120571. /**
  120572. * Initialize the block and prepare the context for build
  120573. * @param state defines the state that will be used for the build
  120574. */
  120575. initialize(state: NodeMaterialBuildState): void;
  120576. /**
  120577. * Gets the current class name
  120578. * @returns the class name
  120579. */
  120580. getClassName(): string;
  120581. /**
  120582. * Gets the matrix indices input component
  120583. */
  120584. readonly matricesIndices: NodeMaterialConnectionPoint;
  120585. /**
  120586. * Gets the matrix weights input component
  120587. */
  120588. readonly matricesWeights: NodeMaterialConnectionPoint;
  120589. /**
  120590. * Gets the extra matrix indices input component
  120591. */
  120592. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  120593. /**
  120594. * Gets the extra matrix weights input component
  120595. */
  120596. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  120597. /**
  120598. * Gets the world input component
  120599. */
  120600. readonly world: NodeMaterialConnectionPoint;
  120601. /**
  120602. * Gets the output component
  120603. */
  120604. readonly output: NodeMaterialConnectionPoint;
  120605. autoConfigure(material: NodeMaterial): void;
  120606. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  120607. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120608. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120609. protected _buildBlock(state: NodeMaterialBuildState): this;
  120610. }
  120611. }
  120612. declare module BABYLON {
  120613. /**
  120614. * Block used to add support for instances
  120615. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  120616. */
  120617. export class InstancesBlock extends NodeMaterialBlock {
  120618. /**
  120619. * Creates a new InstancesBlock
  120620. * @param name defines the block name
  120621. */
  120622. constructor(name: string);
  120623. /**
  120624. * Gets the current class name
  120625. * @returns the class name
  120626. */
  120627. getClassName(): string;
  120628. /**
  120629. * Gets the first world row input component
  120630. */
  120631. readonly world0: NodeMaterialConnectionPoint;
  120632. /**
  120633. * Gets the second world row input component
  120634. */
  120635. readonly world1: NodeMaterialConnectionPoint;
  120636. /**
  120637. * Gets the third world row input component
  120638. */
  120639. readonly world2: NodeMaterialConnectionPoint;
  120640. /**
  120641. * Gets the forth world row input component
  120642. */
  120643. readonly world3: NodeMaterialConnectionPoint;
  120644. /**
  120645. * Gets the world input component
  120646. */
  120647. readonly world: NodeMaterialConnectionPoint;
  120648. /**
  120649. * Gets the output component
  120650. */
  120651. readonly output: NodeMaterialConnectionPoint;
  120652. autoConfigure(material: NodeMaterial): void;
  120653. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  120654. protected _buildBlock(state: NodeMaterialBuildState): this;
  120655. }
  120656. }
  120657. declare module BABYLON {
  120658. /**
  120659. * Block used to add morph targets support to vertex shader
  120660. */
  120661. export class MorphTargetsBlock extends NodeMaterialBlock {
  120662. private _repeatableContentAnchor;
  120663. private _repeatebleContentGenerated;
  120664. /**
  120665. * Create a new MorphTargetsBlock
  120666. * @param name defines the block name
  120667. */
  120668. constructor(name: string);
  120669. /**
  120670. * Gets the current class name
  120671. * @returns the class name
  120672. */
  120673. getClassName(): string;
  120674. /**
  120675. * Gets the position input component
  120676. */
  120677. readonly position: NodeMaterialConnectionPoint;
  120678. /**
  120679. * Gets the normal input component
  120680. */
  120681. readonly normal: NodeMaterialConnectionPoint;
  120682. /**
  120683. * Gets the tangent input component
  120684. */
  120685. readonly tangent: NodeMaterialConnectionPoint;
  120686. /**
  120687. * Gets the tangent input component
  120688. */
  120689. readonly uv: NodeMaterialConnectionPoint;
  120690. /**
  120691. * Gets the position output component
  120692. */
  120693. readonly positionOutput: NodeMaterialConnectionPoint;
  120694. /**
  120695. * Gets the normal output component
  120696. */
  120697. readonly normalOutput: NodeMaterialConnectionPoint;
  120698. /**
  120699. * Gets the tangent output component
  120700. */
  120701. readonly tangentOutput: NodeMaterialConnectionPoint;
  120702. /**
  120703. * Gets the tangent output component
  120704. */
  120705. readonly uvOutput: NodeMaterialConnectionPoint;
  120706. initialize(state: NodeMaterialBuildState): void;
  120707. autoConfigure(material: NodeMaterial): void;
  120708. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120709. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120710. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  120711. protected _buildBlock(state: NodeMaterialBuildState): this;
  120712. }
  120713. }
  120714. declare module BABYLON {
  120715. /**
  120716. * Block used to get data information from a light
  120717. */
  120718. export class LightInformationBlock extends NodeMaterialBlock {
  120719. private _lightDataUniformName;
  120720. private _lightColorUniformName;
  120721. private _lightTypeDefineName;
  120722. /**
  120723. * Gets or sets the light associated with this block
  120724. */
  120725. light: Nullable<Light>;
  120726. /**
  120727. * Creates a new LightInformationBlock
  120728. * @param name defines the block name
  120729. */
  120730. constructor(name: string);
  120731. /**
  120732. * Gets the current class name
  120733. * @returns the class name
  120734. */
  120735. getClassName(): string;
  120736. /**
  120737. * Gets the world position input component
  120738. */
  120739. readonly worldPosition: NodeMaterialConnectionPoint;
  120740. /**
  120741. * Gets the direction output component
  120742. */
  120743. readonly direction: NodeMaterialConnectionPoint;
  120744. /**
  120745. * Gets the direction output component
  120746. */
  120747. readonly color: NodeMaterialConnectionPoint;
  120748. /**
  120749. * Gets the direction output component
  120750. */
  120751. readonly intensity: NodeMaterialConnectionPoint;
  120752. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120753. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120754. protected _buildBlock(state: NodeMaterialBuildState): this;
  120755. serialize(): any;
  120756. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120757. }
  120758. }
  120759. declare module BABYLON {
  120760. /**
  120761. * Block used to add image processing support to fragment shader
  120762. */
  120763. export class ImageProcessingBlock extends NodeMaterialBlock {
  120764. /**
  120765. * Create a new ImageProcessingBlock
  120766. * @param name defines the block name
  120767. */
  120768. constructor(name: string);
  120769. /**
  120770. * Gets the current class name
  120771. * @returns the class name
  120772. */
  120773. getClassName(): string;
  120774. /**
  120775. * Gets the color input component
  120776. */
  120777. readonly color: NodeMaterialConnectionPoint;
  120778. /**
  120779. * Gets the output component
  120780. */
  120781. readonly output: NodeMaterialConnectionPoint;
  120782. /**
  120783. * Initialize the block and prepare the context for build
  120784. * @param state defines the state that will be used for the build
  120785. */
  120786. initialize(state: NodeMaterialBuildState): void;
  120787. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  120788. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120789. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120790. protected _buildBlock(state: NodeMaterialBuildState): this;
  120791. }
  120792. }
  120793. declare module BABYLON {
  120794. /**
  120795. * Block used to pertub normals based on a normal map
  120796. */
  120797. export class PerturbNormalBlock extends NodeMaterialBlock {
  120798. private _tangentSpaceParameterName;
  120799. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  120800. invertX: boolean;
  120801. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  120802. invertY: boolean;
  120803. /**
  120804. * Create a new PerturbNormalBlock
  120805. * @param name defines the block name
  120806. */
  120807. constructor(name: string);
  120808. /**
  120809. * Gets the current class name
  120810. * @returns the class name
  120811. */
  120812. getClassName(): string;
  120813. /**
  120814. * Gets the world position input component
  120815. */
  120816. readonly worldPosition: NodeMaterialConnectionPoint;
  120817. /**
  120818. * Gets the world normal input component
  120819. */
  120820. readonly worldNormal: NodeMaterialConnectionPoint;
  120821. /**
  120822. * Gets the uv input component
  120823. */
  120824. readonly uv: NodeMaterialConnectionPoint;
  120825. /**
  120826. * Gets the normal map color input component
  120827. */
  120828. readonly normalMapColor: NodeMaterialConnectionPoint;
  120829. /**
  120830. * Gets the strength input component
  120831. */
  120832. readonly strength: NodeMaterialConnectionPoint;
  120833. /**
  120834. * Gets the output component
  120835. */
  120836. readonly output: NodeMaterialConnectionPoint;
  120837. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120838. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120839. autoConfigure(material: NodeMaterial): void;
  120840. protected _buildBlock(state: NodeMaterialBuildState): this;
  120841. protected _dumpPropertiesCode(): string;
  120842. serialize(): any;
  120843. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120844. }
  120845. }
  120846. declare module BABYLON {
  120847. /**
  120848. * Block used to discard a pixel if a value is smaller than a cutoff
  120849. */
  120850. export class DiscardBlock extends NodeMaterialBlock {
  120851. /**
  120852. * Create a new DiscardBlock
  120853. * @param name defines the block name
  120854. */
  120855. constructor(name: string);
  120856. /**
  120857. * Gets the current class name
  120858. * @returns the class name
  120859. */
  120860. getClassName(): string;
  120861. /**
  120862. * Gets the color input component
  120863. */
  120864. readonly value: NodeMaterialConnectionPoint;
  120865. /**
  120866. * Gets the cutoff input component
  120867. */
  120868. readonly cutoff: NodeMaterialConnectionPoint;
  120869. protected _buildBlock(state: NodeMaterialBuildState): this;
  120870. }
  120871. }
  120872. declare module BABYLON {
  120873. /**
  120874. * Block used to add support for scene fog
  120875. */
  120876. export class FogBlock extends NodeMaterialBlock {
  120877. private _fogDistanceName;
  120878. private _fogParameters;
  120879. /**
  120880. * Create a new FogBlock
  120881. * @param name defines the block name
  120882. */
  120883. constructor(name: string);
  120884. /**
  120885. * Gets the current class name
  120886. * @returns the class name
  120887. */
  120888. getClassName(): string;
  120889. /**
  120890. * Gets the world position input component
  120891. */
  120892. readonly worldPosition: NodeMaterialConnectionPoint;
  120893. /**
  120894. * Gets the view input component
  120895. */
  120896. readonly view: NodeMaterialConnectionPoint;
  120897. /**
  120898. * Gets the color input component
  120899. */
  120900. readonly input: NodeMaterialConnectionPoint;
  120901. /**
  120902. * Gets the fog color input component
  120903. */
  120904. readonly fogColor: NodeMaterialConnectionPoint;
  120905. /**
  120906. * Gets the output component
  120907. */
  120908. readonly output: NodeMaterialConnectionPoint;
  120909. autoConfigure(material: NodeMaterial): void;
  120910. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120911. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120912. protected _buildBlock(state: NodeMaterialBuildState): this;
  120913. }
  120914. }
  120915. declare module BABYLON {
  120916. /**
  120917. * Block used to add light in the fragment shader
  120918. */
  120919. export class LightBlock extends NodeMaterialBlock {
  120920. private _lightId;
  120921. /**
  120922. * Gets or sets the light associated with this block
  120923. */
  120924. light: Nullable<Light>;
  120925. /**
  120926. * Create a new LightBlock
  120927. * @param name defines the block name
  120928. */
  120929. constructor(name: string);
  120930. /**
  120931. * Gets the current class name
  120932. * @returns the class name
  120933. */
  120934. getClassName(): string;
  120935. /**
  120936. * Gets the world position input component
  120937. */
  120938. readonly worldPosition: NodeMaterialConnectionPoint;
  120939. /**
  120940. * Gets the world normal input component
  120941. */
  120942. readonly worldNormal: NodeMaterialConnectionPoint;
  120943. /**
  120944. * Gets the camera (or eye) position component
  120945. */
  120946. readonly cameraPosition: NodeMaterialConnectionPoint;
  120947. /**
  120948. * Gets the glossiness component
  120949. */
  120950. readonly glossiness: NodeMaterialConnectionPoint;
  120951. /**
  120952. * Gets the glossinness power component
  120953. */
  120954. readonly glossPower: NodeMaterialConnectionPoint;
  120955. /**
  120956. * Gets the diffuse color component
  120957. */
  120958. readonly diffuseColor: NodeMaterialConnectionPoint;
  120959. /**
  120960. * Gets the specular color component
  120961. */
  120962. readonly specularColor: NodeMaterialConnectionPoint;
  120963. /**
  120964. * Gets the diffuse output component
  120965. */
  120966. readonly diffuseOutput: NodeMaterialConnectionPoint;
  120967. /**
  120968. * Gets the specular output component
  120969. */
  120970. readonly specularOutput: NodeMaterialConnectionPoint;
  120971. autoConfigure(material: NodeMaterial): void;
  120972. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120973. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120974. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120975. private _injectVertexCode;
  120976. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  120977. serialize(): any;
  120978. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120979. }
  120980. }
  120981. declare module BABYLON {
  120982. /**
  120983. * Block used to multiply 2 values
  120984. */
  120985. export class MultiplyBlock extends NodeMaterialBlock {
  120986. /**
  120987. * Creates a new MultiplyBlock
  120988. * @param name defines the block name
  120989. */
  120990. constructor(name: string);
  120991. /**
  120992. * Gets the current class name
  120993. * @returns the class name
  120994. */
  120995. getClassName(): string;
  120996. /**
  120997. * Gets the left operand input component
  120998. */
  120999. readonly left: NodeMaterialConnectionPoint;
  121000. /**
  121001. * Gets the right operand input component
  121002. */
  121003. readonly right: NodeMaterialConnectionPoint;
  121004. /**
  121005. * Gets the output component
  121006. */
  121007. readonly output: NodeMaterialConnectionPoint;
  121008. protected _buildBlock(state: NodeMaterialBuildState): this;
  121009. }
  121010. }
  121011. declare module BABYLON {
  121012. /**
  121013. * Block used to add 2 vectors
  121014. */
  121015. export class AddBlock extends NodeMaterialBlock {
  121016. /**
  121017. * Creates a new AddBlock
  121018. * @param name defines the block name
  121019. */
  121020. constructor(name: string);
  121021. /**
  121022. * Gets the current class name
  121023. * @returns the class name
  121024. */
  121025. getClassName(): string;
  121026. /**
  121027. * Gets the left operand input component
  121028. */
  121029. readonly left: NodeMaterialConnectionPoint;
  121030. /**
  121031. * Gets the right operand input component
  121032. */
  121033. readonly right: NodeMaterialConnectionPoint;
  121034. /**
  121035. * Gets the output component
  121036. */
  121037. readonly output: NodeMaterialConnectionPoint;
  121038. protected _buildBlock(state: NodeMaterialBuildState): this;
  121039. }
  121040. }
  121041. declare module BABYLON {
  121042. /**
  121043. * Block used to scale a vector by a float
  121044. */
  121045. export class ScaleBlock extends NodeMaterialBlock {
  121046. /**
  121047. * Creates a new ScaleBlock
  121048. * @param name defines the block name
  121049. */
  121050. constructor(name: string);
  121051. /**
  121052. * Gets the current class name
  121053. * @returns the class name
  121054. */
  121055. getClassName(): string;
  121056. /**
  121057. * Gets the input component
  121058. */
  121059. readonly input: NodeMaterialConnectionPoint;
  121060. /**
  121061. * Gets the factor input component
  121062. */
  121063. readonly factor: NodeMaterialConnectionPoint;
  121064. /**
  121065. * Gets the output component
  121066. */
  121067. readonly output: NodeMaterialConnectionPoint;
  121068. protected _buildBlock(state: NodeMaterialBuildState): this;
  121069. }
  121070. }
  121071. declare module BABYLON {
  121072. /**
  121073. * Block used to clamp a float
  121074. */
  121075. export class ClampBlock extends NodeMaterialBlock {
  121076. /** Gets or sets the minimum range */
  121077. minimum: number;
  121078. /** Gets or sets the maximum range */
  121079. maximum: number;
  121080. /**
  121081. * Creates a new ClampBlock
  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 value input component
  121092. */
  121093. readonly value: NodeMaterialConnectionPoint;
  121094. /**
  121095. * Gets the output component
  121096. */
  121097. readonly output: NodeMaterialConnectionPoint;
  121098. protected _buildBlock(state: NodeMaterialBuildState): this;
  121099. protected _dumpPropertiesCode(): string;
  121100. serialize(): any;
  121101. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121102. }
  121103. }
  121104. declare module BABYLON {
  121105. /**
  121106. * Block used to apply a cross product between 2 vectors
  121107. */
  121108. export class CrossBlock extends NodeMaterialBlock {
  121109. /**
  121110. * Creates a new CrossBlock
  121111. * @param name defines the block name
  121112. */
  121113. constructor(name: string);
  121114. /**
  121115. * Gets the current class name
  121116. * @returns the class name
  121117. */
  121118. getClassName(): string;
  121119. /**
  121120. * Gets the left operand input component
  121121. */
  121122. readonly left: NodeMaterialConnectionPoint;
  121123. /**
  121124. * Gets the right operand input component
  121125. */
  121126. readonly right: NodeMaterialConnectionPoint;
  121127. /**
  121128. * Gets the output component
  121129. */
  121130. readonly output: NodeMaterialConnectionPoint;
  121131. protected _buildBlock(state: NodeMaterialBuildState): this;
  121132. }
  121133. }
  121134. declare module BABYLON {
  121135. /**
  121136. * Block used to apply a dot product between 2 vectors
  121137. */
  121138. export class DotBlock extends NodeMaterialBlock {
  121139. /**
  121140. * Creates a new DotBlock
  121141. * @param name defines the block name
  121142. */
  121143. constructor(name: string);
  121144. /**
  121145. * Gets the current class name
  121146. * @returns the class name
  121147. */
  121148. getClassName(): string;
  121149. /**
  121150. * Gets the left operand input component
  121151. */
  121152. readonly left: NodeMaterialConnectionPoint;
  121153. /**
  121154. * Gets the right operand input component
  121155. */
  121156. readonly right: NodeMaterialConnectionPoint;
  121157. /**
  121158. * Gets the output component
  121159. */
  121160. readonly output: NodeMaterialConnectionPoint;
  121161. protected _buildBlock(state: NodeMaterialBuildState): this;
  121162. }
  121163. }
  121164. declare module BABYLON {
  121165. /**
  121166. * Block used to remap a float from a range to a new one
  121167. */
  121168. export class RemapBlock extends NodeMaterialBlock {
  121169. /**
  121170. * Gets or sets the source range
  121171. */
  121172. sourceRange: Vector2;
  121173. /**
  121174. * Gets or sets the target range
  121175. */
  121176. targetRange: Vector2;
  121177. /**
  121178. * Creates a new RemapBlock
  121179. * @param name defines the block name
  121180. */
  121181. constructor(name: string);
  121182. /**
  121183. * Gets the current class name
  121184. * @returns the class name
  121185. */
  121186. getClassName(): string;
  121187. /**
  121188. * Gets the input component
  121189. */
  121190. readonly input: NodeMaterialConnectionPoint;
  121191. /**
  121192. * Gets the source min input component
  121193. */
  121194. readonly sourceMin: NodeMaterialConnectionPoint;
  121195. /**
  121196. * Gets the source max input component
  121197. */
  121198. readonly sourceMax: NodeMaterialConnectionPoint;
  121199. /**
  121200. * Gets the target min input component
  121201. */
  121202. readonly targetMin: NodeMaterialConnectionPoint;
  121203. /**
  121204. * Gets the target max input component
  121205. */
  121206. readonly targetMax: NodeMaterialConnectionPoint;
  121207. /**
  121208. * Gets the output component
  121209. */
  121210. readonly output: NodeMaterialConnectionPoint;
  121211. protected _buildBlock(state: NodeMaterialBuildState): this;
  121212. protected _dumpPropertiesCode(): string;
  121213. serialize(): any;
  121214. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121215. }
  121216. }
  121217. declare module BABYLON {
  121218. /**
  121219. * Block used to normalize a vector
  121220. */
  121221. export class NormalizeBlock extends NodeMaterialBlock {
  121222. /**
  121223. * Creates a new NormalizeBlock
  121224. * @param name defines the block name
  121225. */
  121226. constructor(name: string);
  121227. /**
  121228. * Gets the current class name
  121229. * @returns the class name
  121230. */
  121231. getClassName(): string;
  121232. /**
  121233. * Gets the input component
  121234. */
  121235. readonly input: NodeMaterialConnectionPoint;
  121236. /**
  121237. * Gets the output component
  121238. */
  121239. readonly output: NodeMaterialConnectionPoint;
  121240. protected _buildBlock(state: NodeMaterialBuildState): this;
  121241. }
  121242. }
  121243. declare module BABYLON {
  121244. /**
  121245. * Operations supported by the Trigonometry block
  121246. */
  121247. export enum TrigonometryBlockOperations {
  121248. /** Cos */
  121249. Cos = 0,
  121250. /** Sin */
  121251. Sin = 1,
  121252. /** Abs */
  121253. Abs = 2,
  121254. /** Exp */
  121255. Exp = 3,
  121256. /** Exp2 */
  121257. Exp2 = 4,
  121258. /** Round */
  121259. Round = 5,
  121260. /** Floor */
  121261. Floor = 6,
  121262. /** Ceiling */
  121263. Ceiling = 7,
  121264. /** Square root */
  121265. Sqrt = 8,
  121266. /** Log */
  121267. Log = 9,
  121268. /** Tangent */
  121269. Tan = 10,
  121270. /** Arc tangent */
  121271. ArcTan = 11,
  121272. /** Arc cosinus */
  121273. ArcCos = 12,
  121274. /** Arc sinus */
  121275. ArcSin = 13,
  121276. /** Fraction */
  121277. Fract = 14,
  121278. /** Sign */
  121279. Sign = 15,
  121280. /** To radians (from degrees) */
  121281. Radians = 16,
  121282. /** To degrees (from radians) */
  121283. Degrees = 17
  121284. }
  121285. /**
  121286. * Block used to apply trigonometry operation to floats
  121287. */
  121288. export class TrigonometryBlock extends NodeMaterialBlock {
  121289. /**
  121290. * Gets or sets the operation applied by the block
  121291. */
  121292. operation: TrigonometryBlockOperations;
  121293. /**
  121294. * Creates a new TrigonometryBlock
  121295. * @param name defines the block name
  121296. */
  121297. constructor(name: string);
  121298. /**
  121299. * Gets the current class name
  121300. * @returns the class name
  121301. */
  121302. getClassName(): string;
  121303. /**
  121304. * Gets the input component
  121305. */
  121306. readonly input: NodeMaterialConnectionPoint;
  121307. /**
  121308. * Gets the output component
  121309. */
  121310. readonly output: NodeMaterialConnectionPoint;
  121311. protected _buildBlock(state: NodeMaterialBuildState): this;
  121312. serialize(): any;
  121313. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121314. }
  121315. }
  121316. declare module BABYLON {
  121317. /**
  121318. * Block used to create a Color3/4 out of individual inputs (one for each component)
  121319. */
  121320. export class ColorMergerBlock extends NodeMaterialBlock {
  121321. /**
  121322. * Create a new ColorMergerBlock
  121323. * @param name defines the block name
  121324. */
  121325. constructor(name: string);
  121326. /**
  121327. * Gets the current class name
  121328. * @returns the class name
  121329. */
  121330. getClassName(): string;
  121331. /**
  121332. * Gets the r component (input)
  121333. */
  121334. readonly r: NodeMaterialConnectionPoint;
  121335. /**
  121336. * Gets the g component (input)
  121337. */
  121338. readonly g: NodeMaterialConnectionPoint;
  121339. /**
  121340. * Gets the b component (input)
  121341. */
  121342. readonly b: NodeMaterialConnectionPoint;
  121343. /**
  121344. * Gets the a component (input)
  121345. */
  121346. readonly a: NodeMaterialConnectionPoint;
  121347. /**
  121348. * Gets the rgba component (output)
  121349. */
  121350. readonly rgba: NodeMaterialConnectionPoint;
  121351. /**
  121352. * Gets the rgb component (output)
  121353. */
  121354. readonly rgb: NodeMaterialConnectionPoint;
  121355. protected _buildBlock(state: NodeMaterialBuildState): this;
  121356. }
  121357. }
  121358. declare module BABYLON {
  121359. /**
  121360. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  121361. */
  121362. export class VectorMergerBlock extends NodeMaterialBlock {
  121363. /**
  121364. * Create a new VectorMergerBlock
  121365. * @param name defines the block name
  121366. */
  121367. constructor(name: string);
  121368. /**
  121369. * Gets the current class name
  121370. * @returns the class name
  121371. */
  121372. getClassName(): string;
  121373. /**
  121374. * Gets the x component (input)
  121375. */
  121376. readonly x: NodeMaterialConnectionPoint;
  121377. /**
  121378. * Gets the y component (input)
  121379. */
  121380. readonly y: NodeMaterialConnectionPoint;
  121381. /**
  121382. * Gets the z component (input)
  121383. */
  121384. readonly z: NodeMaterialConnectionPoint;
  121385. /**
  121386. * Gets the w component (input)
  121387. */
  121388. readonly w: NodeMaterialConnectionPoint;
  121389. /**
  121390. * Gets the xyzw component (output)
  121391. */
  121392. readonly xyzw: NodeMaterialConnectionPoint;
  121393. /**
  121394. * Gets the xyz component (output)
  121395. */
  121396. readonly xyz: NodeMaterialConnectionPoint;
  121397. /**
  121398. * Gets the xy component (output)
  121399. */
  121400. readonly xy: NodeMaterialConnectionPoint;
  121401. protected _buildBlock(state: NodeMaterialBuildState): this;
  121402. }
  121403. }
  121404. declare module BABYLON {
  121405. /**
  121406. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  121407. */
  121408. export class ColorSplitterBlock extends NodeMaterialBlock {
  121409. /**
  121410. * Create a new ColorSplitterBlock
  121411. * @param name defines the block name
  121412. */
  121413. constructor(name: string);
  121414. /**
  121415. * Gets the current class name
  121416. * @returns the class name
  121417. */
  121418. getClassName(): string;
  121419. /**
  121420. * Gets the rgba component (input)
  121421. */
  121422. readonly rgba: NodeMaterialConnectionPoint;
  121423. /**
  121424. * Gets the rgb component (input)
  121425. */
  121426. readonly rgbIn: NodeMaterialConnectionPoint;
  121427. /**
  121428. * Gets the rgb component (output)
  121429. */
  121430. readonly rgbOut: NodeMaterialConnectionPoint;
  121431. /**
  121432. * Gets the r component (output)
  121433. */
  121434. readonly r: NodeMaterialConnectionPoint;
  121435. /**
  121436. * Gets the g component (output)
  121437. */
  121438. readonly g: NodeMaterialConnectionPoint;
  121439. /**
  121440. * Gets the b component (output)
  121441. */
  121442. readonly b: NodeMaterialConnectionPoint;
  121443. /**
  121444. * Gets the a component (output)
  121445. */
  121446. readonly a: NodeMaterialConnectionPoint;
  121447. protected _inputRename(name: string): string;
  121448. protected _outputRename(name: string): string;
  121449. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  121450. }
  121451. }
  121452. declare module BABYLON {
  121453. /**
  121454. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  121455. */
  121456. export class VectorSplitterBlock extends NodeMaterialBlock {
  121457. /**
  121458. * Create a new VectorSplitterBlock
  121459. * @param name defines the block name
  121460. */
  121461. constructor(name: string);
  121462. /**
  121463. * Gets the current class name
  121464. * @returns the class name
  121465. */
  121466. getClassName(): string;
  121467. /**
  121468. * Gets the xyzw component (input)
  121469. */
  121470. readonly xyzw: NodeMaterialConnectionPoint;
  121471. /**
  121472. * Gets the xyz component (input)
  121473. */
  121474. readonly xyzIn: NodeMaterialConnectionPoint;
  121475. /**
  121476. * Gets the xy component (input)
  121477. */
  121478. readonly xyIn: NodeMaterialConnectionPoint;
  121479. /**
  121480. * Gets the xyz component (output)
  121481. */
  121482. readonly xyzOut: NodeMaterialConnectionPoint;
  121483. /**
  121484. * Gets the xy component (output)
  121485. */
  121486. readonly xyOut: NodeMaterialConnectionPoint;
  121487. /**
  121488. * Gets the x component (output)
  121489. */
  121490. readonly x: NodeMaterialConnectionPoint;
  121491. /**
  121492. * Gets the y component (output)
  121493. */
  121494. readonly y: NodeMaterialConnectionPoint;
  121495. /**
  121496. * Gets the z component (output)
  121497. */
  121498. readonly z: NodeMaterialConnectionPoint;
  121499. /**
  121500. * Gets the w component (output)
  121501. */
  121502. readonly w: NodeMaterialConnectionPoint;
  121503. protected _inputRename(name: string): string;
  121504. protected _outputRename(name: string): string;
  121505. protected _buildBlock(state: NodeMaterialBuildState): this;
  121506. }
  121507. }
  121508. declare module BABYLON {
  121509. /**
  121510. * Block used to lerp between 2 values
  121511. */
  121512. export class LerpBlock extends NodeMaterialBlock {
  121513. /**
  121514. * Creates a new LerpBlock
  121515. * @param name defines the block name
  121516. */
  121517. constructor(name: string);
  121518. /**
  121519. * Gets the current class name
  121520. * @returns the class name
  121521. */
  121522. getClassName(): string;
  121523. /**
  121524. * Gets the left operand input component
  121525. */
  121526. readonly left: NodeMaterialConnectionPoint;
  121527. /**
  121528. * Gets the right operand input component
  121529. */
  121530. readonly right: NodeMaterialConnectionPoint;
  121531. /**
  121532. * Gets the gradient operand input component
  121533. */
  121534. readonly gradient: NodeMaterialConnectionPoint;
  121535. /**
  121536. * Gets the output component
  121537. */
  121538. readonly output: NodeMaterialConnectionPoint;
  121539. protected _buildBlock(state: NodeMaterialBuildState): this;
  121540. }
  121541. }
  121542. declare module BABYLON {
  121543. /**
  121544. * Block used to divide 2 vectors
  121545. */
  121546. export class DivideBlock extends NodeMaterialBlock {
  121547. /**
  121548. * Creates a new DivideBlock
  121549. * @param name defines the block name
  121550. */
  121551. constructor(name: string);
  121552. /**
  121553. * Gets the current class name
  121554. * @returns the class name
  121555. */
  121556. getClassName(): string;
  121557. /**
  121558. * Gets the left operand input component
  121559. */
  121560. readonly left: NodeMaterialConnectionPoint;
  121561. /**
  121562. * Gets the right operand input component
  121563. */
  121564. readonly right: NodeMaterialConnectionPoint;
  121565. /**
  121566. * Gets the output component
  121567. */
  121568. readonly output: NodeMaterialConnectionPoint;
  121569. protected _buildBlock(state: NodeMaterialBuildState): this;
  121570. }
  121571. }
  121572. declare module BABYLON {
  121573. /**
  121574. * Block used to subtract 2 vectors
  121575. */
  121576. export class SubtractBlock extends NodeMaterialBlock {
  121577. /**
  121578. * Creates a new SubtractBlock
  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 output component
  121597. */
  121598. readonly output: NodeMaterialConnectionPoint;
  121599. protected _buildBlock(state: NodeMaterialBuildState): this;
  121600. }
  121601. }
  121602. declare module BABYLON {
  121603. /**
  121604. * Block used to step a value
  121605. */
  121606. export class StepBlock extends NodeMaterialBlock {
  121607. /**
  121608. * Creates a new StepBlock
  121609. * @param name defines the block name
  121610. */
  121611. constructor(name: string);
  121612. /**
  121613. * Gets the current class name
  121614. * @returns the class name
  121615. */
  121616. getClassName(): string;
  121617. /**
  121618. * Gets the value operand input component
  121619. */
  121620. readonly value: NodeMaterialConnectionPoint;
  121621. /**
  121622. * Gets the edge operand input component
  121623. */
  121624. readonly edge: NodeMaterialConnectionPoint;
  121625. /**
  121626. * Gets the output component
  121627. */
  121628. readonly output: NodeMaterialConnectionPoint;
  121629. protected _buildBlock(state: NodeMaterialBuildState): this;
  121630. }
  121631. }
  121632. declare module BABYLON {
  121633. /**
  121634. * Block used to get the opposite (1 - x) of a value
  121635. */
  121636. export class OneMinusBlock extends NodeMaterialBlock {
  121637. /**
  121638. * Creates a new OneMinusBlock
  121639. * @param name defines the block name
  121640. */
  121641. constructor(name: string);
  121642. /**
  121643. * Gets the current class name
  121644. * @returns the class name
  121645. */
  121646. getClassName(): string;
  121647. /**
  121648. * Gets the input component
  121649. */
  121650. readonly input: NodeMaterialConnectionPoint;
  121651. /**
  121652. * Gets the output component
  121653. */
  121654. readonly output: NodeMaterialConnectionPoint;
  121655. protected _buildBlock(state: NodeMaterialBuildState): this;
  121656. }
  121657. }
  121658. declare module BABYLON {
  121659. /**
  121660. * Block used to get the view direction
  121661. */
  121662. export class ViewDirectionBlock extends NodeMaterialBlock {
  121663. /**
  121664. * Creates a new ViewDirectionBlock
  121665. * @param name defines the block name
  121666. */
  121667. constructor(name: string);
  121668. /**
  121669. * Gets the current class name
  121670. * @returns the class name
  121671. */
  121672. getClassName(): string;
  121673. /**
  121674. * Gets the world position component
  121675. */
  121676. readonly worldPosition: NodeMaterialConnectionPoint;
  121677. /**
  121678. * Gets the camera position component
  121679. */
  121680. readonly cameraPosition: NodeMaterialConnectionPoint;
  121681. /**
  121682. * Gets the output component
  121683. */
  121684. readonly output: NodeMaterialConnectionPoint;
  121685. autoConfigure(material: NodeMaterial): void;
  121686. protected _buildBlock(state: NodeMaterialBuildState): this;
  121687. }
  121688. }
  121689. declare module BABYLON {
  121690. /**
  121691. * Block used to compute fresnel value
  121692. */
  121693. export class FresnelBlock extends NodeMaterialBlock {
  121694. /**
  121695. * Create a new FresnelBlock
  121696. * @param name defines the block name
  121697. */
  121698. constructor(name: string);
  121699. /**
  121700. * Gets the current class name
  121701. * @returns the class name
  121702. */
  121703. getClassName(): string;
  121704. /**
  121705. * Gets the world normal input component
  121706. */
  121707. readonly worldNormal: NodeMaterialConnectionPoint;
  121708. /**
  121709. * Gets the view direction input component
  121710. */
  121711. readonly viewDirection: NodeMaterialConnectionPoint;
  121712. /**
  121713. * Gets the bias input component
  121714. */
  121715. readonly bias: NodeMaterialConnectionPoint;
  121716. /**
  121717. * Gets the camera (or eye) position component
  121718. */
  121719. readonly power: NodeMaterialConnectionPoint;
  121720. /**
  121721. * Gets the fresnel output component
  121722. */
  121723. readonly fresnel: NodeMaterialConnectionPoint;
  121724. autoConfigure(material: NodeMaterial): void;
  121725. protected _buildBlock(state: NodeMaterialBuildState): this;
  121726. }
  121727. }
  121728. declare module BABYLON {
  121729. /**
  121730. * Block used to get the max of 2 values
  121731. */
  121732. export class MaxBlock extends NodeMaterialBlock {
  121733. /**
  121734. * Creates a new MaxBlock
  121735. * @param name defines the block name
  121736. */
  121737. constructor(name: string);
  121738. /**
  121739. * Gets the current class name
  121740. * @returns the class name
  121741. */
  121742. getClassName(): string;
  121743. /**
  121744. * Gets the left operand input component
  121745. */
  121746. readonly left: NodeMaterialConnectionPoint;
  121747. /**
  121748. * Gets the right operand input component
  121749. */
  121750. readonly right: NodeMaterialConnectionPoint;
  121751. /**
  121752. * Gets the output component
  121753. */
  121754. readonly output: NodeMaterialConnectionPoint;
  121755. protected _buildBlock(state: NodeMaterialBuildState): this;
  121756. }
  121757. }
  121758. declare module BABYLON {
  121759. /**
  121760. * Block used to get the min of 2 values
  121761. */
  121762. export class MinBlock extends NodeMaterialBlock {
  121763. /**
  121764. * Creates a new MinBlock
  121765. * @param name defines the block name
  121766. */
  121767. constructor(name: string);
  121768. /**
  121769. * Gets the current class name
  121770. * @returns the class name
  121771. */
  121772. getClassName(): string;
  121773. /**
  121774. * Gets the left operand input component
  121775. */
  121776. readonly left: NodeMaterialConnectionPoint;
  121777. /**
  121778. * Gets the right operand input component
  121779. */
  121780. readonly right: NodeMaterialConnectionPoint;
  121781. /**
  121782. * Gets the output component
  121783. */
  121784. readonly output: NodeMaterialConnectionPoint;
  121785. protected _buildBlock(state: NodeMaterialBuildState): this;
  121786. }
  121787. }
  121788. declare module BABYLON {
  121789. /**
  121790. * Block used to get the distance between 2 values
  121791. */
  121792. export class DistanceBlock extends NodeMaterialBlock {
  121793. /**
  121794. * Creates a new DistanceBlock
  121795. * @param name defines the block name
  121796. */
  121797. constructor(name: string);
  121798. /**
  121799. * Gets the current class name
  121800. * @returns the class name
  121801. */
  121802. getClassName(): string;
  121803. /**
  121804. * Gets the left operand input component
  121805. */
  121806. readonly left: NodeMaterialConnectionPoint;
  121807. /**
  121808. * Gets the right operand input component
  121809. */
  121810. readonly right: NodeMaterialConnectionPoint;
  121811. /**
  121812. * Gets the output component
  121813. */
  121814. readonly output: NodeMaterialConnectionPoint;
  121815. protected _buildBlock(state: NodeMaterialBuildState): this;
  121816. }
  121817. }
  121818. declare module BABYLON {
  121819. /**
  121820. * Block used to get the length of a vector
  121821. */
  121822. export class LengthBlock extends NodeMaterialBlock {
  121823. /**
  121824. * Creates a new LengthBlock
  121825. * @param name defines the block name
  121826. */
  121827. constructor(name: string);
  121828. /**
  121829. * Gets the current class name
  121830. * @returns the class name
  121831. */
  121832. getClassName(): string;
  121833. /**
  121834. * Gets the value input component
  121835. */
  121836. readonly value: NodeMaterialConnectionPoint;
  121837. /**
  121838. * Gets the output component
  121839. */
  121840. readonly output: NodeMaterialConnectionPoint;
  121841. protected _buildBlock(state: NodeMaterialBuildState): this;
  121842. }
  121843. }
  121844. declare module BABYLON {
  121845. /**
  121846. * Block used to get negative version of a value (i.e. x * -1)
  121847. */
  121848. export class NegateBlock extends NodeMaterialBlock {
  121849. /**
  121850. * Creates a new NegateBlock
  121851. * @param name defines the block name
  121852. */
  121853. constructor(name: string);
  121854. /**
  121855. * Gets the current class name
  121856. * @returns the class name
  121857. */
  121858. getClassName(): string;
  121859. /**
  121860. * Gets the value input component
  121861. */
  121862. readonly value: NodeMaterialConnectionPoint;
  121863. /**
  121864. * Gets the output component
  121865. */
  121866. readonly output: NodeMaterialConnectionPoint;
  121867. protected _buildBlock(state: NodeMaterialBuildState): this;
  121868. }
  121869. }
  121870. declare module BABYLON {
  121871. /**
  121872. * Block used to get the value of the first parameter raised to the power of the second
  121873. */
  121874. export class PowBlock extends NodeMaterialBlock {
  121875. /**
  121876. * Creates a new PowBlock
  121877. * @param name defines the block name
  121878. */
  121879. constructor(name: string);
  121880. /**
  121881. * Gets the current class name
  121882. * @returns the class name
  121883. */
  121884. getClassName(): string;
  121885. /**
  121886. * Gets the value operand input component
  121887. */
  121888. readonly value: NodeMaterialConnectionPoint;
  121889. /**
  121890. * Gets the power operand input component
  121891. */
  121892. readonly power: NodeMaterialConnectionPoint;
  121893. /**
  121894. * Gets the output component
  121895. */
  121896. readonly output: NodeMaterialConnectionPoint;
  121897. protected _buildBlock(state: NodeMaterialBuildState): this;
  121898. }
  121899. }
  121900. declare module BABYLON {
  121901. /**
  121902. * Block used to get a random number
  121903. */
  121904. export class RandomNumberBlock extends NodeMaterialBlock {
  121905. /**
  121906. * Creates a new RandomNumberBlock
  121907. * @param name defines the block name
  121908. */
  121909. constructor(name: string);
  121910. /**
  121911. * Gets the current class name
  121912. * @returns the class name
  121913. */
  121914. getClassName(): string;
  121915. /**
  121916. * Gets the seed input component
  121917. */
  121918. readonly seed: NodeMaterialConnectionPoint;
  121919. /**
  121920. * Gets the output component
  121921. */
  121922. readonly output: NodeMaterialConnectionPoint;
  121923. protected _buildBlock(state: NodeMaterialBuildState): this;
  121924. }
  121925. }
  121926. declare module BABYLON {
  121927. /**
  121928. * Block used to compute arc tangent of 2 values
  121929. */
  121930. export class ArcTan2Block extends NodeMaterialBlock {
  121931. /**
  121932. * Creates a new ArcTan2Block
  121933. * @param name defines the block name
  121934. */
  121935. constructor(name: string);
  121936. /**
  121937. * Gets the current class name
  121938. * @returns the class name
  121939. */
  121940. getClassName(): string;
  121941. /**
  121942. * Gets the x operand input component
  121943. */
  121944. readonly x: NodeMaterialConnectionPoint;
  121945. /**
  121946. * Gets the y operand input component
  121947. */
  121948. readonly y: NodeMaterialConnectionPoint;
  121949. /**
  121950. * Gets the output component
  121951. */
  121952. readonly output: NodeMaterialConnectionPoint;
  121953. protected _buildBlock(state: NodeMaterialBuildState): this;
  121954. }
  121955. }
  121956. declare module BABYLON {
  121957. /**
  121958. * Block used to smooth step a value
  121959. */
  121960. export class SmoothStepBlock extends NodeMaterialBlock {
  121961. /**
  121962. * Creates a new SmoothStepBlock
  121963. * @param name defines the block name
  121964. */
  121965. constructor(name: string);
  121966. /**
  121967. * Gets the current class name
  121968. * @returns the class name
  121969. */
  121970. getClassName(): string;
  121971. /**
  121972. * Gets the value operand input component
  121973. */
  121974. readonly value: NodeMaterialConnectionPoint;
  121975. /**
  121976. * Gets the first edge operand input component
  121977. */
  121978. readonly edge0: NodeMaterialConnectionPoint;
  121979. /**
  121980. * Gets the second edge operand input component
  121981. */
  121982. readonly edge1: 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 get the reciprocal (1 / x) of a value
  121993. */
  121994. export class ReciprocalBlock extends NodeMaterialBlock {
  121995. /**
  121996. * Creates a new ReciprocalBlock
  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 input component
  122007. */
  122008. readonly input: NodeMaterialConnectionPoint;
  122009. /**
  122010. * Gets the output component
  122011. */
  122012. readonly output: NodeMaterialConnectionPoint;
  122013. protected _buildBlock(state: NodeMaterialBuildState): this;
  122014. }
  122015. }
  122016. declare module BABYLON {
  122017. /**
  122018. * Block used to replace a color by another one
  122019. */
  122020. export class ReplaceColorBlock extends NodeMaterialBlock {
  122021. /**
  122022. * Creates a new ReplaceColorBlock
  122023. * @param name defines the block name
  122024. */
  122025. constructor(name: string);
  122026. /**
  122027. * Gets the current class name
  122028. * @returns the class name
  122029. */
  122030. getClassName(): string;
  122031. /**
  122032. * Gets the value input component
  122033. */
  122034. readonly value: NodeMaterialConnectionPoint;
  122035. /**
  122036. * Gets the reference input component
  122037. */
  122038. readonly reference: NodeMaterialConnectionPoint;
  122039. /**
  122040. * Gets the distance input component
  122041. */
  122042. readonly distance: NodeMaterialConnectionPoint;
  122043. /**
  122044. * Gets the replacement input component
  122045. */
  122046. readonly replacement: 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 posterize a value
  122057. * @see https://en.wikipedia.org/wiki/Posterization
  122058. */
  122059. export class PosterizeBlock extends NodeMaterialBlock {
  122060. /**
  122061. * Creates a new PosterizeBlock
  122062. * @param name defines the block name
  122063. */
  122064. constructor(name: string);
  122065. /**
  122066. * Gets the current class name
  122067. * @returns the class name
  122068. */
  122069. getClassName(): string;
  122070. /**
  122071. * Gets the value input component
  122072. */
  122073. readonly value: NodeMaterialConnectionPoint;
  122074. /**
  122075. * Gets the steps input component
  122076. */
  122077. readonly steps: NodeMaterialConnectionPoint;
  122078. /**
  122079. * Gets the output component
  122080. */
  122081. readonly output: NodeMaterialConnectionPoint;
  122082. protected _buildBlock(state: NodeMaterialBuildState): this;
  122083. }
  122084. }
  122085. declare module BABYLON {
  122086. /**
  122087. * Operations supported by the Wave block
  122088. */
  122089. export enum WaveBlockKind {
  122090. /** SawTooth */
  122091. SawTooth = 0,
  122092. /** Square */
  122093. Square = 1,
  122094. /** Triangle */
  122095. Triangle = 2
  122096. }
  122097. /**
  122098. * Block used to apply wave operation to floats
  122099. */
  122100. export class WaveBlock extends NodeMaterialBlock {
  122101. /**
  122102. * Gets or sets the kibnd of wave to be applied by the block
  122103. */
  122104. kind: WaveBlockKind;
  122105. /**
  122106. * Creates a new WaveBlock
  122107. * @param name defines the block name
  122108. */
  122109. constructor(name: string);
  122110. /**
  122111. * Gets the current class name
  122112. * @returns the class name
  122113. */
  122114. getClassName(): string;
  122115. /**
  122116. * Gets the input component
  122117. */
  122118. readonly input: NodeMaterialConnectionPoint;
  122119. /**
  122120. * Gets the output component
  122121. */
  122122. readonly output: NodeMaterialConnectionPoint;
  122123. protected _buildBlock(state: NodeMaterialBuildState): this;
  122124. serialize(): any;
  122125. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122126. }
  122127. }
  122128. declare module BABYLON {
  122129. /**
  122130. * Class used to store a color step for the GradientBlock
  122131. */
  122132. export class GradientBlockColorStep {
  122133. /**
  122134. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  122135. */
  122136. step: number;
  122137. /**
  122138. * Gets or sets the color associated with this step
  122139. */
  122140. color: Color3;
  122141. /**
  122142. * Creates a new GradientBlockColorStep
  122143. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  122144. * @param color defines the color associated with this step
  122145. */
  122146. constructor(
  122147. /**
  122148. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  122149. */
  122150. step: number,
  122151. /**
  122152. * Gets or sets the color associated with this step
  122153. */
  122154. color: Color3);
  122155. }
  122156. /**
  122157. * Block used to return a color from a gradient based on an input value between 0 and 1
  122158. */
  122159. export class GradientBlock extends NodeMaterialBlock {
  122160. /**
  122161. * Gets or sets the list of color steps
  122162. */
  122163. colorSteps: GradientBlockColorStep[];
  122164. /**
  122165. * Creates a new GradientBlock
  122166. * @param name defines the block name
  122167. */
  122168. constructor(name: string);
  122169. /**
  122170. * Gets the current class name
  122171. * @returns the class name
  122172. */
  122173. getClassName(): string;
  122174. /**
  122175. * Gets the gradient input component
  122176. */
  122177. readonly gradient: NodeMaterialConnectionPoint;
  122178. /**
  122179. * Gets the output component
  122180. */
  122181. readonly output: NodeMaterialConnectionPoint;
  122182. private _writeColorConstant;
  122183. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  122184. serialize(): any;
  122185. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122186. protected _dumpPropertiesCode(): string;
  122187. }
  122188. }
  122189. declare module BABYLON {
  122190. /**
  122191. * Block used to normalize lerp between 2 values
  122192. */
  122193. export class NLerpBlock extends NodeMaterialBlock {
  122194. /**
  122195. * Creates a new NLerpBlock
  122196. * @param name defines the block name
  122197. */
  122198. constructor(name: string);
  122199. /**
  122200. * Gets the current class name
  122201. * @returns the class name
  122202. */
  122203. getClassName(): string;
  122204. /**
  122205. * Gets the left operand input component
  122206. */
  122207. readonly left: NodeMaterialConnectionPoint;
  122208. /**
  122209. * Gets the right operand input component
  122210. */
  122211. readonly right: NodeMaterialConnectionPoint;
  122212. /**
  122213. * Gets the gradient operand input component
  122214. */
  122215. readonly gradient: NodeMaterialConnectionPoint;
  122216. /**
  122217. * Gets the output component
  122218. */
  122219. readonly output: NodeMaterialConnectionPoint;
  122220. protected _buildBlock(state: NodeMaterialBuildState): this;
  122221. }
  122222. }
  122223. declare module BABYLON {
  122224. /**
  122225. * Effect Render Options
  122226. */
  122227. export interface IEffectRendererOptions {
  122228. /**
  122229. * Defines the vertices positions.
  122230. */
  122231. positions?: number[];
  122232. /**
  122233. * Defines the indices.
  122234. */
  122235. indices?: number[];
  122236. }
  122237. /**
  122238. * Helper class to render one or more effects
  122239. */
  122240. export class EffectRenderer {
  122241. private engine;
  122242. private static _DefaultOptions;
  122243. private _vertexBuffers;
  122244. private _indexBuffer;
  122245. private _ringBufferIndex;
  122246. private _ringScreenBuffer;
  122247. private _fullscreenViewport;
  122248. private _getNextFrameBuffer;
  122249. /**
  122250. * Creates an effect renderer
  122251. * @param engine the engine to use for rendering
  122252. * @param options defines the options of the effect renderer
  122253. */
  122254. constructor(engine: Engine, options?: IEffectRendererOptions);
  122255. /**
  122256. * Sets the current viewport in normalized coordinates 0-1
  122257. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  122258. */
  122259. setViewport(viewport?: Viewport): void;
  122260. /**
  122261. * Binds the embedded attributes buffer to the effect.
  122262. * @param effect Defines the effect to bind the attributes for
  122263. */
  122264. bindBuffers(effect: Effect): void;
  122265. /**
  122266. * Sets the current effect wrapper to use during draw.
  122267. * The effect needs to be ready before calling this api.
  122268. * This also sets the default full screen position attribute.
  122269. * @param effectWrapper Defines the effect to draw with
  122270. */
  122271. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  122272. /**
  122273. * Draws a full screen quad.
  122274. */
  122275. draw(): void;
  122276. /**
  122277. * renders one or more effects to a specified texture
  122278. * @param effectWrappers list of effects to renderer
  122279. * @param outputTexture texture to draw to, if null it will render to the screen
  122280. */
  122281. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  122282. /**
  122283. * Disposes of the effect renderer
  122284. */
  122285. dispose(): void;
  122286. }
  122287. /**
  122288. * Options to create an EffectWrapper
  122289. */
  122290. interface EffectWrapperCreationOptions {
  122291. /**
  122292. * Engine to use to create the effect
  122293. */
  122294. engine: Engine;
  122295. /**
  122296. * Fragment shader for the effect
  122297. */
  122298. fragmentShader: string;
  122299. /**
  122300. * Vertex shader for the effect
  122301. */
  122302. vertexShader?: string;
  122303. /**
  122304. * Attributes to use in the shader
  122305. */
  122306. attributeNames?: Array<string>;
  122307. /**
  122308. * Uniforms to use in the shader
  122309. */
  122310. uniformNames?: Array<string>;
  122311. /**
  122312. * Texture sampler names to use in the shader
  122313. */
  122314. samplerNames?: Array<string>;
  122315. /**
  122316. * The friendly name of the effect displayed in Spector.
  122317. */
  122318. name?: string;
  122319. }
  122320. /**
  122321. * Wraps an effect to be used for rendering
  122322. */
  122323. export class EffectWrapper {
  122324. /**
  122325. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  122326. */
  122327. onApplyObservable: Observable<{}>;
  122328. /**
  122329. * The underlying effect
  122330. */
  122331. effect: Effect;
  122332. /**
  122333. * Creates an effect to be renderer
  122334. * @param creationOptions options to create the effect
  122335. */
  122336. constructor(creationOptions: EffectWrapperCreationOptions);
  122337. /**
  122338. * Disposes of the effect wrapper
  122339. */
  122340. dispose(): void;
  122341. }
  122342. }
  122343. declare module BABYLON {
  122344. /**
  122345. * Helper class to push actions to a pool of workers.
  122346. */
  122347. export class WorkerPool implements IDisposable {
  122348. private _workerInfos;
  122349. private _pendingActions;
  122350. /**
  122351. * Constructor
  122352. * @param workers Array of workers to use for actions
  122353. */
  122354. constructor(workers: Array<Worker>);
  122355. /**
  122356. * Terminates all workers and clears any pending actions.
  122357. */
  122358. dispose(): void;
  122359. /**
  122360. * Pushes an action to the worker pool. If all the workers are active, the action will be
  122361. * pended until a worker has completed its action.
  122362. * @param action The action to perform. Call onComplete when the action is complete.
  122363. */
  122364. push(action: (worker: Worker, onComplete: () => void) => void): void;
  122365. private _execute;
  122366. }
  122367. }
  122368. declare module BABYLON {
  122369. /**
  122370. * Configuration for Draco compression
  122371. */
  122372. export interface IDracoCompressionConfiguration {
  122373. /**
  122374. * Configuration for the decoder.
  122375. */
  122376. decoder: {
  122377. /**
  122378. * The url to the WebAssembly module.
  122379. */
  122380. wasmUrl?: string;
  122381. /**
  122382. * The url to the WebAssembly binary.
  122383. */
  122384. wasmBinaryUrl?: string;
  122385. /**
  122386. * The url to the fallback JavaScript module.
  122387. */
  122388. fallbackUrl?: string;
  122389. };
  122390. }
  122391. /**
  122392. * Draco compression (https://google.github.io/draco/)
  122393. *
  122394. * This class wraps the Draco module.
  122395. *
  122396. * **Encoder**
  122397. *
  122398. * The encoder is not currently implemented.
  122399. *
  122400. * **Decoder**
  122401. *
  122402. * 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.
  122403. *
  122404. * To update the configuration, use the following code:
  122405. * ```javascript
  122406. * DracoCompression.Configuration = {
  122407. * decoder: {
  122408. * wasmUrl: "<url to the WebAssembly library>",
  122409. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  122410. * fallbackUrl: "<url to the fallback JavaScript library>",
  122411. * }
  122412. * };
  122413. * ```
  122414. *
  122415. * 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.
  122416. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  122417. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  122418. *
  122419. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  122420. * ```javascript
  122421. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  122422. * ```
  122423. *
  122424. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  122425. */
  122426. export class DracoCompression implements IDisposable {
  122427. private _workerPoolPromise?;
  122428. private _decoderModulePromise?;
  122429. /**
  122430. * The configuration. Defaults to the following urls:
  122431. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  122432. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  122433. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  122434. */
  122435. static Configuration: IDracoCompressionConfiguration;
  122436. /**
  122437. * Returns true if the decoder configuration is available.
  122438. */
  122439. static readonly DecoderAvailable: boolean;
  122440. /**
  122441. * Default number of workers to create when creating the draco compression object.
  122442. */
  122443. static DefaultNumWorkers: number;
  122444. private static GetDefaultNumWorkers;
  122445. private static _Default;
  122446. /**
  122447. * Default instance for the draco compression object.
  122448. */
  122449. static readonly Default: DracoCompression;
  122450. /**
  122451. * Constructor
  122452. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  122453. */
  122454. constructor(numWorkers?: number);
  122455. /**
  122456. * Stop all async operations and release resources.
  122457. */
  122458. dispose(): void;
  122459. /**
  122460. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  122461. * @returns a promise that resolves when ready
  122462. */
  122463. whenReadyAsync(): Promise<void>;
  122464. /**
  122465. * Decode Draco compressed mesh data to vertex data.
  122466. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  122467. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  122468. * @returns A promise that resolves with the decoded vertex data
  122469. */
  122470. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  122471. [kind: string]: number;
  122472. }): Promise<VertexData>;
  122473. }
  122474. }
  122475. declare module BABYLON {
  122476. /**
  122477. * Class for building Constructive Solid Geometry
  122478. */
  122479. export class CSG {
  122480. private polygons;
  122481. /**
  122482. * The world matrix
  122483. */
  122484. matrix: Matrix;
  122485. /**
  122486. * Stores the position
  122487. */
  122488. position: Vector3;
  122489. /**
  122490. * Stores the rotation
  122491. */
  122492. rotation: Vector3;
  122493. /**
  122494. * Stores the rotation quaternion
  122495. */
  122496. rotationQuaternion: Nullable<Quaternion>;
  122497. /**
  122498. * Stores the scaling vector
  122499. */
  122500. scaling: Vector3;
  122501. /**
  122502. * Convert the Mesh to CSG
  122503. * @param mesh The Mesh to convert to CSG
  122504. * @returns A new CSG from the Mesh
  122505. */
  122506. static FromMesh(mesh: Mesh): CSG;
  122507. /**
  122508. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  122509. * @param polygons Polygons used to construct a CSG solid
  122510. */
  122511. private static FromPolygons;
  122512. /**
  122513. * Clones, or makes a deep copy, of the CSG
  122514. * @returns A new CSG
  122515. */
  122516. clone(): CSG;
  122517. /**
  122518. * Unions this CSG with another CSG
  122519. * @param csg The CSG to union against this CSG
  122520. * @returns The unioned CSG
  122521. */
  122522. union(csg: CSG): CSG;
  122523. /**
  122524. * Unions this CSG with another CSG in place
  122525. * @param csg The CSG to union against this CSG
  122526. */
  122527. unionInPlace(csg: CSG): void;
  122528. /**
  122529. * Subtracts this CSG with another CSG
  122530. * @param csg The CSG to subtract against this CSG
  122531. * @returns A new CSG
  122532. */
  122533. subtract(csg: CSG): CSG;
  122534. /**
  122535. * Subtracts this CSG with another CSG in place
  122536. * @param csg The CSG to subtact against this CSG
  122537. */
  122538. subtractInPlace(csg: CSG): void;
  122539. /**
  122540. * Intersect this CSG with another CSG
  122541. * @param csg The CSG to intersect against this CSG
  122542. * @returns A new CSG
  122543. */
  122544. intersect(csg: CSG): CSG;
  122545. /**
  122546. * Intersects this CSG with another CSG in place
  122547. * @param csg The CSG to intersect against this CSG
  122548. */
  122549. intersectInPlace(csg: CSG): void;
  122550. /**
  122551. * Return a new CSG solid with solid and empty space switched. This solid is
  122552. * not modified.
  122553. * @returns A new CSG solid with solid and empty space switched
  122554. */
  122555. inverse(): CSG;
  122556. /**
  122557. * Inverses the CSG in place
  122558. */
  122559. inverseInPlace(): void;
  122560. /**
  122561. * This is used to keep meshes transformations so they can be restored
  122562. * when we build back a Babylon Mesh
  122563. * NB : All CSG operations are performed in world coordinates
  122564. * @param csg The CSG to copy the transform attributes from
  122565. * @returns This CSG
  122566. */
  122567. copyTransformAttributes(csg: CSG): CSG;
  122568. /**
  122569. * Build Raw mesh from CSG
  122570. * Coordinates here are in world space
  122571. * @param name The name of the mesh geometry
  122572. * @param scene The Scene
  122573. * @param keepSubMeshes Specifies if the submeshes should be kept
  122574. * @returns A new Mesh
  122575. */
  122576. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  122577. /**
  122578. * Build Mesh from CSG taking material and transforms into account
  122579. * @param name The name of the Mesh
  122580. * @param material The material of the Mesh
  122581. * @param scene The Scene
  122582. * @param keepSubMeshes Specifies if submeshes should be kept
  122583. * @returns The new Mesh
  122584. */
  122585. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  122586. }
  122587. }
  122588. declare module BABYLON {
  122589. /**
  122590. * Class used to create a trail following a mesh
  122591. */
  122592. export class TrailMesh extends Mesh {
  122593. private _generator;
  122594. private _autoStart;
  122595. private _running;
  122596. private _diameter;
  122597. private _length;
  122598. private _sectionPolygonPointsCount;
  122599. private _sectionVectors;
  122600. private _sectionNormalVectors;
  122601. private _beforeRenderObserver;
  122602. /**
  122603. * @constructor
  122604. * @param name The value used by scene.getMeshByName() to do a lookup.
  122605. * @param generator The mesh to generate a trail.
  122606. * @param scene The scene to add this mesh to.
  122607. * @param diameter Diameter of trailing mesh. Default is 1.
  122608. * @param length Length of trailing mesh. Default is 60.
  122609. * @param autoStart Automatically start trailing mesh. Default true.
  122610. */
  122611. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  122612. /**
  122613. * "TrailMesh"
  122614. * @returns "TrailMesh"
  122615. */
  122616. getClassName(): string;
  122617. private _createMesh;
  122618. /**
  122619. * Start trailing mesh.
  122620. */
  122621. start(): void;
  122622. /**
  122623. * Stop trailing mesh.
  122624. */
  122625. stop(): void;
  122626. /**
  122627. * Update trailing mesh geometry.
  122628. */
  122629. update(): void;
  122630. /**
  122631. * Returns a new TrailMesh object.
  122632. * @param name is a string, the name given to the new mesh
  122633. * @param newGenerator use new generator object for cloned trail mesh
  122634. * @returns a new mesh
  122635. */
  122636. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  122637. /**
  122638. * Serializes this trail mesh
  122639. * @param serializationObject object to write serialization to
  122640. */
  122641. serialize(serializationObject: any): void;
  122642. /**
  122643. * Parses a serialized trail mesh
  122644. * @param parsedMesh the serialized mesh
  122645. * @param scene the scene to create the trail mesh in
  122646. * @returns the created trail mesh
  122647. */
  122648. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  122649. }
  122650. }
  122651. declare module BABYLON {
  122652. /**
  122653. * Class containing static functions to help procedurally build meshes
  122654. */
  122655. export class TiledBoxBuilder {
  122656. /**
  122657. * Creates a box mesh
  122658. * 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)
  122659. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  122660. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122661. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122662. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122663. * @param name defines the name of the mesh
  122664. * @param options defines the options used to create the mesh
  122665. * @param scene defines the hosting scene
  122666. * @returns the box mesh
  122667. */
  122668. static CreateTiledBox(name: string, options: {
  122669. pattern?: number;
  122670. width?: number;
  122671. height?: number;
  122672. depth?: number;
  122673. tileSize?: number;
  122674. tileWidth?: number;
  122675. tileHeight?: number;
  122676. alignHorizontal?: number;
  122677. alignVertical?: number;
  122678. faceUV?: Vector4[];
  122679. faceColors?: Color4[];
  122680. sideOrientation?: number;
  122681. updatable?: boolean;
  122682. }, scene?: Nullable<Scene>): Mesh;
  122683. }
  122684. }
  122685. declare module BABYLON {
  122686. /**
  122687. * Class containing static functions to help procedurally build meshes
  122688. */
  122689. export class TorusKnotBuilder {
  122690. /**
  122691. * Creates a torus knot mesh
  122692. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  122693. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  122694. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  122695. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  122696. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122697. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122698. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  122699. * @param name defines the name of the mesh
  122700. * @param options defines the options used to create the mesh
  122701. * @param scene defines the hosting scene
  122702. * @returns the torus knot mesh
  122703. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  122704. */
  122705. static CreateTorusKnot(name: string, options: {
  122706. radius?: number;
  122707. tube?: number;
  122708. radialSegments?: number;
  122709. tubularSegments?: number;
  122710. p?: number;
  122711. q?: number;
  122712. updatable?: boolean;
  122713. sideOrientation?: number;
  122714. frontUVs?: Vector4;
  122715. backUVs?: Vector4;
  122716. }, scene: any): Mesh;
  122717. }
  122718. }
  122719. declare module BABYLON {
  122720. /**
  122721. * Polygon
  122722. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  122723. */
  122724. export class Polygon {
  122725. /**
  122726. * Creates a rectangle
  122727. * @param xmin bottom X coord
  122728. * @param ymin bottom Y coord
  122729. * @param xmax top X coord
  122730. * @param ymax top Y coord
  122731. * @returns points that make the resulting rectation
  122732. */
  122733. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  122734. /**
  122735. * Creates a circle
  122736. * @param radius radius of circle
  122737. * @param cx scale in x
  122738. * @param cy scale in y
  122739. * @param numberOfSides number of sides that make up the circle
  122740. * @returns points that make the resulting circle
  122741. */
  122742. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  122743. /**
  122744. * Creates a polygon from input string
  122745. * @param input Input polygon data
  122746. * @returns the parsed points
  122747. */
  122748. static Parse(input: string): Vector2[];
  122749. /**
  122750. * Starts building a polygon from x and y coordinates
  122751. * @param x x coordinate
  122752. * @param y y coordinate
  122753. * @returns the started path2
  122754. */
  122755. static StartingAt(x: number, y: number): Path2;
  122756. }
  122757. /**
  122758. * Builds a polygon
  122759. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  122760. */
  122761. export class PolygonMeshBuilder {
  122762. private _points;
  122763. private _outlinepoints;
  122764. private _holes;
  122765. private _name;
  122766. private _scene;
  122767. private _epoints;
  122768. private _eholes;
  122769. private _addToepoint;
  122770. /**
  122771. * Babylon reference to the earcut plugin.
  122772. */
  122773. bjsEarcut: any;
  122774. /**
  122775. * Creates a PolygonMeshBuilder
  122776. * @param name name of the builder
  122777. * @param contours Path of the polygon
  122778. * @param scene scene to add to when creating the mesh
  122779. * @param earcutInjection can be used to inject your own earcut reference
  122780. */
  122781. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  122782. /**
  122783. * Adds a whole within the polygon
  122784. * @param hole Array of points defining the hole
  122785. * @returns this
  122786. */
  122787. addHole(hole: Vector2[]): PolygonMeshBuilder;
  122788. /**
  122789. * Creates the polygon
  122790. * @param updatable If the mesh should be updatable
  122791. * @param depth The depth of the mesh created
  122792. * @returns the created mesh
  122793. */
  122794. build(updatable?: boolean, depth?: number): Mesh;
  122795. /**
  122796. * Creates the polygon
  122797. * @param depth The depth of the mesh created
  122798. * @returns the created VertexData
  122799. */
  122800. buildVertexData(depth?: number): VertexData;
  122801. /**
  122802. * Adds a side to the polygon
  122803. * @param positions points that make the polygon
  122804. * @param normals normals of the polygon
  122805. * @param uvs uvs of the polygon
  122806. * @param indices indices of the polygon
  122807. * @param bounds bounds of the polygon
  122808. * @param points points of the polygon
  122809. * @param depth depth of the polygon
  122810. * @param flip flip of the polygon
  122811. */
  122812. private addSide;
  122813. }
  122814. }
  122815. declare module BABYLON {
  122816. /**
  122817. * Class containing static functions to help procedurally build meshes
  122818. */
  122819. export class PolygonBuilder {
  122820. /**
  122821. * Creates a polygon mesh
  122822. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  122823. * * 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
  122824. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  122825. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122826. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  122827. * * Remember you can only change the shape positions, not their number when updating a polygon
  122828. * @param name defines the name of the mesh
  122829. * @param options defines the options used to create the mesh
  122830. * @param scene defines the hosting scene
  122831. * @param earcutInjection can be used to inject your own earcut reference
  122832. * @returns the polygon mesh
  122833. */
  122834. static CreatePolygon(name: string, options: {
  122835. shape: Vector3[];
  122836. holes?: Vector3[][];
  122837. depth?: number;
  122838. faceUV?: Vector4[];
  122839. faceColors?: Color4[];
  122840. updatable?: boolean;
  122841. sideOrientation?: number;
  122842. frontUVs?: Vector4;
  122843. backUVs?: Vector4;
  122844. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  122845. /**
  122846. * Creates an extruded polygon mesh, with depth in the Y direction.
  122847. * * 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)
  122848. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  122849. * @param name defines the name of the mesh
  122850. * @param options defines the options used to create the mesh
  122851. * @param scene defines the hosting scene
  122852. * @param earcutInjection can be used to inject your own earcut reference
  122853. * @returns the polygon mesh
  122854. */
  122855. static ExtrudePolygon(name: string, options: {
  122856. shape: Vector3[];
  122857. holes?: Vector3[][];
  122858. depth?: number;
  122859. faceUV?: Vector4[];
  122860. faceColors?: Color4[];
  122861. updatable?: boolean;
  122862. sideOrientation?: number;
  122863. frontUVs?: Vector4;
  122864. backUVs?: Vector4;
  122865. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  122866. }
  122867. }
  122868. declare module BABYLON {
  122869. /**
  122870. * Class containing static functions to help procedurally build meshes
  122871. */
  122872. export class LatheBuilder {
  122873. /**
  122874. * Creates lathe mesh.
  122875. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  122876. * * 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
  122877. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  122878. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  122879. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  122880. * * 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
  122881. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  122882. * * 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
  122883. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122884. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122885. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  122886. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122887. * @param name defines the name of the mesh
  122888. * @param options defines the options used to create the mesh
  122889. * @param scene defines the hosting scene
  122890. * @returns the lathe mesh
  122891. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  122892. */
  122893. static CreateLathe(name: string, options: {
  122894. shape: Vector3[];
  122895. radius?: number;
  122896. tessellation?: number;
  122897. clip?: number;
  122898. arc?: number;
  122899. closed?: boolean;
  122900. updatable?: boolean;
  122901. sideOrientation?: number;
  122902. frontUVs?: Vector4;
  122903. backUVs?: Vector4;
  122904. cap?: number;
  122905. invertUV?: boolean;
  122906. }, scene?: Nullable<Scene>): Mesh;
  122907. }
  122908. }
  122909. declare module BABYLON {
  122910. /**
  122911. * Class containing static functions to help procedurally build meshes
  122912. */
  122913. export class TiledPlaneBuilder {
  122914. /**
  122915. * Creates a tiled plane mesh
  122916. * * The parameter `pattern` will, depending on value, do nothing or
  122917. * * * flip (reflect about central vertical) alternate tiles across and up
  122918. * * * flip every tile on alternate rows
  122919. * * * rotate (180 degs) alternate tiles across and up
  122920. * * * rotate every tile on alternate rows
  122921. * * * flip and rotate alternate tiles across and up
  122922. * * * flip and rotate every tile on alternate rows
  122923. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  122924. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  122925. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122926. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  122927. * * 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)
  122928. * * 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)
  122929. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  122930. * @param name defines the name of the mesh
  122931. * @param options defines the options used to create the mesh
  122932. * @param scene defines the hosting scene
  122933. * @returns the box mesh
  122934. */
  122935. static CreateTiledPlane(name: string, options: {
  122936. pattern?: number;
  122937. tileSize?: number;
  122938. tileWidth?: number;
  122939. tileHeight?: number;
  122940. size?: number;
  122941. width?: number;
  122942. height?: number;
  122943. alignHorizontal?: number;
  122944. alignVertical?: number;
  122945. sideOrientation?: number;
  122946. frontUVs?: Vector4;
  122947. backUVs?: Vector4;
  122948. updatable?: boolean;
  122949. }, scene?: Nullable<Scene>): Mesh;
  122950. }
  122951. }
  122952. declare module BABYLON {
  122953. /**
  122954. * Class containing static functions to help procedurally build meshes
  122955. */
  122956. export class TubeBuilder {
  122957. /**
  122958. * Creates a tube mesh.
  122959. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  122960. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  122961. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  122962. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  122963. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  122964. * * 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)
  122965. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  122966. * * 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
  122967. * * 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
  122968. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122969. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122970. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  122971. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122972. * @param name defines the name of the mesh
  122973. * @param options defines the options used to create the mesh
  122974. * @param scene defines the hosting scene
  122975. * @returns the tube mesh
  122976. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  122977. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  122978. */
  122979. static CreateTube(name: string, options: {
  122980. path: Vector3[];
  122981. radius?: number;
  122982. tessellation?: number;
  122983. radiusFunction?: {
  122984. (i: number, distance: number): number;
  122985. };
  122986. cap?: number;
  122987. arc?: number;
  122988. updatable?: boolean;
  122989. sideOrientation?: number;
  122990. frontUVs?: Vector4;
  122991. backUVs?: Vector4;
  122992. instance?: Mesh;
  122993. invertUV?: boolean;
  122994. }, scene?: Nullable<Scene>): Mesh;
  122995. }
  122996. }
  122997. declare module BABYLON {
  122998. /**
  122999. * Class containing static functions to help procedurally build meshes
  123000. */
  123001. export class IcoSphereBuilder {
  123002. /**
  123003. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  123004. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  123005. * * 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`)
  123006. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  123007. * * 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
  123008. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123009. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123010. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123011. * @param name defines the name of the mesh
  123012. * @param options defines the options used to create the mesh
  123013. * @param scene defines the hosting scene
  123014. * @returns the icosahedron mesh
  123015. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  123016. */
  123017. static CreateIcoSphere(name: string, options: {
  123018. radius?: number;
  123019. radiusX?: number;
  123020. radiusY?: number;
  123021. radiusZ?: number;
  123022. flat?: boolean;
  123023. subdivisions?: number;
  123024. sideOrientation?: number;
  123025. frontUVs?: Vector4;
  123026. backUVs?: Vector4;
  123027. updatable?: boolean;
  123028. }, scene?: Nullable<Scene>): Mesh;
  123029. }
  123030. }
  123031. declare module BABYLON {
  123032. /**
  123033. * Class containing static functions to help procedurally build meshes
  123034. */
  123035. export class DecalBuilder {
  123036. /**
  123037. * Creates a decal mesh.
  123038. * 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
  123039. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  123040. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  123041. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  123042. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  123043. * @param name defines the name of the mesh
  123044. * @param sourceMesh defines the mesh where the decal must be applied
  123045. * @param options defines the options used to create the mesh
  123046. * @param scene defines the hosting scene
  123047. * @returns the decal mesh
  123048. * @see https://doc.babylonjs.com/how_to/decals
  123049. */
  123050. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  123051. position?: Vector3;
  123052. normal?: Vector3;
  123053. size?: Vector3;
  123054. angle?: number;
  123055. }): Mesh;
  123056. }
  123057. }
  123058. declare module BABYLON {
  123059. /**
  123060. * Class containing static functions to help procedurally build meshes
  123061. */
  123062. export class MeshBuilder {
  123063. /**
  123064. * Creates a box mesh
  123065. * * The parameter `size` sets the size (float) of each box side (default 1)
  123066. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  123067. * * 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)
  123068. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  123069. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123070. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123071. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123072. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  123073. * @param name defines the name of the mesh
  123074. * @param options defines the options used to create the mesh
  123075. * @param scene defines the hosting scene
  123076. * @returns the box mesh
  123077. */
  123078. static CreateBox(name: string, options: {
  123079. size?: number;
  123080. width?: number;
  123081. height?: number;
  123082. depth?: number;
  123083. faceUV?: Vector4[];
  123084. faceColors?: Color4[];
  123085. sideOrientation?: number;
  123086. frontUVs?: Vector4;
  123087. backUVs?: Vector4;
  123088. updatable?: boolean;
  123089. }, scene?: Nullable<Scene>): Mesh;
  123090. /**
  123091. * Creates a tiled box mesh
  123092. * * faceTiles sets the pattern, tile size and number of tiles for a face
  123093. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123094. * @param name defines the name of the mesh
  123095. * @param options defines the options used to create the mesh
  123096. * @param scene defines the hosting scene
  123097. * @returns the tiled box mesh
  123098. */
  123099. static CreateTiledBox(name: string, options: {
  123100. pattern?: number;
  123101. size?: number;
  123102. width?: number;
  123103. height?: number;
  123104. depth: number;
  123105. tileSize?: number;
  123106. tileWidth?: number;
  123107. tileHeight?: number;
  123108. faceUV?: Vector4[];
  123109. faceColors?: Color4[];
  123110. alignHorizontal?: number;
  123111. alignVertical?: number;
  123112. sideOrientation?: number;
  123113. updatable?: boolean;
  123114. }, scene?: Nullable<Scene>): Mesh;
  123115. /**
  123116. * Creates a sphere mesh
  123117. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  123118. * * 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`)
  123119. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  123120. * * 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
  123121. * * 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)
  123122. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123123. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123124. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123125. * @param name defines the name of the mesh
  123126. * @param options defines the options used to create the mesh
  123127. * @param scene defines the hosting scene
  123128. * @returns the sphere mesh
  123129. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  123130. */
  123131. static CreateSphere(name: string, options: {
  123132. segments?: number;
  123133. diameter?: number;
  123134. diameterX?: number;
  123135. diameterY?: number;
  123136. diameterZ?: number;
  123137. arc?: number;
  123138. slice?: number;
  123139. sideOrientation?: number;
  123140. frontUVs?: Vector4;
  123141. backUVs?: Vector4;
  123142. updatable?: boolean;
  123143. }, scene?: Nullable<Scene>): Mesh;
  123144. /**
  123145. * Creates a plane polygonal mesh. By default, this is a disc
  123146. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  123147. * * 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
  123148. * * 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
  123149. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123150. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123151. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123152. * @param name defines the name of the mesh
  123153. * @param options defines the options used to create the mesh
  123154. * @param scene defines the hosting scene
  123155. * @returns the plane polygonal mesh
  123156. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  123157. */
  123158. static CreateDisc(name: string, options: {
  123159. radius?: number;
  123160. tessellation?: number;
  123161. arc?: number;
  123162. updatable?: boolean;
  123163. sideOrientation?: number;
  123164. frontUVs?: Vector4;
  123165. backUVs?: Vector4;
  123166. }, scene?: Nullable<Scene>): Mesh;
  123167. /**
  123168. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  123169. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  123170. * * 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`)
  123171. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  123172. * * 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
  123173. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123174. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123175. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123176. * @param name defines the name of the mesh
  123177. * @param options defines the options used to create the mesh
  123178. * @param scene defines the hosting scene
  123179. * @returns the icosahedron mesh
  123180. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  123181. */
  123182. static CreateIcoSphere(name: string, options: {
  123183. radius?: number;
  123184. radiusX?: number;
  123185. radiusY?: number;
  123186. radiusZ?: number;
  123187. flat?: boolean;
  123188. subdivisions?: number;
  123189. sideOrientation?: number;
  123190. frontUVs?: Vector4;
  123191. backUVs?: Vector4;
  123192. updatable?: boolean;
  123193. }, scene?: Nullable<Scene>): Mesh;
  123194. /**
  123195. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  123196. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  123197. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  123198. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  123199. * * 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
  123200. * * 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
  123201. * * 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
  123202. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123203. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123204. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  123205. * * 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
  123206. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  123207. * * 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
  123208. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  123209. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123210. * @param name defines the name of the mesh
  123211. * @param options defines the options used to create the mesh
  123212. * @param scene defines the hosting scene
  123213. * @returns the ribbon mesh
  123214. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  123215. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  123216. */
  123217. static CreateRibbon(name: string, options: {
  123218. pathArray: Vector3[][];
  123219. closeArray?: boolean;
  123220. closePath?: boolean;
  123221. offset?: number;
  123222. updatable?: boolean;
  123223. sideOrientation?: number;
  123224. frontUVs?: Vector4;
  123225. backUVs?: Vector4;
  123226. instance?: Mesh;
  123227. invertUV?: boolean;
  123228. uvs?: Vector2[];
  123229. colors?: Color4[];
  123230. }, scene?: Nullable<Scene>): Mesh;
  123231. /**
  123232. * Creates a cylinder or a cone mesh
  123233. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  123234. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  123235. * * 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.
  123236. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  123237. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  123238. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  123239. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  123240. * * 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).
  123241. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  123242. * * 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).
  123243. * * 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
  123244. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  123245. * * 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
  123246. * * 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.
  123247. * * If `enclose` is false, a ring surface is one element.
  123248. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  123249. * * 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
  123250. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123251. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123252. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123253. * @param name defines the name of the mesh
  123254. * @param options defines the options used to create the mesh
  123255. * @param scene defines the hosting scene
  123256. * @returns the cylinder mesh
  123257. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  123258. */
  123259. static CreateCylinder(name: string, options: {
  123260. height?: number;
  123261. diameterTop?: number;
  123262. diameterBottom?: number;
  123263. diameter?: number;
  123264. tessellation?: number;
  123265. subdivisions?: number;
  123266. arc?: number;
  123267. faceColors?: Color4[];
  123268. faceUV?: Vector4[];
  123269. updatable?: boolean;
  123270. hasRings?: boolean;
  123271. enclose?: boolean;
  123272. cap?: number;
  123273. sideOrientation?: number;
  123274. frontUVs?: Vector4;
  123275. backUVs?: Vector4;
  123276. }, scene?: Nullable<Scene>): Mesh;
  123277. /**
  123278. * Creates a torus mesh
  123279. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  123280. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  123281. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  123282. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123283. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123284. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123285. * @param name defines the name of the mesh
  123286. * @param options defines the options used to create the mesh
  123287. * @param scene defines the hosting scene
  123288. * @returns the torus mesh
  123289. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  123290. */
  123291. static CreateTorus(name: string, options: {
  123292. diameter?: number;
  123293. thickness?: number;
  123294. tessellation?: number;
  123295. updatable?: boolean;
  123296. sideOrientation?: number;
  123297. frontUVs?: Vector4;
  123298. backUVs?: Vector4;
  123299. }, scene?: Nullable<Scene>): Mesh;
  123300. /**
  123301. * Creates a torus knot mesh
  123302. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  123303. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  123304. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  123305. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  123306. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123307. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123308. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123309. * @param name defines the name of the mesh
  123310. * @param options defines the options used to create the mesh
  123311. * @param scene defines the hosting scene
  123312. * @returns the torus knot mesh
  123313. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  123314. */
  123315. static CreateTorusKnot(name: string, options: {
  123316. radius?: number;
  123317. tube?: number;
  123318. radialSegments?: number;
  123319. tubularSegments?: number;
  123320. p?: number;
  123321. q?: number;
  123322. updatable?: boolean;
  123323. sideOrientation?: number;
  123324. frontUVs?: Vector4;
  123325. backUVs?: Vector4;
  123326. }, scene?: Nullable<Scene>): Mesh;
  123327. /**
  123328. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  123329. * * 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
  123330. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  123331. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  123332. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  123333. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  123334. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  123335. * * 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
  123336. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  123337. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123338. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  123339. * @param name defines the name of the new line system
  123340. * @param options defines the options used to create the line system
  123341. * @param scene defines the hosting scene
  123342. * @returns a new line system mesh
  123343. */
  123344. static CreateLineSystem(name: string, options: {
  123345. lines: Vector3[][];
  123346. updatable?: boolean;
  123347. instance?: Nullable<LinesMesh>;
  123348. colors?: Nullable<Color4[][]>;
  123349. useVertexAlpha?: boolean;
  123350. }, scene: Nullable<Scene>): LinesMesh;
  123351. /**
  123352. * Creates a line mesh
  123353. * 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
  123354. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  123355. * * The parameter `points` is an array successive Vector3
  123356. * * 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
  123357. * * The optional parameter `colors` is an array of successive Color4, one per line point
  123358. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  123359. * * When updating an instance, remember that only point positions can change, not the number of points
  123360. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123361. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  123362. * @param name defines the name of the new line system
  123363. * @param options defines the options used to create the line system
  123364. * @param scene defines the hosting scene
  123365. * @returns a new line mesh
  123366. */
  123367. static CreateLines(name: string, options: {
  123368. points: Vector3[];
  123369. updatable?: boolean;
  123370. instance?: Nullable<LinesMesh>;
  123371. colors?: Color4[];
  123372. useVertexAlpha?: boolean;
  123373. }, scene?: Nullable<Scene>): LinesMesh;
  123374. /**
  123375. * Creates a dashed line mesh
  123376. * * 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
  123377. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  123378. * * The parameter `points` is an array successive Vector3
  123379. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  123380. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  123381. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  123382. * * 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
  123383. * * When updating an instance, remember that only point positions can change, not the number of points
  123384. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123385. * @param name defines the name of the mesh
  123386. * @param options defines the options used to create the mesh
  123387. * @param scene defines the hosting scene
  123388. * @returns the dashed line mesh
  123389. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  123390. */
  123391. static CreateDashedLines(name: string, options: {
  123392. points: Vector3[];
  123393. dashSize?: number;
  123394. gapSize?: number;
  123395. dashNb?: number;
  123396. updatable?: boolean;
  123397. instance?: LinesMesh;
  123398. }, scene?: Nullable<Scene>): LinesMesh;
  123399. /**
  123400. * 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.
  123401. * * 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.
  123402. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  123403. * * 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.
  123404. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  123405. * * 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
  123406. * * 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
  123407. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  123408. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123409. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123410. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  123411. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123412. * @param name defines the name of the mesh
  123413. * @param options defines the options used to create the mesh
  123414. * @param scene defines the hosting scene
  123415. * @returns the extruded shape mesh
  123416. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  123417. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  123418. */
  123419. static ExtrudeShape(name: string, options: {
  123420. shape: Vector3[];
  123421. path: Vector3[];
  123422. scale?: number;
  123423. rotation?: number;
  123424. cap?: number;
  123425. updatable?: boolean;
  123426. sideOrientation?: number;
  123427. frontUVs?: Vector4;
  123428. backUVs?: Vector4;
  123429. instance?: Mesh;
  123430. invertUV?: boolean;
  123431. }, scene?: Nullable<Scene>): Mesh;
  123432. /**
  123433. * Creates an custom extruded shape mesh.
  123434. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  123435. * * 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.
  123436. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  123437. * * 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
  123438. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  123439. * * 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
  123440. * * It must returns a float value that will be the scale value applied to the shape on each path point
  123441. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  123442. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  123443. * * 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
  123444. * * 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
  123445. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  123446. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123447. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123448. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  123449. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123450. * @param name defines the name of the mesh
  123451. * @param options defines the options used to create the mesh
  123452. * @param scene defines the hosting scene
  123453. * @returns the custom extruded shape mesh
  123454. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  123455. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  123456. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  123457. */
  123458. static ExtrudeShapeCustom(name: string, options: {
  123459. shape: Vector3[];
  123460. path: Vector3[];
  123461. scaleFunction?: any;
  123462. rotationFunction?: any;
  123463. ribbonCloseArray?: boolean;
  123464. ribbonClosePath?: boolean;
  123465. cap?: number;
  123466. updatable?: boolean;
  123467. sideOrientation?: number;
  123468. frontUVs?: Vector4;
  123469. backUVs?: Vector4;
  123470. instance?: Mesh;
  123471. invertUV?: boolean;
  123472. }, scene?: Nullable<Scene>): Mesh;
  123473. /**
  123474. * Creates lathe mesh.
  123475. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  123476. * * 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
  123477. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  123478. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  123479. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  123480. * * 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
  123481. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  123482. * * 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
  123483. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123484. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123485. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  123486. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123487. * @param name defines the name of the mesh
  123488. * @param options defines the options used to create the mesh
  123489. * @param scene defines the hosting scene
  123490. * @returns the lathe mesh
  123491. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  123492. */
  123493. static CreateLathe(name: string, options: {
  123494. shape: Vector3[];
  123495. radius?: number;
  123496. tessellation?: number;
  123497. clip?: number;
  123498. arc?: number;
  123499. closed?: boolean;
  123500. updatable?: boolean;
  123501. sideOrientation?: number;
  123502. frontUVs?: Vector4;
  123503. backUVs?: Vector4;
  123504. cap?: number;
  123505. invertUV?: boolean;
  123506. }, scene?: Nullable<Scene>): Mesh;
  123507. /**
  123508. * Creates a tiled plane mesh
  123509. * * You can set a limited pattern arrangement with the tiles
  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 mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123513. * @param name defines the name of the mesh
  123514. * @param options defines the options used to create the mesh
  123515. * @param scene defines the hosting scene
  123516. * @returns the plane mesh
  123517. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  123518. */
  123519. static CreateTiledPlane(name: string, options: {
  123520. pattern?: number;
  123521. tileSize?: number;
  123522. tileWidth?: number;
  123523. tileHeight?: number;
  123524. size?: number;
  123525. width?: number;
  123526. height?: number;
  123527. alignHorizontal?: number;
  123528. alignVertical?: number;
  123529. sideOrientation?: number;
  123530. frontUVs?: Vector4;
  123531. backUVs?: Vector4;
  123532. updatable?: boolean;
  123533. }, scene?: Nullable<Scene>): Mesh;
  123534. /**
  123535. * Creates a plane mesh
  123536. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  123537. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  123538. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  123539. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123540. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123541. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123542. * @param name defines the name of the mesh
  123543. * @param options defines the options used to create the mesh
  123544. * @param scene defines the hosting scene
  123545. * @returns the plane mesh
  123546. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  123547. */
  123548. static CreatePlane(name: string, options: {
  123549. size?: number;
  123550. width?: number;
  123551. height?: number;
  123552. sideOrientation?: number;
  123553. frontUVs?: Vector4;
  123554. backUVs?: Vector4;
  123555. updatable?: boolean;
  123556. sourcePlane?: Plane;
  123557. }, scene?: Nullable<Scene>): Mesh;
  123558. /**
  123559. * Creates a ground mesh
  123560. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  123561. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  123562. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123563. * @param name defines the name of the mesh
  123564. * @param options defines the options used to create the mesh
  123565. * @param scene defines the hosting scene
  123566. * @returns the ground mesh
  123567. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  123568. */
  123569. static CreateGround(name: string, options: {
  123570. width?: number;
  123571. height?: number;
  123572. subdivisions?: number;
  123573. subdivisionsX?: number;
  123574. subdivisionsY?: number;
  123575. updatable?: boolean;
  123576. }, scene?: Nullable<Scene>): Mesh;
  123577. /**
  123578. * Creates a tiled ground mesh
  123579. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  123580. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  123581. * * 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
  123582. * * 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
  123583. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123584. * @param name defines the name of the mesh
  123585. * @param options defines the options used to create the mesh
  123586. * @param scene defines the hosting scene
  123587. * @returns the tiled ground mesh
  123588. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  123589. */
  123590. static CreateTiledGround(name: string, options: {
  123591. xmin: number;
  123592. zmin: number;
  123593. xmax: number;
  123594. zmax: number;
  123595. subdivisions?: {
  123596. w: number;
  123597. h: number;
  123598. };
  123599. precision?: {
  123600. w: number;
  123601. h: number;
  123602. };
  123603. updatable?: boolean;
  123604. }, scene?: Nullable<Scene>): Mesh;
  123605. /**
  123606. * Creates a ground mesh from a height map
  123607. * * The parameter `url` sets the URL of the height map image resource.
  123608. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  123609. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  123610. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  123611. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  123612. * * 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.
  123613. * * 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).
  123614. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  123615. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123616. * @param name defines the name of the mesh
  123617. * @param url defines the url to the height map
  123618. * @param options defines the options used to create the mesh
  123619. * @param scene defines the hosting scene
  123620. * @returns the ground mesh
  123621. * @see https://doc.babylonjs.com/babylon101/height_map
  123622. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  123623. */
  123624. static CreateGroundFromHeightMap(name: string, url: string, options: {
  123625. width?: number;
  123626. height?: number;
  123627. subdivisions?: number;
  123628. minHeight?: number;
  123629. maxHeight?: number;
  123630. colorFilter?: Color3;
  123631. alphaFilter?: number;
  123632. updatable?: boolean;
  123633. onReady?: (mesh: GroundMesh) => void;
  123634. }, scene?: Nullable<Scene>): GroundMesh;
  123635. /**
  123636. * Creates a polygon mesh
  123637. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  123638. * * 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
  123639. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  123640. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123641. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  123642. * * Remember you can only change the shape positions, not their number when updating a polygon
  123643. * @param name defines the name of the mesh
  123644. * @param options defines the options used to create the mesh
  123645. * @param scene defines the hosting scene
  123646. * @param earcutInjection can be used to inject your own earcut reference
  123647. * @returns the polygon mesh
  123648. */
  123649. static CreatePolygon(name: string, options: {
  123650. shape: Vector3[];
  123651. holes?: Vector3[][];
  123652. depth?: number;
  123653. faceUV?: Vector4[];
  123654. faceColors?: Color4[];
  123655. updatable?: boolean;
  123656. sideOrientation?: number;
  123657. frontUVs?: Vector4;
  123658. backUVs?: Vector4;
  123659. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  123660. /**
  123661. * Creates an extruded polygon mesh, with depth in the Y direction.
  123662. * * 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)
  123663. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  123664. * @param name defines the name of the mesh
  123665. * @param options defines the options used to create the mesh
  123666. * @param scene defines the hosting scene
  123667. * @param earcutInjection can be used to inject your own earcut reference
  123668. * @returns the polygon mesh
  123669. */
  123670. static ExtrudePolygon(name: string, options: {
  123671. shape: Vector3[];
  123672. holes?: Vector3[][];
  123673. depth?: number;
  123674. faceUV?: Vector4[];
  123675. faceColors?: Color4[];
  123676. updatable?: boolean;
  123677. sideOrientation?: number;
  123678. frontUVs?: Vector4;
  123679. backUVs?: Vector4;
  123680. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  123681. /**
  123682. * Creates a tube mesh.
  123683. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  123684. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  123685. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  123686. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  123687. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  123688. * * 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)
  123689. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  123690. * * 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
  123691. * * 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
  123692. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123693. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123694. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  123695. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123696. * @param name defines the name of the mesh
  123697. * @param options defines the options used to create the mesh
  123698. * @param scene defines the hosting scene
  123699. * @returns the tube mesh
  123700. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  123701. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  123702. */
  123703. static CreateTube(name: string, options: {
  123704. path: Vector3[];
  123705. radius?: number;
  123706. tessellation?: number;
  123707. radiusFunction?: {
  123708. (i: number, distance: number): number;
  123709. };
  123710. cap?: number;
  123711. arc?: number;
  123712. updatable?: boolean;
  123713. sideOrientation?: number;
  123714. frontUVs?: Vector4;
  123715. backUVs?: Vector4;
  123716. instance?: Mesh;
  123717. invertUV?: boolean;
  123718. }, scene?: Nullable<Scene>): Mesh;
  123719. /**
  123720. * Creates a polyhedron mesh
  123721. * * 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
  123722. * * The parameter `size` (positive float, default 1) sets the polygon size
  123723. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  123724. * * 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`
  123725. * * 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
  123726. * * 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)`)
  123727. * * 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
  123728. * * 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
  123729. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123730. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123731. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123732. * @param name defines the name of the mesh
  123733. * @param options defines the options used to create the mesh
  123734. * @param scene defines the hosting scene
  123735. * @returns the polyhedron mesh
  123736. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  123737. */
  123738. static CreatePolyhedron(name: string, options: {
  123739. type?: number;
  123740. size?: number;
  123741. sizeX?: number;
  123742. sizeY?: number;
  123743. sizeZ?: number;
  123744. custom?: any;
  123745. faceUV?: Vector4[];
  123746. faceColors?: Color4[];
  123747. flat?: boolean;
  123748. updatable?: boolean;
  123749. sideOrientation?: number;
  123750. frontUVs?: Vector4;
  123751. backUVs?: Vector4;
  123752. }, scene?: Nullable<Scene>): Mesh;
  123753. /**
  123754. * Creates a decal mesh.
  123755. * 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
  123756. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  123757. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  123758. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  123759. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  123760. * @param name defines the name of the mesh
  123761. * @param sourceMesh defines the mesh where the decal must be applied
  123762. * @param options defines the options used to create the mesh
  123763. * @param scene defines the hosting scene
  123764. * @returns the decal mesh
  123765. * @see https://doc.babylonjs.com/how_to/decals
  123766. */
  123767. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  123768. position?: Vector3;
  123769. normal?: Vector3;
  123770. size?: Vector3;
  123771. angle?: number;
  123772. }): Mesh;
  123773. }
  123774. }
  123775. declare module BABYLON {
  123776. /**
  123777. * A simplifier interface for future simplification implementations
  123778. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  123779. */
  123780. export interface ISimplifier {
  123781. /**
  123782. * Simplification of a given mesh according to the given settings.
  123783. * Since this requires computation, it is assumed that the function runs async.
  123784. * @param settings The settings of the simplification, including quality and distance
  123785. * @param successCallback A callback that will be called after the mesh was simplified.
  123786. * @param errorCallback in case of an error, this callback will be called. optional.
  123787. */
  123788. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  123789. }
  123790. /**
  123791. * Expected simplification settings.
  123792. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  123793. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  123794. */
  123795. export interface ISimplificationSettings {
  123796. /**
  123797. * Gets or sets the expected quality
  123798. */
  123799. quality: number;
  123800. /**
  123801. * Gets or sets the distance when this optimized version should be used
  123802. */
  123803. distance: number;
  123804. /**
  123805. * Gets an already optimized mesh
  123806. */
  123807. optimizeMesh?: boolean;
  123808. }
  123809. /**
  123810. * Class used to specify simplification options
  123811. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  123812. */
  123813. export class SimplificationSettings implements ISimplificationSettings {
  123814. /** expected quality */
  123815. quality: number;
  123816. /** distance when this optimized version should be used */
  123817. distance: number;
  123818. /** already optimized mesh */
  123819. optimizeMesh?: boolean | undefined;
  123820. /**
  123821. * Creates a SimplificationSettings
  123822. * @param quality expected quality
  123823. * @param distance distance when this optimized version should be used
  123824. * @param optimizeMesh already optimized mesh
  123825. */
  123826. constructor(
  123827. /** expected quality */
  123828. quality: number,
  123829. /** distance when this optimized version should be used */
  123830. distance: number,
  123831. /** already optimized mesh */
  123832. optimizeMesh?: boolean | undefined);
  123833. }
  123834. /**
  123835. * Interface used to define a simplification task
  123836. */
  123837. export interface ISimplificationTask {
  123838. /**
  123839. * Array of settings
  123840. */
  123841. settings: Array<ISimplificationSettings>;
  123842. /**
  123843. * Simplification type
  123844. */
  123845. simplificationType: SimplificationType;
  123846. /**
  123847. * Mesh to simplify
  123848. */
  123849. mesh: Mesh;
  123850. /**
  123851. * Callback called on success
  123852. */
  123853. successCallback?: () => void;
  123854. /**
  123855. * Defines if parallel processing can be used
  123856. */
  123857. parallelProcessing: boolean;
  123858. }
  123859. /**
  123860. * Queue used to order the simplification tasks
  123861. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  123862. */
  123863. export class SimplificationQueue {
  123864. private _simplificationArray;
  123865. /**
  123866. * Gets a boolean indicating that the process is still running
  123867. */
  123868. running: boolean;
  123869. /**
  123870. * Creates a new queue
  123871. */
  123872. constructor();
  123873. /**
  123874. * Adds a new simplification task
  123875. * @param task defines a task to add
  123876. */
  123877. addTask(task: ISimplificationTask): void;
  123878. /**
  123879. * Execute next task
  123880. */
  123881. executeNext(): void;
  123882. /**
  123883. * Execute a simplification task
  123884. * @param task defines the task to run
  123885. */
  123886. runSimplification(task: ISimplificationTask): void;
  123887. private getSimplifier;
  123888. }
  123889. /**
  123890. * The implemented types of simplification
  123891. * At the moment only Quadratic Error Decimation is implemented
  123892. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  123893. */
  123894. export enum SimplificationType {
  123895. /** Quadratic error decimation */
  123896. QUADRATIC = 0
  123897. }
  123898. }
  123899. declare module BABYLON {
  123900. interface Scene {
  123901. /** @hidden (Backing field) */
  123902. _simplificationQueue: SimplificationQueue;
  123903. /**
  123904. * Gets or sets the simplification queue attached to the scene
  123905. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  123906. */
  123907. simplificationQueue: SimplificationQueue;
  123908. }
  123909. interface Mesh {
  123910. /**
  123911. * Simplify the mesh according to the given array of settings.
  123912. * Function will return immediately and will simplify async
  123913. * @param settings a collection of simplification settings
  123914. * @param parallelProcessing should all levels calculate parallel or one after the other
  123915. * @param simplificationType the type of simplification to run
  123916. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  123917. * @returns the current mesh
  123918. */
  123919. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  123920. }
  123921. /**
  123922. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  123923. * created in a scene
  123924. */
  123925. export class SimplicationQueueSceneComponent implements ISceneComponent {
  123926. /**
  123927. * The component name helpfull to identify the component in the list of scene components.
  123928. */
  123929. readonly name: string;
  123930. /**
  123931. * The scene the component belongs to.
  123932. */
  123933. scene: Scene;
  123934. /**
  123935. * Creates a new instance of the component for the given scene
  123936. * @param scene Defines the scene to register the component in
  123937. */
  123938. constructor(scene: Scene);
  123939. /**
  123940. * Registers the component in a given scene
  123941. */
  123942. register(): void;
  123943. /**
  123944. * Rebuilds the elements related to this component in case of
  123945. * context lost for instance.
  123946. */
  123947. rebuild(): void;
  123948. /**
  123949. * Disposes the component and the associated ressources
  123950. */
  123951. dispose(): void;
  123952. private _beforeCameraUpdate;
  123953. }
  123954. }
  123955. declare module BABYLON {
  123956. /**
  123957. * Navigation plugin interface to add navigation constrained by a navigation mesh
  123958. */
  123959. export interface INavigationEnginePlugin {
  123960. /**
  123961. * plugin name
  123962. */
  123963. name: string;
  123964. /**
  123965. * Creates a navigation mesh
  123966. * @param meshes array of all the geometry used to compute the navigatio mesh
  123967. * @param parameters bunch of parameters used to filter geometry
  123968. */
  123969. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  123970. /**
  123971. * Create a navigation mesh debug mesh
  123972. * @param scene is where the mesh will be added
  123973. * @returns debug display mesh
  123974. */
  123975. createDebugNavMesh(scene: Scene): Mesh;
  123976. /**
  123977. * Get a navigation mesh constrained position, closest to the parameter position
  123978. * @param position world position
  123979. * @returns the closest point to position constrained by the navigation mesh
  123980. */
  123981. getClosestPoint(position: Vector3): Vector3;
  123982. /**
  123983. * Get a navigation mesh constrained position, within a particular radius
  123984. * @param position world position
  123985. * @param maxRadius the maximum distance to the constrained world position
  123986. * @returns the closest point to position constrained by the navigation mesh
  123987. */
  123988. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  123989. /**
  123990. * Compute the final position from a segment made of destination-position
  123991. * @param position world position
  123992. * @param destination world position
  123993. * @returns the resulting point along the navmesh
  123994. */
  123995. moveAlong(position: Vector3, destination: Vector3): Vector3;
  123996. /**
  123997. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  123998. * @param start world position
  123999. * @param end world position
  124000. * @returns array containing world position composing the path
  124001. */
  124002. computePath(start: Vector3, end: Vector3): Vector3[];
  124003. /**
  124004. * If this plugin is supported
  124005. * @returns true if plugin is supported
  124006. */
  124007. isSupported(): boolean;
  124008. /**
  124009. * Create a new Crowd so you can add agents
  124010. * @param maxAgents the maximum agent count in the crowd
  124011. * @param maxAgentRadius the maximum radius an agent can have
  124012. * @param scene to attach the crowd to
  124013. * @returns the crowd you can add agents to
  124014. */
  124015. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  124016. /**
  124017. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  124018. * The queries will try to find a solution within those bounds
  124019. * default is (1,1,1)
  124020. * @param extent x,y,z value that define the extent around the queries point of reference
  124021. */
  124022. setDefaultQueryExtent(extent: Vector3): void;
  124023. /**
  124024. * Get the Bounding box extent specified by setDefaultQueryExtent
  124025. * @returns the box extent values
  124026. */
  124027. getDefaultQueryExtent(): Vector3;
  124028. /**
  124029. * Release all resources
  124030. */
  124031. dispose(): void;
  124032. }
  124033. /**
  124034. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  124035. */
  124036. export interface ICrowd {
  124037. /**
  124038. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  124039. * You can attach anything to that node. The node position is updated in the scene update tick.
  124040. * @param pos world position that will be constrained by the navigation mesh
  124041. * @param parameters agent parameters
  124042. * @param transform hooked to the agent that will be update by the scene
  124043. * @returns agent index
  124044. */
  124045. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  124046. /**
  124047. * Returns the agent position in world space
  124048. * @param index agent index returned by addAgent
  124049. * @returns world space position
  124050. */
  124051. getAgentPosition(index: number): Vector3;
  124052. /**
  124053. * Gets the agent velocity in world space
  124054. * @param index agent index returned by addAgent
  124055. * @returns world space velocity
  124056. */
  124057. getAgentVelocity(index: number): Vector3;
  124058. /**
  124059. * remove a particular agent previously created
  124060. * @param index agent index returned by addAgent
  124061. */
  124062. removeAgent(index: number): void;
  124063. /**
  124064. * get the list of all agents attached to this crowd
  124065. * @returns list of agent indices
  124066. */
  124067. getAgents(): number[];
  124068. /**
  124069. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  124070. * @param deltaTime in seconds
  124071. */
  124072. update(deltaTime: number): void;
  124073. /**
  124074. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  124075. * @param index agent index returned by addAgent
  124076. * @param destination targeted world position
  124077. */
  124078. agentGoto(index: number, destination: Vector3): void;
  124079. /**
  124080. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  124081. * The queries will try to find a solution within those bounds
  124082. * default is (1,1,1)
  124083. * @param extent x,y,z value that define the extent around the queries point of reference
  124084. */
  124085. setDefaultQueryExtent(extent: Vector3): void;
  124086. /**
  124087. * Get the Bounding box extent specified by setDefaultQueryExtent
  124088. * @returns the box extent values
  124089. */
  124090. getDefaultQueryExtent(): Vector3;
  124091. /**
  124092. * Release all resources
  124093. */
  124094. dispose(): void;
  124095. }
  124096. /**
  124097. * Configures an agent
  124098. */
  124099. export interface IAgentParameters {
  124100. /**
  124101. * Agent radius. [Limit: >= 0]
  124102. */
  124103. radius: number;
  124104. /**
  124105. * Agent height. [Limit: > 0]
  124106. */
  124107. height: number;
  124108. /**
  124109. * Maximum allowed acceleration. [Limit: >= 0]
  124110. */
  124111. maxAcceleration: number;
  124112. /**
  124113. * Maximum allowed speed. [Limit: >= 0]
  124114. */
  124115. maxSpeed: number;
  124116. /**
  124117. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  124118. */
  124119. collisionQueryRange: number;
  124120. /**
  124121. * The path visibility optimization range. [Limit: > 0]
  124122. */
  124123. pathOptimizationRange: number;
  124124. /**
  124125. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  124126. */
  124127. separationWeight: number;
  124128. }
  124129. /**
  124130. * Configures the navigation mesh creation
  124131. */
  124132. export interface INavMeshParameters {
  124133. /**
  124134. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  124135. */
  124136. cs: number;
  124137. /**
  124138. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  124139. */
  124140. ch: number;
  124141. /**
  124142. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  124143. */
  124144. walkableSlopeAngle: number;
  124145. /**
  124146. * Minimum floor to 'ceiling' height that will still allow the floor area to
  124147. * be considered walkable. [Limit: >= 3] [Units: vx]
  124148. */
  124149. walkableHeight: number;
  124150. /**
  124151. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  124152. */
  124153. walkableClimb: number;
  124154. /**
  124155. * The distance to erode/shrink the walkable area of the heightfield away from
  124156. * obstructions. [Limit: >=0] [Units: vx]
  124157. */
  124158. walkableRadius: number;
  124159. /**
  124160. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  124161. */
  124162. maxEdgeLen: number;
  124163. /**
  124164. * The maximum distance a simplfied contour's border edges should deviate
  124165. * the original raw contour. [Limit: >=0] [Units: vx]
  124166. */
  124167. maxSimplificationError: number;
  124168. /**
  124169. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  124170. */
  124171. minRegionArea: number;
  124172. /**
  124173. * Any regions with a span count smaller than this value will, if possible,
  124174. * be merged with larger regions. [Limit: >=0] [Units: vx]
  124175. */
  124176. mergeRegionArea: number;
  124177. /**
  124178. * The maximum number of vertices allowed for polygons generated during the
  124179. * contour to polygon conversion process. [Limit: >= 3]
  124180. */
  124181. maxVertsPerPoly: number;
  124182. /**
  124183. * Sets the sampling distance to use when generating the detail mesh.
  124184. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  124185. */
  124186. detailSampleDist: number;
  124187. /**
  124188. * The maximum distance the detail mesh surface should deviate from heightfield
  124189. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  124190. */
  124191. detailSampleMaxError: number;
  124192. }
  124193. }
  124194. declare module BABYLON {
  124195. /**
  124196. * RecastJS navigation plugin
  124197. */
  124198. export class RecastJSPlugin implements INavigationEnginePlugin {
  124199. /**
  124200. * Reference to the Recast library
  124201. */
  124202. bjsRECAST: any;
  124203. /**
  124204. * plugin name
  124205. */
  124206. name: string;
  124207. /**
  124208. * the first navmesh created. We might extend this to support multiple navmeshes
  124209. */
  124210. navMesh: any;
  124211. /**
  124212. * Initializes the recastJS plugin
  124213. * @param recastInjection can be used to inject your own recast reference
  124214. */
  124215. constructor(recastInjection?: any);
  124216. /**
  124217. * Creates a navigation mesh
  124218. * @param meshes array of all the geometry used to compute the navigatio mesh
  124219. * @param parameters bunch of parameters used to filter geometry
  124220. */
  124221. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  124222. /**
  124223. * Create a navigation mesh debug mesh
  124224. * @param scene is where the mesh will be added
  124225. * @returns debug display mesh
  124226. */
  124227. createDebugNavMesh(scene: Scene): Mesh;
  124228. /**
  124229. * Get a navigation mesh constrained position, closest to the parameter position
  124230. * @param position world position
  124231. * @returns the closest point to position constrained by the navigation mesh
  124232. */
  124233. getClosestPoint(position: Vector3): Vector3;
  124234. /**
  124235. * Get a navigation mesh constrained position, within a particular radius
  124236. * @param position world position
  124237. * @param maxRadius the maximum distance to the constrained world position
  124238. * @returns the closest point to position constrained by the navigation mesh
  124239. */
  124240. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  124241. /**
  124242. * Compute the final position from a segment made of destination-position
  124243. * @param position world position
  124244. * @param destination world position
  124245. * @returns the resulting point along the navmesh
  124246. */
  124247. moveAlong(position: Vector3, destination: Vector3): Vector3;
  124248. /**
  124249. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  124250. * @param start world position
  124251. * @param end world position
  124252. * @returns array containing world position composing the path
  124253. */
  124254. computePath(start: Vector3, end: Vector3): Vector3[];
  124255. /**
  124256. * Create a new Crowd so you can add agents
  124257. * @param maxAgents the maximum agent count in the crowd
  124258. * @param maxAgentRadius the maximum radius an agent can have
  124259. * @param scene to attach the crowd to
  124260. * @returns the crowd you can add agents to
  124261. */
  124262. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  124263. /**
  124264. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  124265. * The queries will try to find a solution within those bounds
  124266. * default is (1,1,1)
  124267. * @param extent x,y,z value that define the extent around the queries point of reference
  124268. */
  124269. setDefaultQueryExtent(extent: Vector3): void;
  124270. /**
  124271. * Get the Bounding box extent specified by setDefaultQueryExtent
  124272. * @returns the box extent values
  124273. */
  124274. getDefaultQueryExtent(): Vector3;
  124275. /**
  124276. * Disposes
  124277. */
  124278. dispose(): void;
  124279. /**
  124280. * If this plugin is supported
  124281. * @returns true if plugin is supported
  124282. */
  124283. isSupported(): boolean;
  124284. }
  124285. /**
  124286. * Recast detour crowd implementation
  124287. */
  124288. export class RecastJSCrowd implements ICrowd {
  124289. /**
  124290. * Recast/detour plugin
  124291. */
  124292. bjsRECASTPlugin: RecastJSPlugin;
  124293. /**
  124294. * Link to the detour crowd
  124295. */
  124296. recastCrowd: any;
  124297. /**
  124298. * One transform per agent
  124299. */
  124300. transforms: TransformNode[];
  124301. /**
  124302. * All agents created
  124303. */
  124304. agents: number[];
  124305. /**
  124306. * Link to the scene is kept to unregister the crowd from the scene
  124307. */
  124308. private _scene;
  124309. /**
  124310. * Observer for crowd updates
  124311. */
  124312. private _onBeforeAnimationsObserver;
  124313. /**
  124314. * Constructor
  124315. * @param plugin recastJS plugin
  124316. * @param maxAgents the maximum agent count in the crowd
  124317. * @param maxAgentRadius the maximum radius an agent can have
  124318. * @param scene to attach the crowd to
  124319. * @returns the crowd you can add agents to
  124320. */
  124321. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  124322. /**
  124323. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  124324. * You can attach anything to that node. The node position is updated in the scene update tick.
  124325. * @param pos world position that will be constrained by the navigation mesh
  124326. * @param parameters agent parameters
  124327. * @param transform hooked to the agent that will be update by the scene
  124328. * @returns agent index
  124329. */
  124330. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  124331. /**
  124332. * Returns the agent position in world space
  124333. * @param index agent index returned by addAgent
  124334. * @returns world space position
  124335. */
  124336. getAgentPosition(index: number): Vector3;
  124337. /**
  124338. * Returns the agent velocity in world space
  124339. * @param index agent index returned by addAgent
  124340. * @returns world space velocity
  124341. */
  124342. getAgentVelocity(index: number): Vector3;
  124343. /**
  124344. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  124345. * @param index agent index returned by addAgent
  124346. * @param destination targeted world position
  124347. */
  124348. agentGoto(index: number, destination: Vector3): void;
  124349. /**
  124350. * remove a particular agent previously created
  124351. * @param index agent index returned by addAgent
  124352. */
  124353. removeAgent(index: number): void;
  124354. /**
  124355. * get the list of all agents attached to this crowd
  124356. * @returns list of agent indices
  124357. */
  124358. getAgents(): number[];
  124359. /**
  124360. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  124361. * @param deltaTime in seconds
  124362. */
  124363. update(deltaTime: number): void;
  124364. /**
  124365. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  124366. * The queries will try to find a solution within those bounds
  124367. * default is (1,1,1)
  124368. * @param extent x,y,z value that define the extent around the queries point of reference
  124369. */
  124370. setDefaultQueryExtent(extent: Vector3): void;
  124371. /**
  124372. * Get the Bounding box extent specified by setDefaultQueryExtent
  124373. * @returns the box extent values
  124374. */
  124375. getDefaultQueryExtent(): Vector3;
  124376. /**
  124377. * Release all resources
  124378. */
  124379. dispose(): void;
  124380. }
  124381. }
  124382. declare module BABYLON {
  124383. /**
  124384. * Class used to enable access to IndexedDB
  124385. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  124386. */
  124387. export class Database implements IOfflineProvider {
  124388. private _callbackManifestChecked;
  124389. private _currentSceneUrl;
  124390. private _db;
  124391. private _enableSceneOffline;
  124392. private _enableTexturesOffline;
  124393. private _manifestVersionFound;
  124394. private _mustUpdateRessources;
  124395. private _hasReachedQuota;
  124396. private _isSupported;
  124397. private _idbFactory;
  124398. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  124399. private static IsUASupportingBlobStorage;
  124400. /**
  124401. * Gets a boolean indicating if Database storate is enabled (off by default)
  124402. */
  124403. static IDBStorageEnabled: boolean;
  124404. /**
  124405. * Gets a boolean indicating if scene must be saved in the database
  124406. */
  124407. readonly enableSceneOffline: boolean;
  124408. /**
  124409. * Gets a boolean indicating if textures must be saved in the database
  124410. */
  124411. readonly enableTexturesOffline: boolean;
  124412. /**
  124413. * Creates a new Database
  124414. * @param urlToScene defines the url to load the scene
  124415. * @param callbackManifestChecked defines the callback to use when manifest is checked
  124416. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  124417. */
  124418. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  124419. private static _ParseURL;
  124420. private static _ReturnFullUrlLocation;
  124421. private _checkManifestFile;
  124422. /**
  124423. * Open the database and make it available
  124424. * @param successCallback defines the callback to call on success
  124425. * @param errorCallback defines the callback to call on error
  124426. */
  124427. open(successCallback: () => void, errorCallback: () => void): void;
  124428. /**
  124429. * Loads an image from the database
  124430. * @param url defines the url to load from
  124431. * @param image defines the target DOM image
  124432. */
  124433. loadImage(url: string, image: HTMLImageElement): void;
  124434. private _loadImageFromDBAsync;
  124435. private _saveImageIntoDBAsync;
  124436. private _checkVersionFromDB;
  124437. private _loadVersionFromDBAsync;
  124438. private _saveVersionIntoDBAsync;
  124439. /**
  124440. * Loads a file from database
  124441. * @param url defines the URL to load from
  124442. * @param sceneLoaded defines a callback to call on success
  124443. * @param progressCallBack defines a callback to call when progress changed
  124444. * @param errorCallback defines a callback to call on error
  124445. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  124446. */
  124447. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  124448. private _loadFileAsync;
  124449. private _saveFileAsync;
  124450. /**
  124451. * Validates if xhr data is correct
  124452. * @param xhr defines the request to validate
  124453. * @param dataType defines the expected data type
  124454. * @returns true if data is correct
  124455. */
  124456. private static _ValidateXHRData;
  124457. }
  124458. }
  124459. declare module BABYLON {
  124460. /** @hidden */
  124461. export var gpuUpdateParticlesPixelShader: {
  124462. name: string;
  124463. shader: string;
  124464. };
  124465. }
  124466. declare module BABYLON {
  124467. /** @hidden */
  124468. export var gpuUpdateParticlesVertexShader: {
  124469. name: string;
  124470. shader: string;
  124471. };
  124472. }
  124473. declare module BABYLON {
  124474. /** @hidden */
  124475. export var clipPlaneFragmentDeclaration2: {
  124476. name: string;
  124477. shader: string;
  124478. };
  124479. }
  124480. declare module BABYLON {
  124481. /** @hidden */
  124482. export var gpuRenderParticlesPixelShader: {
  124483. name: string;
  124484. shader: string;
  124485. };
  124486. }
  124487. declare module BABYLON {
  124488. /** @hidden */
  124489. export var clipPlaneVertexDeclaration2: {
  124490. name: string;
  124491. shader: string;
  124492. };
  124493. }
  124494. declare module BABYLON {
  124495. /** @hidden */
  124496. export var gpuRenderParticlesVertexShader: {
  124497. name: string;
  124498. shader: string;
  124499. };
  124500. }
  124501. declare module BABYLON {
  124502. /**
  124503. * This represents a GPU particle system in Babylon
  124504. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  124505. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  124506. */
  124507. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  124508. /**
  124509. * The layer mask we are rendering the particles through.
  124510. */
  124511. layerMask: number;
  124512. private _capacity;
  124513. private _activeCount;
  124514. private _currentActiveCount;
  124515. private _accumulatedCount;
  124516. private _renderEffect;
  124517. private _updateEffect;
  124518. private _buffer0;
  124519. private _buffer1;
  124520. private _spriteBuffer;
  124521. private _updateVAO;
  124522. private _renderVAO;
  124523. private _targetIndex;
  124524. private _sourceBuffer;
  124525. private _targetBuffer;
  124526. private _engine;
  124527. private _currentRenderId;
  124528. private _started;
  124529. private _stopped;
  124530. private _timeDelta;
  124531. private _randomTexture;
  124532. private _randomTexture2;
  124533. private _attributesStrideSize;
  124534. private _updateEffectOptions;
  124535. private _randomTextureSize;
  124536. private _actualFrame;
  124537. private readonly _rawTextureWidth;
  124538. /**
  124539. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  124540. */
  124541. static readonly IsSupported: boolean;
  124542. /**
  124543. * An event triggered when the system is disposed.
  124544. */
  124545. onDisposeObservable: Observable<GPUParticleSystem>;
  124546. /**
  124547. * Gets the maximum number of particles active at the same time.
  124548. * @returns The max number of active particles.
  124549. */
  124550. getCapacity(): number;
  124551. /**
  124552. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  124553. * to override the particles.
  124554. */
  124555. forceDepthWrite: boolean;
  124556. /**
  124557. * Gets or set the number of active particles
  124558. */
  124559. activeParticleCount: number;
  124560. private _preWarmDone;
  124561. /**
  124562. * Is this system ready to be used/rendered
  124563. * @return true if the system is ready
  124564. */
  124565. isReady(): boolean;
  124566. /**
  124567. * Gets if the system has been started. (Note: this will still be true after stop is called)
  124568. * @returns True if it has been started, otherwise false.
  124569. */
  124570. isStarted(): boolean;
  124571. /**
  124572. * Starts the particle system and begins to emit
  124573. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  124574. */
  124575. start(delay?: number): void;
  124576. /**
  124577. * Stops the particle system.
  124578. */
  124579. stop(): void;
  124580. /**
  124581. * Remove all active particles
  124582. */
  124583. reset(): void;
  124584. /**
  124585. * Returns the string "GPUParticleSystem"
  124586. * @returns a string containing the class name
  124587. */
  124588. getClassName(): string;
  124589. private _colorGradientsTexture;
  124590. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  124591. /**
  124592. * Adds a new color gradient
  124593. * @param gradient defines the gradient to use (between 0 and 1)
  124594. * @param color1 defines the color to affect to the specified gradient
  124595. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  124596. * @returns the current particle system
  124597. */
  124598. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  124599. /**
  124600. * Remove a specific color gradient
  124601. * @param gradient defines the gradient to remove
  124602. * @returns the current particle system
  124603. */
  124604. removeColorGradient(gradient: number): GPUParticleSystem;
  124605. private _angularSpeedGradientsTexture;
  124606. private _sizeGradientsTexture;
  124607. private _velocityGradientsTexture;
  124608. private _limitVelocityGradientsTexture;
  124609. private _dragGradientsTexture;
  124610. private _addFactorGradient;
  124611. /**
  124612. * Adds a new size gradient
  124613. * @param gradient defines the gradient to use (between 0 and 1)
  124614. * @param factor defines the size factor to affect to the specified gradient
  124615. * @returns the current particle system
  124616. */
  124617. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  124618. /**
  124619. * Remove a specific size gradient
  124620. * @param gradient defines the gradient to remove
  124621. * @returns the current particle system
  124622. */
  124623. removeSizeGradient(gradient: number): GPUParticleSystem;
  124624. /**
  124625. * Adds a new angular speed gradient
  124626. * @param gradient defines the gradient to use (between 0 and 1)
  124627. * @param factor defines the angular speed to affect to the specified gradient
  124628. * @returns the current particle system
  124629. */
  124630. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  124631. /**
  124632. * Remove a specific angular speed gradient
  124633. * @param gradient defines the gradient to remove
  124634. * @returns the current particle system
  124635. */
  124636. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  124637. /**
  124638. * Adds a new velocity gradient
  124639. * @param gradient defines the gradient to use (between 0 and 1)
  124640. * @param factor defines the velocity to affect to the specified gradient
  124641. * @returns the current particle system
  124642. */
  124643. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  124644. /**
  124645. * Remove a specific velocity gradient
  124646. * @param gradient defines the gradient to remove
  124647. * @returns the current particle system
  124648. */
  124649. removeVelocityGradient(gradient: number): GPUParticleSystem;
  124650. /**
  124651. * Adds a new limit velocity gradient
  124652. * @param gradient defines the gradient to use (between 0 and 1)
  124653. * @param factor defines the limit velocity value to affect to the specified gradient
  124654. * @returns the current particle system
  124655. */
  124656. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  124657. /**
  124658. * Remove a specific limit velocity gradient
  124659. * @param gradient defines the gradient to remove
  124660. * @returns the current particle system
  124661. */
  124662. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  124663. /**
  124664. * Adds a new drag gradient
  124665. * @param gradient defines the gradient to use (between 0 and 1)
  124666. * @param factor defines the drag value to affect to the specified gradient
  124667. * @returns the current particle system
  124668. */
  124669. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  124670. /**
  124671. * Remove a specific drag gradient
  124672. * @param gradient defines the gradient to remove
  124673. * @returns the current particle system
  124674. */
  124675. removeDragGradient(gradient: number): GPUParticleSystem;
  124676. /**
  124677. * Not supported by GPUParticleSystem
  124678. * @param gradient defines the gradient to use (between 0 and 1)
  124679. * @param factor defines the emit rate value to affect to the specified gradient
  124680. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  124681. * @returns the current particle system
  124682. */
  124683. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  124684. /**
  124685. * Not supported by GPUParticleSystem
  124686. * @param gradient defines the gradient to remove
  124687. * @returns the current particle system
  124688. */
  124689. removeEmitRateGradient(gradient: number): IParticleSystem;
  124690. /**
  124691. * Not supported by GPUParticleSystem
  124692. * @param gradient defines the gradient to use (between 0 and 1)
  124693. * @param factor defines the start size value to affect to the specified gradient
  124694. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  124695. * @returns the current particle system
  124696. */
  124697. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  124698. /**
  124699. * Not supported by GPUParticleSystem
  124700. * @param gradient defines the gradient to remove
  124701. * @returns the current particle system
  124702. */
  124703. removeStartSizeGradient(gradient: number): IParticleSystem;
  124704. /**
  124705. * Not supported by GPUParticleSystem
  124706. * @param gradient defines the gradient to use (between 0 and 1)
  124707. * @param min defines the color remap minimal range
  124708. * @param max defines the color remap maximal range
  124709. * @returns the current particle system
  124710. */
  124711. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  124712. /**
  124713. * Not supported by GPUParticleSystem
  124714. * @param gradient defines the gradient to remove
  124715. * @returns the current particle system
  124716. */
  124717. removeColorRemapGradient(): IParticleSystem;
  124718. /**
  124719. * Not supported by GPUParticleSystem
  124720. * @param gradient defines the gradient to use (between 0 and 1)
  124721. * @param min defines the alpha remap minimal range
  124722. * @param max defines the alpha remap maximal range
  124723. * @returns the current particle system
  124724. */
  124725. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  124726. /**
  124727. * Not supported by GPUParticleSystem
  124728. * @param gradient defines the gradient to remove
  124729. * @returns the current particle system
  124730. */
  124731. removeAlphaRemapGradient(): IParticleSystem;
  124732. /**
  124733. * Not supported by GPUParticleSystem
  124734. * @param gradient defines the gradient to use (between 0 and 1)
  124735. * @param color defines the color to affect to the specified gradient
  124736. * @returns the current particle system
  124737. */
  124738. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  124739. /**
  124740. * Not supported by GPUParticleSystem
  124741. * @param gradient defines the gradient to remove
  124742. * @returns the current particle system
  124743. */
  124744. removeRampGradient(): IParticleSystem;
  124745. /**
  124746. * Not supported by GPUParticleSystem
  124747. * @returns the list of ramp gradients
  124748. */
  124749. getRampGradients(): Nullable<Array<Color3Gradient>>;
  124750. /**
  124751. * Not supported by GPUParticleSystem
  124752. * Gets or sets a boolean indicating that ramp gradients must be used
  124753. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  124754. */
  124755. useRampGradients: boolean;
  124756. /**
  124757. * Not supported by GPUParticleSystem
  124758. * @param gradient defines the gradient to use (between 0 and 1)
  124759. * @param factor defines the life time factor to affect to the specified gradient
  124760. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  124761. * @returns the current particle system
  124762. */
  124763. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  124764. /**
  124765. * Not supported by GPUParticleSystem
  124766. * @param gradient defines the gradient to remove
  124767. * @returns the current particle system
  124768. */
  124769. removeLifeTimeGradient(gradient: number): IParticleSystem;
  124770. /**
  124771. * Instantiates a GPU particle system.
  124772. * 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.
  124773. * @param name The name of the particle system
  124774. * @param options The options used to create the system
  124775. * @param scene The scene the particle system belongs to
  124776. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  124777. */
  124778. constructor(name: string, options: Partial<{
  124779. capacity: number;
  124780. randomTextureSize: number;
  124781. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  124782. protected _reset(): void;
  124783. private _createUpdateVAO;
  124784. private _createRenderVAO;
  124785. private _initialize;
  124786. /** @hidden */
  124787. _recreateUpdateEffect(): void;
  124788. /** @hidden */
  124789. _recreateRenderEffect(): void;
  124790. /**
  124791. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  124792. * @param preWarm defines if we are in the pre-warmimg phase
  124793. */
  124794. animate(preWarm?: boolean): void;
  124795. private _createFactorGradientTexture;
  124796. private _createSizeGradientTexture;
  124797. private _createAngularSpeedGradientTexture;
  124798. private _createVelocityGradientTexture;
  124799. private _createLimitVelocityGradientTexture;
  124800. private _createDragGradientTexture;
  124801. private _createColorGradientTexture;
  124802. /**
  124803. * Renders the particle system in its current state
  124804. * @param preWarm defines if the system should only update the particles but not render them
  124805. * @returns the current number of particles
  124806. */
  124807. render(preWarm?: boolean): number;
  124808. /**
  124809. * Rebuilds the particle system
  124810. */
  124811. rebuild(): void;
  124812. private _releaseBuffers;
  124813. private _releaseVAOs;
  124814. /**
  124815. * Disposes the particle system and free the associated resources
  124816. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  124817. */
  124818. dispose(disposeTexture?: boolean): void;
  124819. /**
  124820. * Clones the particle system.
  124821. * @param name The name of the cloned object
  124822. * @param newEmitter The new emitter to use
  124823. * @returns the cloned particle system
  124824. */
  124825. clone(name: string, newEmitter: any): GPUParticleSystem;
  124826. /**
  124827. * Serializes the particle system to a JSON object.
  124828. * @returns the JSON object
  124829. */
  124830. serialize(): any;
  124831. /**
  124832. * Parses a JSON object to create a GPU particle system.
  124833. * @param parsedParticleSystem The JSON object to parse
  124834. * @param scene The scene to create the particle system in
  124835. * @param rootUrl The root url to use to load external dependencies like texture
  124836. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  124837. * @returns the parsed GPU particle system
  124838. */
  124839. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  124840. }
  124841. }
  124842. declare module BABYLON {
  124843. /**
  124844. * Represents a set of particle systems working together to create a specific effect
  124845. */
  124846. export class ParticleSystemSet implements IDisposable {
  124847. private _emitterCreationOptions;
  124848. private _emitterNode;
  124849. /**
  124850. * Gets the particle system list
  124851. */
  124852. systems: IParticleSystem[];
  124853. /**
  124854. * Gets the emitter node used with this set
  124855. */
  124856. readonly emitterNode: Nullable<TransformNode>;
  124857. /**
  124858. * Creates a new emitter mesh as a sphere
  124859. * @param options defines the options used to create the sphere
  124860. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  124861. * @param scene defines the hosting scene
  124862. */
  124863. setEmitterAsSphere(options: {
  124864. diameter: number;
  124865. segments: number;
  124866. color: Color3;
  124867. }, renderingGroupId: number, scene: Scene): void;
  124868. /**
  124869. * Starts all particle systems of the set
  124870. * @param emitter defines an optional mesh to use as emitter for the particle systems
  124871. */
  124872. start(emitter?: AbstractMesh): void;
  124873. /**
  124874. * Release all associated resources
  124875. */
  124876. dispose(): void;
  124877. /**
  124878. * Serialize the set into a JSON compatible object
  124879. * @returns a JSON compatible representation of the set
  124880. */
  124881. serialize(): any;
  124882. /**
  124883. * Parse a new ParticleSystemSet from a serialized source
  124884. * @param data defines a JSON compatible representation of the set
  124885. * @param scene defines the hosting scene
  124886. * @param gpu defines if we want GPU particles or CPU particles
  124887. * @returns a new ParticleSystemSet
  124888. */
  124889. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  124890. }
  124891. }
  124892. declare module BABYLON {
  124893. /**
  124894. * This class is made for on one-liner static method to help creating particle system set.
  124895. */
  124896. export class ParticleHelper {
  124897. /**
  124898. * Gets or sets base Assets URL
  124899. */
  124900. static BaseAssetsUrl: string;
  124901. /**
  124902. * Create a default particle system that you can tweak
  124903. * @param emitter defines the emitter to use
  124904. * @param capacity defines the system capacity (default is 500 particles)
  124905. * @param scene defines the hosting scene
  124906. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  124907. * @returns the new Particle system
  124908. */
  124909. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  124910. /**
  124911. * This is the main static method (one-liner) of this helper to create different particle systems
  124912. * @param type This string represents the type to the particle system to create
  124913. * @param scene The scene where the particle system should live
  124914. * @param gpu If the system will use gpu
  124915. * @returns the ParticleSystemSet created
  124916. */
  124917. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  124918. /**
  124919. * Static function used to export a particle system to a ParticleSystemSet variable.
  124920. * Please note that the emitter shape is not exported
  124921. * @param systems defines the particle systems to export
  124922. * @returns the created particle system set
  124923. */
  124924. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  124925. }
  124926. }
  124927. declare module BABYLON {
  124928. interface Engine {
  124929. /**
  124930. * Create an effect to use with particle systems.
  124931. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  124932. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  124933. * @param uniformsNames defines a list of attribute names
  124934. * @param samplers defines an array of string used to represent textures
  124935. * @param defines defines the string containing the defines to use to compile the shaders
  124936. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  124937. * @param onCompiled defines a function to call when the effect creation is successful
  124938. * @param onError defines a function to call when the effect creation has failed
  124939. * @returns the new Effect
  124940. */
  124941. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  124942. }
  124943. interface Mesh {
  124944. /**
  124945. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  124946. * @returns an array of IParticleSystem
  124947. */
  124948. getEmittedParticleSystems(): IParticleSystem[];
  124949. /**
  124950. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  124951. * @returns an array of IParticleSystem
  124952. */
  124953. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  124954. }
  124955. /**
  124956. * @hidden
  124957. */
  124958. export var _IDoNeedToBeInTheBuild: number;
  124959. }
  124960. declare module BABYLON {
  124961. interface Scene {
  124962. /** @hidden (Backing field) */
  124963. _physicsEngine: Nullable<IPhysicsEngine>;
  124964. /**
  124965. * Gets the current physics engine
  124966. * @returns a IPhysicsEngine or null if none attached
  124967. */
  124968. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  124969. /**
  124970. * Enables physics to the current scene
  124971. * @param gravity defines the scene's gravity for the physics engine
  124972. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  124973. * @return a boolean indicating if the physics engine was initialized
  124974. */
  124975. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  124976. /**
  124977. * Disables and disposes the physics engine associated with the scene
  124978. */
  124979. disablePhysicsEngine(): void;
  124980. /**
  124981. * Gets a boolean indicating if there is an active physics engine
  124982. * @returns a boolean indicating if there is an active physics engine
  124983. */
  124984. isPhysicsEnabled(): boolean;
  124985. /**
  124986. * Deletes a physics compound impostor
  124987. * @param compound defines the compound to delete
  124988. */
  124989. deleteCompoundImpostor(compound: any): void;
  124990. /**
  124991. * An event triggered when physic simulation is about to be run
  124992. */
  124993. onBeforePhysicsObservable: Observable<Scene>;
  124994. /**
  124995. * An event triggered when physic simulation has been done
  124996. */
  124997. onAfterPhysicsObservable: Observable<Scene>;
  124998. }
  124999. interface AbstractMesh {
  125000. /** @hidden */
  125001. _physicsImpostor: Nullable<PhysicsImpostor>;
  125002. /**
  125003. * Gets or sets impostor used for physic simulation
  125004. * @see http://doc.babylonjs.com/features/physics_engine
  125005. */
  125006. physicsImpostor: Nullable<PhysicsImpostor>;
  125007. /**
  125008. * Gets the current physics impostor
  125009. * @see http://doc.babylonjs.com/features/physics_engine
  125010. * @returns a physics impostor or null
  125011. */
  125012. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  125013. /** Apply a physic impulse to the mesh
  125014. * @param force defines the force to apply
  125015. * @param contactPoint defines where to apply the force
  125016. * @returns the current mesh
  125017. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  125018. */
  125019. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  125020. /**
  125021. * Creates a physic joint between two meshes
  125022. * @param otherMesh defines the other mesh to use
  125023. * @param pivot1 defines the pivot to use on this mesh
  125024. * @param pivot2 defines the pivot to use on the other mesh
  125025. * @param options defines additional options (can be plugin dependent)
  125026. * @returns the current mesh
  125027. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  125028. */
  125029. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  125030. /** @hidden */
  125031. _disposePhysicsObserver: Nullable<Observer<Node>>;
  125032. }
  125033. /**
  125034. * Defines the physics engine scene component responsible to manage a physics engine
  125035. */
  125036. export class PhysicsEngineSceneComponent implements ISceneComponent {
  125037. /**
  125038. * The component name helpful to identify the component in the list of scene components.
  125039. */
  125040. readonly name: string;
  125041. /**
  125042. * The scene the component belongs to.
  125043. */
  125044. scene: Scene;
  125045. /**
  125046. * Creates a new instance of the component for the given scene
  125047. * @param scene Defines the scene to register the component in
  125048. */
  125049. constructor(scene: Scene);
  125050. /**
  125051. * Registers the component in a given scene
  125052. */
  125053. register(): void;
  125054. /**
  125055. * Rebuilds the elements related to this component in case of
  125056. * context lost for instance.
  125057. */
  125058. rebuild(): void;
  125059. /**
  125060. * Disposes the component and the associated ressources
  125061. */
  125062. dispose(): void;
  125063. }
  125064. }
  125065. declare module BABYLON {
  125066. /**
  125067. * A helper for physics simulations
  125068. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125069. */
  125070. export class PhysicsHelper {
  125071. private _scene;
  125072. private _physicsEngine;
  125073. /**
  125074. * Initializes the Physics helper
  125075. * @param scene Babylon.js scene
  125076. */
  125077. constructor(scene: Scene);
  125078. /**
  125079. * Applies a radial explosion impulse
  125080. * @param origin the origin of the explosion
  125081. * @param radiusOrEventOptions the radius or the options of radial explosion
  125082. * @param strength the explosion strength
  125083. * @param falloff possible options: Constant & Linear. Defaults to Constant
  125084. * @returns A physics radial explosion event, or null
  125085. */
  125086. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  125087. /**
  125088. * Applies a radial explosion force
  125089. * @param origin the origin of the explosion
  125090. * @param radiusOrEventOptions the radius or the options of radial explosion
  125091. * @param strength the explosion strength
  125092. * @param falloff possible options: Constant & Linear. Defaults to Constant
  125093. * @returns A physics radial explosion event, or null
  125094. */
  125095. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  125096. /**
  125097. * Creates a gravitational field
  125098. * @param origin the origin of the explosion
  125099. * @param radiusOrEventOptions the radius or the options of radial explosion
  125100. * @param strength the explosion strength
  125101. * @param falloff possible options: Constant & Linear. Defaults to Constant
  125102. * @returns A physics gravitational field event, or null
  125103. */
  125104. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  125105. /**
  125106. * Creates a physics updraft event
  125107. * @param origin the origin of the updraft
  125108. * @param radiusOrEventOptions the radius or the options of the updraft
  125109. * @param strength the strength of the updraft
  125110. * @param height the height of the updraft
  125111. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  125112. * @returns A physics updraft event, or null
  125113. */
  125114. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  125115. /**
  125116. * Creates a physics vortex event
  125117. * @param origin the of the vortex
  125118. * @param radiusOrEventOptions the radius or the options of the vortex
  125119. * @param strength the strength of the vortex
  125120. * @param height the height of the vortex
  125121. * @returns a Physics vortex event, or null
  125122. * A physics vortex event or null
  125123. */
  125124. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  125125. }
  125126. /**
  125127. * Represents a physics radial explosion event
  125128. */
  125129. class PhysicsRadialExplosionEvent {
  125130. private _scene;
  125131. private _options;
  125132. private _sphere;
  125133. private _dataFetched;
  125134. /**
  125135. * Initializes a radial explosioin event
  125136. * @param _scene BabylonJS scene
  125137. * @param _options The options for the vortex event
  125138. */
  125139. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  125140. /**
  125141. * Returns the data related to the radial explosion event (sphere).
  125142. * @returns The radial explosion event data
  125143. */
  125144. getData(): PhysicsRadialExplosionEventData;
  125145. /**
  125146. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  125147. * @param impostor A physics imposter
  125148. * @param origin the origin of the explosion
  125149. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  125150. */
  125151. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  125152. /**
  125153. * Triggers affecterd impostors callbacks
  125154. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  125155. */
  125156. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  125157. /**
  125158. * Disposes the sphere.
  125159. * @param force Specifies if the sphere should be disposed by force
  125160. */
  125161. dispose(force?: boolean): void;
  125162. /*** Helpers ***/
  125163. private _prepareSphere;
  125164. private _intersectsWithSphere;
  125165. }
  125166. /**
  125167. * Represents a gravitational field event
  125168. */
  125169. class PhysicsGravitationalFieldEvent {
  125170. private _physicsHelper;
  125171. private _scene;
  125172. private _origin;
  125173. private _options;
  125174. private _tickCallback;
  125175. private _sphere;
  125176. private _dataFetched;
  125177. /**
  125178. * Initializes the physics gravitational field event
  125179. * @param _physicsHelper A physics helper
  125180. * @param _scene BabylonJS scene
  125181. * @param _origin The origin position of the gravitational field event
  125182. * @param _options The options for the vortex event
  125183. */
  125184. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  125185. /**
  125186. * Returns the data related to the gravitational field event (sphere).
  125187. * @returns A gravitational field event
  125188. */
  125189. getData(): PhysicsGravitationalFieldEventData;
  125190. /**
  125191. * Enables the gravitational field.
  125192. */
  125193. enable(): void;
  125194. /**
  125195. * Disables the gravitational field.
  125196. */
  125197. disable(): void;
  125198. /**
  125199. * Disposes the sphere.
  125200. * @param force The force to dispose from the gravitational field event
  125201. */
  125202. dispose(force?: boolean): void;
  125203. private _tick;
  125204. }
  125205. /**
  125206. * Represents a physics updraft event
  125207. */
  125208. class PhysicsUpdraftEvent {
  125209. private _scene;
  125210. private _origin;
  125211. private _options;
  125212. private _physicsEngine;
  125213. private _originTop;
  125214. private _originDirection;
  125215. private _tickCallback;
  125216. private _cylinder;
  125217. private _cylinderPosition;
  125218. private _dataFetched;
  125219. /**
  125220. * Initializes the physics updraft event
  125221. * @param _scene BabylonJS scene
  125222. * @param _origin The origin position of the updraft
  125223. * @param _options The options for the updraft event
  125224. */
  125225. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  125226. /**
  125227. * Returns the data related to the updraft event (cylinder).
  125228. * @returns A physics updraft event
  125229. */
  125230. getData(): PhysicsUpdraftEventData;
  125231. /**
  125232. * Enables the updraft.
  125233. */
  125234. enable(): void;
  125235. /**
  125236. * Disables the updraft.
  125237. */
  125238. disable(): void;
  125239. /**
  125240. * Disposes the cylinder.
  125241. * @param force Specifies if the updraft should be disposed by force
  125242. */
  125243. dispose(force?: boolean): void;
  125244. private getImpostorHitData;
  125245. private _tick;
  125246. /*** Helpers ***/
  125247. private _prepareCylinder;
  125248. private _intersectsWithCylinder;
  125249. }
  125250. /**
  125251. * Represents a physics vortex event
  125252. */
  125253. class PhysicsVortexEvent {
  125254. private _scene;
  125255. private _origin;
  125256. private _options;
  125257. private _physicsEngine;
  125258. private _originTop;
  125259. private _tickCallback;
  125260. private _cylinder;
  125261. private _cylinderPosition;
  125262. private _dataFetched;
  125263. /**
  125264. * Initializes the physics vortex event
  125265. * @param _scene The BabylonJS scene
  125266. * @param _origin The origin position of the vortex
  125267. * @param _options The options for the vortex event
  125268. */
  125269. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  125270. /**
  125271. * Returns the data related to the vortex event (cylinder).
  125272. * @returns The physics vortex event data
  125273. */
  125274. getData(): PhysicsVortexEventData;
  125275. /**
  125276. * Enables the vortex.
  125277. */
  125278. enable(): void;
  125279. /**
  125280. * Disables the cortex.
  125281. */
  125282. disable(): void;
  125283. /**
  125284. * Disposes the sphere.
  125285. * @param force
  125286. */
  125287. dispose(force?: boolean): void;
  125288. private getImpostorHitData;
  125289. private _tick;
  125290. /*** Helpers ***/
  125291. private _prepareCylinder;
  125292. private _intersectsWithCylinder;
  125293. }
  125294. /**
  125295. * Options fot the radial explosion event
  125296. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125297. */
  125298. export class PhysicsRadialExplosionEventOptions {
  125299. /**
  125300. * The radius of the sphere for the radial explosion.
  125301. */
  125302. radius: number;
  125303. /**
  125304. * The strenth of the explosion.
  125305. */
  125306. strength: number;
  125307. /**
  125308. * The strenght of the force in correspondence to the distance of the affected object
  125309. */
  125310. falloff: PhysicsRadialImpulseFalloff;
  125311. /**
  125312. * Sphere options for the radial explosion.
  125313. */
  125314. sphere: {
  125315. segments: number;
  125316. diameter: number;
  125317. };
  125318. /**
  125319. * Sphere options for the radial explosion.
  125320. */
  125321. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  125322. }
  125323. /**
  125324. * Options fot the updraft event
  125325. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125326. */
  125327. export class PhysicsUpdraftEventOptions {
  125328. /**
  125329. * The radius of the cylinder for the vortex
  125330. */
  125331. radius: number;
  125332. /**
  125333. * The strenth of the updraft.
  125334. */
  125335. strength: number;
  125336. /**
  125337. * The height of the cylinder for the updraft.
  125338. */
  125339. height: number;
  125340. /**
  125341. * The mode for the the updraft.
  125342. */
  125343. updraftMode: PhysicsUpdraftMode;
  125344. }
  125345. /**
  125346. * Options fot the vortex event
  125347. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125348. */
  125349. export class PhysicsVortexEventOptions {
  125350. /**
  125351. * The radius of the cylinder for the vortex
  125352. */
  125353. radius: number;
  125354. /**
  125355. * The strenth of the vortex.
  125356. */
  125357. strength: number;
  125358. /**
  125359. * The height of the cylinder for the vortex.
  125360. */
  125361. height: number;
  125362. /**
  125363. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  125364. */
  125365. centripetalForceThreshold: number;
  125366. /**
  125367. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  125368. */
  125369. centripetalForceMultiplier: number;
  125370. /**
  125371. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  125372. */
  125373. centrifugalForceMultiplier: number;
  125374. /**
  125375. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  125376. */
  125377. updraftForceMultiplier: number;
  125378. }
  125379. /**
  125380. * The strenght of the force in correspondence to the distance of the affected object
  125381. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125382. */
  125383. export enum PhysicsRadialImpulseFalloff {
  125384. /** Defines that impulse is constant in strength across it's whole radius */
  125385. Constant = 0,
  125386. /** Defines that impulse gets weaker if it's further from the origin */
  125387. Linear = 1
  125388. }
  125389. /**
  125390. * The strength of the force in correspondence to the distance of the affected object
  125391. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125392. */
  125393. export enum PhysicsUpdraftMode {
  125394. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  125395. Center = 0,
  125396. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  125397. Perpendicular = 1
  125398. }
  125399. /**
  125400. * Interface for a physics hit data
  125401. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125402. */
  125403. export interface PhysicsHitData {
  125404. /**
  125405. * The force applied at the contact point
  125406. */
  125407. force: Vector3;
  125408. /**
  125409. * The contact point
  125410. */
  125411. contactPoint: Vector3;
  125412. /**
  125413. * The distance from the origin to the contact point
  125414. */
  125415. distanceFromOrigin: number;
  125416. }
  125417. /**
  125418. * Interface for radial explosion event data
  125419. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125420. */
  125421. export interface PhysicsRadialExplosionEventData {
  125422. /**
  125423. * A sphere used for the radial explosion event
  125424. */
  125425. sphere: Mesh;
  125426. }
  125427. /**
  125428. * Interface for gravitational field event data
  125429. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125430. */
  125431. export interface PhysicsGravitationalFieldEventData {
  125432. /**
  125433. * A sphere mesh used for the gravitational field event
  125434. */
  125435. sphere: Mesh;
  125436. }
  125437. /**
  125438. * Interface for updraft event data
  125439. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125440. */
  125441. export interface PhysicsUpdraftEventData {
  125442. /**
  125443. * A cylinder used for the updraft event
  125444. */
  125445. cylinder: Mesh;
  125446. }
  125447. /**
  125448. * Interface for vortex event data
  125449. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125450. */
  125451. export interface PhysicsVortexEventData {
  125452. /**
  125453. * A cylinder used for the vortex event
  125454. */
  125455. cylinder: Mesh;
  125456. }
  125457. /**
  125458. * Interface for an affected physics impostor
  125459. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125460. */
  125461. export interface PhysicsAffectedImpostorWithData {
  125462. /**
  125463. * The impostor affected by the effect
  125464. */
  125465. impostor: PhysicsImpostor;
  125466. /**
  125467. * The data about the hit/horce from the explosion
  125468. */
  125469. hitData: PhysicsHitData;
  125470. }
  125471. }
  125472. declare module BABYLON {
  125473. /** @hidden */
  125474. export var blackAndWhitePixelShader: {
  125475. name: string;
  125476. shader: string;
  125477. };
  125478. }
  125479. declare module BABYLON {
  125480. /**
  125481. * Post process used to render in black and white
  125482. */
  125483. export class BlackAndWhitePostProcess extends PostProcess {
  125484. /**
  125485. * Linear about to convert he result to black and white (default: 1)
  125486. */
  125487. degree: number;
  125488. /**
  125489. * Creates a black and white post process
  125490. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  125491. * @param name The name of the effect.
  125492. * @param options The required width/height ratio to downsize to before computing the render pass.
  125493. * @param camera The camera to apply the render pass to.
  125494. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125495. * @param engine The engine which the post process will be applied. (default: current engine)
  125496. * @param reusable If the post process can be reused on the same frame. (default: false)
  125497. */
  125498. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  125499. }
  125500. }
  125501. declare module BABYLON {
  125502. /**
  125503. * This represents a set of one or more post processes in Babylon.
  125504. * A post process can be used to apply a shader to a texture after it is rendered.
  125505. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  125506. */
  125507. export class PostProcessRenderEffect {
  125508. private _postProcesses;
  125509. private _getPostProcesses;
  125510. private _singleInstance;
  125511. private _cameras;
  125512. private _indicesForCamera;
  125513. /**
  125514. * Name of the effect
  125515. * @hidden
  125516. */
  125517. _name: string;
  125518. /**
  125519. * Instantiates a post process render effect.
  125520. * A post process can be used to apply a shader to a texture after it is rendered.
  125521. * @param engine The engine the effect is tied to
  125522. * @param name The name of the effect
  125523. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  125524. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  125525. */
  125526. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  125527. /**
  125528. * Checks if all the post processes in the effect are supported.
  125529. */
  125530. readonly isSupported: boolean;
  125531. /**
  125532. * Updates the current state of the effect
  125533. * @hidden
  125534. */
  125535. _update(): void;
  125536. /**
  125537. * Attaches the effect on cameras
  125538. * @param cameras The camera to attach to.
  125539. * @hidden
  125540. */
  125541. _attachCameras(cameras: Camera): void;
  125542. /**
  125543. * Attaches the effect on cameras
  125544. * @param cameras The camera to attach to.
  125545. * @hidden
  125546. */
  125547. _attachCameras(cameras: Camera[]): void;
  125548. /**
  125549. * Detaches the effect on cameras
  125550. * @param cameras The camera to detatch from.
  125551. * @hidden
  125552. */
  125553. _detachCameras(cameras: Camera): void;
  125554. /**
  125555. * Detatches the effect on cameras
  125556. * @param cameras The camera to detatch from.
  125557. * @hidden
  125558. */
  125559. _detachCameras(cameras: Camera[]): void;
  125560. /**
  125561. * Enables the effect on given cameras
  125562. * @param cameras The camera to enable.
  125563. * @hidden
  125564. */
  125565. _enable(cameras: Camera): void;
  125566. /**
  125567. * Enables the effect on given cameras
  125568. * @param cameras The camera to enable.
  125569. * @hidden
  125570. */
  125571. _enable(cameras: Nullable<Camera[]>): void;
  125572. /**
  125573. * Disables the effect on the given cameras
  125574. * @param cameras The camera to disable.
  125575. * @hidden
  125576. */
  125577. _disable(cameras: Camera): void;
  125578. /**
  125579. * Disables the effect on the given cameras
  125580. * @param cameras The camera to disable.
  125581. * @hidden
  125582. */
  125583. _disable(cameras: Nullable<Camera[]>): void;
  125584. /**
  125585. * Gets a list of the post processes contained in the effect.
  125586. * @param camera The camera to get the post processes on.
  125587. * @returns The list of the post processes in the effect.
  125588. */
  125589. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  125590. }
  125591. }
  125592. declare module BABYLON {
  125593. /** @hidden */
  125594. export var extractHighlightsPixelShader: {
  125595. name: string;
  125596. shader: string;
  125597. };
  125598. }
  125599. declare module BABYLON {
  125600. /**
  125601. * 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.
  125602. */
  125603. export class ExtractHighlightsPostProcess extends PostProcess {
  125604. /**
  125605. * The luminance threshold, pixels below this value will be set to black.
  125606. */
  125607. threshold: number;
  125608. /** @hidden */
  125609. _exposure: number;
  125610. /**
  125611. * Post process which has the input texture to be used when performing highlight extraction
  125612. * @hidden
  125613. */
  125614. _inputPostProcess: Nullable<PostProcess>;
  125615. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  125616. }
  125617. }
  125618. declare module BABYLON {
  125619. /** @hidden */
  125620. export var bloomMergePixelShader: {
  125621. name: string;
  125622. shader: string;
  125623. };
  125624. }
  125625. declare module BABYLON {
  125626. /**
  125627. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  125628. */
  125629. export class BloomMergePostProcess extends PostProcess {
  125630. /** Weight of the bloom to be added to the original input. */
  125631. weight: number;
  125632. /**
  125633. * Creates a new instance of @see BloomMergePostProcess
  125634. * @param name The name of the effect.
  125635. * @param originalFromInput Post process which's input will be used for the merge.
  125636. * @param blurred Blurred highlights post process which's output will be used.
  125637. * @param weight Weight of the bloom to be added to the original input.
  125638. * @param options The required width/height ratio to downsize to before computing the render pass.
  125639. * @param camera The camera to apply the render pass to.
  125640. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125641. * @param engine The engine which the post process will be applied. (default: current engine)
  125642. * @param reusable If the post process can be reused on the same frame. (default: false)
  125643. * @param textureType Type of textures used when performing the post process. (default: 0)
  125644. * @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)
  125645. */
  125646. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  125647. /** Weight of the bloom to be added to the original input. */
  125648. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  125649. }
  125650. }
  125651. declare module BABYLON {
  125652. /**
  125653. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  125654. */
  125655. export class BloomEffect extends PostProcessRenderEffect {
  125656. private bloomScale;
  125657. /**
  125658. * @hidden Internal
  125659. */
  125660. _effects: Array<PostProcess>;
  125661. /**
  125662. * @hidden Internal
  125663. */
  125664. _downscale: ExtractHighlightsPostProcess;
  125665. private _blurX;
  125666. private _blurY;
  125667. private _merge;
  125668. /**
  125669. * The luminance threshold to find bright areas of the image to bloom.
  125670. */
  125671. threshold: number;
  125672. /**
  125673. * The strength of the bloom.
  125674. */
  125675. weight: number;
  125676. /**
  125677. * Specifies the size of the bloom blur kernel, relative to the final output size
  125678. */
  125679. kernel: number;
  125680. /**
  125681. * Creates a new instance of @see BloomEffect
  125682. * @param scene The scene the effect belongs to.
  125683. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  125684. * @param bloomKernel The size of the kernel to be used when applying the blur.
  125685. * @param bloomWeight The the strength of bloom.
  125686. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  125687. * @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)
  125688. */
  125689. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  125690. /**
  125691. * Disposes each of the internal effects for a given camera.
  125692. * @param camera The camera to dispose the effect on.
  125693. */
  125694. disposeEffects(camera: Camera): void;
  125695. /**
  125696. * @hidden Internal
  125697. */
  125698. _updateEffects(): void;
  125699. /**
  125700. * Internal
  125701. * @returns if all the contained post processes are ready.
  125702. * @hidden
  125703. */
  125704. _isReady(): boolean;
  125705. }
  125706. }
  125707. declare module BABYLON {
  125708. /** @hidden */
  125709. export var chromaticAberrationPixelShader: {
  125710. name: string;
  125711. shader: string;
  125712. };
  125713. }
  125714. declare module BABYLON {
  125715. /**
  125716. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  125717. */
  125718. export class ChromaticAberrationPostProcess extends PostProcess {
  125719. /**
  125720. * The amount of seperation of rgb channels (default: 30)
  125721. */
  125722. aberrationAmount: number;
  125723. /**
  125724. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  125725. */
  125726. radialIntensity: number;
  125727. /**
  125728. * 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))
  125729. */
  125730. direction: Vector2;
  125731. /**
  125732. * 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))
  125733. */
  125734. centerPosition: Vector2;
  125735. /**
  125736. * Creates a new instance ChromaticAberrationPostProcess
  125737. * @param name The name of the effect.
  125738. * @param screenWidth The width of the screen to apply the effect on.
  125739. * @param screenHeight The height of the screen to apply the effect on.
  125740. * @param options The required width/height ratio to downsize to before computing the render pass.
  125741. * @param camera The camera to apply the render pass to.
  125742. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125743. * @param engine The engine which the post process will be applied. (default: current engine)
  125744. * @param reusable If the post process can be reused on the same frame. (default: false)
  125745. * @param textureType Type of textures used when performing the post process. (default: 0)
  125746. * @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)
  125747. */
  125748. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  125749. }
  125750. }
  125751. declare module BABYLON {
  125752. /** @hidden */
  125753. export var circleOfConfusionPixelShader: {
  125754. name: string;
  125755. shader: string;
  125756. };
  125757. }
  125758. declare module BABYLON {
  125759. /**
  125760. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  125761. */
  125762. export class CircleOfConfusionPostProcess extends PostProcess {
  125763. /**
  125764. * 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.
  125765. */
  125766. lensSize: number;
  125767. /**
  125768. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  125769. */
  125770. fStop: number;
  125771. /**
  125772. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  125773. */
  125774. focusDistance: number;
  125775. /**
  125776. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  125777. */
  125778. focalLength: number;
  125779. private _depthTexture;
  125780. /**
  125781. * Creates a new instance CircleOfConfusionPostProcess
  125782. * @param name The name of the effect.
  125783. * @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.
  125784. * @param options The required width/height ratio to downsize to before computing the render pass.
  125785. * @param camera The camera to apply the render pass to.
  125786. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125787. * @param engine The engine which the post process will be applied. (default: current engine)
  125788. * @param reusable If the post process can be reused on the same frame. (default: false)
  125789. * @param textureType Type of textures used when performing the post process. (default: 0)
  125790. * @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)
  125791. */
  125792. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  125793. /**
  125794. * 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.
  125795. */
  125796. depthTexture: RenderTargetTexture;
  125797. }
  125798. }
  125799. declare module BABYLON {
  125800. /** @hidden */
  125801. export var colorCorrectionPixelShader: {
  125802. name: string;
  125803. shader: string;
  125804. };
  125805. }
  125806. declare module BABYLON {
  125807. /**
  125808. *
  125809. * This post-process allows the modification of rendered colors by using
  125810. * a 'look-up table' (LUT). This effect is also called Color Grading.
  125811. *
  125812. * The object needs to be provided an url to a texture containing the color
  125813. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  125814. * Use an image editing software to tweak the LUT to match your needs.
  125815. *
  125816. * For an example of a color LUT, see here:
  125817. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  125818. * For explanations on color grading, see here:
  125819. * @see http://udn.epicgames.com/Three/ColorGrading.html
  125820. *
  125821. */
  125822. export class ColorCorrectionPostProcess extends PostProcess {
  125823. private _colorTableTexture;
  125824. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  125825. }
  125826. }
  125827. declare module BABYLON {
  125828. /** @hidden */
  125829. export var convolutionPixelShader: {
  125830. name: string;
  125831. shader: string;
  125832. };
  125833. }
  125834. declare module BABYLON {
  125835. /**
  125836. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  125837. * input texture to perform effects such as edge detection or sharpening
  125838. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  125839. */
  125840. export class ConvolutionPostProcess extends PostProcess {
  125841. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  125842. kernel: number[];
  125843. /**
  125844. * Creates a new instance ConvolutionPostProcess
  125845. * @param name The name of the effect.
  125846. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  125847. * @param options The required width/height ratio to downsize to before computing the render pass.
  125848. * @param camera The camera to apply the render pass to.
  125849. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125850. * @param engine The engine which the post process will be applied. (default: current engine)
  125851. * @param reusable If the post process can be reused on the same frame. (default: false)
  125852. * @param textureType Type of textures used when performing the post process. (default: 0)
  125853. */
  125854. constructor(name: string,
  125855. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  125856. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  125857. /**
  125858. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  125859. */
  125860. static EdgeDetect0Kernel: number[];
  125861. /**
  125862. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  125863. */
  125864. static EdgeDetect1Kernel: number[];
  125865. /**
  125866. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  125867. */
  125868. static EdgeDetect2Kernel: number[];
  125869. /**
  125870. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  125871. */
  125872. static SharpenKernel: number[];
  125873. /**
  125874. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  125875. */
  125876. static EmbossKernel: number[];
  125877. /**
  125878. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  125879. */
  125880. static GaussianKernel: number[];
  125881. }
  125882. }
  125883. declare module BABYLON {
  125884. /**
  125885. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  125886. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  125887. * based on samples that have a large difference in distance than the center pixel.
  125888. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  125889. */
  125890. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  125891. direction: Vector2;
  125892. /**
  125893. * Creates a new instance CircleOfConfusionPostProcess
  125894. * @param name The name of the effect.
  125895. * @param scene The scene the effect belongs to.
  125896. * @param direction The direction the blur should be applied.
  125897. * @param kernel The size of the kernel used to blur.
  125898. * @param options The required width/height ratio to downsize to before computing the render pass.
  125899. * @param camera The camera to apply the render pass to.
  125900. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  125901. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  125902. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125903. * @param engine The engine which the post process will be applied. (default: current engine)
  125904. * @param reusable If the post process can be reused on the same frame. (default: false)
  125905. * @param textureType Type of textures used when performing the post process. (default: 0)
  125906. * @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)
  125907. */
  125908. 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);
  125909. }
  125910. }
  125911. declare module BABYLON {
  125912. /** @hidden */
  125913. export var depthOfFieldMergePixelShader: {
  125914. name: string;
  125915. shader: string;
  125916. };
  125917. }
  125918. declare module BABYLON {
  125919. /**
  125920. * Options to be set when merging outputs from the default pipeline.
  125921. */
  125922. export class DepthOfFieldMergePostProcessOptions {
  125923. /**
  125924. * The original image to merge on top of
  125925. */
  125926. originalFromInput: PostProcess;
  125927. /**
  125928. * Parameters to perform the merge of the depth of field effect
  125929. */
  125930. depthOfField?: {
  125931. circleOfConfusion: PostProcess;
  125932. blurSteps: Array<PostProcess>;
  125933. };
  125934. /**
  125935. * Parameters to perform the merge of bloom effect
  125936. */
  125937. bloom?: {
  125938. blurred: PostProcess;
  125939. weight: number;
  125940. };
  125941. }
  125942. /**
  125943. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  125944. */
  125945. export class DepthOfFieldMergePostProcess extends PostProcess {
  125946. private blurSteps;
  125947. /**
  125948. * Creates a new instance of DepthOfFieldMergePostProcess
  125949. * @param name The name of the effect.
  125950. * @param originalFromInput Post process which's input will be used for the merge.
  125951. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  125952. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  125953. * @param options The required width/height ratio to downsize to before computing the render pass.
  125954. * @param camera The camera to apply the render pass to.
  125955. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125956. * @param engine The engine which the post process will be applied. (default: current engine)
  125957. * @param reusable If the post process can be reused on the same frame. (default: false)
  125958. * @param textureType Type of textures used when performing the post process. (default: 0)
  125959. * @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)
  125960. */
  125961. 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);
  125962. /**
  125963. * Updates the effect with the current post process compile time values and recompiles the shader.
  125964. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  125965. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  125966. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  125967. * @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
  125968. * @param onCompiled Called when the shader has been compiled.
  125969. * @param onError Called if there is an error when compiling a shader.
  125970. */
  125971. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  125972. }
  125973. }
  125974. declare module BABYLON {
  125975. /**
  125976. * Specifies the level of max blur that should be applied when using the depth of field effect
  125977. */
  125978. export enum DepthOfFieldEffectBlurLevel {
  125979. /**
  125980. * Subtle blur
  125981. */
  125982. Low = 0,
  125983. /**
  125984. * Medium blur
  125985. */
  125986. Medium = 1,
  125987. /**
  125988. * Large blur
  125989. */
  125990. High = 2
  125991. }
  125992. /**
  125993. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  125994. */
  125995. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  125996. private _circleOfConfusion;
  125997. /**
  125998. * @hidden Internal, blurs from high to low
  125999. */
  126000. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  126001. private _depthOfFieldBlurY;
  126002. private _dofMerge;
  126003. /**
  126004. * @hidden Internal post processes in depth of field effect
  126005. */
  126006. _effects: Array<PostProcess>;
  126007. /**
  126008. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  126009. */
  126010. focalLength: number;
  126011. /**
  126012. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  126013. */
  126014. fStop: number;
  126015. /**
  126016. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  126017. */
  126018. focusDistance: number;
  126019. /**
  126020. * 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.
  126021. */
  126022. lensSize: number;
  126023. /**
  126024. * Creates a new instance DepthOfFieldEffect
  126025. * @param scene The scene the effect belongs to.
  126026. * @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.
  126027. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  126028. * @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)
  126029. */
  126030. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  126031. /**
  126032. * Get the current class name of the current effet
  126033. * @returns "DepthOfFieldEffect"
  126034. */
  126035. getClassName(): string;
  126036. /**
  126037. * 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.
  126038. */
  126039. depthTexture: RenderTargetTexture;
  126040. /**
  126041. * Disposes each of the internal effects for a given camera.
  126042. * @param camera The camera to dispose the effect on.
  126043. */
  126044. disposeEffects(camera: Camera): void;
  126045. /**
  126046. * @hidden Internal
  126047. */
  126048. _updateEffects(): void;
  126049. /**
  126050. * Internal
  126051. * @returns if all the contained post processes are ready.
  126052. * @hidden
  126053. */
  126054. _isReady(): boolean;
  126055. }
  126056. }
  126057. declare module BABYLON {
  126058. /** @hidden */
  126059. export var displayPassPixelShader: {
  126060. name: string;
  126061. shader: string;
  126062. };
  126063. }
  126064. declare module BABYLON {
  126065. /**
  126066. * DisplayPassPostProcess which produces an output the same as it's input
  126067. */
  126068. export class DisplayPassPostProcess extends PostProcess {
  126069. /**
  126070. * Creates the DisplayPassPostProcess
  126071. * @param name The name of the effect.
  126072. * @param options The required width/height ratio to downsize to before computing the render pass.
  126073. * @param camera The camera to apply the render pass to.
  126074. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126075. * @param engine The engine which the post process will be applied. (default: current engine)
  126076. * @param reusable If the post process can be reused on the same frame. (default: false)
  126077. */
  126078. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  126079. }
  126080. }
  126081. declare module BABYLON {
  126082. /** @hidden */
  126083. export var filterPixelShader: {
  126084. name: string;
  126085. shader: string;
  126086. };
  126087. }
  126088. declare module BABYLON {
  126089. /**
  126090. * Applies a kernel filter to the image
  126091. */
  126092. export class FilterPostProcess extends PostProcess {
  126093. /** The matrix to be applied to the image */
  126094. kernelMatrix: Matrix;
  126095. /**
  126096. *
  126097. * @param name The name of the effect.
  126098. * @param kernelMatrix The matrix to be applied to the image
  126099. * @param options The required width/height ratio to downsize to before computing the render pass.
  126100. * @param camera The camera to apply the render pass to.
  126101. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126102. * @param engine The engine which the post process will be applied. (default: current engine)
  126103. * @param reusable If the post process can be reused on the same frame. (default: false)
  126104. */
  126105. constructor(name: string,
  126106. /** The matrix to be applied to the image */
  126107. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  126108. }
  126109. }
  126110. declare module BABYLON {
  126111. /** @hidden */
  126112. export var fxaaPixelShader: {
  126113. name: string;
  126114. shader: string;
  126115. };
  126116. }
  126117. declare module BABYLON {
  126118. /** @hidden */
  126119. export var fxaaVertexShader: {
  126120. name: string;
  126121. shader: string;
  126122. };
  126123. }
  126124. declare module BABYLON {
  126125. /**
  126126. * Fxaa post process
  126127. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  126128. */
  126129. export class FxaaPostProcess extends PostProcess {
  126130. /** @hidden */
  126131. texelWidth: number;
  126132. /** @hidden */
  126133. texelHeight: number;
  126134. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  126135. private _getDefines;
  126136. }
  126137. }
  126138. declare module BABYLON {
  126139. /** @hidden */
  126140. export var grainPixelShader: {
  126141. name: string;
  126142. shader: string;
  126143. };
  126144. }
  126145. declare module BABYLON {
  126146. /**
  126147. * The GrainPostProcess adds noise to the image at mid luminance levels
  126148. */
  126149. export class GrainPostProcess extends PostProcess {
  126150. /**
  126151. * The intensity of the grain added (default: 30)
  126152. */
  126153. intensity: number;
  126154. /**
  126155. * If the grain should be randomized on every frame
  126156. */
  126157. animated: boolean;
  126158. /**
  126159. * Creates a new instance of @see GrainPostProcess
  126160. * @param name The name of the effect.
  126161. * @param options The required width/height ratio to downsize to before computing the render pass.
  126162. * @param camera The camera to apply the render pass to.
  126163. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126164. * @param engine The engine which the post process will be applied. (default: current engine)
  126165. * @param reusable If the post process can be reused on the same frame. (default: false)
  126166. * @param textureType Type of textures used when performing the post process. (default: 0)
  126167. * @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)
  126168. */
  126169. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  126170. }
  126171. }
  126172. declare module BABYLON {
  126173. /** @hidden */
  126174. export var highlightsPixelShader: {
  126175. name: string;
  126176. shader: string;
  126177. };
  126178. }
  126179. declare module BABYLON {
  126180. /**
  126181. * Extracts highlights from the image
  126182. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  126183. */
  126184. export class HighlightsPostProcess extends PostProcess {
  126185. /**
  126186. * Extracts highlights from the image
  126187. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  126188. * @param name The name of the effect.
  126189. * @param options The required width/height ratio to downsize to before computing the render pass.
  126190. * @param camera The camera to apply the render pass to.
  126191. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126192. * @param engine The engine which the post process will be applied. (default: current engine)
  126193. * @param reusable If the post process can be reused on the same frame. (default: false)
  126194. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  126195. */
  126196. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  126197. }
  126198. }
  126199. declare module BABYLON {
  126200. /** @hidden */
  126201. export var mrtFragmentDeclaration: {
  126202. name: string;
  126203. shader: string;
  126204. };
  126205. }
  126206. declare module BABYLON {
  126207. /** @hidden */
  126208. export var geometryPixelShader: {
  126209. name: string;
  126210. shader: string;
  126211. };
  126212. }
  126213. declare module BABYLON {
  126214. /** @hidden */
  126215. export var geometryVertexShader: {
  126216. name: string;
  126217. shader: string;
  126218. };
  126219. }
  126220. declare module BABYLON {
  126221. /** @hidden */
  126222. interface ISavedTransformationMatrix {
  126223. world: Matrix;
  126224. viewProjection: Matrix;
  126225. }
  126226. /**
  126227. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  126228. */
  126229. export class GeometryBufferRenderer {
  126230. /**
  126231. * Constant used to retrieve the position texture index in the G-Buffer textures array
  126232. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  126233. */
  126234. static readonly POSITION_TEXTURE_TYPE: number;
  126235. /**
  126236. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  126237. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  126238. */
  126239. static readonly VELOCITY_TEXTURE_TYPE: number;
  126240. /**
  126241. * Dictionary used to store the previous transformation matrices of each rendered mesh
  126242. * in order to compute objects velocities when enableVelocity is set to "true"
  126243. * @hidden
  126244. */
  126245. _previousTransformationMatrices: {
  126246. [index: number]: ISavedTransformationMatrix;
  126247. };
  126248. /**
  126249. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  126250. * in order to compute objects velocities when enableVelocity is set to "true"
  126251. * @hidden
  126252. */
  126253. _previousBonesTransformationMatrices: {
  126254. [index: number]: Float32Array;
  126255. };
  126256. /**
  126257. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  126258. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  126259. */
  126260. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  126261. private _scene;
  126262. private _multiRenderTarget;
  126263. private _ratio;
  126264. private _enablePosition;
  126265. private _enableVelocity;
  126266. private _positionIndex;
  126267. private _velocityIndex;
  126268. protected _effect: Effect;
  126269. protected _cachedDefines: string;
  126270. /**
  126271. * Set the render list (meshes to be rendered) used in the G buffer.
  126272. */
  126273. renderList: Mesh[];
  126274. /**
  126275. * Gets wether or not G buffer are supported by the running hardware.
  126276. * This requires draw buffer supports
  126277. */
  126278. readonly isSupported: boolean;
  126279. /**
  126280. * Returns the index of the given texture type in the G-Buffer textures array
  126281. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  126282. * @returns the index of the given texture type in the G-Buffer textures array
  126283. */
  126284. getTextureIndex(textureType: number): number;
  126285. /**
  126286. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  126287. */
  126288. /**
  126289. * Sets whether or not objects positions are enabled for the G buffer.
  126290. */
  126291. enablePosition: boolean;
  126292. /**
  126293. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  126294. */
  126295. /**
  126296. * Sets wether or not objects velocities are enabled for the G buffer.
  126297. */
  126298. enableVelocity: boolean;
  126299. /**
  126300. * Gets the scene associated with the buffer.
  126301. */
  126302. readonly scene: Scene;
  126303. /**
  126304. * Gets the ratio used by the buffer during its creation.
  126305. * How big is the buffer related to the main canvas.
  126306. */
  126307. readonly ratio: number;
  126308. /** @hidden */
  126309. static _SceneComponentInitialization: (scene: Scene) => void;
  126310. /**
  126311. * Creates a new G Buffer for the scene
  126312. * @param scene The scene the buffer belongs to
  126313. * @param ratio How big is the buffer related to the main canvas.
  126314. */
  126315. constructor(scene: Scene, ratio?: number);
  126316. /**
  126317. * Checks wether everything is ready to render a submesh to the G buffer.
  126318. * @param subMesh the submesh to check readiness for
  126319. * @param useInstances is the mesh drawn using instance or not
  126320. * @returns true if ready otherwise false
  126321. */
  126322. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126323. /**
  126324. * Gets the current underlying G Buffer.
  126325. * @returns the buffer
  126326. */
  126327. getGBuffer(): MultiRenderTarget;
  126328. /**
  126329. * Gets the number of samples used to render the buffer (anti aliasing).
  126330. */
  126331. /**
  126332. * Sets the number of samples used to render the buffer (anti aliasing).
  126333. */
  126334. samples: number;
  126335. /**
  126336. * Disposes the renderer and frees up associated resources.
  126337. */
  126338. dispose(): void;
  126339. protected _createRenderTargets(): void;
  126340. private _copyBonesTransformationMatrices;
  126341. }
  126342. }
  126343. declare module BABYLON {
  126344. interface Scene {
  126345. /** @hidden (Backing field) */
  126346. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  126347. /**
  126348. * Gets or Sets the current geometry buffer associated to the scene.
  126349. */
  126350. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  126351. /**
  126352. * Enables a GeometryBufferRender and associates it with the scene
  126353. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  126354. * @returns the GeometryBufferRenderer
  126355. */
  126356. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  126357. /**
  126358. * Disables the GeometryBufferRender associated with the scene
  126359. */
  126360. disableGeometryBufferRenderer(): void;
  126361. }
  126362. /**
  126363. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  126364. * in several rendering techniques.
  126365. */
  126366. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  126367. /**
  126368. * The component name helpful to identify the component in the list of scene components.
  126369. */
  126370. readonly name: string;
  126371. /**
  126372. * The scene the component belongs to.
  126373. */
  126374. scene: Scene;
  126375. /**
  126376. * Creates a new instance of the component for the given scene
  126377. * @param scene Defines the scene to register the component in
  126378. */
  126379. constructor(scene: Scene);
  126380. /**
  126381. * Registers the component in a given scene
  126382. */
  126383. register(): void;
  126384. /**
  126385. * Rebuilds the elements related to this component in case of
  126386. * context lost for instance.
  126387. */
  126388. rebuild(): void;
  126389. /**
  126390. * Disposes the component and the associated ressources
  126391. */
  126392. dispose(): void;
  126393. private _gatherRenderTargets;
  126394. }
  126395. }
  126396. declare module BABYLON {
  126397. /** @hidden */
  126398. export var motionBlurPixelShader: {
  126399. name: string;
  126400. shader: string;
  126401. };
  126402. }
  126403. declare module BABYLON {
  126404. /**
  126405. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  126406. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  126407. * As an example, all you have to do is to create the post-process:
  126408. * var mb = new BABYLON.MotionBlurPostProcess(
  126409. * 'mb', // The name of the effect.
  126410. * scene, // The scene containing the objects to blur according to their velocity.
  126411. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  126412. * camera // The camera to apply the render pass to.
  126413. * );
  126414. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  126415. */
  126416. export class MotionBlurPostProcess extends PostProcess {
  126417. /**
  126418. * Defines how much the image is blurred by the movement. Default value is equal to 1
  126419. */
  126420. motionStrength: number;
  126421. /**
  126422. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  126423. */
  126424. /**
  126425. * Sets the number of iterations to be used for motion blur quality
  126426. */
  126427. motionBlurSamples: number;
  126428. private _motionBlurSamples;
  126429. private _geometryBufferRenderer;
  126430. /**
  126431. * Creates a new instance MotionBlurPostProcess
  126432. * @param name The name of the effect.
  126433. * @param scene The scene containing the objects to blur according to their velocity.
  126434. * @param options The required width/height ratio to downsize to before computing the render pass.
  126435. * @param camera The camera to apply the render pass to.
  126436. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126437. * @param engine The engine which the post process will be applied. (default: current engine)
  126438. * @param reusable If the post process can be reused on the same frame. (default: false)
  126439. * @param textureType Type of textures used when performing the post process. (default: 0)
  126440. * @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)
  126441. */
  126442. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  126443. /**
  126444. * Excludes the given skinned mesh from computing bones velocities.
  126445. * 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.
  126446. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  126447. */
  126448. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  126449. /**
  126450. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  126451. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  126452. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  126453. */
  126454. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  126455. /**
  126456. * Disposes the post process.
  126457. * @param camera The camera to dispose the post process on.
  126458. */
  126459. dispose(camera?: Camera): void;
  126460. }
  126461. }
  126462. declare module BABYLON {
  126463. /** @hidden */
  126464. export var refractionPixelShader: {
  126465. name: string;
  126466. shader: string;
  126467. };
  126468. }
  126469. declare module BABYLON {
  126470. /**
  126471. * Post process which applies a refractin texture
  126472. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  126473. */
  126474. export class RefractionPostProcess extends PostProcess {
  126475. /** the base color of the refraction (used to taint the rendering) */
  126476. color: Color3;
  126477. /** simulated refraction depth */
  126478. depth: number;
  126479. /** the coefficient of the base color (0 to remove base color tainting) */
  126480. colorLevel: number;
  126481. private _refTexture;
  126482. private _ownRefractionTexture;
  126483. /**
  126484. * Gets or sets the refraction texture
  126485. * Please note that you are responsible for disposing the texture if you set it manually
  126486. */
  126487. refractionTexture: Texture;
  126488. /**
  126489. * Initializes the RefractionPostProcess
  126490. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  126491. * @param name The name of the effect.
  126492. * @param refractionTextureUrl Url of the refraction texture to use
  126493. * @param color the base color of the refraction (used to taint the rendering)
  126494. * @param depth simulated refraction depth
  126495. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  126496. * @param camera The camera to apply the render pass to.
  126497. * @param options The required width/height ratio to downsize to before computing the render pass.
  126498. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126499. * @param engine The engine which the post process will be applied. (default: current engine)
  126500. * @param reusable If the post process can be reused on the same frame. (default: false)
  126501. */
  126502. constructor(name: string, refractionTextureUrl: string,
  126503. /** the base color of the refraction (used to taint the rendering) */
  126504. color: Color3,
  126505. /** simulated refraction depth */
  126506. depth: number,
  126507. /** the coefficient of the base color (0 to remove base color tainting) */
  126508. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  126509. /**
  126510. * Disposes of the post process
  126511. * @param camera Camera to dispose post process on
  126512. */
  126513. dispose(camera: Camera): void;
  126514. }
  126515. }
  126516. declare module BABYLON {
  126517. /** @hidden */
  126518. export var sharpenPixelShader: {
  126519. name: string;
  126520. shader: string;
  126521. };
  126522. }
  126523. declare module BABYLON {
  126524. /**
  126525. * The SharpenPostProcess applies a sharpen kernel to every pixel
  126526. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  126527. */
  126528. export class SharpenPostProcess extends PostProcess {
  126529. /**
  126530. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  126531. */
  126532. colorAmount: number;
  126533. /**
  126534. * How much sharpness should be applied (default: 0.3)
  126535. */
  126536. edgeAmount: number;
  126537. /**
  126538. * Creates a new instance ConvolutionPostProcess
  126539. * @param name The name of the effect.
  126540. * @param options The required width/height ratio to downsize to before computing the render pass.
  126541. * @param camera The camera to apply the render pass to.
  126542. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126543. * @param engine The engine which the post process will be applied. (default: current engine)
  126544. * @param reusable If the post process can be reused on the same frame. (default: false)
  126545. * @param textureType Type of textures used when performing the post process. (default: 0)
  126546. * @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)
  126547. */
  126548. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  126549. }
  126550. }
  126551. declare module BABYLON {
  126552. /**
  126553. * PostProcessRenderPipeline
  126554. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  126555. */
  126556. export class PostProcessRenderPipeline {
  126557. private engine;
  126558. private _renderEffects;
  126559. private _renderEffectsForIsolatedPass;
  126560. /**
  126561. * List of inspectable custom properties (used by the Inspector)
  126562. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  126563. */
  126564. inspectableCustomProperties: IInspectable[];
  126565. /**
  126566. * @hidden
  126567. */
  126568. protected _cameras: Camera[];
  126569. /** @hidden */
  126570. _name: string;
  126571. /**
  126572. * Gets pipeline name
  126573. */
  126574. readonly name: string;
  126575. /**
  126576. * Initializes a PostProcessRenderPipeline
  126577. * @param engine engine to add the pipeline to
  126578. * @param name name of the pipeline
  126579. */
  126580. constructor(engine: Engine, name: string);
  126581. /**
  126582. * Gets the class name
  126583. * @returns "PostProcessRenderPipeline"
  126584. */
  126585. getClassName(): string;
  126586. /**
  126587. * If all the render effects in the pipeline are supported
  126588. */
  126589. readonly isSupported: boolean;
  126590. /**
  126591. * Adds an effect to the pipeline
  126592. * @param renderEffect the effect to add
  126593. */
  126594. addEffect(renderEffect: PostProcessRenderEffect): void;
  126595. /** @hidden */
  126596. _rebuild(): void;
  126597. /** @hidden */
  126598. _enableEffect(renderEffectName: string, cameras: Camera): void;
  126599. /** @hidden */
  126600. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  126601. /** @hidden */
  126602. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  126603. /** @hidden */
  126604. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  126605. /** @hidden */
  126606. _attachCameras(cameras: Camera, unique: boolean): void;
  126607. /** @hidden */
  126608. _attachCameras(cameras: Camera[], unique: boolean): void;
  126609. /** @hidden */
  126610. _detachCameras(cameras: Camera): void;
  126611. /** @hidden */
  126612. _detachCameras(cameras: Nullable<Camera[]>): void;
  126613. /** @hidden */
  126614. _update(): void;
  126615. /** @hidden */
  126616. _reset(): void;
  126617. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  126618. /**
  126619. * Disposes of the pipeline
  126620. */
  126621. dispose(): void;
  126622. }
  126623. }
  126624. declare module BABYLON {
  126625. /**
  126626. * PostProcessRenderPipelineManager class
  126627. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  126628. */
  126629. export class PostProcessRenderPipelineManager {
  126630. private _renderPipelines;
  126631. /**
  126632. * Initializes a PostProcessRenderPipelineManager
  126633. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  126634. */
  126635. constructor();
  126636. /**
  126637. * Gets the list of supported render pipelines
  126638. */
  126639. readonly supportedPipelines: PostProcessRenderPipeline[];
  126640. /**
  126641. * Adds a pipeline to the manager
  126642. * @param renderPipeline The pipeline to add
  126643. */
  126644. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  126645. /**
  126646. * Attaches a camera to the pipeline
  126647. * @param renderPipelineName The name of the pipeline to attach to
  126648. * @param cameras the camera to attach
  126649. * @param unique if the camera can be attached multiple times to the pipeline
  126650. */
  126651. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  126652. /**
  126653. * Detaches a camera from the pipeline
  126654. * @param renderPipelineName The name of the pipeline to detach from
  126655. * @param cameras the camera to detach
  126656. */
  126657. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  126658. /**
  126659. * Enables an effect by name on a pipeline
  126660. * @param renderPipelineName the name of the pipeline to enable the effect in
  126661. * @param renderEffectName the name of the effect to enable
  126662. * @param cameras the cameras that the effect should be enabled on
  126663. */
  126664. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  126665. /**
  126666. * Disables an effect by name on a pipeline
  126667. * @param renderPipelineName the name of the pipeline to disable the effect in
  126668. * @param renderEffectName the name of the effect to disable
  126669. * @param cameras the cameras that the effect should be disabled on
  126670. */
  126671. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  126672. /**
  126673. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  126674. */
  126675. update(): void;
  126676. /** @hidden */
  126677. _rebuild(): void;
  126678. /**
  126679. * Disposes of the manager and pipelines
  126680. */
  126681. dispose(): void;
  126682. }
  126683. }
  126684. declare module BABYLON {
  126685. interface Scene {
  126686. /** @hidden (Backing field) */
  126687. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  126688. /**
  126689. * Gets the postprocess render pipeline manager
  126690. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  126691. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  126692. */
  126693. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  126694. }
  126695. /**
  126696. * Defines the Render Pipeline scene component responsible to rendering pipelines
  126697. */
  126698. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  126699. /**
  126700. * The component name helpfull to identify the component in the list of scene components.
  126701. */
  126702. readonly name: string;
  126703. /**
  126704. * The scene the component belongs to.
  126705. */
  126706. scene: Scene;
  126707. /**
  126708. * Creates a new instance of the component for the given scene
  126709. * @param scene Defines the scene to register the component in
  126710. */
  126711. constructor(scene: Scene);
  126712. /**
  126713. * Registers the component in a given scene
  126714. */
  126715. register(): void;
  126716. /**
  126717. * Rebuilds the elements related to this component in case of
  126718. * context lost for instance.
  126719. */
  126720. rebuild(): void;
  126721. /**
  126722. * Disposes the component and the associated ressources
  126723. */
  126724. dispose(): void;
  126725. private _gatherRenderTargets;
  126726. }
  126727. }
  126728. declare module BABYLON {
  126729. /**
  126730. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  126731. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  126732. */
  126733. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  126734. private _scene;
  126735. private _camerasToBeAttached;
  126736. /**
  126737. * ID of the sharpen post process,
  126738. */
  126739. private readonly SharpenPostProcessId;
  126740. /**
  126741. * @ignore
  126742. * ID of the image processing post process;
  126743. */
  126744. readonly ImageProcessingPostProcessId: string;
  126745. /**
  126746. * @ignore
  126747. * ID of the Fast Approximate Anti-Aliasing post process;
  126748. */
  126749. readonly FxaaPostProcessId: string;
  126750. /**
  126751. * ID of the chromatic aberration post process,
  126752. */
  126753. private readonly ChromaticAberrationPostProcessId;
  126754. /**
  126755. * ID of the grain post process
  126756. */
  126757. private readonly GrainPostProcessId;
  126758. /**
  126759. * Sharpen post process which will apply a sharpen convolution to enhance edges
  126760. */
  126761. sharpen: SharpenPostProcess;
  126762. private _sharpenEffect;
  126763. private bloom;
  126764. /**
  126765. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  126766. */
  126767. depthOfField: DepthOfFieldEffect;
  126768. /**
  126769. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  126770. */
  126771. fxaa: FxaaPostProcess;
  126772. /**
  126773. * Image post processing pass used to perform operations such as tone mapping or color grading.
  126774. */
  126775. imageProcessing: ImageProcessingPostProcess;
  126776. /**
  126777. * Chromatic aberration post process which will shift rgb colors in the image
  126778. */
  126779. chromaticAberration: ChromaticAberrationPostProcess;
  126780. private _chromaticAberrationEffect;
  126781. /**
  126782. * Grain post process which add noise to the image
  126783. */
  126784. grain: GrainPostProcess;
  126785. private _grainEffect;
  126786. /**
  126787. * Glow post process which adds a glow to emissive areas of the image
  126788. */
  126789. private _glowLayer;
  126790. /**
  126791. * Animations which can be used to tweak settings over a period of time
  126792. */
  126793. animations: Animation[];
  126794. private _imageProcessingConfigurationObserver;
  126795. private _sharpenEnabled;
  126796. private _bloomEnabled;
  126797. private _depthOfFieldEnabled;
  126798. private _depthOfFieldBlurLevel;
  126799. private _fxaaEnabled;
  126800. private _imageProcessingEnabled;
  126801. private _defaultPipelineTextureType;
  126802. private _bloomScale;
  126803. private _chromaticAberrationEnabled;
  126804. private _grainEnabled;
  126805. private _buildAllowed;
  126806. /**
  126807. * Gets active scene
  126808. */
  126809. readonly scene: Scene;
  126810. /**
  126811. * Enable or disable the sharpen process from the pipeline
  126812. */
  126813. sharpenEnabled: boolean;
  126814. private _resizeObserver;
  126815. private _hardwareScaleLevel;
  126816. private _bloomKernel;
  126817. /**
  126818. * Specifies the size of the bloom blur kernel, relative to the final output size
  126819. */
  126820. bloomKernel: number;
  126821. /**
  126822. * Specifies the weight of the bloom in the final rendering
  126823. */
  126824. private _bloomWeight;
  126825. /**
  126826. * Specifies the luma threshold for the area that will be blurred by the bloom
  126827. */
  126828. private _bloomThreshold;
  126829. private _hdr;
  126830. /**
  126831. * The strength of the bloom.
  126832. */
  126833. bloomWeight: number;
  126834. /**
  126835. * The strength of the bloom.
  126836. */
  126837. bloomThreshold: number;
  126838. /**
  126839. * The scale of the bloom, lower value will provide better performance.
  126840. */
  126841. bloomScale: number;
  126842. /**
  126843. * Enable or disable the bloom from the pipeline
  126844. */
  126845. bloomEnabled: boolean;
  126846. private _rebuildBloom;
  126847. /**
  126848. * If the depth of field is enabled.
  126849. */
  126850. depthOfFieldEnabled: boolean;
  126851. /**
  126852. * Blur level of the depth of field effect. (Higher blur will effect performance)
  126853. */
  126854. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  126855. /**
  126856. * If the anti aliasing is enabled.
  126857. */
  126858. fxaaEnabled: boolean;
  126859. private _samples;
  126860. /**
  126861. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  126862. */
  126863. samples: number;
  126864. /**
  126865. * If image processing is enabled.
  126866. */
  126867. imageProcessingEnabled: boolean;
  126868. /**
  126869. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  126870. */
  126871. glowLayerEnabled: boolean;
  126872. /**
  126873. * Gets the glow layer (or null if not defined)
  126874. */
  126875. readonly glowLayer: Nullable<GlowLayer>;
  126876. /**
  126877. * Enable or disable the chromaticAberration process from the pipeline
  126878. */
  126879. chromaticAberrationEnabled: boolean;
  126880. /**
  126881. * Enable or disable the grain process from the pipeline
  126882. */
  126883. grainEnabled: boolean;
  126884. /**
  126885. * @constructor
  126886. * @param name - The rendering pipeline name (default: "")
  126887. * @param hdr - If high dynamic range textures should be used (default: true)
  126888. * @param scene - The scene linked to this pipeline (default: the last created scene)
  126889. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  126890. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  126891. */
  126892. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  126893. /**
  126894. * Get the class name
  126895. * @returns "DefaultRenderingPipeline"
  126896. */
  126897. getClassName(): string;
  126898. /**
  126899. * Force the compilation of the entire pipeline.
  126900. */
  126901. prepare(): void;
  126902. private _hasCleared;
  126903. private _prevPostProcess;
  126904. private _prevPrevPostProcess;
  126905. private _setAutoClearAndTextureSharing;
  126906. private _depthOfFieldSceneObserver;
  126907. private _buildPipeline;
  126908. private _disposePostProcesses;
  126909. /**
  126910. * Adds a camera to the pipeline
  126911. * @param camera the camera to be added
  126912. */
  126913. addCamera(camera: Camera): void;
  126914. /**
  126915. * Removes a camera from the pipeline
  126916. * @param camera the camera to remove
  126917. */
  126918. removeCamera(camera: Camera): void;
  126919. /**
  126920. * Dispose of the pipeline and stop all post processes
  126921. */
  126922. dispose(): void;
  126923. /**
  126924. * Serialize the rendering pipeline (Used when exporting)
  126925. * @returns the serialized object
  126926. */
  126927. serialize(): any;
  126928. /**
  126929. * Parse the serialized pipeline
  126930. * @param source Source pipeline.
  126931. * @param scene The scene to load the pipeline to.
  126932. * @param rootUrl The URL of the serialized pipeline.
  126933. * @returns An instantiated pipeline from the serialized object.
  126934. */
  126935. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  126936. }
  126937. }
  126938. declare module BABYLON {
  126939. /** @hidden */
  126940. export var lensHighlightsPixelShader: {
  126941. name: string;
  126942. shader: string;
  126943. };
  126944. }
  126945. declare module BABYLON {
  126946. /** @hidden */
  126947. export var depthOfFieldPixelShader: {
  126948. name: string;
  126949. shader: string;
  126950. };
  126951. }
  126952. declare module BABYLON {
  126953. /**
  126954. * BABYLON.JS Chromatic Aberration GLSL Shader
  126955. * Author: Olivier Guyot
  126956. * Separates very slightly R, G and B colors on the edges of the screen
  126957. * Inspired by Francois Tarlier & Martins Upitis
  126958. */
  126959. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  126960. /**
  126961. * @ignore
  126962. * The chromatic aberration PostProcess id in the pipeline
  126963. */
  126964. LensChromaticAberrationEffect: string;
  126965. /**
  126966. * @ignore
  126967. * The highlights enhancing PostProcess id in the pipeline
  126968. */
  126969. HighlightsEnhancingEffect: string;
  126970. /**
  126971. * @ignore
  126972. * The depth-of-field PostProcess id in the pipeline
  126973. */
  126974. LensDepthOfFieldEffect: string;
  126975. private _scene;
  126976. private _depthTexture;
  126977. private _grainTexture;
  126978. private _chromaticAberrationPostProcess;
  126979. private _highlightsPostProcess;
  126980. private _depthOfFieldPostProcess;
  126981. private _edgeBlur;
  126982. private _grainAmount;
  126983. private _chromaticAberration;
  126984. private _distortion;
  126985. private _highlightsGain;
  126986. private _highlightsThreshold;
  126987. private _dofDistance;
  126988. private _dofAperture;
  126989. private _dofDarken;
  126990. private _dofPentagon;
  126991. private _blurNoise;
  126992. /**
  126993. * @constructor
  126994. *
  126995. * Effect parameters are as follow:
  126996. * {
  126997. * chromatic_aberration: number; // from 0 to x (1 for realism)
  126998. * edge_blur: number; // from 0 to x (1 for realism)
  126999. * distortion: number; // from 0 to x (1 for realism)
  127000. * grain_amount: number; // from 0 to 1
  127001. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  127002. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  127003. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  127004. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  127005. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  127006. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  127007. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  127008. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  127009. * }
  127010. * Note: if an effect parameter is unset, effect is disabled
  127011. *
  127012. * @param name The rendering pipeline name
  127013. * @param parameters - An object containing all parameters (see above)
  127014. * @param scene The scene linked to this pipeline
  127015. * @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)
  127016. * @param cameras The array of cameras that the rendering pipeline will be attached to
  127017. */
  127018. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  127019. /**
  127020. * Get the class name
  127021. * @returns "LensRenderingPipeline"
  127022. */
  127023. getClassName(): string;
  127024. /**
  127025. * Gets associated scene
  127026. */
  127027. readonly scene: Scene;
  127028. /**
  127029. * Gets or sets the edge blur
  127030. */
  127031. edgeBlur: number;
  127032. /**
  127033. * Gets or sets the grain amount
  127034. */
  127035. grainAmount: number;
  127036. /**
  127037. * Gets or sets the chromatic aberration amount
  127038. */
  127039. chromaticAberration: number;
  127040. /**
  127041. * Gets or sets the depth of field aperture
  127042. */
  127043. dofAperture: number;
  127044. /**
  127045. * Gets or sets the edge distortion
  127046. */
  127047. edgeDistortion: number;
  127048. /**
  127049. * Gets or sets the depth of field distortion
  127050. */
  127051. dofDistortion: number;
  127052. /**
  127053. * Gets or sets the darken out of focus amount
  127054. */
  127055. darkenOutOfFocus: number;
  127056. /**
  127057. * Gets or sets a boolean indicating if blur noise is enabled
  127058. */
  127059. blurNoise: boolean;
  127060. /**
  127061. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  127062. */
  127063. pentagonBokeh: boolean;
  127064. /**
  127065. * Gets or sets the highlight grain amount
  127066. */
  127067. highlightsGain: number;
  127068. /**
  127069. * Gets or sets the highlight threshold
  127070. */
  127071. highlightsThreshold: number;
  127072. /**
  127073. * Sets the amount of blur at the edges
  127074. * @param amount blur amount
  127075. */
  127076. setEdgeBlur(amount: number): void;
  127077. /**
  127078. * Sets edge blur to 0
  127079. */
  127080. disableEdgeBlur(): void;
  127081. /**
  127082. * Sets the amout of grain
  127083. * @param amount Amount of grain
  127084. */
  127085. setGrainAmount(amount: number): void;
  127086. /**
  127087. * Set grain amount to 0
  127088. */
  127089. disableGrain(): void;
  127090. /**
  127091. * Sets the chromatic aberration amount
  127092. * @param amount amount of chromatic aberration
  127093. */
  127094. setChromaticAberration(amount: number): void;
  127095. /**
  127096. * Sets chromatic aberration amount to 0
  127097. */
  127098. disableChromaticAberration(): void;
  127099. /**
  127100. * Sets the EdgeDistortion amount
  127101. * @param amount amount of EdgeDistortion
  127102. */
  127103. setEdgeDistortion(amount: number): void;
  127104. /**
  127105. * Sets edge distortion to 0
  127106. */
  127107. disableEdgeDistortion(): void;
  127108. /**
  127109. * Sets the FocusDistance amount
  127110. * @param amount amount of FocusDistance
  127111. */
  127112. setFocusDistance(amount: number): void;
  127113. /**
  127114. * Disables depth of field
  127115. */
  127116. disableDepthOfField(): void;
  127117. /**
  127118. * Sets the Aperture amount
  127119. * @param amount amount of Aperture
  127120. */
  127121. setAperture(amount: number): void;
  127122. /**
  127123. * Sets the DarkenOutOfFocus amount
  127124. * @param amount amount of DarkenOutOfFocus
  127125. */
  127126. setDarkenOutOfFocus(amount: number): void;
  127127. private _pentagonBokehIsEnabled;
  127128. /**
  127129. * Creates a pentagon bokeh effect
  127130. */
  127131. enablePentagonBokeh(): void;
  127132. /**
  127133. * Disables the pentagon bokeh effect
  127134. */
  127135. disablePentagonBokeh(): void;
  127136. /**
  127137. * Enables noise blur
  127138. */
  127139. enableNoiseBlur(): void;
  127140. /**
  127141. * Disables noise blur
  127142. */
  127143. disableNoiseBlur(): void;
  127144. /**
  127145. * Sets the HighlightsGain amount
  127146. * @param amount amount of HighlightsGain
  127147. */
  127148. setHighlightsGain(amount: number): void;
  127149. /**
  127150. * Sets the HighlightsThreshold amount
  127151. * @param amount amount of HighlightsThreshold
  127152. */
  127153. setHighlightsThreshold(amount: number): void;
  127154. /**
  127155. * Disables highlights
  127156. */
  127157. disableHighlights(): void;
  127158. /**
  127159. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  127160. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  127161. */
  127162. dispose(disableDepthRender?: boolean): void;
  127163. private _createChromaticAberrationPostProcess;
  127164. private _createHighlightsPostProcess;
  127165. private _createDepthOfFieldPostProcess;
  127166. private _createGrainTexture;
  127167. }
  127168. }
  127169. declare module BABYLON {
  127170. /** @hidden */
  127171. export var ssao2PixelShader: {
  127172. name: string;
  127173. shader: string;
  127174. };
  127175. }
  127176. declare module BABYLON {
  127177. /** @hidden */
  127178. export var ssaoCombinePixelShader: {
  127179. name: string;
  127180. shader: string;
  127181. };
  127182. }
  127183. declare module BABYLON {
  127184. /**
  127185. * Render pipeline to produce ssao effect
  127186. */
  127187. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  127188. /**
  127189. * @ignore
  127190. * The PassPostProcess id in the pipeline that contains the original scene color
  127191. */
  127192. SSAOOriginalSceneColorEffect: string;
  127193. /**
  127194. * @ignore
  127195. * The SSAO PostProcess id in the pipeline
  127196. */
  127197. SSAORenderEffect: string;
  127198. /**
  127199. * @ignore
  127200. * The horizontal blur PostProcess id in the pipeline
  127201. */
  127202. SSAOBlurHRenderEffect: string;
  127203. /**
  127204. * @ignore
  127205. * The vertical blur PostProcess id in the pipeline
  127206. */
  127207. SSAOBlurVRenderEffect: string;
  127208. /**
  127209. * @ignore
  127210. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  127211. */
  127212. SSAOCombineRenderEffect: string;
  127213. /**
  127214. * The output strength of the SSAO post-process. Default value is 1.0.
  127215. */
  127216. totalStrength: number;
  127217. /**
  127218. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  127219. */
  127220. maxZ: number;
  127221. /**
  127222. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  127223. */
  127224. minZAspect: number;
  127225. private _samples;
  127226. /**
  127227. * Number of samples used for the SSAO calculations. Default value is 8
  127228. */
  127229. samples: number;
  127230. private _textureSamples;
  127231. /**
  127232. * Number of samples to use for antialiasing
  127233. */
  127234. textureSamples: number;
  127235. /**
  127236. * Ratio object used for SSAO ratio and blur ratio
  127237. */
  127238. private _ratio;
  127239. /**
  127240. * Dynamically generated sphere sampler.
  127241. */
  127242. private _sampleSphere;
  127243. /**
  127244. * Blur filter offsets
  127245. */
  127246. private _samplerOffsets;
  127247. private _expensiveBlur;
  127248. /**
  127249. * If bilateral blur should be used
  127250. */
  127251. expensiveBlur: boolean;
  127252. /**
  127253. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  127254. */
  127255. radius: number;
  127256. /**
  127257. * The base color of the SSAO post-process
  127258. * The final result is "base + ssao" between [0, 1]
  127259. */
  127260. base: number;
  127261. /**
  127262. * Support test.
  127263. */
  127264. static readonly IsSupported: boolean;
  127265. private _scene;
  127266. private _depthTexture;
  127267. private _normalTexture;
  127268. private _randomTexture;
  127269. private _originalColorPostProcess;
  127270. private _ssaoPostProcess;
  127271. private _blurHPostProcess;
  127272. private _blurVPostProcess;
  127273. private _ssaoCombinePostProcess;
  127274. private _firstUpdate;
  127275. /**
  127276. * Gets active scene
  127277. */
  127278. readonly scene: Scene;
  127279. /**
  127280. * @constructor
  127281. * @param name The rendering pipeline name
  127282. * @param scene The scene linked to this pipeline
  127283. * @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 }
  127284. * @param cameras The array of cameras that the rendering pipeline will be attached to
  127285. */
  127286. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  127287. /**
  127288. * Get the class name
  127289. * @returns "SSAO2RenderingPipeline"
  127290. */
  127291. getClassName(): string;
  127292. /**
  127293. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  127294. */
  127295. dispose(disableGeometryBufferRenderer?: boolean): void;
  127296. private _createBlurPostProcess;
  127297. /** @hidden */
  127298. _rebuild(): void;
  127299. private _bits;
  127300. private _radicalInverse_VdC;
  127301. private _hammersley;
  127302. private _hemisphereSample_uniform;
  127303. private _generateHemisphere;
  127304. private _createSSAOPostProcess;
  127305. private _createSSAOCombinePostProcess;
  127306. private _createRandomTexture;
  127307. /**
  127308. * Serialize the rendering pipeline (Used when exporting)
  127309. * @returns the serialized object
  127310. */
  127311. serialize(): any;
  127312. /**
  127313. * Parse the serialized pipeline
  127314. * @param source Source pipeline.
  127315. * @param scene The scene to load the pipeline to.
  127316. * @param rootUrl The URL of the serialized pipeline.
  127317. * @returns An instantiated pipeline from the serialized object.
  127318. */
  127319. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  127320. }
  127321. }
  127322. declare module BABYLON {
  127323. /** @hidden */
  127324. export var ssaoPixelShader: {
  127325. name: string;
  127326. shader: string;
  127327. };
  127328. }
  127329. declare module BABYLON {
  127330. /**
  127331. * Render pipeline to produce ssao effect
  127332. */
  127333. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  127334. /**
  127335. * @ignore
  127336. * The PassPostProcess id in the pipeline that contains the original scene color
  127337. */
  127338. SSAOOriginalSceneColorEffect: string;
  127339. /**
  127340. * @ignore
  127341. * The SSAO PostProcess id in the pipeline
  127342. */
  127343. SSAORenderEffect: string;
  127344. /**
  127345. * @ignore
  127346. * The horizontal blur PostProcess id in the pipeline
  127347. */
  127348. SSAOBlurHRenderEffect: string;
  127349. /**
  127350. * @ignore
  127351. * The vertical blur PostProcess id in the pipeline
  127352. */
  127353. SSAOBlurVRenderEffect: string;
  127354. /**
  127355. * @ignore
  127356. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  127357. */
  127358. SSAOCombineRenderEffect: string;
  127359. /**
  127360. * The output strength of the SSAO post-process. Default value is 1.0.
  127361. */
  127362. totalStrength: number;
  127363. /**
  127364. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  127365. */
  127366. radius: number;
  127367. /**
  127368. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  127369. * Must not be equal to fallOff and superior to fallOff.
  127370. * Default value is 0.0075
  127371. */
  127372. area: number;
  127373. /**
  127374. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  127375. * Must not be equal to area and inferior to area.
  127376. * Default value is 0.000001
  127377. */
  127378. fallOff: number;
  127379. /**
  127380. * The base color of the SSAO post-process
  127381. * The final result is "base + ssao" between [0, 1]
  127382. */
  127383. base: number;
  127384. private _scene;
  127385. private _depthTexture;
  127386. private _randomTexture;
  127387. private _originalColorPostProcess;
  127388. private _ssaoPostProcess;
  127389. private _blurHPostProcess;
  127390. private _blurVPostProcess;
  127391. private _ssaoCombinePostProcess;
  127392. private _firstUpdate;
  127393. /**
  127394. * Gets active scene
  127395. */
  127396. readonly scene: Scene;
  127397. /**
  127398. * @constructor
  127399. * @param name - The rendering pipeline name
  127400. * @param scene - The scene linked to this pipeline
  127401. * @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 }
  127402. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  127403. */
  127404. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  127405. /**
  127406. * Get the class name
  127407. * @returns "SSAORenderingPipeline"
  127408. */
  127409. getClassName(): string;
  127410. /**
  127411. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  127412. */
  127413. dispose(disableDepthRender?: boolean): void;
  127414. private _createBlurPostProcess;
  127415. /** @hidden */
  127416. _rebuild(): void;
  127417. private _createSSAOPostProcess;
  127418. private _createSSAOCombinePostProcess;
  127419. private _createRandomTexture;
  127420. }
  127421. }
  127422. declare module BABYLON {
  127423. /** @hidden */
  127424. export var standardPixelShader: {
  127425. name: string;
  127426. shader: string;
  127427. };
  127428. }
  127429. declare module BABYLON {
  127430. /**
  127431. * Standard rendering pipeline
  127432. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  127433. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  127434. */
  127435. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  127436. /**
  127437. * Public members
  127438. */
  127439. /**
  127440. * Post-process which contains the original scene color before the pipeline applies all the effects
  127441. */
  127442. originalPostProcess: Nullable<PostProcess>;
  127443. /**
  127444. * Post-process used to down scale an image x4
  127445. */
  127446. downSampleX4PostProcess: Nullable<PostProcess>;
  127447. /**
  127448. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  127449. */
  127450. brightPassPostProcess: Nullable<PostProcess>;
  127451. /**
  127452. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  127453. */
  127454. blurHPostProcesses: PostProcess[];
  127455. /**
  127456. * Post-process array storing all the vertical blur post-processes used by the pipeline
  127457. */
  127458. blurVPostProcesses: PostProcess[];
  127459. /**
  127460. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  127461. */
  127462. textureAdderPostProcess: Nullable<PostProcess>;
  127463. /**
  127464. * Post-process used to create volumetric lighting effect
  127465. */
  127466. volumetricLightPostProcess: Nullable<PostProcess>;
  127467. /**
  127468. * Post-process used to smooth the previous volumetric light post-process on the X axis
  127469. */
  127470. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  127471. /**
  127472. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  127473. */
  127474. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  127475. /**
  127476. * Post-process used to merge the volumetric light effect and the real scene color
  127477. */
  127478. volumetricLightMergePostProces: Nullable<PostProcess>;
  127479. /**
  127480. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  127481. */
  127482. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  127483. /**
  127484. * Base post-process used to calculate the average luminance of the final image for HDR
  127485. */
  127486. luminancePostProcess: Nullable<PostProcess>;
  127487. /**
  127488. * Post-processes used to create down sample post-processes in order to get
  127489. * the average luminance of the final image for HDR
  127490. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  127491. */
  127492. luminanceDownSamplePostProcesses: PostProcess[];
  127493. /**
  127494. * Post-process used to create a HDR effect (light adaptation)
  127495. */
  127496. hdrPostProcess: Nullable<PostProcess>;
  127497. /**
  127498. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  127499. */
  127500. textureAdderFinalPostProcess: Nullable<PostProcess>;
  127501. /**
  127502. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  127503. */
  127504. lensFlareFinalPostProcess: Nullable<PostProcess>;
  127505. /**
  127506. * Post-process used to merge the final HDR post-process and the real scene color
  127507. */
  127508. hdrFinalPostProcess: Nullable<PostProcess>;
  127509. /**
  127510. * Post-process used to create a lens flare effect
  127511. */
  127512. lensFlarePostProcess: Nullable<PostProcess>;
  127513. /**
  127514. * Post-process that merges the result of the lens flare post-process and the real scene color
  127515. */
  127516. lensFlareComposePostProcess: Nullable<PostProcess>;
  127517. /**
  127518. * Post-process used to create a motion blur effect
  127519. */
  127520. motionBlurPostProcess: Nullable<PostProcess>;
  127521. /**
  127522. * Post-process used to create a depth of field effect
  127523. */
  127524. depthOfFieldPostProcess: Nullable<PostProcess>;
  127525. /**
  127526. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  127527. */
  127528. fxaaPostProcess: Nullable<FxaaPostProcess>;
  127529. /**
  127530. * Represents the brightness threshold in order to configure the illuminated surfaces
  127531. */
  127532. brightThreshold: number;
  127533. /**
  127534. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  127535. */
  127536. blurWidth: number;
  127537. /**
  127538. * Sets if the blur for highlighted surfaces must be only horizontal
  127539. */
  127540. horizontalBlur: boolean;
  127541. /**
  127542. * Gets the overall exposure used by the pipeline
  127543. */
  127544. /**
  127545. * Sets the overall exposure used by the pipeline
  127546. */
  127547. exposure: number;
  127548. /**
  127549. * Texture used typically to simulate "dirty" on camera lens
  127550. */
  127551. lensTexture: Nullable<Texture>;
  127552. /**
  127553. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  127554. */
  127555. volumetricLightCoefficient: number;
  127556. /**
  127557. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  127558. */
  127559. volumetricLightPower: number;
  127560. /**
  127561. * Used the set the blur intensity to smooth the volumetric lights
  127562. */
  127563. volumetricLightBlurScale: number;
  127564. /**
  127565. * Light (spot or directional) used to generate the volumetric lights rays
  127566. * The source light must have a shadow generate so the pipeline can get its
  127567. * depth map
  127568. */
  127569. sourceLight: Nullable<SpotLight | DirectionalLight>;
  127570. /**
  127571. * For eye adaptation, represents the minimum luminance the eye can see
  127572. */
  127573. hdrMinimumLuminance: number;
  127574. /**
  127575. * For eye adaptation, represents the decrease luminance speed
  127576. */
  127577. hdrDecreaseRate: number;
  127578. /**
  127579. * For eye adaptation, represents the increase luminance speed
  127580. */
  127581. hdrIncreaseRate: number;
  127582. /**
  127583. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  127584. */
  127585. /**
  127586. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  127587. */
  127588. hdrAutoExposure: boolean;
  127589. /**
  127590. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  127591. */
  127592. lensColorTexture: Nullable<Texture>;
  127593. /**
  127594. * The overall strengh for the lens flare effect
  127595. */
  127596. lensFlareStrength: number;
  127597. /**
  127598. * Dispersion coefficient for lens flare ghosts
  127599. */
  127600. lensFlareGhostDispersal: number;
  127601. /**
  127602. * Main lens flare halo width
  127603. */
  127604. lensFlareHaloWidth: number;
  127605. /**
  127606. * Based on the lens distortion effect, defines how much the lens flare result
  127607. * is distorted
  127608. */
  127609. lensFlareDistortionStrength: number;
  127610. /**
  127611. * Configures the blur intensity used for for lens flare (halo)
  127612. */
  127613. lensFlareBlurWidth: number;
  127614. /**
  127615. * Lens star texture must be used to simulate rays on the flares and is available
  127616. * in the documentation
  127617. */
  127618. lensStarTexture: Nullable<Texture>;
  127619. /**
  127620. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  127621. * flare effect by taking account of the dirt texture
  127622. */
  127623. lensFlareDirtTexture: Nullable<Texture>;
  127624. /**
  127625. * Represents the focal length for the depth of field effect
  127626. */
  127627. depthOfFieldDistance: number;
  127628. /**
  127629. * Represents the blur intensity for the blurred part of the depth of field effect
  127630. */
  127631. depthOfFieldBlurWidth: number;
  127632. /**
  127633. * Gets how much the image is blurred by the movement while using the motion blur post-process
  127634. */
  127635. /**
  127636. * Sets how much the image is blurred by the movement while using the motion blur post-process
  127637. */
  127638. motionStrength: number;
  127639. /**
  127640. * Gets wether or not the motion blur post-process is object based or screen based.
  127641. */
  127642. /**
  127643. * Sets wether or not the motion blur post-process should be object based or screen based
  127644. */
  127645. objectBasedMotionBlur: boolean;
  127646. /**
  127647. * List of animations for the pipeline (IAnimatable implementation)
  127648. */
  127649. animations: Animation[];
  127650. /**
  127651. * Private members
  127652. */
  127653. private _scene;
  127654. private _currentDepthOfFieldSource;
  127655. private _basePostProcess;
  127656. private _fixedExposure;
  127657. private _currentExposure;
  127658. private _hdrAutoExposure;
  127659. private _hdrCurrentLuminance;
  127660. private _motionStrength;
  127661. private _isObjectBasedMotionBlur;
  127662. private _floatTextureType;
  127663. private _camerasToBeAttached;
  127664. private _ratio;
  127665. private _bloomEnabled;
  127666. private _depthOfFieldEnabled;
  127667. private _vlsEnabled;
  127668. private _lensFlareEnabled;
  127669. private _hdrEnabled;
  127670. private _motionBlurEnabled;
  127671. private _fxaaEnabled;
  127672. private _motionBlurSamples;
  127673. private _volumetricLightStepsCount;
  127674. private _samples;
  127675. /**
  127676. * @ignore
  127677. * Specifies if the bloom pipeline is enabled
  127678. */
  127679. BloomEnabled: boolean;
  127680. /**
  127681. * @ignore
  127682. * Specifies if the depth of field pipeline is enabed
  127683. */
  127684. DepthOfFieldEnabled: boolean;
  127685. /**
  127686. * @ignore
  127687. * Specifies if the lens flare pipeline is enabed
  127688. */
  127689. LensFlareEnabled: boolean;
  127690. /**
  127691. * @ignore
  127692. * Specifies if the HDR pipeline is enabled
  127693. */
  127694. HDREnabled: boolean;
  127695. /**
  127696. * @ignore
  127697. * Specifies if the volumetric lights scattering effect is enabled
  127698. */
  127699. VLSEnabled: boolean;
  127700. /**
  127701. * @ignore
  127702. * Specifies if the motion blur effect is enabled
  127703. */
  127704. MotionBlurEnabled: boolean;
  127705. /**
  127706. * Specifies if anti-aliasing is enabled
  127707. */
  127708. fxaaEnabled: boolean;
  127709. /**
  127710. * Specifies the number of steps used to calculate the volumetric lights
  127711. * Typically in interval [50, 200]
  127712. */
  127713. volumetricLightStepsCount: number;
  127714. /**
  127715. * Specifies the number of samples used for the motion blur effect
  127716. * Typically in interval [16, 64]
  127717. */
  127718. motionBlurSamples: number;
  127719. /**
  127720. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  127721. */
  127722. samples: number;
  127723. /**
  127724. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  127725. * @constructor
  127726. * @param name The rendering pipeline name
  127727. * @param scene The scene linked to this pipeline
  127728. * @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)
  127729. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  127730. * @param cameras The array of cameras that the rendering pipeline will be attached to
  127731. */
  127732. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  127733. private _buildPipeline;
  127734. private _createDownSampleX4PostProcess;
  127735. private _createBrightPassPostProcess;
  127736. private _createBlurPostProcesses;
  127737. private _createTextureAdderPostProcess;
  127738. private _createVolumetricLightPostProcess;
  127739. private _createLuminancePostProcesses;
  127740. private _createHdrPostProcess;
  127741. private _createLensFlarePostProcess;
  127742. private _createDepthOfFieldPostProcess;
  127743. private _createMotionBlurPostProcess;
  127744. private _getDepthTexture;
  127745. private _disposePostProcesses;
  127746. /**
  127747. * Dispose of the pipeline and stop all post processes
  127748. */
  127749. dispose(): void;
  127750. /**
  127751. * Serialize the rendering pipeline (Used when exporting)
  127752. * @returns the serialized object
  127753. */
  127754. serialize(): any;
  127755. /**
  127756. * Parse the serialized pipeline
  127757. * @param source Source pipeline.
  127758. * @param scene The scene to load the pipeline to.
  127759. * @param rootUrl The URL of the serialized pipeline.
  127760. * @returns An instantiated pipeline from the serialized object.
  127761. */
  127762. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  127763. /**
  127764. * Luminance steps
  127765. */
  127766. static LuminanceSteps: number;
  127767. }
  127768. }
  127769. declare module BABYLON {
  127770. /** @hidden */
  127771. export var tonemapPixelShader: {
  127772. name: string;
  127773. shader: string;
  127774. };
  127775. }
  127776. declare module BABYLON {
  127777. /** Defines operator used for tonemapping */
  127778. export enum TonemappingOperator {
  127779. /** Hable */
  127780. Hable = 0,
  127781. /** Reinhard */
  127782. Reinhard = 1,
  127783. /** HejiDawson */
  127784. HejiDawson = 2,
  127785. /** Photographic */
  127786. Photographic = 3
  127787. }
  127788. /**
  127789. * Defines a post process to apply tone mapping
  127790. */
  127791. export class TonemapPostProcess extends PostProcess {
  127792. private _operator;
  127793. /** Defines the required exposure adjustement */
  127794. exposureAdjustment: number;
  127795. /**
  127796. * Creates a new TonemapPostProcess
  127797. * @param name defines the name of the postprocess
  127798. * @param _operator defines the operator to use
  127799. * @param exposureAdjustment defines the required exposure adjustement
  127800. * @param camera defines the camera to use (can be null)
  127801. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  127802. * @param engine defines the hosting engine (can be ignore if camera is set)
  127803. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  127804. */
  127805. constructor(name: string, _operator: TonemappingOperator,
  127806. /** Defines the required exposure adjustement */
  127807. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  127808. }
  127809. }
  127810. declare module BABYLON {
  127811. /** @hidden */
  127812. export var depthVertexShader: {
  127813. name: string;
  127814. shader: string;
  127815. };
  127816. }
  127817. declare module BABYLON {
  127818. /** @hidden */
  127819. export var volumetricLightScatteringPixelShader: {
  127820. name: string;
  127821. shader: string;
  127822. };
  127823. }
  127824. declare module BABYLON {
  127825. /** @hidden */
  127826. export var volumetricLightScatteringPassVertexShader: {
  127827. name: string;
  127828. shader: string;
  127829. };
  127830. }
  127831. declare module BABYLON {
  127832. /** @hidden */
  127833. export var volumetricLightScatteringPassPixelShader: {
  127834. name: string;
  127835. shader: string;
  127836. };
  127837. }
  127838. declare module BABYLON {
  127839. /**
  127840. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  127841. */
  127842. export class VolumetricLightScatteringPostProcess extends PostProcess {
  127843. private _volumetricLightScatteringPass;
  127844. private _volumetricLightScatteringRTT;
  127845. private _viewPort;
  127846. private _screenCoordinates;
  127847. private _cachedDefines;
  127848. /**
  127849. * If not undefined, the mesh position is computed from the attached node position
  127850. */
  127851. attachedNode: {
  127852. position: Vector3;
  127853. };
  127854. /**
  127855. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  127856. */
  127857. customMeshPosition: Vector3;
  127858. /**
  127859. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  127860. */
  127861. useCustomMeshPosition: boolean;
  127862. /**
  127863. * If the post-process should inverse the light scattering direction
  127864. */
  127865. invert: boolean;
  127866. /**
  127867. * The internal mesh used by the post-process
  127868. */
  127869. mesh: Mesh;
  127870. /**
  127871. * @hidden
  127872. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  127873. */
  127874. useDiffuseColor: boolean;
  127875. /**
  127876. * Array containing the excluded meshes not rendered in the internal pass
  127877. */
  127878. excludedMeshes: AbstractMesh[];
  127879. /**
  127880. * Controls the overall intensity of the post-process
  127881. */
  127882. exposure: number;
  127883. /**
  127884. * Dissipates each sample's contribution in range [0, 1]
  127885. */
  127886. decay: number;
  127887. /**
  127888. * Controls the overall intensity of each sample
  127889. */
  127890. weight: number;
  127891. /**
  127892. * Controls the density of each sample
  127893. */
  127894. density: number;
  127895. /**
  127896. * @constructor
  127897. * @param name The post-process name
  127898. * @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)
  127899. * @param camera The camera that the post-process will be attached to
  127900. * @param mesh The mesh used to create the light scattering
  127901. * @param samples The post-process quality, default 100
  127902. * @param samplingModeThe post-process filtering mode
  127903. * @param engine The babylon engine
  127904. * @param reusable If the post-process is reusable
  127905. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  127906. */
  127907. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  127908. /**
  127909. * Returns the string "VolumetricLightScatteringPostProcess"
  127910. * @returns "VolumetricLightScatteringPostProcess"
  127911. */
  127912. getClassName(): string;
  127913. private _isReady;
  127914. /**
  127915. * Sets the new light position for light scattering effect
  127916. * @param position The new custom light position
  127917. */
  127918. setCustomMeshPosition(position: Vector3): void;
  127919. /**
  127920. * Returns the light position for light scattering effect
  127921. * @return Vector3 The custom light position
  127922. */
  127923. getCustomMeshPosition(): Vector3;
  127924. /**
  127925. * Disposes the internal assets and detaches the post-process from the camera
  127926. */
  127927. dispose(camera: Camera): void;
  127928. /**
  127929. * Returns the render target texture used by the post-process
  127930. * @return the render target texture used by the post-process
  127931. */
  127932. getPass(): RenderTargetTexture;
  127933. private _meshExcluded;
  127934. private _createPass;
  127935. private _updateMeshScreenCoordinates;
  127936. /**
  127937. * Creates a default mesh for the Volumeric Light Scattering post-process
  127938. * @param name The mesh name
  127939. * @param scene The scene where to create the mesh
  127940. * @return the default mesh
  127941. */
  127942. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  127943. }
  127944. }
  127945. declare module BABYLON {
  127946. interface Scene {
  127947. /** @hidden (Backing field) */
  127948. _boundingBoxRenderer: BoundingBoxRenderer;
  127949. /** @hidden (Backing field) */
  127950. _forceShowBoundingBoxes: boolean;
  127951. /**
  127952. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  127953. */
  127954. forceShowBoundingBoxes: boolean;
  127955. /**
  127956. * Gets the bounding box renderer associated with the scene
  127957. * @returns a BoundingBoxRenderer
  127958. */
  127959. getBoundingBoxRenderer(): BoundingBoxRenderer;
  127960. }
  127961. interface AbstractMesh {
  127962. /** @hidden (Backing field) */
  127963. _showBoundingBox: boolean;
  127964. /**
  127965. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  127966. */
  127967. showBoundingBox: boolean;
  127968. }
  127969. /**
  127970. * Component responsible of rendering the bounding box of the meshes in a scene.
  127971. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  127972. */
  127973. export class BoundingBoxRenderer implements ISceneComponent {
  127974. /**
  127975. * The component name helpfull to identify the component in the list of scene components.
  127976. */
  127977. readonly name: string;
  127978. /**
  127979. * The scene the component belongs to.
  127980. */
  127981. scene: Scene;
  127982. /**
  127983. * Color of the bounding box lines placed in front of an object
  127984. */
  127985. frontColor: Color3;
  127986. /**
  127987. * Color of the bounding box lines placed behind an object
  127988. */
  127989. backColor: Color3;
  127990. /**
  127991. * Defines if the renderer should show the back lines or not
  127992. */
  127993. showBackLines: boolean;
  127994. /**
  127995. * @hidden
  127996. */
  127997. renderList: SmartArray<BoundingBox>;
  127998. private _colorShader;
  127999. private _vertexBuffers;
  128000. private _indexBuffer;
  128001. private _fillIndexBuffer;
  128002. private _fillIndexData;
  128003. /**
  128004. * Instantiates a new bounding box renderer in a scene.
  128005. * @param scene the scene the renderer renders in
  128006. */
  128007. constructor(scene: Scene);
  128008. /**
  128009. * Registers the component in a given scene
  128010. */
  128011. register(): void;
  128012. private _evaluateSubMesh;
  128013. private _activeMesh;
  128014. private _prepareRessources;
  128015. private _createIndexBuffer;
  128016. /**
  128017. * Rebuilds the elements related to this component in case of
  128018. * context lost for instance.
  128019. */
  128020. rebuild(): void;
  128021. /**
  128022. * @hidden
  128023. */
  128024. reset(): void;
  128025. /**
  128026. * Render the bounding boxes of a specific rendering group
  128027. * @param renderingGroupId defines the rendering group to render
  128028. */
  128029. render(renderingGroupId: number): void;
  128030. /**
  128031. * In case of occlusion queries, we can render the occlusion bounding box through this method
  128032. * @param mesh Define the mesh to render the occlusion bounding box for
  128033. */
  128034. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  128035. /**
  128036. * Dispose and release the resources attached to this renderer.
  128037. */
  128038. dispose(): void;
  128039. }
  128040. }
  128041. declare module BABYLON {
  128042. /** @hidden */
  128043. export var depthPixelShader: {
  128044. name: string;
  128045. shader: string;
  128046. };
  128047. }
  128048. declare module BABYLON {
  128049. /**
  128050. * This represents a depth renderer in Babylon.
  128051. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  128052. */
  128053. export class DepthRenderer {
  128054. private _scene;
  128055. private _depthMap;
  128056. private _effect;
  128057. private readonly _storeNonLinearDepth;
  128058. private readonly _clearColor;
  128059. /** Get if the depth renderer is using packed depth or not */
  128060. readonly isPacked: boolean;
  128061. private _cachedDefines;
  128062. private _camera;
  128063. /**
  128064. * Specifiess that the depth renderer will only be used within
  128065. * the camera it is created for.
  128066. * This can help forcing its rendering during the camera processing.
  128067. */
  128068. useOnlyInActiveCamera: boolean;
  128069. /** @hidden */
  128070. static _SceneComponentInitialization: (scene: Scene) => void;
  128071. /**
  128072. * Instantiates a depth renderer
  128073. * @param scene The scene the renderer belongs to
  128074. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  128075. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  128076. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  128077. */
  128078. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  128079. /**
  128080. * Creates the depth rendering effect and checks if the effect is ready.
  128081. * @param subMesh The submesh to be used to render the depth map of
  128082. * @param useInstances If multiple world instances should be used
  128083. * @returns if the depth renderer is ready to render the depth map
  128084. */
  128085. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  128086. /**
  128087. * Gets the texture which the depth map will be written to.
  128088. * @returns The depth map texture
  128089. */
  128090. getDepthMap(): RenderTargetTexture;
  128091. /**
  128092. * Disposes of the depth renderer.
  128093. */
  128094. dispose(): void;
  128095. }
  128096. }
  128097. declare module BABYLON {
  128098. interface Scene {
  128099. /** @hidden (Backing field) */
  128100. _depthRenderer: {
  128101. [id: string]: DepthRenderer;
  128102. };
  128103. /**
  128104. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  128105. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  128106. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  128107. * @returns the created depth renderer
  128108. */
  128109. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  128110. /**
  128111. * Disables a depth renderer for a given camera
  128112. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  128113. */
  128114. disableDepthRenderer(camera?: Nullable<Camera>): void;
  128115. }
  128116. /**
  128117. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  128118. * in several rendering techniques.
  128119. */
  128120. export class DepthRendererSceneComponent implements ISceneComponent {
  128121. /**
  128122. * The component name helpfull to identify the component in the list of scene components.
  128123. */
  128124. readonly name: string;
  128125. /**
  128126. * The scene the component belongs to.
  128127. */
  128128. scene: Scene;
  128129. /**
  128130. * Creates a new instance of the component for the given scene
  128131. * @param scene Defines the scene to register the component in
  128132. */
  128133. constructor(scene: Scene);
  128134. /**
  128135. * Registers the component in a given scene
  128136. */
  128137. register(): void;
  128138. /**
  128139. * Rebuilds the elements related to this component in case of
  128140. * context lost for instance.
  128141. */
  128142. rebuild(): void;
  128143. /**
  128144. * Disposes the component and the associated ressources
  128145. */
  128146. dispose(): void;
  128147. private _gatherRenderTargets;
  128148. private _gatherActiveCameraRenderTargets;
  128149. }
  128150. }
  128151. declare module BABYLON {
  128152. /** @hidden */
  128153. export var outlinePixelShader: {
  128154. name: string;
  128155. shader: string;
  128156. };
  128157. }
  128158. declare module BABYLON {
  128159. /** @hidden */
  128160. export var outlineVertexShader: {
  128161. name: string;
  128162. shader: string;
  128163. };
  128164. }
  128165. declare module BABYLON {
  128166. interface Scene {
  128167. /** @hidden */
  128168. _outlineRenderer: OutlineRenderer;
  128169. /**
  128170. * Gets the outline renderer associated with the scene
  128171. * @returns a OutlineRenderer
  128172. */
  128173. getOutlineRenderer(): OutlineRenderer;
  128174. }
  128175. interface AbstractMesh {
  128176. /** @hidden (Backing field) */
  128177. _renderOutline: boolean;
  128178. /**
  128179. * Gets or sets a boolean indicating if the outline must be rendered as well
  128180. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  128181. */
  128182. renderOutline: boolean;
  128183. /** @hidden (Backing field) */
  128184. _renderOverlay: boolean;
  128185. /**
  128186. * Gets or sets a boolean indicating if the overlay must be rendered as well
  128187. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  128188. */
  128189. renderOverlay: boolean;
  128190. }
  128191. /**
  128192. * This class is responsible to draw bothe outline/overlay of meshes.
  128193. * It should not be used directly but through the available method on mesh.
  128194. */
  128195. export class OutlineRenderer implements ISceneComponent {
  128196. /**
  128197. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  128198. */
  128199. private static _StencilReference;
  128200. /**
  128201. * The name of the component. Each component must have a unique name.
  128202. */
  128203. name: string;
  128204. /**
  128205. * The scene the component belongs to.
  128206. */
  128207. scene: Scene;
  128208. /**
  128209. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  128210. */
  128211. zOffset: number;
  128212. private _engine;
  128213. private _effect;
  128214. private _cachedDefines;
  128215. private _savedDepthWrite;
  128216. /**
  128217. * Instantiates a new outline renderer. (There could be only one per scene).
  128218. * @param scene Defines the scene it belongs to
  128219. */
  128220. constructor(scene: Scene);
  128221. /**
  128222. * Register the component to one instance of a scene.
  128223. */
  128224. register(): void;
  128225. /**
  128226. * Rebuilds the elements related to this component in case of
  128227. * context lost for instance.
  128228. */
  128229. rebuild(): void;
  128230. /**
  128231. * Disposes the component and the associated ressources.
  128232. */
  128233. dispose(): void;
  128234. /**
  128235. * Renders the outline in the canvas.
  128236. * @param subMesh Defines the sumesh to render
  128237. * @param batch Defines the batch of meshes in case of instances
  128238. * @param useOverlay Defines if the rendering is for the overlay or the outline
  128239. */
  128240. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  128241. /**
  128242. * Returns whether or not the outline renderer is ready for a given submesh.
  128243. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  128244. * @param subMesh Defines the submesh to check readyness for
  128245. * @param useInstances Defines wheter wee are trying to render instances or not
  128246. * @returns true if ready otherwise false
  128247. */
  128248. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  128249. private _beforeRenderingMesh;
  128250. private _afterRenderingMesh;
  128251. }
  128252. }
  128253. declare module BABYLON {
  128254. /**
  128255. * Class used to manage multiple sprites of different sizes on the same spritesheet
  128256. * @see http://doc.babylonjs.com/babylon101/sprites
  128257. */
  128258. export class SpritePackedManager extends SpriteManager {
  128259. /** defines the packed manager's name */
  128260. name: string;
  128261. /**
  128262. * Creates a new sprite manager from a packed sprite sheet
  128263. * @param name defines the manager's name
  128264. * @param imgUrl defines the sprite sheet url
  128265. * @param capacity defines the maximum allowed number of sprites
  128266. * @param scene defines the hosting scene
  128267. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  128268. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  128269. * @param samplingMode defines the smapling mode to use with spritesheet
  128270. * @param fromPacked set to true; do not alter
  128271. */
  128272. constructor(
  128273. /** defines the packed manager's name */
  128274. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  128275. }
  128276. }
  128277. declare module BABYLON {
  128278. /**
  128279. * Defines the list of states available for a task inside a AssetsManager
  128280. */
  128281. export enum AssetTaskState {
  128282. /**
  128283. * Initialization
  128284. */
  128285. INIT = 0,
  128286. /**
  128287. * Running
  128288. */
  128289. RUNNING = 1,
  128290. /**
  128291. * Done
  128292. */
  128293. DONE = 2,
  128294. /**
  128295. * Error
  128296. */
  128297. ERROR = 3
  128298. }
  128299. /**
  128300. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  128301. */
  128302. export abstract class AbstractAssetTask {
  128303. /**
  128304. * Task name
  128305. */ name: string;
  128306. /**
  128307. * Callback called when the task is successful
  128308. */
  128309. onSuccess: (task: any) => void;
  128310. /**
  128311. * Callback called when the task is not successful
  128312. */
  128313. onError: (task: any, message?: string, exception?: any) => void;
  128314. /**
  128315. * Creates a new AssetsManager
  128316. * @param name defines the name of the task
  128317. */
  128318. constructor(
  128319. /**
  128320. * Task name
  128321. */ name: string);
  128322. private _isCompleted;
  128323. private _taskState;
  128324. private _errorObject;
  128325. /**
  128326. * Get if the task is completed
  128327. */
  128328. readonly isCompleted: boolean;
  128329. /**
  128330. * Gets the current state of the task
  128331. */
  128332. readonly taskState: AssetTaskState;
  128333. /**
  128334. * Gets the current error object (if task is in error)
  128335. */
  128336. readonly errorObject: {
  128337. message?: string;
  128338. exception?: any;
  128339. };
  128340. /**
  128341. * Internal only
  128342. * @hidden
  128343. */
  128344. _setErrorObject(message?: string, exception?: any): void;
  128345. /**
  128346. * Execute the current task
  128347. * @param scene defines the scene where you want your assets to be loaded
  128348. * @param onSuccess is a callback called when the task is successfully executed
  128349. * @param onError is a callback called if an error occurs
  128350. */
  128351. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128352. /**
  128353. * Execute the current task
  128354. * @param scene defines the scene where you want your assets to be loaded
  128355. * @param onSuccess is a callback called when the task is successfully executed
  128356. * @param onError is a callback called if an error occurs
  128357. */
  128358. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128359. /**
  128360. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  128361. * This can be used with failed tasks that have the reason for failure fixed.
  128362. */
  128363. reset(): void;
  128364. private onErrorCallback;
  128365. private onDoneCallback;
  128366. }
  128367. /**
  128368. * Define the interface used by progress events raised during assets loading
  128369. */
  128370. export interface IAssetsProgressEvent {
  128371. /**
  128372. * Defines the number of remaining tasks to process
  128373. */
  128374. remainingCount: number;
  128375. /**
  128376. * Defines the total number of tasks
  128377. */
  128378. totalCount: number;
  128379. /**
  128380. * Defines the task that was just processed
  128381. */
  128382. task: AbstractAssetTask;
  128383. }
  128384. /**
  128385. * Class used to share progress information about assets loading
  128386. */
  128387. export class AssetsProgressEvent implements IAssetsProgressEvent {
  128388. /**
  128389. * Defines the number of remaining tasks to process
  128390. */
  128391. remainingCount: number;
  128392. /**
  128393. * Defines the total number of tasks
  128394. */
  128395. totalCount: number;
  128396. /**
  128397. * Defines the task that was just processed
  128398. */
  128399. task: AbstractAssetTask;
  128400. /**
  128401. * Creates a AssetsProgressEvent
  128402. * @param remainingCount defines the number of remaining tasks to process
  128403. * @param totalCount defines the total number of tasks
  128404. * @param task defines the task that was just processed
  128405. */
  128406. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  128407. }
  128408. /**
  128409. * Define a task used by AssetsManager to load meshes
  128410. */
  128411. export class MeshAssetTask extends AbstractAssetTask {
  128412. /**
  128413. * Defines the name of the task
  128414. */
  128415. name: string;
  128416. /**
  128417. * Defines the list of mesh's names you want to load
  128418. */
  128419. meshesNames: any;
  128420. /**
  128421. * Defines the root url to use as a base to load your meshes and associated resources
  128422. */
  128423. rootUrl: string;
  128424. /**
  128425. * Defines the filename of the scene to load from
  128426. */
  128427. sceneFilename: string;
  128428. /**
  128429. * Gets the list of loaded meshes
  128430. */
  128431. loadedMeshes: Array<AbstractMesh>;
  128432. /**
  128433. * Gets the list of loaded particle systems
  128434. */
  128435. loadedParticleSystems: Array<IParticleSystem>;
  128436. /**
  128437. * Gets the list of loaded skeletons
  128438. */
  128439. loadedSkeletons: Array<Skeleton>;
  128440. /**
  128441. * Gets the list of loaded animation groups
  128442. */
  128443. loadedAnimationGroups: Array<AnimationGroup>;
  128444. /**
  128445. * Callback called when the task is successful
  128446. */
  128447. onSuccess: (task: MeshAssetTask) => void;
  128448. /**
  128449. * Callback called when the task is successful
  128450. */
  128451. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  128452. /**
  128453. * Creates a new MeshAssetTask
  128454. * @param name defines the name of the task
  128455. * @param meshesNames defines the list of mesh's names you want to load
  128456. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  128457. * @param sceneFilename defines the filename of the scene to load from
  128458. */
  128459. constructor(
  128460. /**
  128461. * Defines the name of the task
  128462. */
  128463. name: string,
  128464. /**
  128465. * Defines the list of mesh's names you want to load
  128466. */
  128467. meshesNames: any,
  128468. /**
  128469. * Defines the root url to use as a base to load your meshes and associated resources
  128470. */
  128471. rootUrl: string,
  128472. /**
  128473. * Defines the filename of the scene to load from
  128474. */
  128475. sceneFilename: string);
  128476. /**
  128477. * Execute the current task
  128478. * @param scene defines the scene where you want your assets to be loaded
  128479. * @param onSuccess is a callback called when the task is successfully executed
  128480. * @param onError is a callback called if an error occurs
  128481. */
  128482. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128483. }
  128484. /**
  128485. * Define a task used by AssetsManager to load text content
  128486. */
  128487. export class TextFileAssetTask extends AbstractAssetTask {
  128488. /**
  128489. * Defines the name of the task
  128490. */
  128491. name: string;
  128492. /**
  128493. * Defines the location of the file to load
  128494. */
  128495. url: string;
  128496. /**
  128497. * Gets the loaded text string
  128498. */
  128499. text: string;
  128500. /**
  128501. * Callback called when the task is successful
  128502. */
  128503. onSuccess: (task: TextFileAssetTask) => void;
  128504. /**
  128505. * Callback called when the task is successful
  128506. */
  128507. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  128508. /**
  128509. * Creates a new TextFileAssetTask object
  128510. * @param name defines the name of the task
  128511. * @param url defines the location of the file to load
  128512. */
  128513. constructor(
  128514. /**
  128515. * Defines the name of the task
  128516. */
  128517. name: string,
  128518. /**
  128519. * Defines the location of the file to load
  128520. */
  128521. url: string);
  128522. /**
  128523. * Execute the current task
  128524. * @param scene defines the scene where you want your assets to be loaded
  128525. * @param onSuccess is a callback called when the task is successfully executed
  128526. * @param onError is a callback called if an error occurs
  128527. */
  128528. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128529. }
  128530. /**
  128531. * Define a task used by AssetsManager to load binary data
  128532. */
  128533. export class BinaryFileAssetTask extends AbstractAssetTask {
  128534. /**
  128535. * Defines the name of the task
  128536. */
  128537. name: string;
  128538. /**
  128539. * Defines the location of the file to load
  128540. */
  128541. url: string;
  128542. /**
  128543. * Gets the lodaded data (as an array buffer)
  128544. */
  128545. data: ArrayBuffer;
  128546. /**
  128547. * Callback called when the task is successful
  128548. */
  128549. onSuccess: (task: BinaryFileAssetTask) => void;
  128550. /**
  128551. * Callback called when the task is successful
  128552. */
  128553. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  128554. /**
  128555. * Creates a new BinaryFileAssetTask object
  128556. * @param name defines the name of the new task
  128557. * @param url defines the location of the file to load
  128558. */
  128559. constructor(
  128560. /**
  128561. * Defines the name of the task
  128562. */
  128563. name: string,
  128564. /**
  128565. * Defines the location of the file to load
  128566. */
  128567. url: string);
  128568. /**
  128569. * Execute the current task
  128570. * @param scene defines the scene where you want your assets to be loaded
  128571. * @param onSuccess is a callback called when the task is successfully executed
  128572. * @param onError is a callback called if an error occurs
  128573. */
  128574. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128575. }
  128576. /**
  128577. * Define a task used by AssetsManager to load images
  128578. */
  128579. export class ImageAssetTask extends AbstractAssetTask {
  128580. /**
  128581. * Defines the name of the task
  128582. */
  128583. name: string;
  128584. /**
  128585. * Defines the location of the image to load
  128586. */
  128587. url: string;
  128588. /**
  128589. * Gets the loaded images
  128590. */
  128591. image: HTMLImageElement;
  128592. /**
  128593. * Callback called when the task is successful
  128594. */
  128595. onSuccess: (task: ImageAssetTask) => void;
  128596. /**
  128597. * Callback called when the task is successful
  128598. */
  128599. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  128600. /**
  128601. * Creates a new ImageAssetTask
  128602. * @param name defines the name of the task
  128603. * @param url defines the location of the image to load
  128604. */
  128605. constructor(
  128606. /**
  128607. * Defines the name of the task
  128608. */
  128609. name: string,
  128610. /**
  128611. * Defines the location of the image to load
  128612. */
  128613. url: string);
  128614. /**
  128615. * Execute the current task
  128616. * @param scene defines the scene where you want your assets to be loaded
  128617. * @param onSuccess is a callback called when the task is successfully executed
  128618. * @param onError is a callback called if an error occurs
  128619. */
  128620. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128621. }
  128622. /**
  128623. * Defines the interface used by texture loading tasks
  128624. */
  128625. export interface ITextureAssetTask<TEX extends BaseTexture> {
  128626. /**
  128627. * Gets the loaded texture
  128628. */
  128629. texture: TEX;
  128630. }
  128631. /**
  128632. * Define a task used by AssetsManager to load 2D textures
  128633. */
  128634. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  128635. /**
  128636. * Defines the name of the task
  128637. */
  128638. name: string;
  128639. /**
  128640. * Defines the location of the file to load
  128641. */
  128642. url: string;
  128643. /**
  128644. * Defines if mipmap should not be generated (default is false)
  128645. */
  128646. noMipmap?: boolean | undefined;
  128647. /**
  128648. * Defines if texture must be inverted on Y axis (default is false)
  128649. */
  128650. invertY?: boolean | undefined;
  128651. /**
  128652. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  128653. */
  128654. samplingMode: number;
  128655. /**
  128656. * Gets the loaded texture
  128657. */
  128658. texture: Texture;
  128659. /**
  128660. * Callback called when the task is successful
  128661. */
  128662. onSuccess: (task: TextureAssetTask) => void;
  128663. /**
  128664. * Callback called when the task is successful
  128665. */
  128666. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  128667. /**
  128668. * Creates a new TextureAssetTask object
  128669. * @param name defines the name of the task
  128670. * @param url defines the location of the file to load
  128671. * @param noMipmap defines if mipmap should not be generated (default is false)
  128672. * @param invertY defines if texture must be inverted on Y axis (default is false)
  128673. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  128674. */
  128675. constructor(
  128676. /**
  128677. * Defines the name of the task
  128678. */
  128679. name: string,
  128680. /**
  128681. * Defines the location of the file to load
  128682. */
  128683. url: string,
  128684. /**
  128685. * Defines if mipmap should not be generated (default is false)
  128686. */
  128687. noMipmap?: boolean | undefined,
  128688. /**
  128689. * Defines if texture must be inverted on Y axis (default is false)
  128690. */
  128691. invertY?: boolean | undefined,
  128692. /**
  128693. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  128694. */
  128695. samplingMode?: number);
  128696. /**
  128697. * Execute the current task
  128698. * @param scene defines the scene where you want your assets to be loaded
  128699. * @param onSuccess is a callback called when the task is successfully executed
  128700. * @param onError is a callback called if an error occurs
  128701. */
  128702. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128703. }
  128704. /**
  128705. * Define a task used by AssetsManager to load cube textures
  128706. */
  128707. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  128708. /**
  128709. * Defines the name of the task
  128710. */
  128711. name: string;
  128712. /**
  128713. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  128714. */
  128715. url: string;
  128716. /**
  128717. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  128718. */
  128719. extensions?: string[] | undefined;
  128720. /**
  128721. * Defines if mipmaps should not be generated (default is false)
  128722. */
  128723. noMipmap?: boolean | undefined;
  128724. /**
  128725. * Defines the explicit list of files (undefined by default)
  128726. */
  128727. files?: string[] | undefined;
  128728. /**
  128729. * Gets the loaded texture
  128730. */
  128731. texture: CubeTexture;
  128732. /**
  128733. * Callback called when the task is successful
  128734. */
  128735. onSuccess: (task: CubeTextureAssetTask) => void;
  128736. /**
  128737. * Callback called when the task is successful
  128738. */
  128739. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  128740. /**
  128741. * Creates a new CubeTextureAssetTask
  128742. * @param name defines the name of the task
  128743. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  128744. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  128745. * @param noMipmap defines if mipmaps should not be generated (default is false)
  128746. * @param files defines the explicit list of files (undefined by default)
  128747. */
  128748. constructor(
  128749. /**
  128750. * Defines the name of the task
  128751. */
  128752. name: string,
  128753. /**
  128754. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  128755. */
  128756. url: string,
  128757. /**
  128758. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  128759. */
  128760. extensions?: string[] | undefined,
  128761. /**
  128762. * Defines if mipmaps should not be generated (default is false)
  128763. */
  128764. noMipmap?: boolean | undefined,
  128765. /**
  128766. * Defines the explicit list of files (undefined by default)
  128767. */
  128768. files?: string[] | undefined);
  128769. /**
  128770. * Execute the current task
  128771. * @param scene defines the scene where you want your assets to be loaded
  128772. * @param onSuccess is a callback called when the task is successfully executed
  128773. * @param onError is a callback called if an error occurs
  128774. */
  128775. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128776. }
  128777. /**
  128778. * Define a task used by AssetsManager to load HDR cube textures
  128779. */
  128780. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  128781. /**
  128782. * Defines the name of the task
  128783. */
  128784. name: string;
  128785. /**
  128786. * Defines the location of the file to load
  128787. */
  128788. url: string;
  128789. /**
  128790. * Defines the desired size (the more it increases the longer the generation will be)
  128791. */
  128792. size: number;
  128793. /**
  128794. * Defines if mipmaps should not be generated (default is false)
  128795. */
  128796. noMipmap: boolean;
  128797. /**
  128798. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  128799. */
  128800. generateHarmonics: boolean;
  128801. /**
  128802. * 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)
  128803. */
  128804. gammaSpace: boolean;
  128805. /**
  128806. * Internal Use Only
  128807. */
  128808. reserved: boolean;
  128809. /**
  128810. * Gets the loaded texture
  128811. */
  128812. texture: HDRCubeTexture;
  128813. /**
  128814. * Callback called when the task is successful
  128815. */
  128816. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  128817. /**
  128818. * Callback called when the task is successful
  128819. */
  128820. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  128821. /**
  128822. * Creates a new HDRCubeTextureAssetTask object
  128823. * @param name defines the name of the task
  128824. * @param url defines the location of the file to load
  128825. * @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.
  128826. * @param noMipmap defines if mipmaps should not be generated (default is false)
  128827. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  128828. * @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)
  128829. * @param reserved Internal use only
  128830. */
  128831. constructor(
  128832. /**
  128833. * Defines the name of the task
  128834. */
  128835. name: string,
  128836. /**
  128837. * Defines the location of the file to load
  128838. */
  128839. url: string,
  128840. /**
  128841. * Defines the desired size (the more it increases the longer the generation will be)
  128842. */
  128843. size: number,
  128844. /**
  128845. * Defines if mipmaps should not be generated (default is false)
  128846. */
  128847. noMipmap?: boolean,
  128848. /**
  128849. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  128850. */
  128851. generateHarmonics?: boolean,
  128852. /**
  128853. * 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)
  128854. */
  128855. gammaSpace?: boolean,
  128856. /**
  128857. * Internal Use Only
  128858. */
  128859. reserved?: boolean);
  128860. /**
  128861. * Execute the current task
  128862. * @param scene defines the scene where you want your assets to be loaded
  128863. * @param onSuccess is a callback called when the task is successfully executed
  128864. * @param onError is a callback called if an error occurs
  128865. */
  128866. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128867. }
  128868. /**
  128869. * Define a task used by AssetsManager to load Equirectangular cube textures
  128870. */
  128871. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  128872. /**
  128873. * Defines the name of the task
  128874. */
  128875. name: string;
  128876. /**
  128877. * Defines the location of the file to load
  128878. */
  128879. url: string;
  128880. /**
  128881. * Defines the desired size (the more it increases the longer the generation will be)
  128882. */
  128883. size: number;
  128884. /**
  128885. * Defines if mipmaps should not be generated (default is false)
  128886. */
  128887. noMipmap: boolean;
  128888. /**
  128889. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  128890. * but the standard material would require them in Gamma space) (default is true)
  128891. */
  128892. gammaSpace: boolean;
  128893. /**
  128894. * Gets the loaded texture
  128895. */
  128896. texture: EquiRectangularCubeTexture;
  128897. /**
  128898. * Callback called when the task is successful
  128899. */
  128900. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  128901. /**
  128902. * Callback called when the task is successful
  128903. */
  128904. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  128905. /**
  128906. * Creates a new EquiRectangularCubeTextureAssetTask object
  128907. * @param name defines the name of the task
  128908. * @param url defines the location of the file to load
  128909. * @param size defines the desired size (the more it increases the longer the generation will be)
  128910. * If the size is omitted this implies you are using a preprocessed cubemap.
  128911. * @param noMipmap defines if mipmaps should not be generated (default is false)
  128912. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  128913. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  128914. * (default is true)
  128915. */
  128916. constructor(
  128917. /**
  128918. * Defines the name of the task
  128919. */
  128920. name: string,
  128921. /**
  128922. * Defines the location of the file to load
  128923. */
  128924. url: string,
  128925. /**
  128926. * Defines the desired size (the more it increases the longer the generation will be)
  128927. */
  128928. size: number,
  128929. /**
  128930. * Defines if mipmaps should not be generated (default is false)
  128931. */
  128932. noMipmap?: boolean,
  128933. /**
  128934. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  128935. * but the standard material would require them in Gamma space) (default is true)
  128936. */
  128937. gammaSpace?: boolean);
  128938. /**
  128939. * Execute the current task
  128940. * @param scene defines the scene where you want your assets to be loaded
  128941. * @param onSuccess is a callback called when the task is successfully executed
  128942. * @param onError is a callback called if an error occurs
  128943. */
  128944. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128945. }
  128946. /**
  128947. * This class can be used to easily import assets into a scene
  128948. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  128949. */
  128950. export class AssetsManager {
  128951. private _scene;
  128952. private _isLoading;
  128953. protected _tasks: AbstractAssetTask[];
  128954. protected _waitingTasksCount: number;
  128955. protected _totalTasksCount: number;
  128956. /**
  128957. * Callback called when all tasks are processed
  128958. */
  128959. onFinish: (tasks: AbstractAssetTask[]) => void;
  128960. /**
  128961. * Callback called when a task is successful
  128962. */
  128963. onTaskSuccess: (task: AbstractAssetTask) => void;
  128964. /**
  128965. * Callback called when a task had an error
  128966. */
  128967. onTaskError: (task: AbstractAssetTask) => void;
  128968. /**
  128969. * Callback called when a task is done (whatever the result is)
  128970. */
  128971. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  128972. /**
  128973. * Observable called when all tasks are processed
  128974. */
  128975. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  128976. /**
  128977. * Observable called when a task had an error
  128978. */
  128979. onTaskErrorObservable: Observable<AbstractAssetTask>;
  128980. /**
  128981. * Observable called when all tasks were executed
  128982. */
  128983. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  128984. /**
  128985. * Observable called when a task is done (whatever the result is)
  128986. */
  128987. onProgressObservable: Observable<IAssetsProgressEvent>;
  128988. /**
  128989. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  128990. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  128991. */
  128992. useDefaultLoadingScreen: boolean;
  128993. /**
  128994. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  128995. * when all assets have been downloaded.
  128996. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  128997. */
  128998. autoHideLoadingUI: boolean;
  128999. /**
  129000. * Creates a new AssetsManager
  129001. * @param scene defines the scene to work on
  129002. */
  129003. constructor(scene: Scene);
  129004. /**
  129005. * Add a MeshAssetTask to the list of active tasks
  129006. * @param taskName defines the name of the new task
  129007. * @param meshesNames defines the name of meshes to load
  129008. * @param rootUrl defines the root url to use to locate files
  129009. * @param sceneFilename defines the filename of the scene file
  129010. * @returns a new MeshAssetTask object
  129011. */
  129012. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  129013. /**
  129014. * Add a TextFileAssetTask to the list of active tasks
  129015. * @param taskName defines the name of the new task
  129016. * @param url defines the url of the file to load
  129017. * @returns a new TextFileAssetTask object
  129018. */
  129019. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  129020. /**
  129021. * Add a BinaryFileAssetTask to the list of active tasks
  129022. * @param taskName defines the name of the new task
  129023. * @param url defines the url of the file to load
  129024. * @returns a new BinaryFileAssetTask object
  129025. */
  129026. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  129027. /**
  129028. * Add a ImageAssetTask to the list of active tasks
  129029. * @param taskName defines the name of the new task
  129030. * @param url defines the url of the file to load
  129031. * @returns a new ImageAssetTask object
  129032. */
  129033. addImageTask(taskName: string, url: string): ImageAssetTask;
  129034. /**
  129035. * Add a TextureAssetTask to the list of active tasks
  129036. * @param taskName defines the name of the new task
  129037. * @param url defines the url of the file to load
  129038. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  129039. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  129040. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  129041. * @returns a new TextureAssetTask object
  129042. */
  129043. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  129044. /**
  129045. * Add a CubeTextureAssetTask to the list of active tasks
  129046. * @param taskName defines the name of the new task
  129047. * @param url defines the url of the file to load
  129048. * @param extensions defines the extension to use to load the cube map (can be null)
  129049. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  129050. * @param files defines the list of files to load (can be null)
  129051. * @returns a new CubeTextureAssetTask object
  129052. */
  129053. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  129054. /**
  129055. *
  129056. * Add a HDRCubeTextureAssetTask to the list of active tasks
  129057. * @param taskName defines the name of the new task
  129058. * @param url defines the url of the file to load
  129059. * @param size defines the size you want for the cubemap (can be null)
  129060. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  129061. * @param generateHarmonics defines if you want to automatically generate (true by default)
  129062. * @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)
  129063. * @param reserved Internal use only
  129064. * @returns a new HDRCubeTextureAssetTask object
  129065. */
  129066. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  129067. /**
  129068. *
  129069. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  129070. * @param taskName defines the name of the new task
  129071. * @param url defines the url of the file to load
  129072. * @param size defines the size you want for the cubemap (can be null)
  129073. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  129074. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  129075. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  129076. * @returns a new EquiRectangularCubeTextureAssetTask object
  129077. */
  129078. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  129079. /**
  129080. * Remove a task from the assets manager.
  129081. * @param task the task to remove
  129082. */
  129083. removeTask(task: AbstractAssetTask): void;
  129084. private _decreaseWaitingTasksCount;
  129085. private _runTask;
  129086. /**
  129087. * Reset the AssetsManager and remove all tasks
  129088. * @return the current instance of the AssetsManager
  129089. */
  129090. reset(): AssetsManager;
  129091. /**
  129092. * Start the loading process
  129093. * @return the current instance of the AssetsManager
  129094. */
  129095. load(): AssetsManager;
  129096. /**
  129097. * Start the loading process as an async operation
  129098. * @return a promise returning the list of failed tasks
  129099. */
  129100. loadAsync(): Promise<void>;
  129101. }
  129102. }
  129103. declare module BABYLON {
  129104. /**
  129105. * Wrapper class for promise with external resolve and reject.
  129106. */
  129107. export class Deferred<T> {
  129108. /**
  129109. * The promise associated with this deferred object.
  129110. */
  129111. readonly promise: Promise<T>;
  129112. private _resolve;
  129113. private _reject;
  129114. /**
  129115. * The resolve method of the promise associated with this deferred object.
  129116. */
  129117. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  129118. /**
  129119. * The reject method of the promise associated with this deferred object.
  129120. */
  129121. readonly reject: (reason?: any) => void;
  129122. /**
  129123. * Constructor for this deferred object.
  129124. */
  129125. constructor();
  129126. }
  129127. }
  129128. declare module BABYLON {
  129129. /**
  129130. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  129131. */
  129132. export class MeshExploder {
  129133. private _centerMesh;
  129134. private _meshes;
  129135. private _meshesOrigins;
  129136. private _toCenterVectors;
  129137. private _scaledDirection;
  129138. private _newPosition;
  129139. private _centerPosition;
  129140. /**
  129141. * Explodes meshes from a center mesh.
  129142. * @param meshes The meshes to explode.
  129143. * @param centerMesh The mesh to be center of explosion.
  129144. */
  129145. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  129146. private _setCenterMesh;
  129147. /**
  129148. * Get class name
  129149. * @returns "MeshExploder"
  129150. */
  129151. getClassName(): string;
  129152. /**
  129153. * "Exploded meshes"
  129154. * @returns Array of meshes with the centerMesh at index 0.
  129155. */
  129156. getMeshes(): Array<Mesh>;
  129157. /**
  129158. * Explodes meshes giving a specific direction
  129159. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  129160. */
  129161. explode(direction?: number): void;
  129162. }
  129163. }
  129164. declare module BABYLON {
  129165. /**
  129166. * Class used to help managing file picking and drag'n'drop
  129167. */
  129168. export class FilesInput {
  129169. /**
  129170. * List of files ready to be loaded
  129171. */
  129172. static readonly FilesToLoad: {
  129173. [key: string]: File;
  129174. };
  129175. /**
  129176. * Callback called when a file is processed
  129177. */
  129178. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  129179. private _engine;
  129180. private _currentScene;
  129181. private _sceneLoadedCallback;
  129182. private _progressCallback;
  129183. private _additionalRenderLoopLogicCallback;
  129184. private _textureLoadingCallback;
  129185. private _startingProcessingFilesCallback;
  129186. private _onReloadCallback;
  129187. private _errorCallback;
  129188. private _elementToMonitor;
  129189. private _sceneFileToLoad;
  129190. private _filesToLoad;
  129191. /**
  129192. * Creates a new FilesInput
  129193. * @param engine defines the rendering engine
  129194. * @param scene defines the hosting scene
  129195. * @param sceneLoadedCallback callback called when scene is loaded
  129196. * @param progressCallback callback called to track progress
  129197. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  129198. * @param textureLoadingCallback callback called when a texture is loading
  129199. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  129200. * @param onReloadCallback callback called when a reload is requested
  129201. * @param errorCallback callback call if an error occurs
  129202. */
  129203. 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);
  129204. private _dragEnterHandler;
  129205. private _dragOverHandler;
  129206. private _dropHandler;
  129207. /**
  129208. * Calls this function to listen to drag'n'drop events on a specific DOM element
  129209. * @param elementToMonitor defines the DOM element to track
  129210. */
  129211. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  129212. /**
  129213. * Release all associated resources
  129214. */
  129215. dispose(): void;
  129216. private renderFunction;
  129217. private drag;
  129218. private drop;
  129219. private _traverseFolder;
  129220. private _processFiles;
  129221. /**
  129222. * Load files from a drop event
  129223. * @param event defines the drop event to use as source
  129224. */
  129225. loadFiles(event: any): void;
  129226. private _processReload;
  129227. /**
  129228. * Reload the current scene from the loaded files
  129229. */
  129230. reload(): void;
  129231. }
  129232. }
  129233. declare module BABYLON {
  129234. /**
  129235. * Defines the root class used to create scene optimization to use with SceneOptimizer
  129236. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129237. */
  129238. export class SceneOptimization {
  129239. /**
  129240. * Defines the priority of this optimization (0 by default which means first in the list)
  129241. */
  129242. priority: number;
  129243. /**
  129244. * Gets a string describing the action executed by the current optimization
  129245. * @returns description string
  129246. */
  129247. getDescription(): string;
  129248. /**
  129249. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129250. * @param scene defines the current scene where to apply this optimization
  129251. * @param optimizer defines the current optimizer
  129252. * @returns true if everything that can be done was applied
  129253. */
  129254. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129255. /**
  129256. * Creates the SceneOptimization object
  129257. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  129258. * @param desc defines the description associated with the optimization
  129259. */
  129260. constructor(
  129261. /**
  129262. * Defines the priority of this optimization (0 by default which means first in the list)
  129263. */
  129264. priority?: number);
  129265. }
  129266. /**
  129267. * Defines an optimization used to reduce the size of render target textures
  129268. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129269. */
  129270. export class TextureOptimization extends SceneOptimization {
  129271. /**
  129272. * Defines the priority of this optimization (0 by default which means first in the list)
  129273. */
  129274. priority: number;
  129275. /**
  129276. * 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
  129277. */
  129278. maximumSize: number;
  129279. /**
  129280. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  129281. */
  129282. step: number;
  129283. /**
  129284. * Gets a string describing the action executed by the current optimization
  129285. * @returns description string
  129286. */
  129287. getDescription(): string;
  129288. /**
  129289. * Creates the TextureOptimization object
  129290. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  129291. * @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
  129292. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  129293. */
  129294. constructor(
  129295. /**
  129296. * Defines the priority of this optimization (0 by default which means first in the list)
  129297. */
  129298. priority?: number,
  129299. /**
  129300. * 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
  129301. */
  129302. maximumSize?: number,
  129303. /**
  129304. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  129305. */
  129306. step?: number);
  129307. /**
  129308. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129309. * @param scene defines the current scene where to apply this optimization
  129310. * @param optimizer defines the current optimizer
  129311. * @returns true if everything that can be done was applied
  129312. */
  129313. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129314. }
  129315. /**
  129316. * Defines an optimization used to increase or decrease the rendering resolution
  129317. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129318. */
  129319. export class HardwareScalingOptimization extends SceneOptimization {
  129320. /**
  129321. * Defines the priority of this optimization (0 by default which means first in the list)
  129322. */
  129323. priority: number;
  129324. /**
  129325. * Defines the maximum scale to use (2 by default)
  129326. */
  129327. maximumScale: number;
  129328. /**
  129329. * Defines the step to use between two passes (0.5 by default)
  129330. */
  129331. step: number;
  129332. private _currentScale;
  129333. private _directionOffset;
  129334. /**
  129335. * Gets a string describing the action executed by the current optimization
  129336. * @return description string
  129337. */
  129338. getDescription(): string;
  129339. /**
  129340. * Creates the HardwareScalingOptimization object
  129341. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  129342. * @param maximumScale defines the maximum scale to use (2 by default)
  129343. * @param step defines the step to use between two passes (0.5 by default)
  129344. */
  129345. constructor(
  129346. /**
  129347. * Defines the priority of this optimization (0 by default which means first in the list)
  129348. */
  129349. priority?: number,
  129350. /**
  129351. * Defines the maximum scale to use (2 by default)
  129352. */
  129353. maximumScale?: number,
  129354. /**
  129355. * Defines the step to use between two passes (0.5 by default)
  129356. */
  129357. step?: number);
  129358. /**
  129359. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129360. * @param scene defines the current scene where to apply this optimization
  129361. * @param optimizer defines the current optimizer
  129362. * @returns true if everything that can be done was applied
  129363. */
  129364. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129365. }
  129366. /**
  129367. * Defines an optimization used to remove shadows
  129368. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129369. */
  129370. export class ShadowsOptimization extends SceneOptimization {
  129371. /**
  129372. * Gets a string describing the action executed by the current optimization
  129373. * @return description string
  129374. */
  129375. getDescription(): string;
  129376. /**
  129377. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129378. * @param scene defines the current scene where to apply this optimization
  129379. * @param optimizer defines the current optimizer
  129380. * @returns true if everything that can be done was applied
  129381. */
  129382. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129383. }
  129384. /**
  129385. * Defines an optimization used to turn post-processes off
  129386. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129387. */
  129388. export class PostProcessesOptimization extends SceneOptimization {
  129389. /**
  129390. * Gets a string describing the action executed by the current optimization
  129391. * @return description string
  129392. */
  129393. getDescription(): string;
  129394. /**
  129395. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129396. * @param scene defines the current scene where to apply this optimization
  129397. * @param optimizer defines the current optimizer
  129398. * @returns true if everything that can be done was applied
  129399. */
  129400. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129401. }
  129402. /**
  129403. * Defines an optimization used to turn lens flares off
  129404. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129405. */
  129406. export class LensFlaresOptimization extends SceneOptimization {
  129407. /**
  129408. * Gets a string describing the action executed by the current optimization
  129409. * @return description string
  129410. */
  129411. getDescription(): string;
  129412. /**
  129413. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129414. * @param scene defines the current scene where to apply this optimization
  129415. * @param optimizer defines the current optimizer
  129416. * @returns true if everything that can be done was applied
  129417. */
  129418. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129419. }
  129420. /**
  129421. * Defines an optimization based on user defined callback.
  129422. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129423. */
  129424. export class CustomOptimization extends SceneOptimization {
  129425. /**
  129426. * Callback called to apply the custom optimization.
  129427. */
  129428. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  129429. /**
  129430. * Callback called to get custom description
  129431. */
  129432. onGetDescription: () => string;
  129433. /**
  129434. * Gets a string describing the action executed by the current optimization
  129435. * @returns description string
  129436. */
  129437. getDescription(): string;
  129438. /**
  129439. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129440. * @param scene defines the current scene where to apply this optimization
  129441. * @param optimizer defines the current optimizer
  129442. * @returns true if everything that can be done was applied
  129443. */
  129444. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129445. }
  129446. /**
  129447. * Defines an optimization used to turn particles off
  129448. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129449. */
  129450. export class ParticlesOptimization extends SceneOptimization {
  129451. /**
  129452. * Gets a string describing the action executed by the current optimization
  129453. * @return description string
  129454. */
  129455. getDescription(): string;
  129456. /**
  129457. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129458. * @param scene defines the current scene where to apply this optimization
  129459. * @param optimizer defines the current optimizer
  129460. * @returns true if everything that can be done was applied
  129461. */
  129462. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129463. }
  129464. /**
  129465. * Defines an optimization used to turn render targets off
  129466. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129467. */
  129468. export class RenderTargetsOptimization extends SceneOptimization {
  129469. /**
  129470. * Gets a string describing the action executed by the current optimization
  129471. * @return description string
  129472. */
  129473. getDescription(): string;
  129474. /**
  129475. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129476. * @param scene defines the current scene where to apply this optimization
  129477. * @param optimizer defines the current optimizer
  129478. * @returns true if everything that can be done was applied
  129479. */
  129480. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129481. }
  129482. /**
  129483. * Defines an optimization used to merge meshes with compatible materials
  129484. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129485. */
  129486. export class MergeMeshesOptimization extends SceneOptimization {
  129487. private static _UpdateSelectionTree;
  129488. /**
  129489. * Gets or sets a boolean which defines if optimization octree has to be updated
  129490. */
  129491. /**
  129492. * Gets or sets a boolean which defines if optimization octree has to be updated
  129493. */
  129494. static UpdateSelectionTree: boolean;
  129495. /**
  129496. * Gets a string describing the action executed by the current optimization
  129497. * @return description string
  129498. */
  129499. getDescription(): string;
  129500. private _canBeMerged;
  129501. /**
  129502. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129503. * @param scene defines the current scene where to apply this optimization
  129504. * @param optimizer defines the current optimizer
  129505. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  129506. * @returns true if everything that can be done was applied
  129507. */
  129508. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  129509. }
  129510. /**
  129511. * Defines a list of options used by SceneOptimizer
  129512. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129513. */
  129514. export class SceneOptimizerOptions {
  129515. /**
  129516. * Defines the target frame rate to reach (60 by default)
  129517. */
  129518. targetFrameRate: number;
  129519. /**
  129520. * Defines the interval between two checkes (2000ms by default)
  129521. */
  129522. trackerDuration: number;
  129523. /**
  129524. * Gets the list of optimizations to apply
  129525. */
  129526. optimizations: SceneOptimization[];
  129527. /**
  129528. * Creates a new list of options used by SceneOptimizer
  129529. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  129530. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  129531. */
  129532. constructor(
  129533. /**
  129534. * Defines the target frame rate to reach (60 by default)
  129535. */
  129536. targetFrameRate?: number,
  129537. /**
  129538. * Defines the interval between two checkes (2000ms by default)
  129539. */
  129540. trackerDuration?: number);
  129541. /**
  129542. * Add a new optimization
  129543. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  129544. * @returns the current SceneOptimizerOptions
  129545. */
  129546. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  129547. /**
  129548. * Add a new custom optimization
  129549. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  129550. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  129551. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  129552. * @returns the current SceneOptimizerOptions
  129553. */
  129554. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  129555. /**
  129556. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  129557. * @param targetFrameRate defines the target frame rate (60 by default)
  129558. * @returns a SceneOptimizerOptions object
  129559. */
  129560. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  129561. /**
  129562. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  129563. * @param targetFrameRate defines the target frame rate (60 by default)
  129564. * @returns a SceneOptimizerOptions object
  129565. */
  129566. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  129567. /**
  129568. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  129569. * @param targetFrameRate defines the target frame rate (60 by default)
  129570. * @returns a SceneOptimizerOptions object
  129571. */
  129572. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  129573. }
  129574. /**
  129575. * Class used to run optimizations in order to reach a target frame rate
  129576. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129577. */
  129578. export class SceneOptimizer implements IDisposable {
  129579. private _isRunning;
  129580. private _options;
  129581. private _scene;
  129582. private _currentPriorityLevel;
  129583. private _targetFrameRate;
  129584. private _trackerDuration;
  129585. private _currentFrameRate;
  129586. private _sceneDisposeObserver;
  129587. private _improvementMode;
  129588. /**
  129589. * Defines an observable called when the optimizer reaches the target frame rate
  129590. */
  129591. onSuccessObservable: Observable<SceneOptimizer>;
  129592. /**
  129593. * Defines an observable called when the optimizer enables an optimization
  129594. */
  129595. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  129596. /**
  129597. * Defines an observable called when the optimizer is not able to reach the target frame rate
  129598. */
  129599. onFailureObservable: Observable<SceneOptimizer>;
  129600. /**
  129601. * Gets a boolean indicating if the optimizer is in improvement mode
  129602. */
  129603. readonly isInImprovementMode: boolean;
  129604. /**
  129605. * Gets the current priority level (0 at start)
  129606. */
  129607. readonly currentPriorityLevel: number;
  129608. /**
  129609. * Gets the current frame rate checked by the SceneOptimizer
  129610. */
  129611. readonly currentFrameRate: number;
  129612. /**
  129613. * Gets or sets the current target frame rate (60 by default)
  129614. */
  129615. /**
  129616. * Gets or sets the current target frame rate (60 by default)
  129617. */
  129618. targetFrameRate: number;
  129619. /**
  129620. * Gets or sets the current interval between two checks (every 2000ms by default)
  129621. */
  129622. /**
  129623. * Gets or sets the current interval between two checks (every 2000ms by default)
  129624. */
  129625. trackerDuration: number;
  129626. /**
  129627. * Gets the list of active optimizations
  129628. */
  129629. readonly optimizations: SceneOptimization[];
  129630. /**
  129631. * Creates a new SceneOptimizer
  129632. * @param scene defines the scene to work on
  129633. * @param options defines the options to use with the SceneOptimizer
  129634. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  129635. * @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)
  129636. */
  129637. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  129638. /**
  129639. * Stops the current optimizer
  129640. */
  129641. stop(): void;
  129642. /**
  129643. * Reset the optimizer to initial step (current priority level = 0)
  129644. */
  129645. reset(): void;
  129646. /**
  129647. * Start the optimizer. By default it will try to reach a specific framerate
  129648. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  129649. */
  129650. start(): void;
  129651. private _checkCurrentState;
  129652. /**
  129653. * Release all resources
  129654. */
  129655. dispose(): void;
  129656. /**
  129657. * Helper function to create a SceneOptimizer with one single line of code
  129658. * @param scene defines the scene to work on
  129659. * @param options defines the options to use with the SceneOptimizer
  129660. * @param onSuccess defines a callback to call on success
  129661. * @param onFailure defines a callback to call on failure
  129662. * @returns the new SceneOptimizer object
  129663. */
  129664. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  129665. }
  129666. }
  129667. declare module BABYLON {
  129668. /**
  129669. * Class used to serialize a scene into a string
  129670. */
  129671. export class SceneSerializer {
  129672. /**
  129673. * Clear cache used by a previous serialization
  129674. */
  129675. static ClearCache(): void;
  129676. /**
  129677. * Serialize a scene into a JSON compatible object
  129678. * @param scene defines the scene to serialize
  129679. * @returns a JSON compatible object
  129680. */
  129681. static Serialize(scene: Scene): any;
  129682. /**
  129683. * Serialize a mesh into a JSON compatible object
  129684. * @param toSerialize defines the mesh to serialize
  129685. * @param withParents defines if parents must be serialized as well
  129686. * @param withChildren defines if children must be serialized as well
  129687. * @returns a JSON compatible object
  129688. */
  129689. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  129690. }
  129691. }
  129692. declare module BABYLON {
  129693. /**
  129694. * Class used to host texture specific utilities
  129695. */
  129696. export class TextureTools {
  129697. /**
  129698. * Uses the GPU to create a copy texture rescaled at a given size
  129699. * @param texture Texture to copy from
  129700. * @param width defines the desired width
  129701. * @param height defines the desired height
  129702. * @param useBilinearMode defines if bilinear mode has to be used
  129703. * @return the generated texture
  129704. */
  129705. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  129706. }
  129707. }
  129708. declare module BABYLON {
  129709. /**
  129710. * This represents the different options available for the video capture.
  129711. */
  129712. export interface VideoRecorderOptions {
  129713. /** Defines the mime type of the video. */
  129714. mimeType: string;
  129715. /** Defines the FPS the video should be recorded at. */
  129716. fps: number;
  129717. /** Defines the chunk size for the recording data. */
  129718. recordChunckSize: number;
  129719. /** The audio tracks to attach to the recording. */
  129720. audioTracks?: MediaStreamTrack[];
  129721. }
  129722. /**
  129723. * This can help with recording videos from BabylonJS.
  129724. * This is based on the available WebRTC functionalities of the browser.
  129725. *
  129726. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  129727. */
  129728. export class VideoRecorder {
  129729. private static readonly _defaultOptions;
  129730. /**
  129731. * Returns whether or not the VideoRecorder is available in your browser.
  129732. * @param engine Defines the Babylon Engine.
  129733. * @returns true if supported otherwise false.
  129734. */
  129735. static IsSupported(engine: Engine): boolean;
  129736. private readonly _options;
  129737. private _canvas;
  129738. private _mediaRecorder;
  129739. private _recordedChunks;
  129740. private _fileName;
  129741. private _resolve;
  129742. private _reject;
  129743. /**
  129744. * True when a recording is already in progress.
  129745. */
  129746. readonly isRecording: boolean;
  129747. /**
  129748. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  129749. * @param engine Defines the BabylonJS Engine you wish to record.
  129750. * @param options Defines options that can be used to customize the capture.
  129751. */
  129752. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  129753. /**
  129754. * Stops the current recording before the default capture timeout passed in the startRecording function.
  129755. */
  129756. stopRecording(): void;
  129757. /**
  129758. * Starts recording the canvas for a max duration specified in parameters.
  129759. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  129760. * If null no automatic download will start and you can rely on the promise to get the data back.
  129761. * @param maxDuration Defines the maximum recording time in seconds.
  129762. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  129763. * @return A promise callback at the end of the recording with the video data in Blob.
  129764. */
  129765. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  129766. /**
  129767. * Releases internal resources used during the recording.
  129768. */
  129769. dispose(): void;
  129770. private _handleDataAvailable;
  129771. private _handleError;
  129772. private _handleStop;
  129773. }
  129774. }
  129775. declare module BABYLON {
  129776. /**
  129777. * Class containing a set of static utilities functions for screenshots
  129778. */
  129779. export class ScreenshotTools {
  129780. /**
  129781. * Captures a screenshot of the current rendering
  129782. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  129783. * @param engine defines the rendering engine
  129784. * @param camera defines the source camera
  129785. * @param size This parameter can be set to a single number or to an object with the
  129786. * following (optional) properties: precision, width, height. If a single number is passed,
  129787. * it will be used for both width and height. If an object is passed, the screenshot size
  129788. * will be derived from the parameters. The precision property is a multiplier allowing
  129789. * rendering at a higher or lower resolution
  129790. * @param successCallback defines the callback receives a single parameter which contains the
  129791. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  129792. * src parameter of an <img> to display it
  129793. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  129794. * Check your browser for supported MIME types
  129795. */
  129796. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  129797. /**
  129798. * Captures a screenshot of the current rendering
  129799. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  129800. * @param engine defines the rendering engine
  129801. * @param camera defines the source camera
  129802. * @param size This parameter can be set to a single number or to an object with the
  129803. * following (optional) properties: precision, width, height. If a single number is passed,
  129804. * it will be used for both width and height. If an object is passed, the screenshot size
  129805. * will be derived from the parameters. The precision property is a multiplier allowing
  129806. * rendering at a higher or lower resolution
  129807. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  129808. * Check your browser for supported MIME types
  129809. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  129810. * to the src parameter of an <img> to display it
  129811. */
  129812. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  129813. /**
  129814. * Generates an image screenshot from the specified camera.
  129815. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  129816. * @param engine The engine to use for rendering
  129817. * @param camera The camera to use for rendering
  129818. * @param size This parameter can be set to a single number or to an object with the
  129819. * following (optional) properties: precision, width, height. If a single number is passed,
  129820. * it will be used for both width and height. If an object is passed, the screenshot size
  129821. * will be derived from the parameters. The precision property is a multiplier allowing
  129822. * rendering at a higher or lower resolution
  129823. * @param successCallback The callback receives a single parameter which contains the
  129824. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  129825. * src parameter of an <img> to display it
  129826. * @param mimeType The MIME type of the screenshot image (default: image/png).
  129827. * Check your browser for supported MIME types
  129828. * @param samples Texture samples (default: 1)
  129829. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  129830. * @param fileName A name for for the downloaded file.
  129831. */
  129832. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  129833. /**
  129834. * Generates an image screenshot from the specified camera.
  129835. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  129836. * @param engine The engine to use for rendering
  129837. * @param camera The camera to use for rendering
  129838. * @param size This parameter can be set to a single number or to an object with the
  129839. * following (optional) properties: precision, width, height. If a single number is passed,
  129840. * it will be used for both width and height. If an object is passed, the screenshot size
  129841. * will be derived from the parameters. The precision property is a multiplier allowing
  129842. * rendering at a higher or lower resolution
  129843. * @param mimeType The MIME type of the screenshot image (default: image/png).
  129844. * Check your browser for supported MIME types
  129845. * @param samples Texture samples (default: 1)
  129846. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  129847. * @param fileName A name for for the downloaded file.
  129848. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  129849. * to the src parameter of an <img> to display it
  129850. */
  129851. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  129852. /**
  129853. * Gets height and width for screenshot size
  129854. * @private
  129855. */
  129856. private static _getScreenshotSize;
  129857. }
  129858. }
  129859. declare module BABYLON {
  129860. /**
  129861. * A cursor which tracks a point on a path
  129862. */
  129863. export class PathCursor {
  129864. private path;
  129865. /**
  129866. * Stores path cursor callbacks for when an onchange event is triggered
  129867. */
  129868. private _onchange;
  129869. /**
  129870. * The value of the path cursor
  129871. */
  129872. value: number;
  129873. /**
  129874. * The animation array of the path cursor
  129875. */
  129876. animations: Animation[];
  129877. /**
  129878. * Initializes the path cursor
  129879. * @param path The path to track
  129880. */
  129881. constructor(path: Path2);
  129882. /**
  129883. * Gets the cursor point on the path
  129884. * @returns A point on the path cursor at the cursor location
  129885. */
  129886. getPoint(): Vector3;
  129887. /**
  129888. * Moves the cursor ahead by the step amount
  129889. * @param step The amount to move the cursor forward
  129890. * @returns This path cursor
  129891. */
  129892. moveAhead(step?: number): PathCursor;
  129893. /**
  129894. * Moves the cursor behind by the step amount
  129895. * @param step The amount to move the cursor back
  129896. * @returns This path cursor
  129897. */
  129898. moveBack(step?: number): PathCursor;
  129899. /**
  129900. * Moves the cursor by the step amount
  129901. * If the step amount is greater than one, an exception is thrown
  129902. * @param step The amount to move the cursor
  129903. * @returns This path cursor
  129904. */
  129905. move(step: number): PathCursor;
  129906. /**
  129907. * Ensures that the value is limited between zero and one
  129908. * @returns This path cursor
  129909. */
  129910. private ensureLimits;
  129911. /**
  129912. * Runs onchange callbacks on change (used by the animation engine)
  129913. * @returns This path cursor
  129914. */
  129915. private raiseOnChange;
  129916. /**
  129917. * Executes a function on change
  129918. * @param f A path cursor onchange callback
  129919. * @returns This path cursor
  129920. */
  129921. onchange(f: (cursor: PathCursor) => void): PathCursor;
  129922. }
  129923. }
  129924. declare module BABYLON {
  129925. /** @hidden */
  129926. export var blurPixelShader: {
  129927. name: string;
  129928. shader: string;
  129929. };
  129930. }
  129931. declare module BABYLON {
  129932. /** @hidden */
  129933. export var pointCloudVertexDeclaration: {
  129934. name: string;
  129935. shader: string;
  129936. };
  129937. }
  129938. // Mixins
  129939. interface Window {
  129940. mozIndexedDB: IDBFactory;
  129941. webkitIndexedDB: IDBFactory;
  129942. msIndexedDB: IDBFactory;
  129943. webkitURL: typeof URL;
  129944. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  129945. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  129946. WebGLRenderingContext: WebGLRenderingContext;
  129947. MSGesture: MSGesture;
  129948. CANNON: any;
  129949. AudioContext: AudioContext;
  129950. webkitAudioContext: AudioContext;
  129951. PointerEvent: any;
  129952. Math: Math;
  129953. Uint8Array: Uint8ArrayConstructor;
  129954. Float32Array: Float32ArrayConstructor;
  129955. mozURL: typeof URL;
  129956. msURL: typeof URL;
  129957. VRFrameData: any; // WebVR, from specs 1.1
  129958. DracoDecoderModule: any;
  129959. setImmediate(handler: (...args: any[]) => void): number;
  129960. }
  129961. interface HTMLCanvasElement {
  129962. requestPointerLock(): void;
  129963. msRequestPointerLock?(): void;
  129964. mozRequestPointerLock?(): void;
  129965. webkitRequestPointerLock?(): void;
  129966. /** Track wether a record is in progress */
  129967. isRecording: boolean;
  129968. /** Capture Stream method defined by some browsers */
  129969. captureStream(fps?: number): MediaStream;
  129970. }
  129971. interface CanvasRenderingContext2D {
  129972. msImageSmoothingEnabled: boolean;
  129973. }
  129974. interface MouseEvent {
  129975. mozMovementX: number;
  129976. mozMovementY: number;
  129977. webkitMovementX: number;
  129978. webkitMovementY: number;
  129979. msMovementX: number;
  129980. msMovementY: number;
  129981. }
  129982. interface Navigator {
  129983. mozGetVRDevices: (any: any) => any;
  129984. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  129985. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  129986. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  129987. webkitGetGamepads(): Gamepad[];
  129988. msGetGamepads(): Gamepad[];
  129989. webkitGamepads(): Gamepad[];
  129990. }
  129991. interface HTMLVideoElement {
  129992. mozSrcObject: any;
  129993. }
  129994. interface Math {
  129995. fround(x: number): number;
  129996. imul(a: number, b: number): number;
  129997. }
  129998. interface WebGLRenderingContext {
  129999. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  130000. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  130001. vertexAttribDivisor(index: number, divisor: number): void;
  130002. createVertexArray(): any;
  130003. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  130004. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  130005. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  130006. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  130007. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  130008. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  130009. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  130010. // Queries
  130011. createQuery(): WebGLQuery;
  130012. deleteQuery(query: WebGLQuery): void;
  130013. beginQuery(target: number, query: WebGLQuery): void;
  130014. endQuery(target: number): void;
  130015. getQueryParameter(query: WebGLQuery, pname: number): any;
  130016. getQuery(target: number, pname: number): any;
  130017. MAX_SAMPLES: number;
  130018. RGBA8: number;
  130019. READ_FRAMEBUFFER: number;
  130020. DRAW_FRAMEBUFFER: number;
  130021. UNIFORM_BUFFER: number;
  130022. HALF_FLOAT_OES: number;
  130023. RGBA16F: number;
  130024. RGBA32F: number;
  130025. R32F: number;
  130026. RG32F: number;
  130027. RGB32F: number;
  130028. R16F: number;
  130029. RG16F: number;
  130030. RGB16F: number;
  130031. RED: number;
  130032. RG: number;
  130033. R8: number;
  130034. RG8: number;
  130035. UNSIGNED_INT_24_8: number;
  130036. DEPTH24_STENCIL8: number;
  130037. MIN: number;
  130038. MAX: number;
  130039. /* Multiple Render Targets */
  130040. drawBuffers(buffers: number[]): void;
  130041. readBuffer(src: number): void;
  130042. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  130043. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  130044. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  130045. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  130046. // Occlusion Query
  130047. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  130048. ANY_SAMPLES_PASSED: number;
  130049. QUERY_RESULT_AVAILABLE: number;
  130050. QUERY_RESULT: number;
  130051. }
  130052. interface WebGLProgram {
  130053. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  130054. }
  130055. interface EXT_disjoint_timer_query {
  130056. QUERY_COUNTER_BITS_EXT: number;
  130057. TIME_ELAPSED_EXT: number;
  130058. TIMESTAMP_EXT: number;
  130059. GPU_DISJOINT_EXT: number;
  130060. QUERY_RESULT_EXT: number;
  130061. QUERY_RESULT_AVAILABLE_EXT: number;
  130062. queryCounterEXT(query: WebGLQuery, target: number): void;
  130063. createQueryEXT(): WebGLQuery;
  130064. beginQueryEXT(target: number, query: WebGLQuery): void;
  130065. endQueryEXT(target: number): void;
  130066. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  130067. deleteQueryEXT(query: WebGLQuery): void;
  130068. }
  130069. interface WebGLUniformLocation {
  130070. _currentState: any;
  130071. }
  130072. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  130073. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  130074. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  130075. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  130076. interface WebGLRenderingContext {
  130077. readonly RASTERIZER_DISCARD: number;
  130078. readonly DEPTH_COMPONENT24: number;
  130079. readonly TEXTURE_3D: number;
  130080. readonly TEXTURE_2D_ARRAY: number;
  130081. readonly TEXTURE_COMPARE_FUNC: number;
  130082. readonly TEXTURE_COMPARE_MODE: number;
  130083. readonly COMPARE_REF_TO_TEXTURE: number;
  130084. readonly TEXTURE_WRAP_R: number;
  130085. readonly HALF_FLOAT: number;
  130086. readonly RGB8: number;
  130087. readonly RED_INTEGER: number;
  130088. readonly RG_INTEGER: number;
  130089. readonly RGB_INTEGER: number;
  130090. readonly RGBA_INTEGER: number;
  130091. readonly R8_SNORM: number;
  130092. readonly RG8_SNORM: number;
  130093. readonly RGB8_SNORM: number;
  130094. readonly RGBA8_SNORM: number;
  130095. readonly R8I: number;
  130096. readonly RG8I: number;
  130097. readonly RGB8I: number;
  130098. readonly RGBA8I: number;
  130099. readonly R8UI: number;
  130100. readonly RG8UI: number;
  130101. readonly RGB8UI: number;
  130102. readonly RGBA8UI: number;
  130103. readonly R16I: number;
  130104. readonly RG16I: number;
  130105. readonly RGB16I: number;
  130106. readonly RGBA16I: number;
  130107. readonly R16UI: number;
  130108. readonly RG16UI: number;
  130109. readonly RGB16UI: number;
  130110. readonly RGBA16UI: number;
  130111. readonly R32I: number;
  130112. readonly RG32I: number;
  130113. readonly RGB32I: number;
  130114. readonly RGBA32I: number;
  130115. readonly R32UI: number;
  130116. readonly RG32UI: number;
  130117. readonly RGB32UI: number;
  130118. readonly RGBA32UI: number;
  130119. readonly RGB10_A2UI: number;
  130120. readonly R11F_G11F_B10F: number;
  130121. readonly RGB9_E5: number;
  130122. readonly RGB10_A2: number;
  130123. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  130124. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  130125. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  130126. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  130127. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  130128. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  130129. 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;
  130130. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  130131. readonly TRANSFORM_FEEDBACK: number;
  130132. readonly INTERLEAVED_ATTRIBS: number;
  130133. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  130134. createTransformFeedback(): WebGLTransformFeedback;
  130135. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  130136. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  130137. beginTransformFeedback(primitiveMode: number): void;
  130138. endTransformFeedback(): void;
  130139. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  130140. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  130141. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  130142. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  130143. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  130144. }
  130145. interface ImageBitmap {
  130146. readonly width: number;
  130147. readonly height: number;
  130148. close(): void;
  130149. }
  130150. interface WebGLQuery extends WebGLObject {
  130151. }
  130152. declare var WebGLQuery: {
  130153. prototype: WebGLQuery;
  130154. new(): WebGLQuery;
  130155. };
  130156. interface WebGLSampler extends WebGLObject {
  130157. }
  130158. declare var WebGLSampler: {
  130159. prototype: WebGLSampler;
  130160. new(): WebGLSampler;
  130161. };
  130162. interface WebGLSync extends WebGLObject {
  130163. }
  130164. declare var WebGLSync: {
  130165. prototype: WebGLSync;
  130166. new(): WebGLSync;
  130167. };
  130168. interface WebGLTransformFeedback extends WebGLObject {
  130169. }
  130170. declare var WebGLTransformFeedback: {
  130171. prototype: WebGLTransformFeedback;
  130172. new(): WebGLTransformFeedback;
  130173. };
  130174. interface WebGLVertexArrayObject extends WebGLObject {
  130175. }
  130176. declare var WebGLVertexArrayObject: {
  130177. prototype: WebGLVertexArrayObject;
  130178. new(): WebGLVertexArrayObject;
  130179. };
  130180. // Type definitions for WebVR API
  130181. // Project: https://w3c.github.io/webvr/
  130182. // Definitions by: six a <https://github.com/lostfictions>
  130183. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  130184. interface VRDisplay extends EventTarget {
  130185. /**
  130186. * Dictionary of capabilities describing the VRDisplay.
  130187. */
  130188. readonly capabilities: VRDisplayCapabilities;
  130189. /**
  130190. * z-depth defining the far plane of the eye view frustum
  130191. * enables mapping of values in the render target depth
  130192. * attachment to scene coordinates. Initially set to 10000.0.
  130193. */
  130194. depthFar: number;
  130195. /**
  130196. * z-depth defining the near plane of the eye view frustum
  130197. * enables mapping of values in the render target depth
  130198. * attachment to scene coordinates. Initially set to 0.01.
  130199. */
  130200. depthNear: number;
  130201. /**
  130202. * An identifier for this distinct VRDisplay. Used as an
  130203. * association point in the Gamepad API.
  130204. */
  130205. readonly displayId: number;
  130206. /**
  130207. * A display name, a user-readable name identifying it.
  130208. */
  130209. readonly displayName: string;
  130210. readonly isConnected: boolean;
  130211. readonly isPresenting: boolean;
  130212. /**
  130213. * If this VRDisplay supports room-scale experiences, the optional
  130214. * stage attribute contains details on the room-scale parameters.
  130215. */
  130216. readonly stageParameters: VRStageParameters | null;
  130217. /**
  130218. * Passing the value returned by `requestAnimationFrame` to
  130219. * `cancelAnimationFrame` will unregister the callback.
  130220. * @param handle Define the hanle of the request to cancel
  130221. */
  130222. cancelAnimationFrame(handle: number): void;
  130223. /**
  130224. * Stops presenting to the VRDisplay.
  130225. * @returns a promise to know when it stopped
  130226. */
  130227. exitPresent(): Promise<void>;
  130228. /**
  130229. * Return the current VREyeParameters for the given eye.
  130230. * @param whichEye Define the eye we want the parameter for
  130231. * @returns the eye parameters
  130232. */
  130233. getEyeParameters(whichEye: string): VREyeParameters;
  130234. /**
  130235. * Populates the passed VRFrameData with the information required to render
  130236. * the current frame.
  130237. * @param frameData Define the data structure to populate
  130238. * @returns true if ok otherwise false
  130239. */
  130240. getFrameData(frameData: VRFrameData): boolean;
  130241. /**
  130242. * Get the layers currently being presented.
  130243. * @returns the list of VR layers
  130244. */
  130245. getLayers(): VRLayer[];
  130246. /**
  130247. * Return a VRPose containing the future predicted pose of the VRDisplay
  130248. * when the current frame will be presented. The value returned will not
  130249. * change until JavaScript has returned control to the browser.
  130250. *
  130251. * The VRPose will contain the position, orientation, velocity,
  130252. * and acceleration of each of these properties.
  130253. * @returns the pose object
  130254. */
  130255. getPose(): VRPose;
  130256. /**
  130257. * Return the current instantaneous pose of the VRDisplay, with no
  130258. * prediction applied.
  130259. * @returns the current instantaneous pose
  130260. */
  130261. getImmediatePose(): VRPose;
  130262. /**
  130263. * The callback passed to `requestAnimationFrame` will be called
  130264. * any time a new frame should be rendered. When the VRDisplay is
  130265. * presenting the callback will be called at the native refresh
  130266. * rate of the HMD. When not presenting this function acts
  130267. * identically to how window.requestAnimationFrame acts. Content should
  130268. * make no assumptions of frame rate or vsync behavior as the HMD runs
  130269. * asynchronously from other displays and at differing refresh rates.
  130270. * @param callback Define the eaction to run next frame
  130271. * @returns the request handle it
  130272. */
  130273. requestAnimationFrame(callback: FrameRequestCallback): number;
  130274. /**
  130275. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  130276. * Repeat calls while already presenting will update the VRLayers being displayed.
  130277. * @param layers Define the list of layer to present
  130278. * @returns a promise to know when the request has been fulfilled
  130279. */
  130280. requestPresent(layers: VRLayer[]): Promise<void>;
  130281. /**
  130282. * Reset the pose for this display, treating its current position and
  130283. * orientation as the "origin/zero" values. VRPose.position,
  130284. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  130285. * updated when calling resetPose(). This should be called in only
  130286. * sitting-space experiences.
  130287. */
  130288. resetPose(): void;
  130289. /**
  130290. * The VRLayer provided to the VRDisplay will be captured and presented
  130291. * in the HMD. Calling this function has the same effect on the source
  130292. * canvas as any other operation that uses its source image, and canvases
  130293. * created without preserveDrawingBuffer set to true will be cleared.
  130294. * @param pose Define the pose to submit
  130295. */
  130296. submitFrame(pose?: VRPose): void;
  130297. }
  130298. declare var VRDisplay: {
  130299. prototype: VRDisplay;
  130300. new(): VRDisplay;
  130301. };
  130302. interface VRLayer {
  130303. leftBounds?: number[] | Float32Array | null;
  130304. rightBounds?: number[] | Float32Array | null;
  130305. source?: HTMLCanvasElement | null;
  130306. }
  130307. interface VRDisplayCapabilities {
  130308. readonly canPresent: boolean;
  130309. readonly hasExternalDisplay: boolean;
  130310. readonly hasOrientation: boolean;
  130311. readonly hasPosition: boolean;
  130312. readonly maxLayers: number;
  130313. }
  130314. interface VREyeParameters {
  130315. /** @deprecated */
  130316. readonly fieldOfView: VRFieldOfView;
  130317. readonly offset: Float32Array;
  130318. readonly renderHeight: number;
  130319. readonly renderWidth: number;
  130320. }
  130321. interface VRFieldOfView {
  130322. readonly downDegrees: number;
  130323. readonly leftDegrees: number;
  130324. readonly rightDegrees: number;
  130325. readonly upDegrees: number;
  130326. }
  130327. interface VRFrameData {
  130328. readonly leftProjectionMatrix: Float32Array;
  130329. readonly leftViewMatrix: Float32Array;
  130330. readonly pose: VRPose;
  130331. readonly rightProjectionMatrix: Float32Array;
  130332. readonly rightViewMatrix: Float32Array;
  130333. readonly timestamp: number;
  130334. }
  130335. interface VRPose {
  130336. readonly angularAcceleration: Float32Array | null;
  130337. readonly angularVelocity: Float32Array | null;
  130338. readonly linearAcceleration: Float32Array | null;
  130339. readonly linearVelocity: Float32Array | null;
  130340. readonly orientation: Float32Array | null;
  130341. readonly position: Float32Array | null;
  130342. readonly timestamp: number;
  130343. }
  130344. interface VRStageParameters {
  130345. sittingToStandingTransform?: Float32Array;
  130346. sizeX?: number;
  130347. sizeY?: number;
  130348. }
  130349. interface Navigator {
  130350. getVRDisplays(): Promise<VRDisplay[]>;
  130351. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  130352. }
  130353. interface Window {
  130354. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  130355. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  130356. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  130357. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  130358. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  130359. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  130360. }
  130361. interface Gamepad {
  130362. readonly displayId: number;
  130363. }
  130364. type XRSessionMode =
  130365. | "inline"
  130366. | "immersive-vr"
  130367. | "immersive-ar";
  130368. type XRReferenceSpaceType =
  130369. | "viewer"
  130370. | "local"
  130371. | "local-floor"
  130372. | "bounded-floor"
  130373. | "unbounded";
  130374. type XREnvironmentBlendMode =
  130375. | "opaque"
  130376. | "additive"
  130377. | "alpha-blend";
  130378. type XRVisibilityState =
  130379. | "visible"
  130380. | "visible-blurred"
  130381. | "hidden";
  130382. type XRHandedness =
  130383. | "none"
  130384. | "left"
  130385. | "right";
  130386. type XRTargetRayMode =
  130387. | "gaze"
  130388. | "tracked-pointer"
  130389. | "screen";
  130390. type XREye =
  130391. | "none"
  130392. | "left"
  130393. | "right";
  130394. interface XRSpace extends EventTarget {
  130395. }
  130396. interface XRRenderState {
  130397. depthNear?: number;
  130398. depthFar?: number;
  130399. inlineVerticalFieldOfView?: number;
  130400. baseLayer?: XRWebGLLayer;
  130401. }
  130402. interface XRInputSource {
  130403. handedness: XRHandedness;
  130404. targetRayMode: XRTargetRayMode;
  130405. targetRaySpace: XRSpace;
  130406. gripSpace: XRSpace | undefined;
  130407. gamepad: Gamepad | undefined;
  130408. profiles: Array<string>;
  130409. }
  130410. interface XRSession {
  130411. addEventListener: Function;
  130412. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  130413. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  130414. requestAnimationFrame: Function;
  130415. end(): Promise<void>;
  130416. renderState: XRRenderState;
  130417. inputSources: Array<XRInputSource>;
  130418. }
  130419. interface XRReferenceSpace extends XRSpace {
  130420. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  130421. onreset: any;
  130422. }
  130423. interface XRFrame {
  130424. session: XRSession;
  130425. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  130426. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  130427. }
  130428. interface XRViewerPose extends XRPose {
  130429. views: Array<XRView>;
  130430. }
  130431. interface XRPose {
  130432. transform: XRRigidTransform;
  130433. emulatedPosition: boolean;
  130434. }
  130435. declare var XRWebGLLayer: {
  130436. prototype: XRWebGLLayer;
  130437. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  130438. };
  130439. interface XRWebGLLayer {
  130440. framebuffer: WebGLFramebuffer;
  130441. framebufferWidth: number;
  130442. framebufferHeight: number;
  130443. getViewport: Function;
  130444. }
  130445. interface XRRigidTransform {
  130446. position: DOMPointReadOnly;
  130447. orientation: DOMPointReadOnly;
  130448. matrix: Float32Array;
  130449. inverse: XRRigidTransform;
  130450. }
  130451. interface XRView {
  130452. eye: XREye;
  130453. projectionMatrix: Float32Array;
  130454. transform: XRRigidTransform;
  130455. }
  130456. interface XRInputSourceChangeEvent {
  130457. session: XRSession;
  130458. removed: Array<XRInputSource>;
  130459. added: Array<XRInputSource>;
  130460. }